| Date: | Fri, 29 Oct 1999 14:48:04 +0200 |
| Reply-To: | Eric Hoogenboom <e.hoogenboom@BIG.NL> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Eric Hoogenboom <e.hoogenboom@BIG.NL> |
| Subject: | Re: Unbalanced Quote |
| Content-Type: | text/plain; charset="iso-8859-1" |
I love this part:
goto rien
:-) Eric
> -----Original Message-----
> From: Jean-Pierre Desgoutte [SMTP:desgoutte@CEREQ.FR]
> Sent: Friday, October 29, 1999 2:15 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: Unbalanced Quote
>
>
> Bonjour à tous
>
> I use this code to find LINES with unbalanced quotes (" or ').
> It treats quoted quotes and comment where quotes are free (/* ... */ or *
> ... ;)
> and for this reason tellls when such a comment does not start and end on
> the
> same line
>
> I wish you will never have to use it...
>
> Amicalement
>
> Desgoutte Jean Pierre
> Marseille - France
> Email: desgoutte@cereq.fr <mailto:desgoutte@cereq.fr>
>
> %let pgm = cc;
> * fileref or "OS filename" of code to scan (used by infile);
>
> data _null_;
> infile &pgm length = lus end = fin;
> length zlec zm $ 160 found $ 2;
> retain opc 0 need "12";
> array xf (0:4) $ 2 _temporary_ (" ", "'", '"', ";*", "/*");
> array xs (0:4) $ 2 _temporary_ (" ", "'", '"', ";", "*/");
>
> input zlec $varying160. lus;
> zm = compress (zlec);
> lz = length (zm);
> if opc
> then goto rech;
> opc = _n_;
> need = ";";
> if index (zm, "*") = 1
> then goto rech;
>
> bcl:
> pcr = lz + 1;
> ir = 0;
> do i = 1 to 4;
> pc = index (zm, trim (xf (i)));
> if 0 < pc < pcr
> then do;
> pcr = pc;
> ir = i;
> end;
> end;
> if 0 < opc < _n_
> then put "line " _n_ +2 "closing comment starting at line " opc;
> opc = 0;
> if ^ir /* nothing... */
> then goto rien;
>
> found = xf (ir);
> zm = substr (zm, pcr + length (found));
> need = xs (ir);
> if ir > 2
> then opc = _n_;
>
> rech:
> pcr = index (zm, trim (need));
> zm = substr (zm, pcr + length (need));
> lz = length (zm);
>
> if pcr /* match */
> then goto bcl;
> else if ^opc /* not a comment so missmatch quote */
> then put "line " _n_ "UNBQ (" need +(-1) "):"
> +2 zlec;
>
> rien:
> if fin
> then if opc
> then put / "Comment starting at line " opc /;
> else put /;
> run;
>
|