This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [testsuite] gdb.c++/templates.exp
- From: Michael Elizabeth Chastain <mec at shout dot net>
- To: dberlin at dberlin dot org
- Cc: gdb-patches at sources dot redhat dot com, mludvig at suse dot cz
- Date: Wed, 9 Jul 2003 11:35:42 -0400
- Subject: Re: [testsuite] gdb.c++/templates.exp
Hi Daniel,
mec> \\(unsigned ?(long|)\\);
mec>
mec> It would accept 'unsignedlong' which would be wrong.
berlin> It shouldn't, unless the regex isn't whitespace sensitive
I think you have it backwards:
PATTERN TEXT
'unsigned' -> 'unsigned'
' ?' -> ''
'(long|)' -> 'long'
Matches 'unsignedlong'.
Try it with egrep:
$ egrep 'unsigned ?(long|)'
unsignedlong
unsignedlong
Try it with tclsh:
$ tclsh
% regexp "unsigned ?(long|)" unsignedlong
1
mec> Can you try:
mec>
mec> \\(unsigned( long|)\\);
berlin> Now *this* would accept unsignedlong, unless the regexps in expect are
berlin> unlike any other system i've seen.
berlin>
berlin> This is because the alternation would be between " long" and "", *not*
berlin> "long" and "" (IE your regex would not be equivalent to
berlin> <space>long|<space>
This accepts either '(unsigned);' or '(unsigned long);'.
It does not accept '(unsignedlong);'. Try it with egrep or tclsh.
I did.
$ tclsh
% regexp "\\(unsigned( long|)\\)" "(unsigned)"
1
% regexp "\\(unsigned( long|)\\)" "(unsigned long)"
1
% regexp "\\(unsigned( long|)\\)" "(unsignedlong)"
0
I agree that the alternation is between " long" and "".
These two regular expressions are equivalent:
\\(unsigned( long|)\\);
\\((unsigned long|unsigned)\\);
Michael C