浏览代码

qapi.py: Permit comments starting anywhere on the line

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1374939721-7876-10-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Markus Armbruster 12 年之前
父节点
当前提交
f1a145e154
共有 4 个文件被更改,包括 5 次插入4 次删除
  1. 1 2
      scripts/qapi.py
  2. 0 1
      tests/qapi-schema/comments.err
  3. 1 1
      tests/qapi-schema/comments.exit
  4. 3 0
      tests/qapi-schema/comments.out

+ 1 - 2
scripts/qapi.py

@@ -68,13 +68,12 @@ def __init__(self, fp):
 
     def accept(self):
         while True:
-            bol = self.cursor == 0 or self.src[self.cursor-1] == '\n'
             self.tok = self.src[self.cursor]
             self.pos = self.cursor
             self.cursor += 1
             self.val = None
 
-            if self.tok == '#' and bol:
+            if self.tok == '#':
                 self.cursor = self.src.find('\n', self.cursor)
             elif self.tok in ['{', '}', ':', ',', '[', ']']:
                 return

+ 0 - 1
tests/qapi-schema/comments.err

@@ -1 +0,0 @@
-<stdin>:2:33: Stray "#"

+ 1 - 1
tests/qapi-schema/comments.exit

@@ -1 +1 @@
-1
+0

+ 3 - 0
tests/qapi-schema/comments.out

@@ -0,0 +1,3 @@
+[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
+['Status']
+[]