dosutils: use shared case-insensitive string helper
Replace local case-insensitive argument comparison helpers in MAP, SLIST, WHOAMI and NWTESTS with the shared tool_strsame() helper. This removes small duplicate helpers without changing command parsing behavior. Trustee-specific wrappers and the experimental NCOPY code are intentionally left untouched.
This commit is contained in:
20
map.c
20
map.c
@@ -213,18 +213,6 @@ static int parse_pathins_arg(uint8 *drvstr, NWPATH *nwp,
|
||||
static int set_search_native(uint8 *drvstr, NWPATH *nwp, int pathmode);
|
||||
static int show_search(uint8 *drvstr);
|
||||
|
||||
static int map_same_arg(char *a, char *b)
|
||||
{
|
||||
while (*a || *b) {
|
||||
int ca = *a++;
|
||||
int cb = *b++;
|
||||
if (ca >= 'a' && ca <= 'z') ca -= 32;
|
||||
if (cb >= 'a' && cb <= 'z') cb -= 32;
|
||||
if (ca != cb) return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int map_is_drive_arg(char *s)
|
||||
{
|
||||
if (!s || !s[0] || s[1] != ':' || s[2]) return(0);
|
||||
@@ -372,13 +360,13 @@ int func_map(int argc, char *argv[], int mode)
|
||||
* so handle the Novell syntax here and then reuse the existing primitives.
|
||||
*/
|
||||
if (argc > 1) {
|
||||
if (map_same_arg(argv[1], "/?") || map_same_arg(argv[1], "-?") ||
|
||||
map_same_arg(argv[1], "?")) {
|
||||
if (tool_strsame(argv[1], "/?") || tool_strsame(argv[1], "-?") ||
|
||||
tool_strsame(argv[1], "?")) {
|
||||
fprintf(stderr, "Directory \"/?\" is not locatable.\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (map_same_arg(argv[1], "INS") || map_same_arg(argv[1], "INSERT")) {
|
||||
if (tool_strsame(argv[1], "INS") || tool_strsame(argv[1], "INSERT")) {
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||
return(1);
|
||||
@@ -386,7 +374,7 @@ int func_map(int argc, char *argv[], int mode)
|
||||
return(map_handle_path_command(argc - 1, argv + 1, 2));
|
||||
}
|
||||
|
||||
if (map_same_arg(argv[1], "DEL") || map_same_arg(argv[1], "DELETE")) {
|
||||
if (tool_strsame(argv[1], "DEL") || tool_strsame(argv[1], "DELETE")) {
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||
return(1);
|
||||
|
||||
Reference in New Issue
Block a user