- From: rzeno <ruset.zeno@gmail.com>
- Date: Mon, 18 Oct 2010 19:07:41 +0300
- To: cwm bugs list <public-cwm-bugs@w3.org>
- Message-ID: <20101018160741.GA32420@debian.sort-of.homelinux.org>
On Mon, Oct 18, 2010 at 06:06:53PM +0300, rzeno wrote: > hi, > > n3 parser fail when a literal delimited with """ ends in " or "" as in > this cases: > > :a :b """ some text "quoted text here"""" . > > or > > :a :b """ some text """"" . > > I solved the problem changing the notation3.py. The patch is for the > current notation3.py from CVS and cwm 1.197 from cwm-1.2.1: > > --- notation3.py.orig 2010-10-18 17:40:04.000000000 +0300 > +++ notation3.py 2010-10-18 18:00:23.000000000 +0300 > @@ -1048,14 +1048,28 @@ > ustr = u"" # Empty unicode string > startline = self.lines # Remember where for error messages > while j<len(str): > - i = j + len(delim) > - if str[j:i] == delim: # done. > - return i, ustr > - > - if str[j] == '"': > - ustr = ustr + '"' > - j = j + 1 > - continue > + if delim == '"': # done when delim is " > + i = j + 1 > + return i, ustr > + if delim == '"""': # done when delim is """ and ... > + if str[j:j+5] == '"""""': # ... we have "" before > + i = j + 5 > + ustr = ustr + '""' > + return i, ustr > + if str[j:j+4] == '""""': # ... we have " before > + i = j + 4 > + ustr = ustr + '"' > + return i, ustr > + if str[j:j+3] == '"""': # ... current " is part of delim > + i = j + 3 > + ustr = ustr + '"' > + return i, ustr > + > + # we are inside of the string and current char is " > + j = j + 1 > + ustr = ustr + '"' > + continue > + > m = interesting.search(str, j) # was str[j:]. > # Note for pos param to work, MUST be compiled ... re bug? > assert m , "Quote expected in string at ^ in %s^%s" %( > i apologise, this was a old patch with a error, my mistake. The correct patch for notation3.py 1.200, tested with cwm 1.197 ( from cwm-1.2.1) is: --- notation3.py.orig 2010-10-18 03:48:29.000000000 +0300 +++ notation3.py 2010-10-18 18:59:45.000000000 +0300 @@ -1048,14 +1048,27 @@ ustr = u"" # Empty unicode string startline = self.lines # Remember where for error messages while j<len(str): - i = j + len(delim) - if str[j:i] == delim: # done. - return i, ustr - - if str[j] == '"': - ustr = ustr + '"' - j = j + 1 - continue + if delim == '"': # done when delim is " + i = j + 1 + return i, ustr + if delim == '"""': # done when delim is """ and ... + if str[j:j+5] == '"""""': # ... we have "" before + i = j + 5 + ustr = ustr + '""' + return i, ustr + if str[j:j+4] == '""""': # ... we have " before + i = j + 4 + ustr = ustr + '"' + return i, ustr + if str[j:j+3] == '"""': # ... current " is part of delim + i = j + 3 + return i, ustr + + # we are inside of the string and current char is " + j = j + 1 + ustr = ustr + '"' + continue + m = interesting.search(str, j) # was str[j:]. # Note for pos param to work, MUST be compiled ... re bug? assert m , "Quote expected in string at ^ in %s^%s" %(
Attachments
- text/x-diff attachment: notation3.py.patch
Received on Monday, 18 October 2010 16:08:51 UTC