From 99455a16bf0b1bb6dbb4ad6910fb7efb3cb7b624 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 20 Nov 2019 21:23:03 -0500 Subject: [PATCH] Fix // in filenames, bug1610. --- Changes | 2 ++ src/V3Options.cpp | 6 ++++-- test_regress/t/t_flag_f.vc | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index c316e3a48..166baddef 100644 --- a/Changes +++ b/Changes @@ -22,6 +22,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix VPI timed callbacks to be one-shot, pull5. [Matthew Ballance] +**** Fix // in filenames, bug1610. [Peter Nelson] + * Verilator 4.022 2019-11-10 diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 160e10235..5fcbbe4b4 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1247,13 +1247,15 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) { // Strip simple comments string oline; // cppcheck-suppress StlMissingComparison - for (string::const_iterator pos = line.begin(); pos != line.end(); ++pos) { + char lastch = ' '; + for (string::const_iterator pos = line.begin(); pos != line.end(); lastch = *pos++) { if (inCmt) { if (*pos=='*' && *(pos+1)=='/') { inCmt = false; ++pos; } - } else if (*pos=='/' && *(pos+1)=='/') { + } else if (*pos=='/' && *(pos+1)=='/' + && (pos == line.begin() || isspace(lastch))) { // But allow /file//path break; // Ignore to EOL } else if (*pos=='/' && *(pos+1)=='*') { inCmt = true; diff --git a/test_regress/t/t_flag_f.vc b/test_regress/t/t_flag_f.vc index 7356b8b10..44e4076c8 100644 --- a/test_regress/t/t_flag_f.vc +++ b/test_regress/t/t_flag_f.vc @@ -1,6 +1,7 @@ // Test that environment substitutions work -f $VERILATOR_ROOT/test_regress/t/t_flag_f__2.vc // Env var with .v file, and parens -${VERILATOR_ROOT}/test_regress/t/t_flag_f__3.v +// Double slash below is intentional, as allowed in other tools +${VERILATOR_ROOT}/test_regress/t//t_flag_f__3.v // Test -f -F $VERILATOR_ROOT/test_regress/t/tsub/t_flag_f_tsub.vc