wescott@sauron.UUCP (05/28/87)
I should be surprised that these bugs are as old as they are, but make is difficult enough to get right that most users have figured it was their own fault when things didn't work. I know that I did. These bugs all involve make's handling of automatic get's of SCCS files. Auto get's happen for description files on the command line (-f option), for included files, and for dependencies and targets if the (undocumented) -g option is invoked. Problem 1: Make trys to get the wrong file: make -f ../xxx where s.xxx (and not xxx) exists in .. causes make to cd ..; get ../s.xxx which won't usually work, and if it does is most certainly wrong. Problem 2: Make will remove an s. file: make -f ./xxx where . contains s.xxx will work ok until make finishes at which time it removes s.xxx rather than ./xxx Problem 3: If s.xxx is a description file and s.s.xxx its SCCS file. Then make -f s.xxx will cause make to do a get on s.xxx rather than on s.s.xxx Problem 4: Using the -g option (do an automatic get) causes a get to be done in the cwd rather than creating the intended target. Problem 5: make closes stdin when stdin is a description file: make -f - < Makefile will cause all command invoked by make to be exec'd without an open stdin. This can screw up filename expansion on some older /bin/sh's. Patch with this -- your line numbers are probably different. -Mike Wescott ncrcae!wescott wescott@ncrcae.Columbia.NCR.COM *** doname.c.orig Wed May 27 17:26:04 1987 --- doname.c Wed May 27 17:26:14 1987 *************** *** 353,359 } } else if(IS_OFF(GET) || ! !get(p->namep, NOCD, 0) ) { fatal1(" Don't know how to make %s", p->namep); } --- 353,359 ----- } } else if(IS_OFF(GET) || ! !get(p->namep, CD, 0) ) { fatal1(" Don't know how to make %s", p->namep); } *** main.c.orig Thu May 28 11:24:21 1987 --- main.c Wed May 27 13:12:34 1987 *************** *** 342,348 if( yyparse() ) fatal("Description file error"); ! if(fin != NULL) fclose(fin); return(0); --- 342,348 ----- if( yyparse() ) fatal("Description file error"); ! if(fin != NULL && fin != stdin) fclose(fin); return(0); *** misc.c.orig Wed May 27 17:26:42 1987 --- misc.c Thu May 28 12:57:13 1987 *************** *** 1081,1086 { register CHARSTAR pr; register CHARSTAR pr1; char gbuf[128]; char sfile[128]; int retval; --- 1081,1087 ----- { register CHARSTAR pr; register CHARSTAR pr1; + register CHARSTAR pr2; char gbuf[128]; char sfile[128]; int retval; *************** *** 1084,1089 char gbuf[128]; char sfile[128]; int retval; GOTF gf; copstr(sfile, ssfile); --- 1085,1091 ----- char gbuf[128]; char sfile[128]; int retval; + int retryflg = 0; GOTF gf; #ifdef MKDEBUG *************** *** 1086,1091 int retval; GOTF gf; copstr(sfile, ssfile); if(!sdot(sfile)) trysccs(sfile); --- 1088,1096 ----- int retryflg = 0; GOTF gf; + #ifdef MKDEBUG + if(IS_ON(DBUG))printf("get: %s\n", ssfile); + #endif copstr(sfile, ssfile); if(!sdot(sfile)) trysccs(sfile); *************** *** 1089,1094 copstr(sfile, ssfile); if(!sdot(sfile)) trysccs(sfile); if(access(sfile, 4) != 0 && IS_OFF(GET)) return(NO); --- 1094,1102 ----- copstr(sfile, ssfile); if(!sdot(sfile)) trysccs(sfile); + else + retryflg++; + retry: if(access(sfile, 4) != 0 && IS_OFF(GET)) if (retryflg) { retryflg = 0; *************** *** 1090,1096 if(!sdot(sfile)) trysccs(sfile); if(access(sfile, 4) != 0 && IS_OFF(GET)) ! return(NO); pr = gbuf; if(IS_OFF(SIL)) --- 1098,1111 ----- retryflg++; retry: if(access(sfile, 4) != 0 && IS_OFF(GET)) ! if (retryflg) { ! retryflg = 0; ! copstr(sfile, ssfile); ! trysccs(sfile); ! goto retry; ! } ! else ! return(NO); pr = gbuf; if(IS_OFF(SIL)) *************** *** 1096,1102 if(IS_OFF(SIL)) pr = copstr(pr, "set -x;\n"); ! if(cdflag == CD) if(any(sfile, SLASH)) { pr = copstr(pr, "cd "); --- 1111,1117 ----- if(IS_OFF(SIL)) pr = copstr(pr, "set -x;\n"); ! pr1 = sfile; if(any(sfile, SLASH)) { for(; *pr1; pr1++); *************** *** 1099,1106 if(cdflag == CD) if(any(sfile, SLASH)) { ! pr = copstr(pr, "cd "); ! for(pr1 = sfile; *pr1; pr1++); while(*pr1 != SLASH) pr1--; *pr1 = CNULL; --- 1114,1120 ----- pr1 = sfile; if(any(sfile, SLASH)) { ! for(; *pr1; pr1++); while(*pr1 != SLASH) pr1--; *pr1 = CNULL; *************** *** 1104,1112 while(*pr1 != SLASH) pr1--; *pr1 = CNULL; ! pr = copstr(pr, sfile); ! pr = copstr(pr, ";\n"); ! *pr1 = SLASH; } pr = copstr(pr, varptr("GET")->varval); --- 1118,1129 ----- while(*pr1 != SLASH) pr1--; *pr1 = CNULL; ! if(cdflag == CD) { ! pr = copstr(pr, "cd "); ! pr = copstr(pr, sfile); ! pr = copstr(pr, ";\n"); ! } ! *pr1++ = SLASH; } pr = copstr(pr, varptr("GET")->varval); *************** *** 1114,1121 pr = copstr(pr, varptr("GFLAGS")->varval); pr = copstr(pr, " "); ! pr1 = rlse; ! if(pr1 != NULL && pr1[0] != CNULL) { if(pr1[0] != MINUS) /* RELEASE doesn't have '-r' */ pr = copstr(pr, "-r"); --- 1131,1138 ----- pr = copstr(pr, varptr("GFLAGS")->varval); pr = copstr(pr, " "); ! pr2 = rlse; ! if(pr2 != NULL && pr2[0] != CNULL) { if(pr2[0] != MINUS) /* RELEASE doesn't have '-r' */ pr = copstr(pr, "-r"); *************** *** 1117,1123 pr1 = rlse; if(pr1 != NULL && pr1[0] != CNULL) { ! if(pr1[0] != MINUS) /* RELEASE doesn't have '-r' */ pr = copstr(pr, "-r"); pr = copstr(pr, pr1); pr = copstr(pr, " "); --- 1134,1140 ----- pr2 = rlse; if(pr2 != NULL && pr2[0] != CNULL) { ! if(pr2[0] != MINUS) /* RELEASE doesn't have '-r' */ pr = copstr(pr, "-r"); pr = copstr(pr, pr2); pr = copstr(pr, " "); *************** *** 1119,1125 { if(pr1[0] != MINUS) /* RELEASE doesn't have '-r' */ pr = copstr(pr, "-r"); ! pr = copstr(pr, pr1); pr = copstr(pr, " "); } --- 1136,1142 ----- { if(pr2[0] != MINUS) /* RELEASE doesn't have '-r' */ pr = copstr(pr, "-r"); ! pr = copstr(pr, pr2); pr = copstr(pr, " "); } *************** *** 1123,1129 pr = copstr(pr, " "); } ! pr = copstr(pr, sfile); /* * exit codes are opposite of error codes so do the following: */ --- 1140,1146 ----- pr = copstr(pr, " "); } ! pr = copstr(pr, pr1); /* * exit codes are opposite of error codes so do the following: */ *************** *** 1144,1150 gf = gf->gnextp; gf->gnextp = 0; } ! gf->gnamep = copys(sfile+2); /* `+2' skips `s.' */ gotfiles->endp = gf; } return(retval); --- 1161,1172 ----- gf = gf->gnextp; gf->gnextp = 0; } ! if (cdflag == CD) { ! while(*pr1 = *(pr1+2)) pr1++; /* `+2' skips `s.' */ ! gf->gnamep = copys(sfile); ! } ! else ! gf->gnamep = copys(pr1 + 2); /* GET put it in cwd */ gotfiles->endp = gf; } else if (retryflg) { *************** *** 1147,1152 gf->gnamep = copys(sfile+2); /* `+2' skips `s.' */ gotfiles->endp = gf; } return(retval); } --- 1169,1181 ----- gf->gnamep = copys(pr1 + 2); /* GET put it in cwd */ gotfiles->endp = gf; } + else if (retryflg) { + retryflg = 0; + copstr(sfile, ssfile); + trysccs(sfile); + goto retry; + } + return(retval); } -- -Mike Wescott wescott@ncrcae.Columbia.NCR.COM
wescott@sauron.Columbia.NCR.COM (Mike Wescott) (02/03/89)
These patches are against SysVr3v2 sources. Your line numbers will vary. Bugs: 1. macro substitution doesn't work recursively (misc.c) (with suffix replacement and $(@F) type macros) 2. automatic gets in other directories don't alway get or remove properly (doname.c, misc.c) 3. older bourne shells have bug when stdin is closed before the shell is exec'd (main.c) diff -cr src.V.3.2/doname.c src.1.02/doname.c *** src.V.3.2/doname.c Tue Jan 24 15:56:50 1989 --- src.1.02/doname.c Tue Jan 24 15:57:09 1989 *************** *** 70,79 **** explcom = 0; ptime = exists(p); #ifdef MKDEBUG ! if(reclevel == 0 && if (IS_ON(DBUG)) { ! blprt(reclevel); ! printf("TIME(%s)=%ld\n", p->namep, ptime); } #endif --- 73,82 ---- explcom = 0; ptime = exists(p); #ifdef MKDEBUG ! if(reclevel == 0 && (IS_ON(DBUG))) { ! blprt(reclevel); ! printf("TIME(%s)=%ld\n", p->namep, ptime); } #endif *************** *** 353,359 **** } } else if(IS_OFF(GET) || ! !get(p->namep, NOCD, 0) ) { fatal1(" Don't know how to make %s", p->namep); } --- 356,362 ---- } } else if(IS_OFF(GET) || ! !get(p->namep, CD, 0) ) { fatal1(" Don't know how to make %s", p->namep); } diff -cr src.V.3.2/main.c src.1.02/main.c *** src.V.3.2/main.c Tue Jan 24 15:56:53 1989 --- src.1.02/main.c Tue Jan 24 15:57:14 1989 *************** *** 342,348 **** if( yyparse() ) fatal("Description file error"); ! if(fin != NULL) fclose(fin); return(0); --- 345,351 ---- if( yyparse() ) fatal("Description file error"); ! if(fin != NULL && fin != stdin) fclose(fin); return(0); diff -cr src.V.3.2/misc.c src.1.02/misc.c *** src.V.3.2/misc.c Tue Jan 24 15:56:53 1989 --- src.1.02/misc.c Tue Jan 24 15:57:16 1989 *************** *** 312,331 **** if((vbp = srchvar(vname)) == NULL) return(b); p = vbp->varval; if(dftype) ! { ! if((q = calloc(strlen(p)+2, 1)) == NULL) ! fatal("Cannot alloc mem"); ! do_df(q, p, vname[1]); /* D/F trans gets smaller */ ! p = q; ! } if(p && *p) b = do_colon(b, p, pcolon+1); *pcolon = KOLON; if(dftype) vname[1] = dftype; ! if(q) ! cfree(q); return(b); } /* --- 315,333 ---- if((vbp = srchvar(vname)) == NULL) return(b); p = vbp->varval; + if((q = calloc(OUTMAX, 1)) == NULL) + fatal("Cannot alloc mem"); if(dftype) ! do_df(q, p, dftype); /* D/F trans gets smaller */ ! else ! subst(p, q); ! p = q; if(p && *p) b = do_colon(b, p, pcolon+1); *pcolon = KOLON; if(dftype) vname[1] = dftype; ! cfree(q); return(b); } /* *************** *** 458,464 **** { if(buf[0] == BLANK || buf[0] == TAB) { ! b = copstr(b, buf); continue; } p = lastslash(buf); --- 460,466 ---- { if(buf[0] == BLANK || buf[0] == TAB) { ! b = subst(buf, b); continue; } p = lastslash(buf); *************** *** 465,475 **** if(p) { *p = CNULL; ! b = copstr(b, type=='D'?(buf[0]==CNULL?"/":buf):p+1); *p = SLASH; } else ! b = copstr(b, type=='D'?".":buf); } return(b); } --- 467,477 ---- if(p) { *p = CNULL; ! b = subst(type=='D'?(buf[0]==CNULL?"/":buf):p+1, b); *p = SLASH; } else ! b = subst(type=='D'?".":buf, b); } return(b); } *************** *** 1081,1112 **** { register CHARSTAR pr; register CHARSTAR pr1; char gbuf[128]; char sfile[128]; int retval; GOTF gf; copstr(sfile, ssfile); if(!sdot(sfile)) trysccs(sfile); if(access(sfile, 4) != 0 && IS_OFF(GET)) ! return(NO); pr = gbuf; if(IS_OFF(SIL)) pr = copstr(pr, "set -x;\n"); ! if(cdflag == CD) if(any(sfile, SLASH)) { ! pr = copstr(pr, "cd "); ! for(pr1 = sfile; *pr1; pr1++); while(*pr1 != SLASH) pr1--; *pr1 = CNULL; ! pr = copstr(pr, sfile); ! pr = copstr(pr, ";\n"); ! *pr1 = SLASH; } pr = copstr(pr, varptr("GET")->varval); --- 1083,1131 ---- { register CHARSTAR pr; register CHARSTAR pr1; + register CHARSTAR pr2; char gbuf[128]; char sfile[128]; int retval; + int retryflg = 0; GOTF gf; + #ifdef MKDEBUG + if(IS_ON(DBUG))printf("get: %s\n", ssfile); + #endif copstr(sfile, ssfile); if(!sdot(sfile)) trysccs(sfile); + else + retryflg++; + retry: if(access(sfile, 4) != 0 && IS_OFF(GET)) ! if (retryflg) { ! retryflg = 0; ! copstr(sfile, ssfile); ! trysccs(sfile); ! goto retry; ! } ! else ! return(NO); pr = gbuf; if(IS_OFF(SIL)) pr = copstr(pr, "set -x;\n"); ! pr1 = sfile; if(any(sfile, SLASH)) { ! for(; *pr1; pr1++); while(*pr1 != SLASH) pr1--; *pr1 = CNULL; ! if(cdflag == CD) { ! pr = copstr(pr, "cd "); ! pr = copstr(pr, sfile); ! pr = copstr(pr, ";\n"); ! } ! *pr1++ = SLASH; } pr = copstr(pr, varptr("GET")->varval); *************** *** 1114,1129 **** pr = copstr(pr, varptr("GFLAGS")->varval); pr = copstr(pr, " "); ! pr1 = rlse; ! if(pr1 != NULL && pr1[0] != CNULL) { ! if(pr1[0] != MINUS) /* RELEASE doesn't have '-r' */ pr = copstr(pr, "-r"); ! pr = copstr(pr, pr1); pr = copstr(pr, " "); } ! pr = copstr(pr, sfile); /* * exit codes are opposite of error codes so do the following: */ --- 1133,1148 ---- pr = copstr(pr, varptr("GFLAGS")->varval); pr = copstr(pr, " "); ! pr2 = rlse; ! if(pr2 != NULL && pr2[0] != CNULL) { ! if(pr2[0] != MINUS) /* RELEASE doesn't have '-r' */ pr = copstr(pr, "-r"); ! pr = copstr(pr, pr2); pr = copstr(pr, " "); } ! pr = copstr(pr, pr1); /* * exit codes are opposite of error codes so do the following: */ *************** *** 1144,1152 **** gf = gf->gnextp; gf->gnextp = 0; } ! gf->gnamep = copys(sfile+2); /* `+2' skips `s.' */ gotfiles->endp = gf; } return(retval); } --- 1163,1183 ---- gf = gf->gnextp; gf->gnextp = 0; } ! if (cdflag == CD) { ! while(*pr1 = *(pr1+2)) pr1++; /* `+2' skips `s.' */ ! gf->gnamep = copys(sfile); ! } ! else ! gf->gnamep = copys(pr1 + 2); /* GET put it in cwd */ gotfiles->endp = gf; } + else if (retryflg) { + retryflg = 0; + copstr(sfile, ssfile); + trysccs(sfile); + goto retry; + } + return(retval); } -- -Mike Wescott mike.wescott@ncrcae.Columbia.NCR.COM