diff options
author | Rob Landley <rob@landley.net> | 2020-04-13 19:45:09 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-04-13 19:45:09 -0500 |
commit | 71ae0e1617218820f405bbf79d5d5dc89d5772ee (patch) | |
tree | b21f46c1a3258b4d5564748374d4291902406e9b /toys/posix/find.c | |
parent | 64aa0f9c06c4215f64f6385d0afe38f02effd888 (diff) | |
download | toybox-71ae0e1617218820f405bbf79d5d5dc89d5772ee.tar.gz |
Add unescape2(), migrate some unescape() users over.
Diffstat (limited to 'toys/posix/find.c')
-rw-r--r-- | toys/posix/find.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c index 3fb97b1c..9b688d46 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -585,16 +585,12 @@ static int do_find(struct dirtree *new) if (check) for (fmt = ss[1]; *fmt; fmt++) { // Print the parts that aren't escapes if (*fmt == '\\') { - int slash = *++fmt, n = unescape(slash); - - if (n) ch = n; - else if (slash=='c') break; - else if (slash=='0') { - ch = 0; - while (*fmt>='0' && *fmt<='7' && n++<3) ch=(ch*8)+*(fmt++)-'0'; - --fmt; - } else error_exit("bad \\%c", *fmt); - putchar(ch); + unsigned u; + + if (fmt[1] == 'c') break; + if ((u = unescape2(&fmt, 0))<128) putchar(u); + else printf("%.*s", (int)wcrtomb(buf, u, 0), buf); + fmt--; } else if (*fmt != '%') putchar(*fmt); else if (*++fmt == '%') putchar('%'); else { |