summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorEric Andersen2000-07-05 17:26:35 +0000
committerEric Andersen2000-07-05 17:26:35 +0000
commitf7cf2f7ef98077c59e4da4bc25de38c22174ac9d (patch)
treea2fa5e67df2ccd2881a21ed4d22c6f7453b793b2 /utility.c
parent57ebebfb01a9a29378b2f0179724661bfc5402e9 (diff)
downloadbusybox-f7cf2f7ef98077c59e4da4bc25de38c22174ac9d.zip
busybox-f7cf2f7ef98077c59e4da4bc25de38c22174ac9d.tar.gz
* Fix to tr so it recognizes standard escape sequences. Merged common
escape seq. code from tr and echo into utility.c. Fix thanks to Matt Kraai <kraai@alumni.carnegiemellon.edu>. * This should close Bug #1015. Please test. -Erik
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/utility.c b/utility.c
index de53dbd..f3af01f 100644
--- a/utility.c
+++ b/utility.c
@@ -1617,6 +1617,51 @@ extern char *get_line_from_file(FILE *file)
return linebuf;
}
+#if defined BB_ECHO || defined BB_TR
+char process_escape_sequence(char **ptr)
+{
+ char c;
+
+ switch (c = *(*ptr)++) {
+ case 'a':
+ c = '\a';
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'v':
+ c = '\v';
+ break;
+ case '\\':
+ c = '\\';
+ break;
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ c -= '0';
+ if ('0' <= **ptr && **ptr <= '7') {
+ c = c * 8 + (*(*ptr)++ - '0');
+ if ('0' <= **ptr && **ptr <= '7')
+ c = c * 8 + (*(*ptr)++ - '0');
+ }
+ break;
+ default:
+ (*ptr)--;
+ c = '\\';
+ break;
+ }
+ return c;
+}
+#endif
+
/* END CODE */
/*
Local Variables: