mail[Wesnoth-commits] r20247 - /trunk/data/tools/wesnoth/wmliterator.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by patrick_X99 on September 10, 2007 - 01:16:
Author: sapient
Date: Mon Sep 10 01:15:32 2007
New Revision: 20247

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20247&view=rev
Log:
fix iteration of multiline strings "\n\n"

Modified:
    trunk/data/tools/wesnoth/wmliterator.py

Modified: trunk/data/tools/wesnoth/wmliterator.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wesnoth/wmliterator.py?rev=20247&r1=20246&r2=20247&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/wmliterator.py (original)
+++ trunk/data/tools/wesnoth/wmliterator.py Mon Sep 10 01:15:32 2007
@@ -6,7 +6,7 @@
 keyPattern = re.compile('(\w+)(,\w+)*\s*=')
 keySplit = re.compile(r'[=,\s]')
 tagPattern = re.compile(r'(\[.*?\])')
-macroOpenPattern = re.compile(r'(\{[^\s\}]+)')
+macroOpenPattern = re.compile(r'(\{[^\s\}]*)')
 macroClosePattern = re.compile(r'\}')
 
 def wmlfind(element, itor):
@@ -30,10 +30,12 @@
         while endquote < 0:
             endquote = text.find('"', beginofend)
             if endquote < 0:
-                # todo: check for no lines left
+                if lineno + span >= len(lines):
+                    print >>sys.stderr, 'wmliterator: reached EOF due to 
unterminated string at line', lineno+1
+                    return text, span
                 text += lines[lineno + span]
                 span += 1
-                beginofend = 0
+                beginofend = text.rfind('\n', beginofend, len(text)-1)
         begincomment = text.find('#', endquote+1)
         if begincomment < 0:
             begincomment = None
@@ -130,7 +132,7 @@
             elif scopes:
                 scopes.pop()
             else:
-                print >>sys.stderr, 'wmliterator: attempt to close empty 
scope at', elementType, 'line', lineno
+                print >>sys.stderr, 'wmliterator: attempt to close empty 
scope at', elementType, 'line', lineno+1
             scopeDelta += 1
         while scopeDelta > 0:
             openedScopes.append((elementType, lineno))




Related Messages


Powered by MHonArc, Updated Mon Sep 10 01:40:12 2007