diff --git a/passes/cmds/logcmd.cc b/passes/cmds/logcmd.cc index 52f6b1e31..c6cba1115 100644 --- a/passes/cmds/logcmd.cc +++ b/passes/cmds/logcmd.cc @@ -97,7 +97,7 @@ struct LogPass : public Pass { text += args[argidx] + ' '; if (!text.empty()) text.resize(text.size()-1); - if (text[0] == '"' && text[text.size()-1] == '"') + if (text.size() > 1 && text[0] == '"' && text[text.size()-1] == '"') text = text.substr(1, text.size()-2); const char *fmtline = newline ? "%s\n" : "%s"; diff --git a/tests/scripts/test_logging.sh b/tests/scripts/test_logging.sh index d69fcc752..d2f635f76 100755 --- a/tests/scripts/test_logging.sh +++ b/tests/scripts/test_logging.sh @@ -31,7 +31,10 @@ test_log "\"!bang\"" "!bang" test_log "\"spaces are cool too\"" "spaces are cool too" test_log "\"log a\"; log b" "log a" test_log "\"log a\"; log b" "b" +test_log "\"" "\"" +test_log "\\\"" "\\\\\"" #\" == \" -if [ -f quotes-*.err ] ; then +errors=( quotes-*.err ) +if [ -f $errors ] ; then exit 1 fi