From: keie Date: Fri, 25 Jan 1985 11:04:18 +0000 (+0000) Subject: The program name is used to set the name X-Git-Tag: release-5-5~5703 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=6d344b67023482603812878186b98229d105d3f2;p=ack.git The program name is used to set the name of the file were the contents of data statements are written. The filename is extracted from the path and the suffix (if present) is replaced by .d. --- diff --git a/lang/basic/src.old/initialize.c b/lang/basic/src.old/initialize.c index 9a6e4851d..12a799127 100644 --- a/lang/basic/src.old/initialize.c +++ b/lang/basic/src.old/initialize.c @@ -13,8 +13,25 @@ FILE *datfile; initialize() { + register char *cindex, *cptr ; + sprintf(tmpfname,"%s/abc%d",TMP_DIR,getpid()); - strcpy(datfname,program); + /* Find the basename */ + /* Strip leading directories */ + cindex= (char *)0 ; + for ( cptr=program ; *cptr ; cptr++ ) if ( *cptr=='/' ) cindex=cptr ; + if ( !cindex ) cindex= program ; + else { + cindex++ ; + if ( !*cindex ) { + warning("Null program name, assuming \"basic\"") ; + cindex= "basic" ; + } + } + cptr=datfname ; + while ( *cptr++ = *cindex++ ) ; + /* Strip trailing suffix */ + if ( cptr>datfname+3 && cptr[-3]=='.' ) cptr[-3]=0 ; strcat(datfname,".d"); yyin= fopen(inpfile,"r"); emfile= fopen(outfile,"w");