tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: standards/38127: awk's: regexps should treat { and } as special, but as regular characters
How about the following patch?
It is worse than standard {n,m} but much better than nothing.
Index: b.c
===================================================================
RCS file: /pub/NetBSD-CVS/src/dist/nawk/b.c,v
retrieving revision 1.12
diff -u -r1.12 b.c
--- b.c 25 Jul 2006 20:52:57 -0000 1.12
+++ b.c 20 Jun 2008 21:05:39 -0000
@@ -789,6 +789,11 @@
case '\\':
rlxval = quoted(&prestr);
return CHAR;
+ case '{':
+ case '}':
+ WARNING ("warning: character `%c' treated as plain `%c'", c, c);
+ rlxval = c;
+ return CHAR;
default:
rlxval = c;
return CHAR;
Result:
0 ~>echo '{}' | /usr/bin/awk '/{}/'
{}
0 ~>echo '{}' | /usr/bin/awk '/[{][}]/'
{}
0 ~>echo '{}' | /srv/src/usr.bin/awk/awk '/{}/'
/srv/src/usr.bin/awk/awk: warning: character `{' treated as plain `{'
source line number 1
context is
>>> /{}/ <<<
/srv/src/usr.bin/awk/awk: warning: character `}' treated as plain `}'
source line number 1
{}
0 ~>echo '{}' | /srv/src/usr.bin/awk/awk '/[{][}]/'
{}
0 ~>
--
Best regards, Aleksey Cheusov.
Home |
Main Index |
Thread Index |
Old Index