9ae3a8
From eee270ab05e29d24d26d8834a00ec0dfcfc99d66 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <eee270ab05e29d24d26d8834a00ec0dfcfc99d66.1387369730.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <091eecc4fa42754760dfff393dabcc2b444e9693.1387369730.git.minovotn@redhat.com>
9ae3a8
References: <091eecc4fa42754760dfff393dabcc2b444e9693.1387369730.git.minovotn@redhat.com>
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
Date: Tue, 10 Dec 2013 15:29:19 +0100
9ae3a8
Subject: [PATCH 19/21] qapi.py: Permit comments starting anywhere on the line
9ae3a8
9ae3a8
RH-Author: Markus Armbruster <armbru@redhat.com>
9ae3a8
Message-id: <1386689361-30281-17-git-send-email-armbru@redhat.com>
9ae3a8
Patchwork-id: 56128
9ae3a8
O-Subject: [PATCH 7.0 qemu-kvm 16/18] qapi.py: Permit comments starting anywhere on the line
9ae3a8
Bugzilla: 997915
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
9ae3a8
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
9ae3a8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Message-id: 1374939721-7876-10-git-send-email-armbru@redhat.com
9ae3a8
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
9ae3a8
(cherry picked from commit f1a145e154b0a227a1e192009ca30b351de0a8ef)
9ae3a8
9ae3a8
Backporting hack: now that indented comments work properly, revert the
9ae3a8
damage to qapi-schema.json.
9ae3a8
---
9ae3a8
 qapi-schema.json                | 2 +-
9ae3a8
 scripts/qapi.py                 | 3 +--
9ae3a8
 tests/qapi-schema/comments.err  | 1 -
9ae3a8
 tests/qapi-schema/comments.exit | 2 +-
9ae3a8
 tests/qapi-schema/comments.out  | 3 +++
9ae3a8
 5 files changed, 6 insertions(+), 5 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 qapi-schema.json                | 2 +-
9ae3a8
 scripts/qapi.py                 | 3 +--
9ae3a8
 tests/qapi-schema/comments.err  | 1 -
9ae3a8
 tests/qapi-schema/comments.exit | 2 +-
9ae3a8
 tests/qapi-schema/comments.out  | 3 +++
9ae3a8
 5 files changed, 6 insertions(+), 5 deletions(-)
9ae3a8
9ae3a8
diff --git a/qapi-schema.json b/qapi-schema.json
9ae3a8
index 81fe591..b27108f 100644
9ae3a8
--- a/qapi-schema.json
9ae3a8
+++ b/qapi-schema.json
9ae3a8
@@ -3437,7 +3437,7 @@
9ae3a8
                                        'spiceport' : 'ChardevSpicePort',
9ae3a8
                                        'vc'     : 'ChardevVC',
9ae3a8
                                        'ringbuf': 'ChardevRingbuf',
9ae3a8
-# next one is just for compatibility
9ae3a8
+                                       # next one is just for compatibility
9ae3a8
                                        'memory' : 'ChardevRingbuf' } }
9ae3a8
 
9ae3a8
 ##
9ae3a8
diff --git a/scripts/qapi.py b/scripts/qapi.py
9ae3a8
index f64b7b2..0ebea94 100644
9ae3a8
--- a/scripts/qapi.py
9ae3a8
+++ b/scripts/qapi.py
9ae3a8
@@ -68,13 +68,12 @@ class QAPISchema:
9ae3a8
 
9ae3a8
     def accept(self):
9ae3a8
         while True:
9ae3a8
-            bol = self.cursor == 0 or self.src[self.cursor-1] == '\n'
9ae3a8
             self.tok = self.src[self.cursor]
9ae3a8
             self.pos = self.cursor
9ae3a8
             self.cursor += 1
9ae3a8
             self.val = None
9ae3a8
 
9ae3a8
-            if self.tok == '#' and bol:
9ae3a8
+            if self.tok == '#':
9ae3a8
                 self.cursor = self.src.find('\n', self.cursor)
9ae3a8
             elif self.tok in ['{', '}', ':', ',', '[', ']']:
9ae3a8
                 return
9ae3a8
diff --git a/tests/qapi-schema/comments.err b/tests/qapi-schema/comments.err
9ae3a8
index 4a82b26..e69de29 100644
9ae3a8
--- a/tests/qapi-schema/comments.err
9ae3a8
+++ b/tests/qapi-schema/comments.err
9ae3a8
@@ -1 +0,0 @@
9ae3a8
-<stdin>:2:33: Stray "#"
9ae3a8
diff --git a/tests/qapi-schema/comments.exit b/tests/qapi-schema/comments.exit
9ae3a8
index d00491f..573541a 100644
9ae3a8
--- a/tests/qapi-schema/comments.exit
9ae3a8
+++ b/tests/qapi-schema/comments.exit
9ae3a8
@@ -1 +1 @@
9ae3a8
-1
9ae3a8
+0
9ae3a8
diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out
9ae3a8
index e69de29..e3bd904 100644
9ae3a8
--- a/tests/qapi-schema/comments.out
9ae3a8
+++ b/tests/qapi-schema/comments.out
9ae3a8
@@ -0,0 +1,3 @@
9ae3a8
+[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
9ae3a8
+['Status']
9ae3a8
+[]
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8