[libvirt PATCH] scripts: fix API parsing of *** pointers

Daniel P. Berrangé posted 1 patch 2 years, 7 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20210920162704.2189224-1-berrange@redhat.com
scripts/apibuild.py | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
[libvirt PATCH] scripts: fix API parsing of *** pointers
Posted by Daniel P. Berrangé 2 years, 7 months ago
The currrent generated API contains *** pointer types with bogus
whitespace in the middle:

  <arg name='keys' type='char ** *' info='pointer to a variable to store authorized keys'/>

because the tokenizer only tries to merge 2 distinct '*' together.
This refactors the code to merge an arbitrary number, resulting
in

  <arg name='keys' type='char ***' info='pointer to a variable to store authorized keys'/>

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 scripts/apibuild.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/scripts/apibuild.py b/scripts/apibuild.py
index b94c0f6c09..722fd33f0e 100755
--- a/scripts/apibuild.py
+++ b/scripts/apibuild.py
@@ -603,13 +603,12 @@ class CLexer:
                         i = i + 3
                         continue
 
-                    j = i + 1
-                    if j < nline and line[j] in "+-*><=/%&!|":
-                        self.tokens.append(('op', line[i:j + 1]))
-                        i = j + 1
-                    else:
-                        self.tokens.append(('op', line[i]))
-                        i = i + 1
+                    j = i
+                    while (j + 1) < nline and line[j+1] in "+-*><=/%&!|":
+                        j = j + 1
+
+                    self.tokens.append(('op', line[i:j+1]))
+                    i = j + 1
                     continue
                 s = i
                 while i < nline:
-- 
2.31.1

Re: [libvirt PATCH] scripts: fix API parsing of *** pointers
Posted by Michal Prívozník 2 years, 7 months ago
On 9/20/21 6:27 PM, Daniel P. Berrangé wrote:
> The currrent generated API contains *** pointer types with bogus
> whitespace in the middle:
> 
>   <arg name='keys' type='char ** *' info='pointer to a variable to store authorized keys'/>
> 
> because the tokenizer only tries to merge 2 distinct '*' together.
> This refactors the code to merge an arbitrary number, resulting
> in
> 
>   <arg name='keys' type='char ***' info='pointer to a variable to store authorized keys'/>
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  scripts/apibuild.py | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal