From b96cc7d9b282c6aed441b791e6cb6eae7b2296bc Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 29 May 2011 15:29:15 -0700 Subject: [PATCH] Fix escaping at end of gas string constant. Patch by: Daniel Diaz --- modules/parsers/gas/gas-token.re | 7 ++++--- modules/parsers/gas/tests/bin/Makefile.inc | 2 ++ modules/parsers/gas/tests/bin/gas-str.asm | 1 + modules/parsers/gas/tests/bin/gas-str.hex | 3 +++ 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 modules/parsers/gas/tests/bin/gas-str.asm create mode 100644 modules/parsers/gas/tests/bin/gas-str.hex diff --git a/modules/parsers/gas/gas-token.re b/modules/parsers/gas/gas-token.re index cf020fbe..f2212af5 100644 --- a/modules/parsers/gas/gas-token.re +++ b/modules/parsers/gas/gas-token.re @@ -523,8 +523,8 @@ stringconst_scan: SCANINIT(); /*!re2c - /* Handle escaped double-quote by copying and continuing */ - "\\\"" { + /* Handle escaped character by copying both and continuing. */ + "\\". { if (cursor == s->eof) { yasm_error_set(YASM_ERROR_SYNTAX, N_("unexpected end of file in string")); @@ -532,7 +532,8 @@ stringconst_scan: lvalp->str.len = count; RETURN(STRING); } - strbuf_append(count++, cursor, s, '"'); + strbuf_append(count++, cursor, s, '\\'); + strbuf_append(count++, cursor, s, s->tok[1]); goto stringconst_scan; } diff --git a/modules/parsers/gas/tests/bin/Makefile.inc b/modules/parsers/gas/tests/bin/Makefile.inc index 39f12f01..bc8f6174 100644 --- a/modules/parsers/gas/tests/bin/Makefile.inc +++ b/modules/parsers/gas/tests/bin/Makefile.inc @@ -14,6 +14,8 @@ EXTRA_DIST += modules/parsers/gas/tests/bin/gas-macro.asm EXTRA_DIST += modules/parsers/gas/tests/bin/gas-macro.hex EXTRA_DIST += modules/parsers/gas/tests/bin/gas-set.asm EXTRA_DIST += modules/parsers/gas/tests/bin/gas-set.hex +EXTRA_DIST += modules/parsers/gas/tests/bin/gas-str.asm +EXTRA_DIST += modules/parsers/gas/tests/bin/gas-str.hex EXTRA_DIST += modules/parsers/gas/tests/bin/rept-err.asm EXTRA_DIST += modules/parsers/gas/tests/bin/rept-err.errwarn EXTRA_DIST += modules/parsers/gas/tests/bin/reptempty.asm diff --git a/modules/parsers/gas/tests/bin/gas-str.asm b/modules/parsers/gas/tests/bin/gas-str.asm new file mode 100644 index 00000000..4d02a02c --- /dev/null +++ b/modules/parsers/gas/tests/bin/gas-str.asm @@ -0,0 +1 @@ +.string "a\\" diff --git a/modules/parsers/gas/tests/bin/gas-str.hex b/modules/parsers/gas/tests/bin/gas-str.hex new file mode 100644 index 00000000..d4eaa859 --- /dev/null +++ b/modules/parsers/gas/tests/bin/gas-str.hex @@ -0,0 +1,3 @@ +61 +5c +00