Index: libcfa/src/iostream.cfa
===================================================================
--- libcfa/src/iostream.cfa	(revision ae0c1c3bd041ed739c4bdaa8dd6b3cd33d35f692)
+++ libcfa/src/iostream.cfa	(revision 1e28e05ba900989f10f4e16a3ef14f7d3e4de9d1)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Apr 14 20:43:14 2025
-// Update Count     : 2081
+// Last Modified On : Sun May 18 08:23:40 2025
+// Update Count     : 2175
 //
 
@@ -944,5 +944,5 @@
 	} // ?|?
 
-	istype & ?|?( istype & is, const char fmt[] ) with ( basic_istream_table ) {		// match text
+	istype & ?|?( istype & is, const char fmt[] ) with ( basic_istream_table ) { // match text
 		size_t len = strlen( fmt );
 		char fmtstr[len + 16];
@@ -1202,66 +1202,72 @@
 } // distribution
 
+// *********************************** enumerations ***********************************
 
 forall( istype & | istream( istype ), E | CfaEnum( E ) | Serial( E ) )
 istype & ?|?( istype & is, E & e ) with ( basic_istream_table ) {
-//	if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
-
 	// Match longest input enumerator string to enumerator labels, where enumerator names are unique.
-
-	int N = countof( E ), lnths[N], fred = 0;
-	int r = 0;
-	for ( s; E ) {										// scan string rows gathering lengths
-		lnths[r] = strlen( label( s ) );
-		if ( lnths[r] > fred ) fred = lnths[r];
-		r += 1;
+	size_t N = countof( E ), lnths[N], maxlen = 0;		// N must be > 0, maxlen must be > 0
+
+	size_t ec = 0;
+	for ( s; E ) {										// gather label lengths
+		lnths[ec] = strlen( label( s ) );
+		if ( lnths[ec] > maxlen ) maxlen = lnths[ec];	// gather longest length
+		// printf( "%s %zd\n", label( s ), lnths[e] );
+		ec += 1;
 	} // for
-
-	int mcol = -1;										// last match column
-	char ch, curr = '\0', prev = '\0';
+	// printf( "maxlen %d\n", maxlen );
 
 	fmt( is, " " );										// remove leading whitespace
-	if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
-
-	for ( c; fred ) {									// scan columns of the label matix (some columns missing)
-		int args = fmt( is, "%c", &ch );				// read character
-	  if ( eof( is ) ) {
-			if ( c == 0 ) return is;					// no characters read ?
+  if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
+	// printf( "after whitespace\n" );
+
+	char ch;
+	ssize_t exact = -1;									// -1 => no exact match seen so far
+
+	for ( c; maxlen ) {									// scan columns of the label matrix (some columns missing)
+		fmt( is, "%c", &ch );							// read character => get a character or EOF
+		// printf( "after fmt %d %d '%c'\n", c, args, ch );
+		if ( eof( is ) || isspace( ch ) != 0 ) {		// enumerator delimiter ? => end of enumerator
+			// printf( "match eof %zd %s\n", exact, label( fromInt( exact ) ) );
+			if ( exact != -1 ) {						// exact match available ?
+				e = fromInt( exact );
+				return is;
+			} // if
+			// printf( "no match\n" );
+			// consume input character(s) as garbage
 			clearerr( is );								// => read something => reset EOF => detect again on next read
-			break;
-		} // if
-	  if ( args != 1 ) throwResume ExceptionInst( missing_data ); // may be unnecessary since reading single character
-
-		for ( r; N ) {									// scan enumeration strings for matching character in current column
-			if ( c < lnths[r] ) {						// string long enough for this column check ?
-				char match = label( fromInt( r ) )[c];	// optimization
-				// Stop on first match, could be other matches.
-				if ( (match == ch) && (c == 0 || curr == label( fromInt( r ) )[c - 1]) ) {
-					mcol = c;							// matching column
-					prev = curr;						// last matching character
-					curr = ch;							// current matching character
-					break;
-				} // if
+			throwResume ExceptionInst( missing_data );	// no matching enumerator
+		} // if
+
+		bool match = false;
+		for ( r; N ) {									// scan all enumeration labels for matching character
+			// if ( lnths[r] > c ) printf( "%d %d %d %c %s %c\n", c, r, lnths[r], ch, label( fromInt( r ) ), label( fromInt( r ) )[c] );
+			if ( lnths[r] > c && label( fromInt( r ) )[c] == ch ) { // label long enough and matching character ?
+				// printf( "match char\n" );
+				match = true;
+				if ( lnths[r] - 1 == c ) exact = r;		// exact match ?
+				else if ( exact != -1 && lnths[exact] <= c ) exact = -1; // previous exact match too short ?
+			} else {
+				lnths[r] = 0;							// mark enumerator ineligible
 			} // if
-		} else {
-			ungetc( ch, is );							// push back last unmatching character
-			if ( mcol == -1 ) throwResume ExceptionInst( missing_data ); // no matching character in first column
-			break;
 		} // for
+		// printf( "match %d\n", match );
+		if ( ! match ) {								// no matching character in column
+			if ( exact != -1 ) {						// exact match available ?
+				// printf( "match %zd unget %c\n", exact, ch );
+				ungetc( ch, is );						// push back last unmatching character
+				e = fromInt( exact );
+				return is;
+			} //  if
+			// consume input character(s) as garbage
+			throwResume ExceptionInst( missing_data );	// no match found
+		} // if
+		//printf( "loop match %d\n", match );
  	} // for
-
-	for ( c; N ) {										// scan enumeration strings of length "mcol" for match
-		if ( mcol == lnths[c] - 1 ) {
-			char match = label( fromInt( c ) )[mcol];	// optimization
-			if ( (match == curr) && (mcol == 0 || prev == label( fromInt( c ) )[mcol - 1]) ) {
-				e = fromInt( c );
-				break;
-			} // if
-		} // if
-	} else {
-		throwResume ExceptionInst( missing_data );		// no match in this column
-	} // for
+	// printf( "loop end\n" );
+	e = fromInt( exact );
 	return is;
 }
-
+ 
 forall( ostype & | ostream( ostype ), E | CfaEnum( E ) ) {
 	ostype & ?|?( ostype & os, E e ) {
Index: libcfa/src/iostream.hfa
===================================================================
--- libcfa/src/iostream.hfa	(revision ae0c1c3bd041ed739c4bdaa8dd6b3cd33d35f692)
+++ libcfa/src/iostream.hfa	(revision 1e28e05ba900989f10f4e16a3ef14f7d3e4de9d1)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Apr 14 20:42:53 2025
-// Update Count     : 767
+// Last Modified On : Mon May 12 17:29:29 2025
+// Update Count     : 769
 //
 
@@ -317,5 +317,7 @@
 } // ?|?
 
+
 // *********************************** istream ***********************************
+
 
 forall( istype & )
@@ -528,4 +530,14 @@
 INPUT_FMT_DECL( long double _Complex )
 
+// *********************************** enumerations ***********************************
+
+forall( istype & | istream( istype ), E | CfaEnum( E ) | Serial(E) )
+istype & ?|?( istype &, E & );
+
+forall( ostype & | ostream( ostype ), E | CfaEnum( E ) ) {
+	ostype & ?|?( ostype &, E );
+	OSTYPE_VOID( E );
+}
+
 // *********************************** time ***********************************
 
@@ -539,12 +551,4 @@
 } // distribution
 
-forall( istype & | istream( istype ), E | CfaEnum( E ) | Serial(E) )
-istype & ?|?( istype &, E & );
-
-forall( ostype & | ostream( ostype ), E | CfaEnum( E ) ) {
-	ostype & ?|?( ostype &, E );
-	OSTYPE_VOID( E );
-}
-
 // Local Variables: //
 // tab-width: 4 //
