Parsing error for struct names starting with two underscore
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
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
parsing_cocci/parse_cocci.ml +2 -0
@@ -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))
Thanks Julia,
Quoted 4 lines · Julia Lawall
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
Quoted 17 lines
The line number in the patch are likely to be off.
julia
parsing_cocci/parse_cocci.ml +2
-0@@ -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))
Quoted 10 lines · Michael Stefaniuc
Thanks Julia,
Quoted 4 lines · Julia Lawall
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