diff options
author | vern <vern> | 1988-05-08 19:51:06 +0000 |
---|---|---|
committer | vern <vern> | 1988-05-08 19:51:06 +0000 |
commit | 935ccbc9af5806637b63f44681580d1782a1ca99 (patch) | |
tree | 7c3e8403e29f89a22337228186256332ed7e1620 /ccl.c | |
parent | b12dad68b1ad88e7ea9acc59b4d50f436eb4e37a (diff) | |
download | flex-935ccbc9af5806637b63f44681580d1782a1ca99.tar.gz |
Added list_character_set()
Diffstat (limited to 'ccl.c')
-rw-r--r-- | ccl.c | 54 |
1 files changed, 50 insertions, 4 deletions
@@ -1,9 +1,5 @@ /* ccl - routines for character classes */ -#ifndef lint -static char rcsid[] = "@(#) $Header: /cvsroot/flex/flex/ccl.c,v 1.4 1988/05/07 00:06:10 vern Exp $ (LBL)"; -#endif - /* * Copyright (c) 1987, the University of California * @@ -18,6 +14,11 @@ static char rcsid[] = "@(#) $Header: /cvsroot/flex/flex/ccl.c,v 1.4 1988/05/07 0 #include "flexdef.h" +#ifndef lint +static char rcsid[] = + "@(#) $Header: /cvsroot/flex/flex/ccl.c,v 1.5 1988/05/08 19:51:06 vern Exp $ (LBL)"; +#endif + /* ccladd - add a single character to a ccl * * synopsis @@ -111,3 +112,48 @@ int cclp; { cclng[cclp] = 1; } + + +/* list_character_set - list the members of a set of characters in CCL form + * + * synopsis + * int cset[CSIZE + 1]; + * list_character_set( cset ); + * + * writes to stderr a character-class representation of those characters + * present in the given set. A character is present if it has a non-zero + * value in the set array. + */ + +list_character_set( cset ) +int cset[]; + + { + register int i; + char *readable_form(); + + putc( '[', stderr ); + + for ( i = 1; i <= CSIZE; ++i ) + { + if ( cset[i] ) + { + register int start_char = i; + + putc( ' ', stderr ); + + fputs( readable_form( i ), stderr ); + + while ( ++i <= CSIZE && cset[i] ) + ; + + if ( i - 1 > start_char ) + /* this was a run */ + fprintf( stderr, "-%s", readable_form( i - 1 ) ); + + putc( ' ', stderr ); + } + } + + putc( ']', stderr ); + } |