hust testsuite: fix a false positive
[oweals/busybox.git] / miscutils / man.c
index ccb57a93f7a3e061f44e09b9cba84cff7e263cc4..f705dd31e3b7b07b43565728b80a741773e975ad 100644 (file)
@@ -66,7 +66,7 @@ static int run_pipe(const char *pager, char *man_filename, int man, int level)
                        goto ordinary_manpage;
 
                line = xmalloc_open_zipped_read_close(man_filename, NULL);
-               if (!line || strncmp(line, ".so ", 4) != 0) {
+               if (!line || !is_prefixed_with(line, ".so ")) {
                        free(line);
                        goto ordinary_manpage;
                }
@@ -155,9 +155,9 @@ static char **add_MANPATH(char **man_path_list, int *count_mp, char *path)
 
                next_path = strchr(path, ':');
                if (next_path) {
-                       *next_path = '\0';
-                       if (next_path++ == path) /* "::"? */
+                       if (next_path == path) /* "::"? */
                                goto next;
+                       *next_path = '\0';
                }
                /* Do we already have path? */
                path_element = man_path_list;
@@ -174,8 +174,10 @@ static char **add_MANPATH(char **man_path_list, int *count_mp, char *path)
  skip:
                if (!next_path)
                        break;
+               /* "path" may be a result of getenv(), be nice and don't mangle it */
+               *next_path = ':';
  next:
-               path = next_path;
+               path = next_path + 1;
        }
        return man_path_list;
 }
@@ -226,8 +228,8 @@ int man_main(int argc UNUSED_PARAM, char **argv)
                if (!token[1])
                        continue;
                if (strcmp("DEFINE", token[0]) == 0) {
-                       if (strncmp("pager", token[1], 5) == 0) {
-                               pager = xstrdup(skip_whitespace(token[1]) + 5);
+                       if (is_prefixed_with(token[1], "pager")) {
+                               pager = xstrdup(skip_whitespace(token[1] + 5));
                        }
                } else
                if (strcmp("MANDATORY_MANPATH"+10, token[0]) == 0 /* "MANPATH"? */