diff options
Diffstat (limited to 'libenv_vprocess_list__.c')
-rw-r--r-- | libenv_vprocess_list__.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libenv_vprocess_list__.c b/libenv_vprocess_list__.c index b590d4b..1eb211f 100644 --- a/libenv_vprocess_list__.c +++ b/libenv_vprocess_list__.c @@ -8,15 +8,14 @@ matches(const char *var, const struct libenv_variable *known, int is_name_only, { size_t i, w, b; for (; known->name; known++) { - for (i = 0;; i++) + for (i = 0; known->name[i]; i++) if (var[i] != known->name[i]) - break; - if (known->name[i]) - continue; + goto next; if (var[i] == (is_name_only ? '\0' : '=')) goto found; + next:; } - return 0; + return all && !classes_head; found: for (; classes_head; classes_head = va_arg(classes_tail, enum libenv_class)) { @@ -51,8 +50,10 @@ libenv_vprocess_list__(void *variables_, enum libenv_class classes_head, va_list known = libenv_get_complete_list(&nclasswords, NULL); for (i = 0; variables[i]; i++) { + int match; va_copy(classes_tail_2, classes_tail); - if (filter ^ matches(variables[i], known, names, classes_head, classes_tail_2, all, nclasswords)) + match = matches(variables[i], known, names, classes_head, classes_tail_2, all, nclasswords); + if (filter ^ match) variables[n++] = variables[i]; else if (dealloc) free(variables[i]); |