flex 2.3 patch #4
Vern Paxson
vern at fjalar.cs.cornell.edu
Tue Aug 14 14:30:58 AEST 1990
Here's a patch for flex release 2.3 which fixes a bug in the
handling of hexadecimal escape sequences (only digits were
recognized in such sequences, not the letters 'a' through 'f').
Vern
*** Patch-3/Changes Fri Aug 3 14:17:00 1990
--- Patch-4/Changes Tue Aug 14 00:08:22 1990
***************
*** 1,4 ****
! Changes between 2.3 Patch #3 (03Aug90) and original 2.3 release:
- Correction to patch #2 for gcc compilation; thanks goes to
Paul Eggert for catching this.
--- 1,11 ----
! Changes between 2.3 Patch #4 (14Aug90) and 2.3 Patch #3:
!
! - Fixed bug in hexadecimal escapes which allowed only digits,
! not letters, in escapes
! - Fixed bug in previous "Changes" file!
!
!
! Changes between 2.3 Patch #3 (03Aug90) and 2.3 Patch #2:
- Correction to patch #2 for gcc compilation; thanks goes to
Paul Eggert for catching this.
*** Original/misc.c Thu Jun 28 00:44:40 1990
--- Patch-4/misc.c Tue Aug 14 00:11:19 1990
***************
*** 28,34 ****
#ifndef lint
static char rcsid[] =
! "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/misc.c,v 2.7 90/06/27 23:48:27 vern Exp $ (LBL)";
#endif
#include <ctype.h>
--- 28,34 ----
#ifndef lint
static char rcsid[] =
! "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/misc.c,v 2.9 90/08/14 00:10:24 vern Exp $ (LBL)";
#endif
#include <ctype.h>
***************
*** 477,482 ****
--- 477,514 ----
}
+ /* is_hex_digit - returns true if a character is a valid hex digit, false
+ * otherwise
+ *
+ * synopsis:
+ * int true_or_false, is_hex_digit();
+ * int ch;
+ * val = is_hex_digit( ch );
+ */
+
+ int is_hex_digit( ch )
+ int ch;
+
+ {
+ if ( isdigit( ch ) )
+ return ( 1 );
+
+ switch ( clower( ch ) )
+ {
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ return ( 1 );
+
+ default:
+ return ( 0 );
+ }
+ }
+
+
/* line_directive_out - spit out a "# line" statement */
void line_directive_out( output_file_name )
***************
*** 584,589 ****
--- 616,624 ----
Char array[];
{
+ Char c, esc_char;
+ register int sptr;
+
switch ( array[1] )
{
case 'a': return ( '\a' );
***************
*** 594,602 ****
case 't': return ( '\t' );
case 'v': return ( '\v' );
- case 'x':
- /* fall through */
-
case '0':
case '1':
case '2':
--- 629,634 ----
***************
*** 607,623 ****
case '7':
case '8':
case '9':
! { /* \<octal> or \x<hex> */
! Char c, esc_char;
! register int sptr = 1;
!
! if ( array[1] == 'x' )
++sptr;
! while ( isascii( array[sptr] ) && isdigit( array[sptr] ) )
/* don't increment inside loop control because if
! * isdigit() is a macro it will expand it to two
* increments ...
*/
++sptr;
--- 639,671 ----
case '7':
case '8':
case '9':
+ { /* \<octal> */
+ sptr = 1;
! while ( isascii( array[sptr] ) && isdigit( array[sptr] ) )
! /* don't increment inside loop control because if
! * isdigit() is a macro it might expand into multiple
! * increments ...
! */
++sptr;
! c = array[sptr];
! array[sptr] = '\0';
!
! esc_char = otoi( array + 1 );
!
! array[sptr] = c;
!
! return ( esc_char );
! }
!
! case 'x':
! { /* \x<hex> */
! int sptr = 2;
!
! while ( isascii( array[sptr] ) && is_hex_digit( array[sptr] ) )
/* don't increment inside loop control because if
! * isdigit() is a macro it might expand into multiple
* increments ...
*/
++sptr;
***************
*** 625,634 ****
c = array[sptr];
array[sptr] = '\0';
! if ( array[1] == 'x' )
! esc_char = htoi( array + 2 );
! else
! esc_char = otoi( array + 1 );
array[sptr] = c;
--- 673,679 ----
c = array[sptr];
array[sptr] = '\0';
! esc_char = htoi( array + 2 );
array[sptr] = c;
More information about the Comp.sources.bugs
mailing list