Skip to content

Commit

Permalink
Improve parsing algorithm to handle spaces and comments #63
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Oct 14, 2021
1 parent 8e9d9a4 commit 95b59aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function registerGoal(goalName, priv) {
if (length(goalName) == 0)
addError("Goal must have a name")
if (goalName in GoalsByName)
addError("Goal '" goalName "' is already defined")
addError("Goal " quote2(goalName,1) " is already defined")
arrPush(GoalNames, goalName)
GoalsByName[goalName] = priv
}
Expand Down Expand Up @@ -335,11 +335,11 @@ function checkBeforeRun( i,dep,depCnt,goalName) {
for (i=0; i < depCnt; i++) {
dep = Dependencies[goalName, i]
if (!(dep in GoalsByName))
addError("Goal '" goalName "' has unknown dependency '" dep "'", DependenciesLineNo[goalName, i])
addError("Goal " quote2(goalName,1) " has unknown dependency '" dep "'", DependenciesLineNo[goalName, i])
}
if (goalName in GoalToLib) {
if (!(GoalToLib[goalName] in Lib))
addError("Goal '" goalName "' uses unknown lib '" GoalToLib[goalName] "'", UseLibLineNo[goalName])
addError("Goal " quote2(goalName,1) " uses unknown lib '" GoalToLib[goalName] "'", UseLibLineNo[goalName])
}
}
}
Expand Down Expand Up @@ -444,14 +444,14 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
t1 = t2 ? t2 : currentTimeMillis()

if (!("silent" in Options))
print " goal '" goalName "' " (reachedGoals[goalName] ? "[already satisfied]." : emptyGoals[goalName] ? "[empty]." : "...")
print " goal " quote2(goalName,1) " " (reachedGoals[goalName] ? "[already satisfied]." : emptyGoals[goalName] ? "[empty]." : "...")

exitCode = (reachedGoals[goalName] || emptyGoals[goalName]) ? 0 : shellExec(goalBodies[goalName])
if (exitCode != 0)
print " goal '" goalName "' failed"
print " goal " quote2(goalName,1) " failed"
if (goalTimed) {
t2 = currentTimeMillis()
print " goal '" goalName "' took " renderDuration(t2 - t1)
print " goal " quote2(goalName,1) " took " renderDuration(t2 - t1)
}
if (exitCode != 0)
break
Expand Down
2 changes: 1 addition & 1 deletion tests/21_parsing.tush
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_quoting.sh
| no_space
| goal 'name with spaces' ...
| name with spaces
| goal 'name with ' quote' ...
| goal $'name with \' quote' ...
| name with ' quote
| goal 'default' [empty].

0 comments on commit 95b59aa

Please sign in to comment.