diff options
| author | Ron Yorston <rmy@pobox.com> | 2026-02-12 12:50:11 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2026-02-12 12:58:38 +0000 |
| commit | de7b34e8c779d8baca5abba1394284e0b6e87dc6 (patch) | |
| tree | 6cad7836abe5610f97c32d9b5d395f5e9c34929d /miscutils | |
| parent | 7e0c303a8804608e3c11151655d270a63bfffcfa (diff) | |
| parent | 8424dc436a66a224b73429675a481d074fc2f8dc (diff) | |
| download | busybox-w32-de7b34e8c779d8baca5abba1394284e0b6e87dc6.tar.gz busybox-w32-de7b34e8c779d8baca5abba1394284e0b6e87dc6.tar.bz2 busybox-w32-de7b34e8c779d8baca5abba1394284e0b6e87dc6.zip | |
Merge branch 'busybox' into merge
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/devfsd.c | 1 | ||||
| -rw-r--r-- | miscutils/less.c | 14 | ||||
| -rw-r--r-- | miscutils/man.c | 44 |
3 files changed, 35 insertions, 24 deletions
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 642cd3637..d57691414 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
| @@ -962,7 +962,6 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int | |||
| 962 | dest_name = dest_buf; | 962 | dest_name = dest_buf; |
| 963 | compat_name = compat_buf; | 963 | compat_name = compat_buf; |
| 964 | 964 | ||
| 965 | |||
| 966 | /* 1 == scsi/generic 2 == scsi/disc 3 == scsi/cd 6 == ide/host/disc 7 == ide/host/cd */ | 965 | /* 1 == scsi/generic 2 == scsi/disc 3 == scsi/cd 6 == ide/host/disc 7 == ide/host/cd */ |
| 967 | if (i == 1 || i == 2 || i == 3 || i == 6 || i ==7) | 966 | if (i == 1 || i == 2 || i == 3 || i == 6 || i ==7) |
| 968 | sprintf(compat_buf, fmt[i], host, bus, target, lun); | 967 | sprintf(compat_buf, fmt[i], host, bus, target, lun); |
diff --git a/miscutils/less.c b/miscutils/less.c index 5a8fc5a74..91403a252 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
| @@ -857,13 +857,13 @@ static void print_found(const char *line) | |||
| 857 | goto start; | 857 | goto start; |
| 858 | 858 | ||
| 859 | while (match_status == 0) { | 859 | while (match_status == 0) { |
| 860 | char *new = xasprintf("%s%.*s"HIGHLIGHT"%.*s"NORMAL, | 860 | xasprintf_inplace(growline, |
| 861 | growline ? growline : "", | 861 | "%s%.*s"HIGHLIGHT"%.*s"NORMAL, |
| 862 | (int)match_structs.rm_so, str, | 862 | growline ? growline : "", |
| 863 | (int)(match_structs.rm_eo - match_structs.rm_so), | 863 | (int)match_structs.rm_so, |
| 864 | str + match_structs.rm_so); | 864 | str, |
| 865 | free(growline); | 865 | (int)(match_structs.rm_eo - match_structs.rm_so), |
| 866 | growline = new; | 866 | str + match_structs.rm_so); |
| 867 | str += match_structs.rm_eo; | 867 | str += match_structs.rm_eo; |
| 868 | line += match_structs.rm_eo; | 868 | line += match_structs.rm_eo; |
| 869 | eflags = REG_NOTBOL; | 869 | eflags = REG_NOTBOL; |
diff --git a/miscutils/man.c b/miscutils/man.c index 38c1b9aa3..cf67f1538 100644 --- a/miscutils/man.c +++ b/miscutils/man.c | |||
| @@ -73,7 +73,7 @@ struct globals { | |||
| 73 | 73 | ||
| 74 | static int show_manpage(char *man_filename, int man, int level); | 74 | static int show_manpage(char *man_filename, int man, int level); |
| 75 | 75 | ||
| 76 | static int run_pipe(char *man_filename, int man, int level) | 76 | static int run_man_pipe(char *man_filename, int man, int level) |
| 77 | { | 77 | { |
| 78 | char *cmd; | 78 | char *cmd; |
| 79 | 79 | ||
| @@ -115,24 +115,36 @@ static int run_pipe(char *man_filename, int man, int level) | |||
| 115 | * ".so man7/path_resolution.7\n<junk>" | 115 | * ".so man7/path_resolution.7\n<junk>" |
| 116 | */ | 116 | */ |
| 117 | *strchrnul(line, '\n') = '\0'; | 117 | *strchrnul(line, '\n') = '\0'; |
| 118 | linkname = skip_whitespace(&line[4]); | 118 | linkname = skip_whitespace(line + 4); |
| 119 | 119 | //testcase: | |
| 120 | /* If link has no slashes, we just replace man page name. | 120 | // cd /usr/share/man/man2 |
| 121 | * If link has slashes (however many), we go back *once*. | 121 | // man ./path_resolution.2.gz |
| 122 | * ".so zzz/ggg/page.3" does NOT go back two levels. */ | 122 | while (man_filename[0] == '.' && man_filename[1] == '/') |
| 123 | man_filename += 2; | ||
| 123 | p = strrchr(man_filename, '/'); | 124 | p = strrchr(man_filename, '/'); |
| 124 | if (!p) | 125 | if (!p) |
| 125 | goto ordinary_manpage; | 126 | man_filename = (char*)".." + 1; /* "NAME.N" -> "." */ |
| 126 | *p = '\0'; | 127 | else |
| 128 | *p = '\0'; /* "PFX/manN/NAME.N" -> "PFX/manN" */ | ||
| 129 | |||
| 130 | /* If link has slashes (however many), we go back *once*. | ||
| 131 | * ".so zzz/ggg/page.3" does NOT go back two levels. | ||
| 132 | */ | ||
| 127 | if (strchr(linkname, '/')) { | 133 | if (strchr(linkname, '/')) { |
| 134 | if (!p) { /* man_filename had no path */ | ||
| 135 | man_filename--; /* ".." */ | ||
| 136 | goto append_link; | ||
| 137 | } | ||
| 128 | p = strrchr(man_filename, '/'); | 138 | p = strrchr(man_filename, '/'); |
| 129 | if (!p) | 139 | if (!p) |
| 130 | goto ordinary_manpage; | 140 | man_filename = (char*)".." + 1; /* "manN" -> "." */ |
| 131 | *p = '\0'; | 141 | else |
| 132 | } | 142 | *p = '\0'; /* "PFX/manN" -> "PFX" */ |
| 143 | } /* else (link has no slashes): will do "PFX/manN" -> "PFX/manN/link" */ | ||
| 133 | 144 | ||
| 134 | /* Links do not have .gz extensions, even if manpage | 145 | /* Links do not have .gz extensions, even if manpage |
| 135 | * is compressed */ | 146 | * is compressed */ |
| 147 | append_link: | ||
| 136 | man_filename = xasprintf("%s/%s", man_filename, linkname); | 148 | man_filename = xasprintf("%s/%s", man_filename, linkname); |
| 137 | free(line); | 149 | free(line); |
| 138 | /* Note: we leak "new" man_filename string as well... */ | 150 | /* Note: we leak "new" man_filename string as well... */ |
| @@ -172,26 +184,26 @@ static int show_manpage(char *man_filename, int man, int level) | |||
| 172 | #endif | 184 | #endif |
| 173 | 185 | ||
| 174 | #if ENABLE_FEATURE_SEAMLESS_LZMA | 186 | #if ENABLE_FEATURE_SEAMLESS_LZMA |
| 175 | if (run_pipe(filename_with_zext, man, level)) | 187 | if (run_man_pipe(filename_with_zext, man, level)) |
| 176 | return 1; | 188 | return 1; |
| 177 | #endif | 189 | #endif |
| 178 | #if ENABLE_FEATURE_SEAMLESS_XZ | 190 | #if ENABLE_FEATURE_SEAMLESS_XZ |
| 179 | strcpy(ext, "xz"); | 191 | strcpy(ext, "xz"); |
| 180 | if (run_pipe(filename_with_zext, man, level)) | 192 | if (run_man_pipe(filename_with_zext, man, level)) |
| 181 | return 1; | 193 | return 1; |
| 182 | #endif | 194 | #endif |
| 183 | #if ENABLE_FEATURE_SEAMLESS_BZ2 | 195 | #if ENABLE_FEATURE_SEAMLESS_BZ2 |
| 184 | strcpy(ext, "bz2"); | 196 | strcpy(ext, "bz2"); |
| 185 | if (run_pipe(filename_with_zext, man, level)) | 197 | if (run_man_pipe(filename_with_zext, man, level)) |
| 186 | return 1; | 198 | return 1; |
| 187 | #endif | 199 | #endif |
| 188 | #if ENABLE_FEATURE_SEAMLESS_GZ | 200 | #if ENABLE_FEATURE_SEAMLESS_GZ |
| 189 | strcpy(ext, "gz"); | 201 | strcpy(ext, "gz"); |
| 190 | if (run_pipe(filename_with_zext, man, level)) | 202 | if (run_man_pipe(filename_with_zext, man, level)) |
| 191 | return 1; | 203 | return 1; |
| 192 | #endif | 204 | #endif |
| 193 | 205 | ||
| 194 | return run_pipe(man_filename, man, level); | 206 | return run_man_pipe(man_filename, man, level); |
| 195 | } | 207 | } |
| 196 | 208 | ||
| 197 | static char **add_MANPATH(char **man_path_list, int *count_mp, char *path) | 209 | static char **add_MANPATH(char **man_path_list, int *count_mp, char *path) |
