wht@gatech.edu@n4hgf.UUCP (Warren Tucker) (08/17/90)
Posting-number: Volume 14, Issue 60 Submitted-by: wht@gatech.edu@n4hgf.UUCP (Warren Tucker) Archive-name: u386mon-2.20/patch01 An embarassing bug. **argv is NOT the same as argv[0] :-(. This fixes a bug which causes the first line to be wrong, if you are lucky, else trap with a bus error mif you are unlucky. *** 2.20/u386mon.c Fri Aug 10 14:23:00 1990 --- u386mon.c Tue Aug 14 19:08:57 1990 *************** *** 1,4 ! char *revision = "2.20"; /*+------------------------------------------------------------------------- u386mon.c - UNIX 386 (and other) system monitor ...!{gatech,emory}!n4hgf!wht --- 1,4 ----- ! char *revision = "2.21"; /*+------------------------------------------------------------------------- u386mon.c - UNIX 386 (and other) system monitor ...!{gatech,emory}!n4hgf!wht *************** *** 38,43 --------------------------------------------------------------------------*/ /*+:EDITS:*/ /*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */ /*:08-07-1990-14:24-wht@n4hgf-nba@sysware.sysware.dk S5R31 updates */ /*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */ --- 38,44 ----- --------------------------------------------------------------------------*/ /*+:EDITS:*/ + /*:08-14-1990-19:08-root@n4hgf-fix **argv bug */ /*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */ /*:08-07-1990-14:24-wht@n4hgf-nba@sysware.sysware.dk S5R31 updates */ /*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */ *************** *** 189,194 time_t wait_ticks[5]; /*+------------------------------------------------------------------------- leaving() - perform leave() basic processing and return --------------------------------------------------------------------------*/ void --- 190,216 ----- time_t wait_ticks[5]; /*+------------------------------------------------------------------------- + basename(fullname) - strip directory name from filename + + returns address of static string + --------------------------------------------------------------------------*/ + char * + basename(fullname) + char *fullname; + { + register char *start; + static char outstr[256]; + char *strrchr(); + + start = strrchr(fullname,'/'); /* find last slash */ + if(!start) + return(fullname); + start++; + strcpy(outstr,start); + return(outstr); + } /* end of basename */ + + /*+------------------------------------------------------------------------- leaving() - perform leave() basic processing and return --------------------------------------------------------------------------*/ void *************** *** 778,784 (char *)0 }; char **cpptr = usage_str; ! fprintf(stderr,"usage: %s [-l] [-p | -P]\n",**argv); while(*cpptr) (void)fprintf(stderr,"%s\n",*(cpptr++)); exit(1); --- 800,806 ----- (char *)0 }; char **cpptr = usage_str; ! fprintf(stderr,"usage: %s [-l] [-p | -P]\n",basename(*argv)); while(*cpptr) (void)fprintf(stderr,"%s\n",*(cpptr++)); exit(1); *************** *** 922,928 wmove(wscr,0,0); use_cp(wscr,cpBANNER); waddch(wscr,(chtype)' '); ! waddstr(wscr,**argv); waddch(wscr,(chtype)' '); waddstr(wscr,revision); --- 944,950 ----- wmove(wscr,0,0); use_cp(wscr,cpBANNER); waddch(wscr,(chtype)' '); ! waddstr(wscr,basename(*argv)); waddch(wscr,(chtype)' '); waddstr(wscr,revision);