[Checkins] SVN: Sandbox/malthe/chameleon.zpt/ Fixed bug that would cause global defines to be parsed incorrectly.

Malthe Borch mborch at gmail.com
Sun Nov 16 19:49:59 EST 2008


Log message for revision 93027:
  Fixed bug that would cause global defines to be parsed incorrectly.

Changed:
  U   Sandbox/malthe/chameleon.zpt/CHANGES.txt
  U   Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/expressions.py

-=-
Modified: Sandbox/malthe/chameleon.zpt/CHANGES.txt
===================================================================
--- Sandbox/malthe/chameleon.zpt/CHANGES.txt	2008-11-16 23:59:38 UTC (rev 93026)
+++ Sandbox/malthe/chameleon.zpt/CHANGES.txt	2008-11-17 00:49:58 UTC (rev 93027)
@@ -4,6 +4,8 @@
 Head
 ~~~~
 
+- Fixed bug that would parse global defines incorrectly. [malthe]
+
 - TAL- and METAL-elements now subclass the XHTML-element class; this
   allows mixed usage of TAL and METAL. [malthe]
 

Modified: Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/expressions.py
===================================================================
--- Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/expressions.py	2008-11-16 23:59:38 UTC (rev 93026)
+++ Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/expressions.py	2008-11-17 00:49:58 UTC (rev 93027)
@@ -151,6 +151,10 @@
         >>> definitions("global variable expression")
         definitions((declaration('variable', global_scope=True), value('expression')),)
 
+        >>> definitions("variable1 expression1; global variable2 expression2")
+        definitions((declaration('variable1'), value('expression1')),
+                    (declaration('variable2', global_scope=True), value('expression2')))
+
         Space, the 'in' operator and '=' may be used to separate
         variable from expression.
 
@@ -187,14 +191,14 @@
         defines = []
         i = 0
         while i < len(string):
+            while string[i] == ' ':
+                i += 1
+
             global_scope = False
-            if string.startswith('global'):
+            if string[i:].startswith('global'):
                 global_scope = True
                 i += 6
 
-            while string[i] == ' ':
-                i += 1
-
             # get variable definition
             if string[i] == '(':
                 j = string.find(')', i+1)



More information about the Checkins mailing list