From 240013872c392fe644bd4f79382d9f5314b4ea60 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Sat, 5 Nov 2011 14:04:02 +0100 Subject: [PATCH] Renamed r1bindex() to mhbasename(), to make its function becomes clear. All calls to r1bindex() had '/' as second argument. For everything else one can use strrchr(3) instead of r1bindex(). --- h/prototypes.h | 2 +- sbr/Makefile.in | 2 +- sbr/ext_hook.c | 2 +- sbr/folder_delmsgs.c | 2 +- sbr/m_backup.c | 2 +- sbr/m_mktemp.c | 2 +- sbr/mhbasename.c | 32 ++++++++++++++++++++++++++++++++ sbr/r1bindex.c | 33 --------------------------------- sbr/refile.c | 2 +- sbr/showfile.c | 4 ++-- uip/ali.c | 2 +- uip/anno.c | 2 +- uip/ap.c | 2 +- uip/burst.c | 2 +- uip/comp.c | 2 +- uip/conflict.c | 4 ++-- uip/dist.c | 2 +- uip/dp.c | 2 +- uip/dropsbr.c | 2 +- uip/flist.c | 2 +- uip/fmtdump.c | 2 +- uip/folder.c | 2 +- uip/forw.c | 4 ++-- uip/inc.c | 2 +- uip/install-mh.c | 2 +- uip/mark.c | 2 +- uip/mhbuild.c | 2 +- uip/mhlist.c | 2 +- uip/mhlistsbr.c | 2 +- uip/mhlsbr.c | 6 +++--- uip/mhmail.c | 6 +++--- uip/mhparam.c | 2 +- uip/mhparse.c | 8 ++++---- uip/mhpath.c | 2 +- uip/mhshow.c | 2 +- uip/mhshowsbr.c | 2 +- uip/mhstore.c | 2 +- uip/mhstoresbr.c | 2 +- uip/mhtest.c | 2 +- uip/msgchk.c | 2 +- uip/new.c | 4 ++-- uip/packf.c | 2 +- uip/pick.c | 2 +- uip/prompter.c | 2 +- uip/rcvdist.c | 4 ++-- uip/rcvpack.c | 2 +- uip/rcvstore.c | 2 +- uip/rcvtty.c | 2 +- uip/refile.c | 4 ++-- uip/repl.c | 2 +- uip/replsbr.c | 2 +- uip/rmf.c | 2 +- uip/rmm.c | 2 +- uip/scan.c | 2 +- uip/send.c | 4 ++-- uip/sendsbr.c | 2 +- uip/show.c | 12 ++++++------ uip/slocal.c | 2 +- uip/sortm.c | 2 +- uip/spost.c | 6 +++--- uip/viamail.c | 4 ++-- uip/whatnowproc.c | 2 +- uip/whatnowsbr.c | 14 +++++++------- 63 files changed, 121 insertions(+), 122 deletions(-) create mode 100644 sbr/mhbasename.c delete mode 100644 sbr/r1bindex.c diff --git a/h/prototypes.h b/h/prototypes.h index 6200ea6..15031ea 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -91,7 +91,7 @@ void print_sw(char *, struct swit *, char *, FILE *); void print_version(char *); void push(void); char *pwd(void); -char *r1bindex(char *, int); +char *mhbasename(char *); void readconfig(struct node **, FILE *, char *, int); int refile(char **, char *); void ruserpass(char *, char **, char **); diff --git a/sbr/Makefile.in b/sbr/Makefile.in index 0cb7488..ad54a95 100644 --- a/sbr/Makefile.in +++ b/sbr/Makefile.in @@ -67,7 +67,7 @@ SRCS = addrsbr.c ambigsw.c atooi.c brkstring.c \ makedir.c mts.c norm_charmap.c \ path.c peekc.c pidwait.c pidstatus.c \ print_help.c print_sw.c print_version.c push.c \ - putenv.c refile.c r1bindex.c \ + putenv.c refile.c mhbasename.c \ readconfig.c ruserpass.c seq_add.c seq_bits.c \ seq_del.c seq_getnum.c seq_list.c seq_nameok.c \ seq_print.c seq_read.c seq_save.c seq_setcur.c \ diff --git a/sbr/ext_hook.c b/sbr/ext_hook.c index db7bcec..a4b0934 100644 --- a/sbr/ext_hook.c +++ b/sbr/ext_hook.c @@ -29,7 +29,7 @@ ext_hook(char *hook_name, char *message_file_name_1, char *message_file_name_2) break; case 0: - vec[0] = r1bindex(hook, '/'); + vec[0] = mhbasename(hook); vec[1] = message_file_name_1; vec[2] = message_file_name_2; vec[3] = (char *)0; diff --git a/sbr/folder_delmsgs.c b/sbr/folder_delmsgs.c index 77131b1..ac93068 100644 --- a/sbr/folder_delmsgs.c +++ b/sbr/folder_delmsgs.c @@ -54,7 +54,7 @@ folder_delmsgs(struct msgs *mp, int unlink_msgs, int nohook) vec[vecp] = NULL; fflush(stdout); - vec[0] = r1bindex(rmmproc, '/'); + vec[0] = mhbasename(rmmproc); switch (pid = vfork()) { case -1: diff --git a/sbr/m_backup.c b/sbr/m_backup.c index 17f7ad5..3749452 100644 --- a/sbr/m_backup.c +++ b/sbr/m_backup.c @@ -15,7 +15,7 @@ m_backup(char *file) char *cp; static char buffer[BUFSIZ]; - if ((cp = r1bindex(file, '/')) == file) + if ((cp = mhbasename(file)) == file) snprintf(buffer, sizeof(buffer), "%s%s", backup_prefix, cp); else snprintf(buffer, sizeof(buffer), "%.*s%s%s", (int)(cp - file), diff --git a/sbr/m_mktemp.c b/sbr/m_mktemp.c index c0c1a9c..68f1a54 100644 --- a/sbr/m_mktemp.c +++ b/sbr/m_mktemp.c @@ -119,7 +119,7 @@ m_mktemp2( return m_mktemp(buffer, fd_ret, fp_ret); } - if ((cp = r1bindex((char *)dir_in, '/')) == dir_in) { + if ((cp = mhbasename((char *)dir_in)) == dir_in) { /* No directory component */ return m_mktemp(pfx_in, fd_ret, fp_ret); } diff --git a/sbr/mhbasename.c b/sbr/mhbasename.c new file mode 100644 index 0000000..038e506 --- /dev/null +++ b/sbr/mhbasename.c @@ -0,0 +1,32 @@ +/* +** mhbasename.c -- Given a path name, return a pointer to the character +** -- after the last slash. If none present, return the the +** -- beginning of the path. +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ + +#include + + +/* +** Note: In contrast to POSIX basename(), we don't handle trailing +** slashes special. If path has a trailing slash, we return a pointer +** to a null byte (i.e. to an empty string). Also different: We don't +** modify the original string neither do we return a pointer to static +** memory. +*/ +char * +mhbasename(char *path) +{ + char *cp; + + if (!path) { + return NULL; + } + cp = strrchr(path, '/'); + return (!cp) ? path : ++cp; + +} diff --git a/sbr/r1bindex.c b/sbr/r1bindex.c deleted file mode 100644 index 49ac0f5..0000000 --- a/sbr/r1bindex.c +++ /dev/null @@ -1,33 +0,0 @@ -/* -** r1bindex.c -- Given a string and a character, return a pointer -** -- to the right of the rightmost occurrence of the -** -- character. If the character doesn't occur, the -** -- pointer will be at the beginning of the string. -** -** This code is Copyright (c) 2002, by the authors of nmh. See the -** COPYRIGHT file in the root directory of the nmh distribution for -** complete copyright information. -*/ - -#include - - -char * -r1bindex(char *str, int chr) -{ - char *cp; - - /* find null at the end of the string */ - for (cp = str; *cp; cp++) - continue; - - /* backup to the rightmost character */ - --cp; - - /* now search for the rightmost occurrence of the character */ - while (cp >= str && *cp != chr) - --cp; - - /* now move one to the right */ - return (++cp); -} diff --git a/sbr/refile.c b/sbr/refile.c index 21d933c..00647dd 100644 --- a/sbr/refile.c +++ b/sbr/refile.c @@ -18,7 +18,7 @@ refile(char **arg, char *file) char *vec[MAXARGS]; vecp = 0; - vec[vecp++] = r1bindex(fileproc, '/'); + vec[vecp++] = mhbasename(fileproc); vec[vecp++] = "-nolink"; /* override bad .mh_profile defaults */ vec[vecp++] = "-nopreserve"; vec[vecp++] = "-file"; diff --git a/sbr/showfile.c b/sbr/showfile.c index c0d3608..3f23801 100644 --- a/sbr/showfile.c +++ b/sbr/showfile.c @@ -24,7 +24,7 @@ showfile(char **arg, char *file) ** then really invoked the mhlproc instead ** (which is usually mhl anyway). */ - if (!strcmp(r1bindex(lproc, '/'), "mhl")) + if (!strcmp(mhbasename(lproc), "mhl")) lproc = mhlproc; switch (pid = vfork()) { @@ -36,7 +36,7 @@ showfile(char **arg, char *file) case 0: /* child */ vecp = 0; - vec[vecp++] = r1bindex(lproc, '/'); + vec[vecp++] = mhbasename(lproc); isdraft = 1; if (arg) { while (*arg) { diff --git a/uip/ali.c b/uip/ali.c index 6b9dbf5..a4ab295 100644 --- a/uip/ali.c +++ b/uip/ali.c @@ -64,7 +64,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/anno.c b/uip/anno.c index a2cfc84..b7c1563 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -99,7 +99,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/ap.c b/uip/ap.c index 41e990a..b835acb 100644 --- a/uip/ap.c +++ b/uip/ap.c @@ -63,7 +63,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/burst.c b/uip/burst.c index 374eff5..a8f42d0 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -56,7 +56,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/comp.c b/uip/comp.c index 83b002a..7a49362 100644 --- a/uip/comp.c +++ b/uip/comp.c @@ -64,7 +64,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/conflict.c b/uip/conflict.c index 909bbc8..5710aab 100644 --- a/uip/conflict.c +++ b/uip/conflict.c @@ -68,7 +68,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* foil search of user profile/context */ if (context_foil(NULL) == -1) @@ -360,7 +360,7 @@ setup(void) dup2(fd, 1); close(fd); } - execlp(mailproc, r1bindex (mailproc, '/'), + execlp(mailproc, mhbasename(mailproc), mail, "-subject", invo_name, NULL); adios(mailproc, "unable to exec "); diff --git a/uip/dist.c b/uip/dist.c index 89315c2..5ff0d6c 100644 --- a/uip/dist.c +++ b/uip/dist.c @@ -53,7 +53,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/dp.c b/uip/dp.c index 878e2c1..a5accf5 100644 --- a/uip/dp.c +++ b/uip/dp.c @@ -57,7 +57,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/dropsbr.c b/uip/dropsbr.c index a857a1a..15cee8f 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -486,7 +486,7 @@ map_name(char *file) register char *cp, *dp; static char buffer[BUFSIZ]; - if ((dp = strchr(cp = r1bindex(file, '/'), '.')) == NULL) + if ((dp = strchr(cp = mhbasename(file), '.')) == NULL) dp = cp + strlen(cp); if (cp == file) snprintf(buffer, sizeof(buffer), ".%.*s%s", diff --git a/uip/flist.c b/uip/flist.c index a86d226..4bf3f82 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -128,7 +128,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/fmtdump.c b/uip/fmtdump.c index 2096c64..adda294 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -52,7 +52,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/folder.c b/uip/folder.c index ac931ce..25ab068 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -122,7 +122,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/forw.c b/uip/forw.c index 9ad2877..13aaaa9 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -109,7 +109,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); @@ -385,7 +385,7 @@ mhl_draft(int out, char *digest, int volume, int issue, if (pipe(pd) == NOTOK) adios("pipe", "unable to create"); - vec[0] = r1bindex(mhlproc, '/'); + vec[0] = mhbasename(mhlproc); for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++) sleep(5); diff --git a/uip/inc.c b/uip/inc.c index 186312e..c06c57c 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -163,7 +163,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/install-mh.c b/uip/install-mh.c index 50854f0..11f7bc5 100644 --- a/uip/install-mh.c +++ b/uip/install-mh.c @@ -43,7 +43,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); arguments = getarguments(invo_name, argc, argv, 0); argp = arguments; diff --git a/uip/mark.c b/uip/mark.c index bdd02ad..fa5c2cb 100644 --- a/uip/mark.c +++ b/uip/mark.c @@ -59,7 +59,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/mhbuild.c b/uip/mhbuild.c index e1ca05f..735a77e 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -130,7 +130,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/mhlist.c b/uip/mhlist.c index 9ec8f5d..f33e39b 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -131,7 +131,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/mhlistsbr.c b/uip/mhlistsbr.c index 2b32b64..7830173 100644 --- a/uip/mhlistsbr.c +++ b/uip/mhlistsbr.c @@ -171,7 +171,7 @@ list_content(CT ct, int toplevel, int realsize, int verbose, int debug) CI ci = &ct->c_ctinfo; printf(toplevel > 0 ? LSTFMT2a : toplevel < 0 ? "part " : " ", - atoi(r1bindex(empty(ct->c_file), '/'))); + atoi(mhbasename(empty(ct->c_file)))); snprintf(buffer, sizeof(buffer), "%s/%s", empty(ci->ci_type), empty(ci->ci_subtype)); printf(LSTFMT2b, empty(ct->c_partno), buffer); diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index c4e822b..ded6194 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -300,7 +300,7 @@ mhl(int argc, char **argv) char buf[BUFSIZ], *files[MAXARGS]; char **argp, **arguments; - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); @@ -1622,7 +1622,7 @@ doface(struct mcomp *c1) close(pdo[1]); } vecp = 0; - vec[vecp++] = r1bindex(faceproc, '/'); + vec[vecp++] = mhbasename(faceproc); vec[vecp++] = "-e"; if (sleepsw != NOTOK) { vec[vecp++] = "-s"; @@ -1790,7 +1790,7 @@ m_popen(char *name) dup2(pd[0], fileno(stdin)); close(pd[0]); } - execlp(name, r1bindex(name, '/'), NULL); + execlp(name, mhbasename(name), NULL); fprintf(stderr, "unable to exec "); perror(name); _exit(-1); diff --git a/uip/mhmail.c b/uip/mhmail.c index c7a7afa..037246d 100644 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@ -54,7 +54,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* foil search of user profile/context */ if (context_foil(NULL) == -1) @@ -62,7 +62,7 @@ main(int argc, char **argv) /* If no arguments, just incorporate new mail */ if (argc == 1) { - execlp(incproc, r1bindex(incproc, '/'), NULL); + execlp(incproc, mhbasename(incproc), NULL); adios(incproc, "unable to exec"); } @@ -160,7 +160,7 @@ main(int argc, char **argv) fclose(out); nvec = 0; - vec[nvec++] = r1bindex(postproc, '/'); + vec[nvec++] = mhbasename(postproc); vec[nvec++] = tmpfil; if (resent) vec[nvec++] = "-dist"; diff --git a/uip/mhparam.c b/uip/mhparam.c index 575c7a7..5bbd9fc 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -84,7 +84,7 @@ main(int argc, char **argv) char *cp, buf[BUFSIZ], **argp; char **arguments, *comps[MAXARGS]; - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/mhparse.c b/uip/mhparse.c index db6f0ad..6553ac3 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -946,11 +946,11 @@ bad_quote: /* ** If there is a Content-Disposition header and ** it doesn't have a *filename=, extract it from - ** the magic contents. The r1bindex call skips + ** the magic contents. The mhbasename call skips ** any leading directory components. */ if (ct->c_dispo) - ct->c_dispo = incl_name_value(ct->c_dispo, "filename", r1bindex(extract_name_value("name", ci->ci_magic), '/')); + ct->c_dispo = incl_name_value(ct->c_dispo, "filename", mhbasename(extract_name_value("name", ci->ci_magic))); } else advise(NULL, "extraneous information in message %s's %s: field\n%*.*s(%s)", ct->c_file, TYPE_FIELD, i, i, "", cp); } @@ -2603,7 +2603,7 @@ openFTP(CT ct, char **file) char *vec[9]; vecp = 0; - vec[vecp++] = r1bindex(ftp, '/'); + vec[vecp++] = mhbasename(ftp); vec[vecp++] = e->eb_site; vec[vecp++] = user; vec[vecp++] = pass; @@ -2757,7 +2757,7 @@ openMail(CT ct, char **file) return NOTOK; vecp = 0; - vec[vecp++] = r1bindex(mailproc, '/'); + vec[vecp++] = mhbasename(mailproc); vec[vecp++] = e->eb_server; vec[vecp++] = "-subject"; vec[vecp++] = e->eb_subject ? e->eb_subject : "mail-server request"; diff --git a/uip/mhpath.c b/uip/mhpath.c index 6f53aba..bce976d 100644 --- a/uip/mhpath.c +++ b/uip/mhpath.c @@ -30,7 +30,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/mhshow.c b/uip/mhshow.c index ea66f32..ba5c037 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -147,7 +147,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index f79d42e..0a527ad 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -200,7 +200,7 @@ DisplayMsgHeader(CT ct, char *form) char *vec[8]; vecp = 0; - vec[vecp++] = r1bindex(mhlproc, '/'); + vec[vecp++] = mhbasename(mhlproc); vec[vecp++] = "-form"; vec[vecp++] = form; vec[vecp++] = "-nobody"; diff --git a/uip/mhstore.c b/uip/mhstore.c index dd5f517..7be9163 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -125,7 +125,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index 8b2dc00..027dac6 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -952,7 +952,7 @@ parse_format_string(CT ct, char *cp, char *buffer, int buflen, char *dir) case 'm': /* insert message number */ - snprintf(bp, buflen, "%s", r1bindex(ct->c_file, '/')); + snprintf(bp, buflen, "%s", mhbasename(ct->c_file)); break; case 'P': diff --git a/uip/mhtest.c b/uip/mhtest.c index 621c701..17ca1ab 100644 --- a/uip/mhtest.c +++ b/uip/mhtest.c @@ -127,7 +127,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/msgchk.c b/uip/msgchk.c index ffde2b4..7b29b54 100644 --- a/uip/msgchk.c +++ b/uip/msgchk.c @@ -68,7 +68,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/new.c b/uip/new.c index 9236662..c1ae0cc 100644 --- a/uip/new.c +++ b/uip/new.c @@ -436,7 +436,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); @@ -475,7 +475,7 @@ main(int argc, char **argv) if (!(invo_name = *argp++) || *invo_name == '-') adios(NULL, "missing argument to %s", argp[-2]); - invo_name = r1bindex(invo_name, '/'); + invo_name = mhbasename(invo_name); continue; } } diff --git a/uip/packf.c b/uip/packf.c index 14ecdaa..d4df05c 100644 --- a/uip/packf.c +++ b/uip/packf.c @@ -50,7 +50,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/pick.c b/uip/pick.c index 040ebec..93a2400 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -84,7 +84,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/prompter.c b/uip/prompter.c index a75c563..5b2131c 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -110,7 +110,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/rcvdist.c b/uip/rcvdist.c index 62ae2a8..24cf48b 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -49,7 +49,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); @@ -107,7 +107,7 @@ main(int argc, char **argv) if (distout(drft, tmpfil, backup) == NOTOK) done(1); - vec[0] = r1bindex(postproc, '/'); + vec[0] = mhbasename(postproc); vec[vecp++] = "-dist"; vec[vecp++] = drft; vec[vecp] = NULL; diff --git a/uip/rcvpack.c b/uip/rcvpack.c index e8934ca..84fcc26 100644 --- a/uip/rcvpack.c +++ b/uip/rcvpack.c @@ -40,7 +40,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/rcvstore.c b/uip/rcvstore.c index 868ed47..06b8b69 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -63,7 +63,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/rcvtty.c b/uip/rcvtty.c index 1e2a3ef..20274e7 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -99,7 +99,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/refile.c b/uip/refile.c index b24e42e..a79e8be 100644 --- a/uip/refile.c +++ b/uip/refile.c @@ -73,7 +73,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); @@ -335,7 +335,7 @@ remove_files(int filep, char **files) files[filep] = NULL; /* NULL terminate list */ fflush(stdout); - vec[0] = r1bindex(rmmproc, '/'); + vec[0] = mhbasename(rmmproc); execvp(rmmproc, vec); adios(rmmproc, "unable to exec"); } diff --git a/uip/repl.c b/uip/repl.c index 6893f56..61ba08c 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -121,7 +121,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/replsbr.c b/uip/replsbr.c index e26badd..1bdab9e 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -436,7 +436,7 @@ replfilter(FILE *in, FILE *out, char *filter) if (access(filter, R_OK) == NOTOK) adios(filter, "unable to read"); - mhl = r1bindex(mhlproc, '/'); + mhl = mhbasename(mhlproc); rewind(in); lseek(fileno(in), (off_t) 0, SEEK_SET); diff --git a/uip/rmf.c b/uip/rmf.c index fff4abb..71fd017 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -37,7 +37,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/rmm.c b/uip/rmm.c index f8a1d23..7f77340 100644 --- a/uip/rmm.c +++ b/uip/rmm.c @@ -35,7 +35,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/scan.c b/uip/scan.c index 03a260b..b42d8a2 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -73,7 +73,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/send.c b/uip/send.c index 2416baf..f777155 100644 --- a/uip/send.c +++ b/uip/send.c @@ -118,7 +118,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); @@ -361,7 +361,7 @@ main(int argc, char **argv) push(); status = 0; - vec[0] = r1bindex(postproc, '/'); + vec[0] = mhbasename(postproc); closefds(3); for (msgnum = 0; msgnum < msgp; msgnum++) { diff --git a/uip/sendsbr.c b/uip/sendsbr.c index c7f4d44..4670345 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -709,7 +709,7 @@ alert(char *file, int out) snprintf(buf, sizeof(buf), "send failed on %s", forwsw ? "enclosed draft" : file); - execlp(mailproc, r1bindex(mailproc, '/'), + execlp(mailproc, mhbasename(mailproc), getusername(), "-subject", buf, NULL); fprintf(stderr, "unable to exec "); perror(mailproc); diff --git a/uip/show.c b/uip/show.c index f536af7..b19f762 100644 --- a/uip/show.c +++ b/uip/show.c @@ -71,7 +71,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); @@ -301,7 +301,7 @@ go_to_it: ; ** then add "-show" option. Add "-file" if showing ** file. */ - if (strcmp(r1bindex(proc, '/'), "mhn") == 0) { + if (strcmp(mhbasename(proc), "mhn") == 0) { if (file) { vec[vecp] = vec[vecp - 1]; vec[vecp - 1] = "-file"; @@ -312,7 +312,7 @@ go_to_it: ; } /* If the "proc" is "mhshow", add "-file" if showing file. */ - if (strcmp(r1bindex(proc, '/'), "mhshow") == 0 && file ) { + if (strcmp(mhbasename(proc), "mhshow") == 0 && file ) { vec[vecp] = vec[vecp - 1]; vec[vecp - 1] = "-file"; vec[++vecp] = NULL; @@ -322,7 +322,7 @@ go_to_it: ; ** If "proc" is mhl, then run it internally ** rather than exec'ing it. */ - if (strcmp(r1bindex(proc, '/'), "mhl") == 0) { + if (strcmp(mhbasename(proc), "mhl") == 0) { vec[0] = "mhl"; mhl(vecp, vec); done(0); @@ -333,7 +333,7 @@ go_to_it: ; ** add the path to the message names. Currently, we are just ** checking for mhn here, since we've already taken care of mhl. */ - if (!strcmp(r1bindex(proc, '/'), "mhl") + if (!strcmp(mhbasename(proc), "mhl") && !file && chdir(maildir = concat(m_maildir(""), "/", NULL)) != NOTOK) { @@ -345,7 +345,7 @@ go_to_it: ; vec[msgnum] = concat(cp, vec[msgnum], NULL); } - vec[0] = r1bindex(proc, '/'); + vec[0] = mhbasename(proc); execvp(proc, vec); adios(proc, "unable to exec"); return 0; /* dead code to satisfy the compiler */ diff --git a/uip/slocal.c b/uip/slocal.c index 2e7c257..8b8d554 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -214,7 +214,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(*argv, '/'); + invo_name = mhbasename(*argv); /* foil search of user profile/context */ if (context_foil(NULL) == -1) diff --git a/uip/sortm.c b/uip/sortm.c index a5d0e11..ffe14f8 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -78,7 +78,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); diff --git a/uip/spost.c b/uip/spost.c index e87fcf1..0679ac6 100644 --- a/uip/spost.c +++ b/uip/spost.c @@ -202,7 +202,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* foil search of user profile/context */ if (context_foil(NULL) == -1) @@ -795,7 +795,7 @@ make_bcc_file(void) cpydgst(fd, fileno(out), tmpfil, bccfil); close(fd); } else { - vec[0] = r1bindex(mhlproc, '/'); + vec[0] = mhbasename(mhlproc); for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++) sleep(5); @@ -871,7 +871,7 @@ fcc(char *file, char *folder) case OK: snprintf(fold, sizeof(fold), "%s%s", *folder == '+' || *folder == '@' ? "" : "+", folder); - execlp(fileproc, r1bindex(fileproc, '/'), + execlp(fileproc, mhbasename(fileproc), "-link", "-file", file, fold, NULL); _exit(-1); diff --git a/uip/viamail.c b/uip/viamail.c index bbae08b..3fff44a 100644 --- a/uip/viamail.c +++ b/uip/viamail.c @@ -75,7 +75,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* foil search of user profile/context */ if (context_foil(NULL) == -1) @@ -218,7 +218,7 @@ via_mail(char *mailsw, char *subjsw, char *parmsw, char *descsw, adios("failed", "fstat of %s", tmpfil); status = 0; - vec[0] = r1bindex(postproc, '/'); + vec[0] = mhbasename(postproc); if (verbsw) vec[vecp++] = "-verbose"; diff --git a/uip/whatnowproc.c b/uip/whatnowproc.c index 583f133..8d6830e 100644 --- a/uip/whatnowproc.c +++ b/uip/whatnowproc.c @@ -32,7 +32,7 @@ what_now(char *ed, int nedit, int use, char *file, char *altmsg, int dist, char buffer[BUFSIZ], *vec[MAXARGS]; vecp = 0; - vec[vecp++] = r1bindex(whatnowproc, '/'); + vec[vecp++] = mhbasename(whatnowproc); vec[vecp] = NULL; m_putenv("mhdraft", file); diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index 5a31a90..a5f8839 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -136,7 +136,7 @@ WhatNow(int argc, char **argv) char *l; /* set on -l to alist command */ int n; /* set on -n to alist command */ - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); @@ -651,7 +651,7 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, if (reedit) { if (!*ed) { /* no explicit editor */ *ed = edsave; /* so use the previous one */ - if ((cp = r1bindex(*ed, '/')) == NULL) + if ((cp = mhbasename(*ed)) == NULL) cp = *ed; /* unless we've specified it via "editor-next" */ @@ -719,7 +719,7 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, } vecp = 0; - vec[vecp++] = r1bindex(*ed, '/'); + vec[vecp++] = mhbasename(*ed); if (arg) while (*arg) vec[vecp++] = *arg++; @@ -734,7 +734,7 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, default: if ((status = pidwait(pid, NOTOK))) { #ifdef ATTVIBUG - if ((cp = r1bindex(*ed, '/')) && + if ((cp = mhbasename(*ed)) && strcmp(cp, "vi") == 0 && (status & 0x00ff) == 0) status = 0; @@ -845,7 +845,7 @@ sendfile(char **arg, char *file, int pushsw) ** If the sendproc is the nmh command `send', then we call ** those routines directly rather than exec'ing the command. */ - if (strcmp(sp = r1bindex(sendproc, '/'), "send") == 0) { + if (strcmp(sp = mhbasename(sendproc), "send") == 0) { cp = invo_name; sendit(invo_name = sp, arg, file, pushsw); invo_name = cp; @@ -909,7 +909,7 @@ buildfile(char **argp, char *file) ** if we are using mhn as buildmimeproc */ i = 0; - if (strcmp(r1bindex(ed, '/'), "mhn") == 0) + if (strcmp(mhbasename(ed), "mhn") == 0) args[i++] = "-build"; /* copy any other arguments */ @@ -1292,7 +1292,7 @@ sendit(char *sp, char **arg, char *file, int pushed) if ((pushsw = pushed)) push(); - vec[0] = r1bindex(postproc, '/'); + vec[0] = mhbasename(postproc); closefds(3); if (sendsbr(vec, vecp, file, &st, 1, attach, attachformat) == OK) -- 1.7.10.4