[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] fixup! qapi: qapi.py: allow the "'" character b
From: |
Luiz Capitulino |
Subject: |
Re: [Qemu-devel] [PATCH] fixup! qapi: qapi.py: allow the "'" character be escaped |
Date: |
Fri, 27 Jul 2012 11:29:52 -0300 |
On Thu, 26 Jul 2012 19:09:13 +0200
Markus Armbruster <address@hidden> wrote:
> Support escaping the escape character, and make more robust (don't die
> for '', handle ' without matching '.
>
> Signed-off-by: Markus Armbruster <address@hidden>
Can you please do you it on top of master so that I can apply it on the qmp
branch?
> ---
> Luiz made me do this. Fixes up his 07/11.
>
> Generates identical qmp-commands.h qapi-types.h qapi-visit.h
> qapi-errors.h tests/test-qapi-types.h tests/test-qapi-visit.h
> tests/test-qmp-commands.h qapi-generated/qga-qapi-types.h
> qapi-generated/qga-qapi-visit.h qapi-generated/qga-qmp-commands.h
>
> scripts/qapi.py | 31 ++++++++++++++++++++-----------
> 1 file changed, 20 insertions(+), 11 deletions(-)
>
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 9aa518f..169ea78 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -13,20 +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 = ''
> + esc = False
> while True:
> - if data[0] == "'" and string[len(string)-1] != "\\":
> - break
> - string += data[0]
> + 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):
- [Qemu-devel] [PATCH 02/11] qerror: rename QERR_SOCK_CONNECT_IN_PROGRESS, (continued)
- [Qemu-devel] [PATCH 02/11] qerror: rename QERR_SOCK_CONNECT_IN_PROGRESS, Luiz Capitulino, 2012/07/25
- [Qemu-devel] [PATCH 07/11] qapi: qapi.py: allow the "'" character be escaped, Luiz Capitulino, 2012/07/25
- Re: [Qemu-devel] [PATCH 07/11] qapi: qapi.py: allow the "'" character be escaped, Peter Maydell, 2012/07/25
- Re: [Qemu-devel] [PATCH 07/11] qapi: qapi.py: allow the "'" character be escaped, Luiz Capitulino, 2012/07/25
- Re: [Qemu-devel] [PATCH 07/11] qapi: qapi.py: allow the "'" character be escaped, Peter Maydell, 2012/07/25
- Re: [Qemu-devel] [PATCH 07/11] qapi: qapi.py: allow the "'" character be escaped, Markus Armbruster, 2012/07/26
- Re: [Qemu-devel] [PATCH 07/11] qapi: qapi.py: allow the "'" character be escaped, Luiz Capitulino, 2012/07/26
- Re: [Qemu-devel] [PATCH 07/11] qapi: qapi.py: allow the "'" character be escaped, Markus Armbruster, 2012/07/26
- [Qemu-devel] [PATCH] fixup! qapi: qapi.py: allow the "'" character be escaped, Markus Armbruster, 2012/07/26
- Re: [Qemu-devel] [PATCH] fixup! qapi: qapi.py: allow the "'" character be escaped, Peter Maydell, 2012/07/26
- Re: [Qemu-devel] [PATCH] fixup! qapi: qapi.py: allow the "'" character be escaped,
Luiz Capitulino <=
- Re: [Qemu-devel] [PATCH] fixup! qapi: qapi.py: allow the "'" character be escaped, Markus Armbruster, 2012/07/28
- Re: [Qemu-devel] [PATCH] fixup! qapi: qapi.py: allow the "'" character be escaped, Luiz Capitulino, 2012/07/30
[Qemu-devel] [PATCH 06/11] qerror: QERR_AMBIGUOUS_PATH: drop %(object) from human msg, Luiz Capitulino, 2012/07/25
[Qemu-devel] [PATCH 01/11] qerror: rename QERR_SOCKET_* macros, Luiz Capitulino, 2012/07/25
[Qemu-devel] [PATCH 10/11] qerror: switch to qapi generated error macros and table, Luiz Capitulino, 2012/07/25