- if (index < pkg->depends_count) {
- return pkg->depends_str[index];
- }
- fprintf(stderr, "pkg_depend_str: index %d out of range for pkg=%s\n", index, pkg->name);
- return NULL;
+ if (i != 0)
+ len += 3; /* space, pipe, space */
+
+ len += strlen(dep->pkg->name);
+
+ if (dep->version) {
+ len += 2; /* space, left parenthesis */
+ len += 3; /* constraint string (<=, >=, etc), space */
+ len += strlen(dep->version);
+ len += 1; /* right parenthesis */
+ }
+ }
+
+ str = xmalloc(len + 1); /* +1 for the NULL terminator */
+ str[0] = '\0';
+
+ for (i=0; i<cdep->possibility_count; i++) {
+ dep = cdep->possibilities[i];
+
+ if (i != 0)
+ strncat(str, " | ", len);
+
+ strncat(str, dep->pkg->name, len);
+
+ if (dep->version) {
+ strncat(str, " (", len);
+ strncat(str, constraint_to_str(dep->constraint), len);
+ strncat(str, dep->version, len);
+ strncat(str, ")", len);
+ }
+ }
+
+ return str;