help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: skelout patch


From: Danen Brücker
Subject: Re: skelout patch
Date: 10 May 2002 13:32:02 -0700

This patch seems to be eating a few too many \n's. The output now looks
pretty garbled and does not compile.

#define YY_REENTRANT 1
#define YY_REENTRANT_BISON_PURE 1
#line 4 "h_compile_scanner.c"
/* -*-C-*- *//* A lexical scanner generated by flex */#define
FLEX_SCANNER#define YY_FLEX_MAJOR_VERSION 2#define YY_FLEX_MINOR_VERSION
5/* %- */
/* begin standard C headers. */#include <stdio.h>#include
<errno.h>#include <stdlib.h>/* end standard C headers. *//* %+ */

On Fri, 2002-05-10 at 12:01, John W. Millaway wrote:
> 
> I see what the bug is. The default skel array does not contain newlines, but
> your skel does, naturally. It has been fixed.  The solution was to eat the
> newlines before processing the buffer. Thank you for bringing this bug to our
> attention!
> 
> FYI, here is the cvs diff:
> 
> 
> Index: flexdef.h
> ===================================================================
> RCS file: /usr/local/cvsroot/flex/flexdef.h,v
> retrieving revision 2.64
> diff -c -r2.64 flexdef.h
> *** flexdef.h   19 Apr 2002 22:20:24 -0000      2.64
> --- flexdef.h   10 May 2002 19:00:48 -0000
> ***************
> *** 1058,1061 ****
> --- 1058,1064 ----
>   extern jmp_buf flex_main_jmp_buf;
>   #define FLEX_EXIT(status) longjmp(flex_main_jmp_buf,(status)+1)
> 
> + /* Removes all \n and \r chars from tail of str. returns str. */
> + extern char* chomp(char* str);
> +
>   #endif /* not defined FLEXDEF_H */
> Index: misc.c
> ===================================================================
> RCS file: /usr/local/cvsroot/flex/misc.c,v
> retrieving revision 2.55
> diff -c -r2.55 misc.c
> *** misc.c      19 Apr 2002 22:20:24 -0000      2.55
> --- misc.c      10 May 2002 19:00:49 -0000
> ***************
> *** 796,802 ****
>         while ( skelfile ?
>                 (fgets( buf, MAXLINE, skelfile ) != NULL) :
>                 ((buf = (char *) skel[skel_ind++]) != 0) )
> !               { /* copy from skel array */
>                 if ( buf[0] == '%' )
>                         { /* control line */
>                         /* print the control line as a comment. */
> --- 796,807 ----
>         while ( skelfile ?
>                 (fgets( buf, MAXLINE, skelfile ) != NULL) :
>                 ((buf = (char *) skel[skel_ind++]) != 0) )
> !               {
> !
> !               if (skelfile )
> !                       chomp(buf);
> !
> !               /* copy from skel array */
>                 if ( buf[0] == '%' )
>                         { /* control line */
>                         /* print the control line as a comment. */
> ***************
> *** 915,917 ****
> --- 920,941 ----
>         while ( rp < rp_end )
>                 *rp++ = 0;
>         }
> +
> + /* Remove all '\n' and '\r' characters, if any, from the end of str.
> +  * str can be any null-terminated string, or NULL.
> +  * returns str. */
> + char* chomp(char* str){
> +     char* p=str;
> +     if (!str || !*str)  /* s is null or empty string */
> +         return str;
> +
> +     /* find end of string minus one*/
> +     while (*p)
> +         ++p;
> +     --p;
> +
> +     /* eat newlines */
> +     while (p >= str && (*p == '\r' || *p == '\n'))
> +         *p-- = 0;
> +     return str;
> + }
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Shopping - Mother's Day is May 12th!
> http://shopping.yahoo.com





reply via email to

[Prev in Thread] Current Thread [Next in Thread]