diff options
author | Chet Ramey <chet.ramey@case.edu> | 2014-01-29 17:00:07 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2014-01-29 17:00:07 -0500 |
commit | b6e23235f28b1c85e18e9a2b7ba8c6b6c46aecbc (patch) | |
tree | 00fdd9c37c261d89c994fc1856252df719afec3a /error.c | |
parent | 8581f42df9a1b1d848e2d4bdf3cc951b8d14b5be (diff) | |
download | bash-4.3-testing.tar.gz |
bash-4.3-rc2 overlaybash-4.3-rc2bash-4.3-testing
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -340,6 +340,36 @@ parser_error (lineno, format, va_alist) } #ifdef DEBUG +/* This assumes ASCII and is suitable only for debugging */ +char * +strescape (str) + const char *str; +{ + char *r, *result; + unsigned char *s; + + r = result = (char *)xmalloc (strlen (str) * 2 + 1); + + for (s = (unsigned char *)str; s && *s; s++) + { + if (*s < ' ') + { + *r++ = '^'; + *r++ = *s+64; + } + else if (*s == 127) + { + *r++ = '^'; + *r++ = '?'; + } + else + *r++ = *s; + } + + *r = '\0'; + return result; +} + void #if defined (PREFER_STDARG) itrace (const char *format, ...) |