* [Cocci] Parsing error for struct names starting with two underscore
@ 2013-01-04 21:53 Michael Stefaniuc
2013-01-05 8:07 ` Julia Lawall
0 siblings, 1 reply; 4+ messages in thread
From: Michael Stefaniuc @ 2013-01-04 21:53 UTC (permalink / raw)
To: cocci
Hello,
there seems to be an error in parsing struct/union names that start with
two underscore:
@@
struct __foo bar;
@@
* sizeof(bar)
Fatal error: exception Failure("meta: parse error:
= File "__foo.cocci", line 2, column 7, charpos = 10
around = '__foo', whole content = struct __foo bar;
")
Removing one of the underscore makes it parse.
thanks
bye
michael
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Cocci] Parsing error for struct names starting with two underscore
2013-01-04 21:53 [Cocci] Parsing error for struct names starting with two underscore Michael Stefaniuc
@ 2013-01-05 8:07 ` Julia Lawall
2013-01-05 22:48 ` Michael Stefaniuc
0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2013-01-05 8:07 UTC (permalink / raw)
To: cocci
The problem is that it was considering anything beginning with __ that is
followed by an identifier to be an attribute. The following patch does
not do that when the __ thing is immediately preceded by a struct.
Perhaps that is not the best solution, but it works in this case.
The line number in the patch are likely to be off.
julia
diff --git a/parsing_cocci/parse_cocci.ml b/parsing_cocci/parse_cocci.ml
index f6ed199..13ce673 100644
--- a/parsing_cocci/parse_cocci.ml
+++ b/parsing_cocci/parse_cocci.ml
@@ -828,6 +828,8 @@ let rec detect_attr l =
let rec loop = function
[] -> []
| [x] -> [x]
+ | ((PC.Tstruct _,_) as t1)::x::rest ->
+ t1::x::loop rest
| ((PC.TIdent(nm,clt),info) as t1)::id::rest when is_id id ->
if String.length nm > 2 && String.sub nm 0 2 = "__"
then (PC.Tattr(nm,clt),info)::(loop (id::rest))
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Cocci] Parsing error for struct names starting with two underscore
2013-01-05 8:07 ` Julia Lawall
@ 2013-01-05 22:48 ` Michael Stefaniuc
2013-01-06 6:21 ` Julia Lawall
0 siblings, 1 reply; 4+ messages in thread
From: Michael Stefaniuc @ 2013-01-05 22:48 UTC (permalink / raw)
To: cocci
Thanks Julia,
On 01/05/2013 09:07 AM, Julia Lawall wrote:
> The problem is that it was considering anything beginning with __ that
> is followed by an identifier to be an attribute. The following patch
> does not do that when the __ thing is immediately preceded by a struct.
> Perhaps that is not the best solution, but it works in this case.
the patch works here though only for structs and not unions. Which is
good enough for Wine. One of this days I should learn OCaml so I can
modify coccinelle myself...
bye
michael
> The line number in the patch are likely to be off.
>
> julia
>
> diff --git a/parsing_cocci/parse_cocci.ml b/parsing_cocci/parse_cocci.ml
> index f6ed199..13ce673 100644
> --- a/parsing_cocci/parse_cocci.ml
> +++ b/parsing_cocci/parse_cocci.ml
> @@ -828,6 +828,8 @@ let rec detect_attr l =
> let rec loop = function
> [] -> []
> | [x] -> [x]
> + | ((PC.Tstruct _,_) as t1)::x::rest ->
> + t1::x::loop rest
> | ((PC.TIdent(nm,clt),info) as t1)::id::rest when is_id id ->
> if String.length nm > 2 && String.sub nm 0 2 = "__"
> then (PC.Tattr(nm,clt),info)::(loop (id::rest))
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Cocci] Parsing error for struct names starting with two underscore
2013-01-05 22:48 ` Michael Stefaniuc
@ 2013-01-06 6:21 ` Julia Lawall
0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2013-01-06 6:21 UTC (permalink / raw)
To: cocci
On Sat, 5 Jan 2013, Michael Stefaniuc wrote:
> Thanks Julia,
>
> On 01/05/2013 09:07 AM, Julia Lawall wrote:
>> The problem is that it was considering anything beginning with __ that
>> is followed by an identifier to be an attribute. The following patch
>> does not do that when the __ thing is immediately preceded by a struct.
>> Perhaps that is not the best solution, but it works in this case.
> the patch works here though only for structs and not unions. Which is
> good enough for Wine. One of this days I should learn OCaml so I can
> modify coccinelle myself...
Thanks. I will adjust the case for unions as well.
julia
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-06 6:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-04 21:53 [Cocci] Parsing error for struct names starting with two underscore Michael Stefaniuc
2013-01-05 8:07 ` Julia Lawall
2013-01-05 22:48 ` Michael Stefaniuc
2013-01-06 6:21 ` Julia Lawall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.