Fix regex's, add tests for DBD::Base

Changed $RXname to accept {} chars in the middle of a PV name.
RXdqs now handles escaped double-quotes and back-slashes properly.
New test program for the DBD::Base class and checks for each of
the $RXxxx variable regex's.
This commit is contained in:
Andrew Johnson
2017-10-19 23:19:27 -05:00
parent 7a0b095fd3
commit d5a3df506c
3 changed files with 105 additions and 5 deletions
+4 -3
View File
@@ -16,15 +16,16 @@ our @EXPORT = qw(&pushContext &popContext &dieContext &warnContext &is_reserved
our $RXident = qr/ [a-zA-Z] [a-zA-Z0-9_]* /x;
our $RXname = qr/ [a-zA-Z0-9_\-:.\[\]<>;]+ /x;
our $RXnchr = qr/ [a-zA-Z0-9_\-:.\[\]<>;] /x;
our $RXname = qr/ $RXnchr+ (?: [{}] $RXnchr+ )* /x;
our $RXhex = qr/ (?: 0 [xX] [0-9A-Fa-f]+ ) /x;
our $RXoct = qr/ 0 [0-7]* /x;
our $RXdqs = qr/ " (?: [^"] | \\" )* " /x;
our $RXuint = qr/ [0-9]+ /x;
our $RXint = qr/ -? $RXuint /x;
our $RXuintx = qr/ ( $RXhex | $RXoct | $RXuint ) /x;
our $RXintx = qr/ ( $RXhex | $RXoct | $RXint ) /x;
our $RXnum = qr/ -? (?: [0-9]+ | [0-9]* \. [0-9]+ ) (?: [eE] [-+]? [0-9]+ )? /x;
our $RXdqs = qr/ " (?> \\. | [^"\\] )* " /x;
our $RXstr = qr/ ( $RXname | $RXnum | $RXdqs ) /x;
our @context;
@@ -93,7 +94,7 @@ sub escapeCcomment {
sub escapeCstring {
($_) = @_;
# How to do this?
# FIXME: How to do this?
return $_;
}