version 1.601, 2021/12/28 19:13:40 |
version 1.602, 2021/12/28 19:41:01 |
Line 508 PrintStackTrace(void) |
|
Line 508 PrintStackTrace(void) |
|
|
|
/* Check if the current character is escaped on the current line. */ |
/* Check if the current character is escaped on the current line. */ |
static bool |
static bool |
ParseIsEscaped(const char *line, const char *p) |
IsEscaped(const char *line, const char *p) |
{ |
{ |
bool active = false; |
bool active = false; |
while (p > line && *--p == '\\') |
while (p > line && *--p == '\\') |
Line 533 RememberLocation(GNode *gn) |
|
Line 533 RememberLocation(GNode *gn) |
|
* Return the index of the keyword, or -1 if it isn't there. |
* Return the index of the keyword, or -1 if it isn't there. |
*/ |
*/ |
static int |
static int |
ParseFindKeyword(const char *str) |
FindKeyword(const char *str) |
{ |
{ |
int start = 0; |
int start = 0; |
int end = sizeof parseKeywords / sizeof parseKeywords[0] - 1; |
int end = sizeof parseKeywords / sizeof parseKeywords[0] - 1; |
Line 674 Parse_Error(ParseErrorLevel type, const |
|
Line 674 Parse_Error(ParseErrorLevel type, const |
|
|
|
|
|
/* |
/* |
* Parse and handle an .info, .warning or .error directive. |
* Handle an .info, .warning or .error directive. For an .error directive, |
* For an .error directive, immediately exit. |
* exit immediately. |
*/ |
*/ |
static void |
static void |
ParseMessage(ParseErrorLevel level, const char *levelName, const char *umsg) |
HandleMessage(ParseErrorLevel level, const char *levelName, const char *umsg) |
{ |
{ |
char *xmsg; |
char *xmsg; |
|
|
Line 845 ApplyDependencySourceKeyword(const char |
|
Line 845 ApplyDependencySourceKeyword(const char |
|
if (*src != '.' || !ch_isupper(src[1])) |
if (*src != '.' || !ch_isupper(src[1])) |
return false; |
return false; |
|
|
keywd = ParseFindKeyword(src); |
keywd = FindKeyword(src); |
if (keywd == -1) |
if (keywd == -1) |
return false; |
return false; |
|
|
Line 869 ApplyDependencySourceMain(const char *sr |
|
Line 869 ApplyDependencySourceMain(const char *sr |
|
* list of things to create, but only if the user didn't specify a |
* list of things to create, but only if the user didn't specify a |
* target on the command line and .MAIN occurs for the first time. |
* target on the command line and .MAIN occurs for the first time. |
* |
* |
* See ParseDependencyTargetSpecial, branch SP_MAIN. |
* See HandleDependencyTargetSpecial, branch SP_MAIN. |
* See unit-tests/cond-func-make-main.mk. |
* See unit-tests/cond-func-make-main.mk. |
*/ |
*/ |
Lst_Append(&opts.create, bmake_strdup(src)); |
Lst_Append(&opts.create, bmake_strdup(src)); |
Line 981 FindMainTarget(void) |
|
Line 981 FindMainTarget(void) |
|
} |
} |
} |
} |
|
|
/* |
|
* We got to the end of the line while we were still looking at targets. |
|
* |
|
* Ending a dependency line without an operator is a Bozo no-no. As a |
|
* heuristic, this is also often triggered by undetected conflicts from |
|
* cvs/rcs merges. |
|
*/ |
|
static void |
static void |
ParseErrorNoDependency(const char *lstart) |
InvalidLineType(const char *lstart) |
{ |
{ |
if ((strncmp(lstart, "<<<<<<", 6) == 0) || |
if ((strncmp(lstart, "<<<<<<", 6) == 0) || |
(strncmp(lstart, "======", 6) == 0) || |
(strncmp(lstart, "======", 6) == 0) || |
Line 1017 ParseDependencyTargetWord(char **pp, con |
|
Line 1010 ParseDependencyTargetWord(char **pp, con |
|
while (*cp != '\0') { |
while (*cp != '\0') { |
if ((ch_isspace(*cp) || *cp == '!' || *cp == ':' || |
if ((ch_isspace(*cp) || *cp == '!' || *cp == ':' || |
*cp == '(') && |
*cp == '(') && |
!ParseIsEscaped(lstart, cp)) |
!IsEscaped(lstart, cp)) |
break; |
break; |
|
|
if (*cp == '$') { |
if (*cp == '$') { |
Line 1051 ParseDependencyTargetWord(char **pp, con |
|
Line 1044 ParseDependencyTargetWord(char **pp, con |
|
* See the tests deptgt-*.mk. |
* See the tests deptgt-*.mk. |
*/ |
*/ |
static void |
static void |
ParseDependencyTargetSpecial(ParseSpecial *inout_special, |
HandleDependencyTargetSpecial(const char *targetName, |
const char *targetName, |
ParseSpecial *inout_special, |
SearchPathList **inout_paths) |
SearchPathList **inout_paths) |
{ |
{ |
switch (*inout_special) { |
switch (*inout_special) { |
case SP_PATH: |
case SP_PATH: |
Line 1112 ParseDependencyTargetSpecial(ParseSpecia |
|
Line 1105 ParseDependencyTargetSpecial(ParseSpecia |
|
} |
} |
} |
} |
|
|
/* |
|
* .PATH<suffix> has to be handled specially. |
|
* Call on the suffix module to give us a path to modify. |
|
*/ |
|
static bool |
static bool |
ParseDependencyTargetPath(const char *suffixName, |
HandleDependencyTargetPath(const char *suffixName, |
SearchPathList **inout_paths) |
SearchPathList **inout_paths) |
{ |
{ |
SearchPath *path; |
SearchPath *path; |
|
|
Line 1140 ParseDependencyTargetPath(const char *su |
|
Line 1129 ParseDependencyTargetPath(const char *su |
|
* See if it's a special target and if so set inout_special to match it. |
* See if it's a special target and if so set inout_special to match it. |
*/ |
*/ |
static bool |
static bool |
ParseDependencyTarget(const char *targetName, |
HandleDependencyTarget(const char *targetName, |
ParseSpecial *inout_special, |
ParseSpecial *inout_special, |
GNodeType *inout_targetAttr, |
GNodeType *inout_targetAttr, |
SearchPathList **inout_paths) |
SearchPathList **inout_paths) |
{ |
{ |
int keywd; |
int keywd; |
|
|
Line 1154 ParseDependencyTarget(const char *target |
|
Line 1143 ParseDependencyTarget(const char *target |
|
* See if the target is a special target that must have it |
* See if the target is a special target that must have it |
* or its sources handled specially. |
* or its sources handled specially. |
*/ |
*/ |
keywd = ParseFindKeyword(targetName); |
keywd = FindKeyword(targetName); |
if (keywd != -1) { |
if (keywd != -1) { |
if (*inout_special == SP_PATH && |
if (*inout_special == SP_PATH && |
parseKeywords[keywd].special != SP_PATH) { |
parseKeywords[keywd].special != SP_PATH) { |
Line 1165 ParseDependencyTarget(const char *target |
|
Line 1154 ParseDependencyTarget(const char *target |
|
*inout_special = parseKeywords[keywd].special; |
*inout_special = parseKeywords[keywd].special; |
*inout_targetAttr = parseKeywords[keywd].targetAttr; |
*inout_targetAttr = parseKeywords[keywd].targetAttr; |
|
|
ParseDependencyTargetSpecial(inout_special, targetName, |
HandleDependencyTargetSpecial(targetName, inout_special, |
inout_paths); |
inout_paths); |
|
|
} else if (strncmp(targetName, ".PATH", 5) == 0) { |
} else if (strncmp(targetName, ".PATH", 5) == 0) { |
*inout_special = SP_PATH; |
*inout_special = SP_PATH; |
if (!ParseDependencyTargetPath(targetName + 5, inout_paths)) |
if (!HandleDependencyTargetPath(targetName + 5, inout_paths)) |
return false; |
return false; |
} |
} |
return true; |
return true; |
} |
} |
|
|
static void |
static void |
ParseDependencyTargetMundane(char *targetName) |
HandleDependencyTargetMundane(char *targetName) |
{ |
{ |
StringList targetNames = LST_INIT; |
StringList targetNames = LST_INIT; |
|
|
Line 1207 ParseDependencyTargetExtraWarn(char **pp |
|
Line 1196 ParseDependencyTargetExtraWarn(char **pp |
|
char *cp = *pp; |
char *cp = *pp; |
|
|
while (*cp != '\0') { |
while (*cp != '\0') { |
if (!ParseIsEscaped(lstart, cp) && (*cp == '!' || *cp == ':')) |
if (!IsEscaped(lstart, cp) && (*cp == '!' || *cp == ':')) |
break; |
break; |
if (ParseIsEscaped(lstart, cp) || (*cp != ' ' && *cp != '\t')) |
if (IsEscaped(lstart, cp) || (*cp != ' ' && *cp != '\t')) |
warning = true; |
warning = true; |
cp++; |
cp++; |
} |
} |
Line 1384 ApplyDependencyTarget(char *name, char * |
|
Line 1373 ApplyDependencyTarget(char *name, char * |
|
char savec = *nameEnd; |
char savec = *nameEnd; |
*nameEnd = '\0'; |
*nameEnd = '\0'; |
|
|
if (!ParseDependencyTarget(name, inout_special, |
if (!HandleDependencyTarget(name, inout_special, |
inout_targetAttr, inout_paths)) |
inout_targetAttr, inout_paths)) |
return false; |
return false; |
|
|
if (*inout_special == SP_NOT && *name != '\0') |
if (*inout_special == SP_NOT && *name != '\0') |
ParseDependencyTargetMundane(name); |
HandleDependencyTargetMundane(name); |
else if (*inout_special == SP_PATH && *name != '.' && *name != '\0') |
else if (*inout_special == SP_PATH && *name != '.' && *name != '\0') |
Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", name); |
Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", name); |
|
|
Line 1416 ParseDependencyTargets(char **inout_cp, |
|
Line 1405 ParseDependencyTargets(char **inout_cp, |
|
* If the word is followed by a left parenthesis, it's the |
* If the word is followed by a left parenthesis, it's the |
* name of one or more files inside an archive. |
* name of one or more files inside an archive. |
*/ |
*/ |
if (!ParseIsEscaped(lstart, cp) && *cp == '(') { |
if (!IsEscaped(lstart, cp) && *cp == '(') { |
if (!Arch_ParseArchive(&tgt, targets, SCOPE_CMDLINE)) { |
if (!Arch_ParseArchive(&tgt, targets, SCOPE_CMDLINE)) { |
Parse_Error(PARSE_FATAL, |
Parse_Error(PARSE_FATAL, |
"Error in archive specification: \"%s\"", |
"Error in archive specification: \"%s\"", |
Line 1429 ParseDependencyTargets(char **inout_cp, |
|
Line 1418 ParseDependencyTargets(char **inout_cp, |
|
} |
} |
|
|
if (*cp == '\0') { |
if (*cp == '\0') { |
ParseErrorNoDependency(lstart); |
InvalidLineType(lstart); |
return false; |
return false; |
} |
} |
|
|
Line 1445 ParseDependencyTargets(char **inout_cp, |
|
Line 1434 ParseDependencyTargets(char **inout_cp, |
|
tgt = cp; |
tgt = cp; |
if (*tgt == '\0') |
if (*tgt == '\0') |
break; |
break; |
if ((*tgt == '!' || *tgt == ':') && |
if ((*tgt == '!' || *tgt == ':') && !IsEscaped(lstart, tgt)) |
!ParseIsEscaped(lstart, tgt)) |
|
break; |
break; |
} |
} |
|
|
Line 2927 ParseDirective(char *line) |
|
Line 2915 ParseDirective(char *line) |
|
else if (Substring_Equals(dir, "unexport-env")) |
else if (Substring_Equals(dir, "unexport-env")) |
Var_UnExport(true, arg); |
Var_UnExport(true, arg); |
else if (Substring_Equals(dir, "info")) |
else if (Substring_Equals(dir, "info")) |
ParseMessage(PARSE_INFO, "info", arg); |
HandleMessage(PARSE_INFO, "info", arg); |
else if (Substring_Equals(dir, "warning")) |
else if (Substring_Equals(dir, "warning")) |
ParseMessage(PARSE_WARNING, "warning", arg); |
HandleMessage(PARSE_WARNING, "warning", arg); |
else if (Substring_Equals(dir, "error")) |
else if (Substring_Equals(dir, "error")) |
ParseMessage(PARSE_FATAL, "error", arg); |
HandleMessage(PARSE_FATAL, "error", arg); |
else |
else |
return false; |
return false; |
return true; |
return true; |