From 38d7959960592775fd3c97f2db987f957a690a52 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Sun, 8 May 1988 19:51:06 +0000 Subject: Added list_character_set() --- ccl.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'ccl.c') diff --git a/ccl.c b/ccl.c index 41e6d47..48addb3 100644 --- a/ccl.c +++ b/ccl.c @@ -1,9 +1,5 @@ /* ccl - routines for character classes */ -#ifndef lint -static char rcsid[] = "@(#) $Header$ (LBL)"; -#endif - /* * Copyright (c) 1987, the University of California * @@ -18,6 +14,11 @@ static char rcsid[] = "@(#) $Header$ (LBL)"; #include "flexdef.h" +#ifndef lint +static char rcsid[] = + "@(#) $Header$ (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 ); + } -- cgit v1.2.3