This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]