On Mon, Nov 19, 2007 at 03:44:08PM +0100, Nagy Gabor wrote:
2. There is something in my mind about alpm_dep_getstring: It shouldn't be used for debug preformat (or in libalpm at all); but that is good for front-ends. I would prefer the following more elegant(?) solution instead of switch(): there is a global const char *deptypestr[] = {">=", "<=", "="} in the correct order somewhere; and from now on, you can pass deptypestr[dep->mod] parameter easily to alpm_log for example (see alpm_depcmp). This is O(1) (<- switch is also O(1), but that floods the code imho) I will create a patch for this, after I can sync my git repo ;-) Bye
I would say this is a neat hack :) neat because it gives the same result in much less lines. hack because : 1) it depends on the actual values of PM_DEP_MOD_* 2) Since the PM_DEP_MOD_* starts at 1, you need to use an empty first column, which I found quite funny :)
+const char *pmdepmodstr[] = {"", "", "=", ">=", "<="};
+ _alpm_log(PM_LOG_DEBUG, "%s satisfies dependency %s%s%s -- skipping\n", + alpm_pkg_get_name(sp), missdep->name, pmdepmodstr[missdep->mod], missdep->version);
And finally, that's really a PITA just to print a dependency. Though we don't need to print dependencies everywhere, but well, I don't know.. I don't think the current situation is that bad.