From 71ae0e1617218820f405bbf79d5d5dc89d5772ee Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 13 Apr 2020 19:45:09 -0500 Subject: Add unescape2(), migrate some unescape() users over. --- toys/posix/find.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'toys/posix/find.c') 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 { -- cgit v1.2.3