From 18acf318364cb5337629df5afe1f304952f0e19e Mon Sep 17 00:00:00 2001 From: fche Date: Fri, 22 Jun 2007 19:39:29 +0000 Subject: [PATCH] 2007-06-22 Frank Ch. Eigler * string.c (_stp_text_str): Fix handling of embedded " and \ characters. --- runtime/ChangeLog | 5 +++++ runtime/string.c | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 14c77c29c..2e9cf9337 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,8 @@ +2007-06-22 Frank Ch. Eigler + + * string.c (_stp_text_str): Fix handling of embedded + " and \ characters. + 2007-06-21 David Smith * lket/b2a/Makefile.in: Regenerated with automake 1.10. diff --git a/runtime/string.c b/runtime/string.c index 804af4454..13c46dda2 100644 --- a/runtime/string.c +++ b/runtime/string.c @@ -69,7 +69,7 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user) len = MAXSTRINGLEN-1; if (quoted) { len -= 2; - *out++ = '\"'; + *out++ = '"'; } if (user) { @@ -82,8 +82,9 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user) while (c && len > 0) { int num = 1; - if (isprint(c) && isascii(c)) - *out++ = c; + if (isprint(c) && isascii(c) + && c != '"' && c != '\\') /* quoteworthy characters */ + *out++ = c; else { switch (c) { case '\a': @@ -93,6 +94,8 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user) case '\r': case '\t': case '\v': + case '"': + case '\\': num = 2; break; default: @@ -131,6 +134,12 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user) case '\v': *out++ = 'v'; break; + case '"': + *out++ = '"'; + break; + case '\\': + *out++ = '\\'; + break; default: /* output octal representation */ if (c > 077) *out++ = to_oct_digit(c >> 6); @@ -152,12 +161,12 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user) if (quoted) { if (c) { out = out - 3 + len; - *out++ = '\"'; + *out++ = '"'; *out++ = '.'; *out++ = '.'; *out++ = '.'; } else - *out++ = '\"'; + *out++ = '"'; } *out = '\0'; return; -- 2.43.5