summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2014-01-29 17:00:07 -0500
committerChet Ramey <chet.ramey@case.edu>2014-01-29 17:00:07 -0500
commitb6e23235f28b1c85e18e9a2b7ba8c6b6c46aecbc (patch)
tree00fdd9c37c261d89c994fc1856252df719afec3a /error.c
parent8581f42df9a1b1d848e2d4bdf3cc951b8d14b5be (diff)
downloadbash-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.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/error.c b/error.c
index 1eac01c4..64c4f411 100644
--- a/error.c
+++ b/error.c
@@ -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, ...)