SV: SV: [Cocci] How to match &(ttyname(0))[5]

Andreas.Aaen at tieto.com Andreas.Aaen at tieto.com
Fri Nov 27 15:45:25 CET 2009


Ok thanks.
________________________________________
Fra: Julia Lawall [julia at diku.dk]
Sendt: 27. november 2009 15:30
Til: Aaen Andreas
Cc: cocci at diku.dk
Emne: Re: SV: [Cocci] How to match &(ttyname(0))[5]

Actually, your patch worked fine for me.  Although in the exact patch you
sent there was no indication of a transformation, or a *, so that by
itself didn't do anything.

julia


On Fri, 27 Nov 2009, Andreas.Aaen at tieto.com wrote:

> Sure:
> ----------------------------------------------
> #include <unistd.h>
> #include <stdio.h>
> int main()
> {
>  char filename[100];
>  sprintf (filename, "/tmp/cnf.%s", &(ttyname(0))[5]) ;
>  printf(filename);
> }
> ---------------------------------------------
> ________________________________________
> Fra: Julia Lawall [julia at diku.dk]
> Sendt: 27. november 2009 10:11
> Til: Aaen Andreas
> Cc: cocci at diku.dk
> Emne: Re: [Cocci] How to match &(ttyname(0))[5]
>
> Could you send a small test file (.c)?
>
> thanks,
> julia
>
>
>
> On Fri, 27 Nov 2009, Andreas.Aaen at tieto.com wrote:
>
> > Hi,
> >
> > I an porting an application from one Unix flavor to another. I have found expressions in the code like this:
> >
> > &(ttyname(0))[5]
> >
> > In some flavors of Unix this might give you a unique number, but it depend very much of the naming convention, so I wan't to find all these.
> > How do I find this?
> >
> > $$
> > expression E1;
> > $$
> > ttyname(E1)
> >
> > does find all uses of ttyname, but
> >
> > $$
> > expression E1;
> > $$
> > &(ttyname(E1))[5]
> >
> > doesn't match anything
> > What did I express wrongly in Coccinelle?
> >
> > Regards
> > Andreas Bach Aaen
> >


More information about the Cocci mailing list