--- src/usr.bin/make/parse.c 2005/02/18 01:23:22 1.47 +++ src/usr.bin/make/parse.c 2005/02/28 12:17:37 1.48 @@ -1319,6 +1319,8 @@ Parse_DoVar(char *line, GNode *ctxt) } type; /* Type of assignment */ char *opc; /* ptr to operator character to * null-terminate the variable name */ + Buffer *buf; + /* * Avoid clobbered variable warnings by forcing the compiler * to ``unregister'' variables @@ -1424,12 +1426,10 @@ Parse_DoVar(char *line, GNode *ctxt) if (!Var_Exists(line, ctxt)) Var_Set(line, "", ctxt); - { - Buffer *buf; - buf = Var_Subst(NULL, cp, ctxt, FALSE); - cp = Buf_GetAll(buf, NULL); - Buf_Destroy(buf, FALSE); - } + buf = Var_Subst(NULL, cp, ctxt, FALSE); + cp = Buf_GetAll(buf, NULL); + Buf_Destroy(buf, FALSE); + oldVars = oldOldVars; Var_Set(line, cp, ctxt); @@ -1446,12 +1446,9 @@ Parse_DoVar(char *line, GNode *ctxt) * expansion on the whole thing. The resulting string will need * freeing when we're done, so set freeCmd to TRUE. */ - { - Buffer *buf1; - buf1 = Var_Subst(NULL, cp, VAR_CMD, TRUE); - cp = Buf_GetAll(buf1, NULL); - Buf_Destroy(buf1, FALSE); - } + buf = Var_Subst(NULL, cp, VAR_CMD, TRUE); + cp = Buf_GetAll(buf, NULL); + Buf_Destroy(buf, FALSE); freeCmd = TRUE; } @@ -1557,6 +1554,7 @@ Parse_AddIncludeDir(char *dir) static void ParseDoError(char *errmsg) { + Buffer *buf; if (!isspace((unsigned char)*errmsg)) { Parse_Error(PARSE_WARNING, "invalid syntax: .error%s", errmsg); @@ -1566,14 +1564,12 @@ ParseDoError(char *errmsg) while (isspace((unsigned char)*errmsg)) errmsg++; - { - Buffer *buf; - buf = Var_Subst(NULL, errmsg, VAR_GLOBAL, FALSE); - errmsg = Buf_GetAll(buf, NULL); - Buf_Destroy(buf, FALSE); - } + buf = Var_Subst(NULL, errmsg, VAR_GLOBAL, FALSE); + errmsg = Buf_GetAll(buf, NULL); Parse_Error(PARSE_FATAL, "%s", errmsg); + Buf_Destroy(buf, TRUE); + /* Terminate immediately. */ exit(1); } @@ -1591,6 +1587,7 @@ ParseDoError(char *errmsg) static void ParseDoWarning(char *warnmsg) { + Buffer *buf; if (!isspace((unsigned char)*warnmsg)) { Parse_Error(PARSE_WARNING, "invalid syntax: .warning%s", @@ -1601,14 +1598,11 @@ ParseDoWarning(char *warnmsg) while (isspace((unsigned char)*warnmsg)) warnmsg++; - { - Buffer *buf; - buf = Var_Subst(NULL, warnmsg, VAR_GLOBAL, FALSE); - warnmsg = Buf_GetAll(buf, NULL); - Buf_Destroy(buf, FALSE); - } + buf = Var_Subst(NULL, warnmsg, VAR_GLOBAL, FALSE); + warnmsg = Buf_GetAll(buf, NULL); Parse_Error(PARSE_WARNING, "%s", warnmsg); + Buf_Destroy(buf, TRUE); } /*- @@ -1637,6 +1631,7 @@ ParseDoInclude(char *file) char endc; /* the character which ends the file spec */ char *cp; /* current position in file spec */ Boolean isSystem; /* TRUE if makefile is a system makefile */ + Buffer *buf; /* * Skip to delimiter character so we know where to look @@ -1683,12 +1678,9 @@ ParseDoInclude(char *file) * Substitute for any variables in the file name before trying to * find the thing. */ - { - Buffer *buf; - buf = Var_Subst(NULL, file, VAR_CMD, FALSE); - file = Buf_GetAll(buf, NULL); - Buf_Destroy(buf, FALSE); - } + buf = Var_Subst(NULL, file, VAR_CMD, FALSE); + file = Buf_GetAll(buf, NULL); + Buf_Destroy(buf, FALSE); /* * Now we know the file's name and its search path, we attempt to @@ -1755,6 +1747,7 @@ ParseDoInclude(char *file) if (fullname == NULL) { *cp = endc; Parse_Error(PARSE_FATAL, "Could not find %s", file); + /* XXXHB free(file) */ return; } @@ -1849,6 +1842,7 @@ ParseTraditionalInclude(char *file) char *fullname; /* full pathname of file */ IFile *oldFile; /* state associated with current file */ char *cp; /* current position in file spec */ + Buffer *buf; /* * Skip over whitespace @@ -1876,12 +1870,9 @@ ParseTraditionalInclude(char *file) * Substitute for any variables in the file name before trying to * find the thing. */ - { - Buffer *buf; - buf = Var_Subst(NULL, file, VAR_CMD, FALSE); - file = Buf_GetAll(buf, NULL); - Buf_Destroy(buf, FALSE); - } + buf = Var_Subst(NULL, file, VAR_CMD, FALSE); + file = Buf_GetAll(buf, NULL); + Buf_Destroy(buf, FALSE); /* * Now we know the file's name, we attempt to find the durn thing. @@ -1903,9 +1894,12 @@ ParseTraditionalInclude(char *file) if (fullname == NULL) { Parse_Error(PARSE_FATAL, "Could not find %s", file); + /* XXXHB free(file) */ return; } + /* XXXHB free(file) */ + /* * Once we find the absolute path to the file, we get to save all the * state from the current file before we can start reading this @@ -2416,6 +2410,7 @@ Parse_File(char *name, FILE *stream) { char *cp, /* pointer into the line */ *line; /* the line we're working on */ + Buffer *buf; inLine = FALSE; curFile.fname = name; @@ -2446,12 +2441,10 @@ Parse_File(char *name, FILE *stream) goto nextLine; } else if (strncmp(cp, "undef", 5) == 0) { cp = stripvarname(cp + 5); - { - Buffer *buf; - buf = Var_Subst(NULL, cp, VAR_CMD, FALSE); - cp = Buf_GetAll(buf, NULL); - Buf_Destroy(buf, FALSE); - } + buf = Var_Subst(NULL, cp, VAR_CMD, FALSE); + cp = Buf_GetAll(buf, NULL); + Buf_Destroy(buf, FALSE); + Var_Delete(cp, VAR_GLOBAL); goto nextLine; } else if (strncmp(cp, "makeenv", 7) == 0) { @@ -2524,12 +2517,10 @@ Parse_File(char *name, FILE *stream) ParseFinishLine(); - { - Buffer *buf; - buf = Var_Subst(NULL, line, VAR_CMD, TRUE); - cp = Buf_GetAll(buf, NULL); - Buf_Destroy(buf, FALSE); - } + buf = Var_Subst(NULL, line, VAR_CMD, TRUE); + cp = Buf_GetAll(buf, NULL); + Buf_Destroy(buf, FALSE); + free(line); line = cp;