aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-08-03 14:28:26 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2012-08-03 14:28:26 -0500
commit2ad728bd4bf26d8144190ca87d5d36d5f33cfae9 (patch)
tree2a01d7c0e541d92d742fc1f932fb6ff6aa65f929 /scripts
parent9c936c8667f15cf729ee602ae2a800658580fe47 (diff)
parent75115d9569164b99a52847450d5133af62f3d370 (diff)
Merge remote-tracking branch 'qmp/queue/qmp' into staging
* qmp/queue/qmp: hmp: show the backing file depth block: Use bdrv_get_backing_file_depth() block: create bdrv_get_backing_file_depth() qapi: qapi.py: allow the "'" character to be escaped
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi.py31
1 files changed, 21 insertions, 10 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 8082af3fcd..d3b8b4d851 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -13,18 +13,29 @@ from ordereddict import OrderedDict
def tokenize(data):
while len(data):
- if data[0] in ['{', '}', ':', ',', '[', ']']:
- yield data[0]
- data = data[1:]
- elif data[0] in ' \n':
- data = data[1:]
- elif data[0] == "'":
- data = data[1:]
+ ch = data[0]
+ data = data[1:]
+ if ch in ['{', '}', ':', ',', '[', ']']:
+ yield ch
+ elif ch in ' \n':
+ None
+ elif ch == "'":
string = ''
- while data[0] != "'":
- string += data[0]
+ esc = False
+ while True:
+ if (data == ''):
+ raise Exception("Mismatched quotes")
+ ch = data[0]
data = data[1:]
- data = data[1:]
+ if esc:
+ string += ch
+ esc = False
+ elif ch == "\\":
+ esc = True
+ elif ch == "'":
+ break
+ else:
+ string += ch
yield string
def parse(tokens):