On Wed, 7 Jul 2010, Kulikov Vasiliy wrote:
> Hi folks,
>
> is there a way to suppress code tabs/spaces reformatting by coccinelle?
>
> E.g. I've got a simple semantic path like
>
> @@
> void* p;
> type t;
> identifier x;
> @@
> -t *x = (t*)p;
> +t *x = p;
>
> spatch producess such patches (a part of it):
> - WRITERAP(lp, LE_CSR0); /* LANCE Controller Status */
> + WRITERAP(lp, LE_CSR0);/* LANCE Controller Status */
>
> I don't need any reformatting, only modifications that I explicitly said to
> do,
> how can I suppress formatting changes?
Sorry about this problem. It was due to a recent improvement in the
pretty printing that turned out to be more aggressive than intended.
A patch against version 0.2.3rc5 is attached.
julia
diff -u -p a/parsing_c/unparse_c.ml b/parsing_c/unparse_c.ml
--- a/parsing_c/unparse_c.ml 2010-06-27 08:57:16.000000000 +0200
+++ b/parsing_c/unparse_c.ml 2010-07-10 11:07:52.000000000 +0200
@@ -761,15 +761,18 @@ let rec drop_space_at_endline = function
let minus_or_comment_or_space_nocpp = function
T2(_,Min adj,_) -> true
| (T2(Parser_c.TCommentSpace _,Ctx,_i)) -> true
- | (T2 (Parser_c.TCommentNewline _,Ctx,_i)) -> false
- | x -> is_minusable_comment_nocpp x in
+ | (T2(Parser_c.TCommentNewline _,Ctx,_i)) -> false
+ | x -> false in
let (minus,rest) = Common.span minus_or_comment_or_space_nocpp rest in
- (match (minus,rest) with
- ([],_) -> a::outer_spaces@(drop_space_at_endline rest)
- | (_,(((T2 (Parser_c.TCommentNewline _,Ctx,_i)) as a) :: rest)) ->
- (* drop trailing spaces *)
- mi...@a::(drop_space_at_endline rest)
- | _ -> a :: outer_spaces @ minus @ (drop_space_at_endline rest))
+ let fail _ = a :: outer_spaces @ minus @ (drop_space_at_endline rest) in
+ if List.exists (function T2(_,Min adj,_) -> true | _ -> false) minus
+ then
+ match rest with
+ ((T2(Parser_c.TCommentNewline _,Ctx,_i)) as a)::rest ->
+ (* drop trailing spaces *)
+ mi...@a::(drop_space_at_endline rest)
+ | _ -> fail()
+ else fail()
| a :: rest -> a :: drop_space_at_endline rest
(* if a removed ( is between two tokens, then add a space *)
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)