Changeset 97f9619 for libcfa/src/enum.cfa
- Timestamp:
- Jul 16, 2024, 10:35:29 PM (4 months ago)
- Branches:
- master
- Children:
- 0097d08
- Parents:
- 68ea8d2 (diff), 88bc876 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/enum.cfa
r68ea8d2 r97f9619 42 42 if ( eof( is ) ) throwResume ExceptionInst( missing_data ); 43 43 44 // Match input enumerator string to enumerator labels. 44 // Match longest input enumerator string to enumerator labels, where enumerator names are unique. 45 45 46 int N = Countof( e ), lnths[N], max = 0; 46 47 // printf( "N %d\n", N ); … … 60 61 for ( c; max ) { 61 62 int args = fmt( is, "%c", &ch ); // read character 62 63 if ( eof( is ) ) { 63 64 // fprintf( stderr, "Eof1\n" ); 64 65 if ( c == 0 ) return is; // no characters read ? 65 clear( is ); // => re set EOF => detect again on next read66 clear( is ); // => read something => reset EOF => detect again on next read 66 67 // fprintf( stderr, "Eof2\n" ); 67 goto W;68 } 68 break; 69 } // if 69 70 if ( args != 1 ) throwResume ExceptionInst( missing_data ); 71 70 72 // printf( "read '%c'\n", ch ); 71 for ( i; N ) { 73 for ( i; N ) { // scan enumeration strings for winner 72 74 // printf( "%d %d %d\n", c, i, lnths[i] ); 73 75 if ( c < lnths[i] ) { // eligible for this checking round ? 74 76 char match = label( fromInt( i ) )[c]; // optimization 75 77 // printf( "%c '%c'\n", match, ch ); 78 // Stop on first match, could be other matches. 76 79 if ( (match == ch) && (c == 0 || curr == label( fromInt( i ) )[c - 1]) ) { 77 80 // printf( "match %d %d %d '%c' '%c' '%c' '%c' 'c'\n", c, i, lnths[i], match, ch, prev, label( fromInt( i ) )[c - 1] ); … … 92 95 // fprintf( stderr, "finished2 %d\n", win ); 93 96 } // for 94 W :;95 for ( i; N ) { // scan for winner, must succeed97 W: ; 98 for ( i; N ) { // scan enumeration strings for winner 96 99 if ( win == lnths[i] - 1 ) { 97 100 char match = label( fromInt( i ) )[win]; // optimization … … 100 103 e = fromInt( i ); 101 104 break; 102 } 105 } // if 103 106 } // if 104 107 } else {
Note: See TracChangeset
for help on using the changeset viewer.