summaryrefslogtreecommitdiff
path: root/coreutils/echo.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 /coreutils/echo.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 'coreutils/echo.c')
-rw-r--r--coreutils/echo.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/coreutils/echo.c b/coreutils/echo.c
index 4659e4b..6e279d1 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -40,7 +40,7 @@ extern int
echo_main(int argc, char** argv)
{
register char **ap;
- register char *p;
+ char *p;
register char c;
int nflag = 0;
int eflag = 0;
@@ -65,28 +65,10 @@ echo_main(int argc, char** argv)
while ((p = *ap++) != NULL) {
while ((c = *p++) != '\0') {
if (c == '\\' && eflag) {
- switch (c = *p++) {
- case 'a': c = '\007'; break;
- case 'b': c = '\b'; break;
- case 'c': exit( 0); /* exit */
- case 'f': c = '\f'; break;
- case 'n': c = '\n'; break;
- case 'r': c = '\r'; break;
- case 't': c = '\t'; break;
- case 'v': c = '\v'; break;
- case '\\': break; /* c = '\\' */
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- c -= '0';
- if (*p >= '0' && *p <= '7')
- c = c * 8 + (*p++ - '0');
- if (*p >= '0' && *p <= '7')
- c = c * 8 + (*p++ - '0');
- break;
- default:
- p--;
- break;
- }
+ if (*p == 'c')
+ exit(0);
+ else
+ c = process_escape_sequence(&p);
}
putchar(c);
}