From 7d46afb81a090ee76708497377539fdb8829e236 Mon Sep 17 00:00:00 2001 From: graydon Date: Fri, 26 Aug 2005 19:41:31 +0000 Subject: 2005-08-26 Graydon Hoare * parse.cxx (scan): Preserve basic C-ish escapes. * translate.cxx (c_tmpcounter::declaring): New flag. (c_tmpcounter::declare_or_init): New helper method. (c_tmpcounter::visit_*): Use declare_or_init. (c_unparser::emit_function): Run a tmpcounter to initialize tmps. (c_unparser::emit_probe): Likewise. (c_unparser::c_strcpy): Use strlcpy. (c_unparser::c_strcat): Use strlcat. --- parse.cxx | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'parse.cxx') diff --git a/parse.cxx b/parse.cxx index 5b25a9c0..4a4b973f 100644 --- a/parse.cxx +++ b/parse.cxx @@ -332,8 +332,32 @@ lexer::scan () if (c == '\"') // closing double-quotes break; else if (c == '\\') - { - // XXX: handle escape sequences + { + c = input_get (); + switch (c) + { + case 'a': + case 'b': + case 't': + case 'n': + case 'v': + case 'f': + case 'r': + case '\\': + + // Pass these escapes through to the string value + // beign parsed; it will "likely" be emitted into + // a C literal. + // + // XXX: verify this assumption. + + n->content.push_back('\\'); + + default: + + n->content.push_back(c); + break; + } } else n->content.push_back(c); -- cgit