From e714bce003a1b0e2c49e58fe14af86abc8b31f23 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Wed, 12 Jul 2000 00:53:06 +0000 Subject: [PATCH] Use global applet_name instead of local versions. --- chmod_chown_chgrp.c | 18 ++++++++---------- console-tools/deallocvt.c | 10 +++------- coreutils/cut.c | 7 ++----- cp_mv.c | 30 ++++++++++++++---------------- cut.c | 7 ++----- deallocvt.c | 10 +++------- 6 files changed, 32 insertions(+), 50 deletions(-) diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c index d3e267827..a5d9af491 100644 --- a/chmod_chown_chgrp.c +++ b/chmod_chown_chgrp.c @@ -36,7 +36,6 @@ static unsigned long uid = -1; static unsigned long gid = -1; static int whichApp; -static char *invocationName = NULL; static char *theMode = NULL; @@ -88,7 +87,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk) case CHMOD_APP: /* Parse the specified modes */ if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) { - fatalError( "%s: unknown mode: %s\n", invocationName, theMode); + fatalError( "%s: unknown mode: %s\n", applet_name, theMode); } if (chmod(fileName, statbuf->st_mode) == 0) return (TRUE); @@ -105,8 +104,8 @@ int chmod_chown_chgrp_main(int argc, char **argv) char *p=NULL; const char *appUsage; - whichApp = (strcmp(*argv, "chown") == 0)? - CHOWN_APP : (strcmp(*argv, "chmod") == 0)? + whichApp = (strcmp(applet_name, "chown") == 0)? + CHOWN_APP : (strcmp(applet_name, "chmod") == 0)? CHMOD_APP : CHGRP_APP; appUsage = (whichApp == CHOWN_APP)? @@ -114,7 +113,6 @@ int chmod_chown_chgrp_main(int argc, char **argv) if (argc < 2) usage(appUsage); - invocationName = *argv; argv++; /* Parse options */ @@ -125,7 +123,7 @@ int chmod_chown_chgrp_main(int argc, char **argv) recursiveFlag = TRUE; break; default: - fprintf(stderr, invalid_option, invocationName, **argv); + fprintf(stderr, invalid_option, applet_name, **argv); usage(appUsage); } } @@ -133,7 +131,7 @@ int chmod_chown_chgrp_main(int argc, char **argv) } if (argc == 0 || *argv == NULL) { - fprintf(stderr, too_few_args, invocationName); + fprintf(stderr, too_few_args, applet_name); usage(appUsage); } @@ -172,14 +170,14 @@ int chmod_chown_chgrp_main(int argc, char **argv) uid = my_getpwnam(*argv); if (uid == -1) { fatalError( "%s: unknown user name: %s\n", - invocationName, *argv); + applet_name, *argv); } } } /* Ok, ready to do the deed now */ if (argc <= 1) { - fatalError( "%s: too few arguments\n", invocationName); + fatalError( "%s: too few arguments\n", applet_name); } while (argc-- > 1) { if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE, @@ -189,7 +187,7 @@ int chmod_chown_chgrp_main(int argc, char **argv) exit(TRUE); bad_group: - fatalError( "%s: unknown group name: %s\n", invocationName, groupName); + fatalError( "%s: unknown group name: %s\n", applet_name, groupName); } /* diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c index 0cad7717b..53d4d9a7c 100644 --- a/console-tools/deallocvt.c +++ b/console-tools/deallocvt.c @@ -14,8 +14,6 @@ #define VT_DISALLOCATE 0x5608 /* free memory associated to vt */ -char *progname; - int deallocvt_main(int argc, char *argv[]) { int fd, num, i; @@ -29,8 +27,6 @@ int deallocvt_main(int argc, char *argv[]) ); } - progname = argv[0]; - fd = get_console_fd("/dev/console"); if (argc == 1) { @@ -43,14 +39,14 @@ int deallocvt_main(int argc, char *argv[]) for (i = 1; i < argc; i++) { num = atoi(argv[i]); if (num == 0) - fprintf(stderr, "%s: 0: illegal VT number\n", progname); + fprintf(stderr, "%s: 0: illegal VT number\n", applet_name); else if (num == 1) fprintf(stderr, "%s: VT 1 cannot be deallocated\n", - progname); + applet_name); else if (ioctl(fd, VT_DISALLOCATE, num)) { perror("VT_DISALLOCATE"); fprintf(stderr, "%s: could not deallocate console %d\n", - progname, num); + applet_name, num); exit( FALSE); } } diff --git a/coreutils/cut.c b/coreutils/cut.c index a8a9d7fd1..820074e60 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c @@ -71,7 +71,6 @@ int num_args; int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */ char delim = '\t'; /* default delimiting character */ FILE *fd; -char *name; char line[BUFSIZ]; int exit_status; int option = 0; /* for -s option */ @@ -91,7 +90,7 @@ void warn(int warn_number, char *option) "%s: Cannot open %s\n" }; - fprintf(stderr, warn_msg[warn_number], name, option); + fprintf(stderr, warn_msg[warn_number], applet_name, option); exit_status = warn_number + 1; } @@ -107,7 +106,7 @@ void cuterror(int err) "%s: MAX_ARGS exceeded\n" }; - fprintf(stderr, err_mes[err - 101], name); + fprintf(stderr, err_mes[err - 101], applet_name); exit(err); } @@ -213,8 +212,6 @@ int cut_main(int argc, char **argv) int i = 1; int numberFilenames = 0; - name = argv[0]; - if (argc == 1 || strcmp(argv[1], dash_dash_help)==0) usage( "cut [OPTION]... [FILE]...\n" #ifndef BB_FEATURE_TRIVIAL_HELP diff --git a/cp_mv.c b/cp_mv.c index b15235a25..3dc637d7f 100644 --- a/cp_mv.c +++ b/cp_mv.c @@ -45,7 +45,6 @@ #define is_cp 0 #define is_mv 1 static int dz_i; /* index into cp_mv_usage */ -static const char *dz; /* dollar zero, .bss */ static const char *cp_mv_usage[] = /* .rodata */ { "cp [OPTION]... SOURCE DEST\n" @@ -89,7 +88,7 @@ static void name_too_long__exit (void) __attribute__((noreturn)); static void name_too_long__exit (void) { - fprintf(stderr, name_too_long, dz); + fprintf(stderr, name_too_long, applet_name); exit(FALSE); } @@ -124,14 +123,14 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk) if (srcDirFlag == TRUE) { if (recursiveFlag == FALSE) { - fprintf(stderr, omitting_directory, dz, baseSrcName); + fprintf(stderr, omitting_directory, applet_name, baseSrcName); return TRUE; } srcBasename = (strstr(fileName, baseSrcName) + strlen(baseSrcName)); if (destLen + strlen(srcBasename) > BUFSIZ) { - fprintf(stderr, name_too_long, dz); + fprintf(stderr, name_too_long, applet_name); return FALSE; } strcat(destName, srcBasename); @@ -146,7 +145,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk) mv_Action_first_time = errno = 0; if (rename(fileName, destName) < 0 && errno != EXDEV) { fprintf(stderr, "%s: rename(%s, %s): %s\n", - dz, fileName, destName, strerror(errno)); + applet_name, fileName, destName, strerror(errno)); goto do_copyFile; /* Try anyway... */ } else if (errno == EXDEV) @@ -159,7 +158,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk) if (is_in_ino_dev_hashtable(statbuf, &name)) { if (link(name, destName) < 0) { fprintf(stderr, "%s: link(%s, %s): %s\n", - dz, name, destName, strerror(errno)); + applet_name, name, destName, strerror(errno)); return FALSE; } return TRUE; @@ -178,11 +177,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk) if (S_ISDIR(statbuf->st_mode)) { if (rmdir(fileName) < 0) { - fprintf(stderr, "%s: rmdir(%s): %s\n", dz, fileName, strerror(errno)); + fprintf(stderr, "%s: rmdir(%s): %s\n", applet_name, fileName, strerror(errno)); status = FALSE; } } else if (unlink(fileName) < 0) { - fprintf(stderr, "%s: unlink(%s): %s\n", dz, fileName, strerror(errno)); + fprintf(stderr, "%s: unlink(%s): %s\n", applet_name, fileName, strerror(errno)); status = FALSE; } return status; @@ -190,8 +189,7 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk) extern int cp_mv_main(int argc, char **argv) { - dz = *argv; /* already basename'd by busybox.c:main */ - if (*dz == 'c' && *(dz + 1) == 'p') + if (*applet_name == 'c' && *(applet_name + 1) == 'p') dz_i = is_cp; else dz_i = is_mv; @@ -276,20 +274,20 @@ extern int cp_mv_main(int argc, char **argv) char *pushd, *d, *p; if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) { - fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno)); + fprintf(stderr, "%s: getcwd(): %s\n", applet_name, strerror(errno)); continue; } if (chdir(baseDestName) < 0) { - fprintf(stderr, "%s: chdir(%s): %s\n", dz, baseSrcName, strerror(errno)); + fprintf(stderr, "%s: chdir(%s): %s\n", applet_name, baseSrcName, strerror(errno)); continue; } if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { - fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno)); + fprintf(stderr, "%s: getcwd(): %s\n", applet_name, strerror(errno)); continue; } while (!state && *d != '\0') { if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ - fprintf(stderr, "%s: stat(%s) :%s\n", dz, d, strerror(errno)); + fprintf(stderr, "%s: stat(%s) :%s\n", applet_name, d, strerror(errno)); state = -1; continue; } @@ -298,7 +296,7 @@ extern int cp_mv_main(int argc, char **argv) fprintf(stderr, "%s: Cannot %s `%s' " "into a subdirectory of itself, `%s/%s'\n", - dz, dz, baseSrcName, baseDestName, baseSrcName); + applet_name, applet_name, baseSrcName, baseDestName, baseSrcName); state = -1; continue; } @@ -307,7 +305,7 @@ extern int cp_mv_main(int argc, char **argv) } } if (chdir(pushd) < 0) { - fprintf(stderr, "%s: chdir(%s): %s\n", dz, pushd, strerror(errno)); + fprintf(stderr, "%s: chdir(%s): %s\n", applet_name, pushd, strerror(errno)); free(pushd); free(d); continue; diff --git a/cut.c b/cut.c index a8a9d7fd1..820074e60 100644 --- a/cut.c +++ b/cut.c @@ -71,7 +71,6 @@ int num_args; int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */ char delim = '\t'; /* default delimiting character */ FILE *fd; -char *name; char line[BUFSIZ]; int exit_status; int option = 0; /* for -s option */ @@ -91,7 +90,7 @@ void warn(int warn_number, char *option) "%s: Cannot open %s\n" }; - fprintf(stderr, warn_msg[warn_number], name, option); + fprintf(stderr, warn_msg[warn_number], applet_name, option); exit_status = warn_number + 1; } @@ -107,7 +106,7 @@ void cuterror(int err) "%s: MAX_ARGS exceeded\n" }; - fprintf(stderr, err_mes[err - 101], name); + fprintf(stderr, err_mes[err - 101], applet_name); exit(err); } @@ -213,8 +212,6 @@ int cut_main(int argc, char **argv) int i = 1; int numberFilenames = 0; - name = argv[0]; - if (argc == 1 || strcmp(argv[1], dash_dash_help)==0) usage( "cut [OPTION]... [FILE]...\n" #ifndef BB_FEATURE_TRIVIAL_HELP diff --git a/deallocvt.c b/deallocvt.c index 0cad7717b..53d4d9a7c 100644 --- a/deallocvt.c +++ b/deallocvt.c @@ -14,8 +14,6 @@ #define VT_DISALLOCATE 0x5608 /* free memory associated to vt */ -char *progname; - int deallocvt_main(int argc, char *argv[]) { int fd, num, i; @@ -29,8 +27,6 @@ int deallocvt_main(int argc, char *argv[]) ); } - progname = argv[0]; - fd = get_console_fd("/dev/console"); if (argc == 1) { @@ -43,14 +39,14 @@ int deallocvt_main(int argc, char *argv[]) for (i = 1; i < argc; i++) { num = atoi(argv[i]); if (num == 0) - fprintf(stderr, "%s: 0: illegal VT number\n", progname); + fprintf(stderr, "%s: 0: illegal VT number\n", applet_name); else if (num == 1) fprintf(stderr, "%s: VT 1 cannot be deallocated\n", - progname); + applet_name); else if (ioctl(fd, VT_DISALLOCATE, num)) { perror("VT_DISALLOCATE"); fprintf(stderr, "%s: could not deallocate console %d\n", - progname, num); + applet_name, num); exit( FALSE); } }