Part of the verbosity of the previous version was due to me having misinterpreted a SMPL parse error. Here is a more concise (although still not optimal) version. Now it will also convert partially converted structures.

Although, actually it might not do the right thing for eg:

struct ty { int a; int b; int c; int d; };

struct ty x = { 1, .b = 2, 3, 4 };

I am assuming that nothing needs to be done to .b = 2 and that c matches up with 3 and d with 4. But what if it had been instead:

struct ty x = { 1, .c = 2, 3, 4 };

Does that means that b should match up with c?

Perhaps doing nothing for partiall C99 declarations was a better idea?

julia

---------------

@r@
field list[n] ds;
type T;
identifier i, virtual.ty;
@@

struct ty {
  ds
  T i;
  ...
};

@rr@
type T;
identifier i, virtual.ty;
@@

struct ty {
  T i;
  ...
};

// --------------------------------------------------------------------

@@
initializer list[r.n] is;
expression a;
identifier nm;
identifier r.i, virtual.ty;
@@

struct ty nm = {
  is,
+  .i =
  a,
  ...
};

@@
expression a;
identifier nm;
identifier rr.i, virtual.ty;
@@

struct ty nm = {
+  .i =
  a,
  ...
};

// --------------------------------------------------------------------

@@
initializer list[r.n] is;
expression a;
identifier nm;
identifier r.i, virtual.ty;
@@

struct ty nm[...] = { ..., {
  is,
+  .i =
  a,
  ...
}, ...};

@@
expression a;
identifier nm;
identifier rr.i, virtual.ty;
@@

struct ty nm[...] = { ..., {
+  .i =
  a,
  ...
}, ...};


// --------------------------------------------------------------------

@@
initializer list[r.n] is;
expression a;
identifier nm;
identifier r.i, virtual.ty;
@@

struct ty nm[] = { ..., {
  is,
+  .i =
  a,
  ...
}, ...};

@@
expression a;
identifier nm;
identifier rr.i, virtual.ty;
@@

struct ty nm[] = { ..., {
+  .i =
  a,
  ...
}, ...};
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to