Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen handle \x sequences like c does
details: https://anonhg.NetBSD.org/src/rev/85e618cf3b49
branches: trunk
changeset: 771013:85e618cf3b49
user: christos <christos%NetBSD.org@localhost>
date: Sun Nov 06 03:42:33 2011 +0000
description:
handle \x sequences like c does
diffstat:
lib/libc/gen/unvis.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diffs (69 lines):
diff -r 8982696da025 -r 85e618cf3b49 lib/libc/gen/unvis.c
--- a/lib/libc/gen/unvis.c Sun Nov 06 03:38:16 2011 +0000
+++ b/lib/libc/gen/unvis.c Sun Nov 06 03:42:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: unvis.c,v 1.36 2011/03/18 09:07:20 martin Exp $ */
+/* $NetBSD: unvis.c,v 1.37 2011/11/06 03:42:33 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unvis.c,v 1.36 2011/03/18 09:07:20 martin Exp $");
+__RCSID("$NetBSD: unvis.c,v 1.37 2011/11/06 03:42:33 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -63,18 +63,19 @@
#define S_CTRL 4 /* control char started (^) */
#define S_OCTAL2 5 /* octal digit 2 */
#define S_OCTAL3 6 /* octal digit 3 */
-#define S_HEX1 7 /* http hex digit */
-#define S_HEX2 8 /* http hex digit 2 */
-#define S_MIME1 9 /* mime hex digit 1 */
-#define S_MIME2 10 /* mime hex digit 2 */
-#define S_EATCRNL 11 /* mime eating CRNL */
-#define S_AMP 12 /* seen & */
-#define S_NUMBER 13 /* collecting number */
-#define S_STRING 14 /* collecting string */
+#define S_HEX 7 /* mandatory hex digit */
+#define S_HEX1 8 /* http hex digit */
+#define S_HEX2 9 /* http hex digit 2 */
+#define S_MIME1 10 /* mime hex digit 1 */
+#define S_MIME2 11 /* mime hex digit 2 */
+#define S_EATCRNL 12 /* mime eating CRNL */
+#define S_AMP 13 /* seen & */
+#define S_NUMBER 14 /* collecting number */
+#define S_STRING 15 /* collecting string */
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
-#define XTOD(c) (isdigit(c) ? (c - '0') : ((c - 'A') + 10))
+#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
+#define XTOD(c) (isdigit(c) ? (c - '0') : ((c - 'A') + 10))
/*
* RFC 1866
@@ -297,6 +298,9 @@
*cp = '\033';
*astate = SS(0, S_GROUND);
return UNVIS_VALID;
+ case 'x':
+ *astate = SS(0, S_HEX);
+ return UNVIS_NOCHAR;
case '\n':
/*
* hidden newline
@@ -360,6 +364,10 @@
*/
return UNVIS_VALIDPUSH;
+ case S_HEX:
+ if (!isxdigit(uc))
+ goto bad;
+ /*FALLTHROUGH*/
case S_HEX1:
if (isxdigit(uc)) {
*cp = xtod(uc);
Home |
Main Index |
Thread Index |
Old Index