Skip to content

Commit db90d1a

Browse files
logcmd.cc: Check length before unquoting
`log "` should log `"`. Also fix test script to correctly fail when more than one test fails.
1 parent c87b478 commit db90d1a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

passes/cmds/logcmd.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct LogPass : public Pass {
9797
text += args[argidx] + ' ';
9898
if (!text.empty()) text.resize(text.size()-1);
9999

100-
if (text[0] == '"' && text[text.size()-1] == '"')
100+
if (text.size() > 1 && text[0] == '"' && text[text.size()-1] == '"')
101101
text = text.substr(1, text.size()-2);
102102

103103
const char *fmtline = newline ? "%s\n" : "%s";

tests/scripts/test_logging.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ test_log "\"!bang\"" "!bang"
3131
test_log "\"spaces are cool too\"" "spaces are cool too"
3232
test_log "\"log a\"; log b" "log a"
3333
test_log "\"log a\"; log b" "b"
34+
test_log "\"" "\""
35+
test_log "\\\"" "\\\\\"" #\" == \"
3436

35-
if [ -f quotes-*.err ] ; then
37+
errors=( quotes-*.err )
38+
if [ -f $errors ] ; then
3639
exit 1
3740
fi

0 commit comments

Comments
 (0)