Changeset 97f9619 for libcfa


Ignore:
Timestamp:
Jul 16, 2024, 10:35:29 PM (2 days ago)
Author:
JiadaL <j82liang@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.cfa

    r68ea8d2 r97f9619  
    4242        if ( eof( is ) ) throwResume ExceptionInst( missing_data );
    4343
    44         // Match input enumerator string to enumerator labels.
     44        // Match longest input enumerator string to enumerator labels, where enumerator names are unique.
     45
    4546        int N = Countof( e ), lnths[N], max = 0;
    4647//      printf( "N %d\n", N );
     
    6061        for ( c; max ) {
    6162                int args = fmt( is, "%c", &ch );                                // read character
    62                 if ( eof( is ) ) {
     63          if ( eof( is ) ) {
    6364//                      fprintf( stderr, "Eof1\n" );
    6465                        if ( c == 0 ) return is;                                        // no characters read ?
    65                         clear( is );                                                            // => reset EOF => detect again on next read
     66                        clear( is );                                                            // => read something => reset EOF => detect again on next read
    6667//                      fprintf( stderr, "Eof2\n" );
    67                         goto W;
    68                 }
     68                        break;
     69                } // if
    6970                if ( args != 1 ) throwResume ExceptionInst( missing_data );
     71
    7072//              printf( "read '%c'\n", ch );
    71                 for ( i; N ) {
     73                for ( i; N ) {                                                                  // scan enumeration strings for winner
    7274//                      printf( "%d %d %d\n", c, i, lnths[i] );
    7375                        if ( c < lnths[i] ) {                                           // eligible for this checking round ?
    7476                                char match = label( fromInt( i ) )[c];  // optimization
    7577//                              printf( "%c '%c'\n", match, ch );
     78                                // Stop on first match, could be other matches.
    7679                                if ( (match == ch) && (c == 0 || curr == label( fromInt( i ) )[c - 1]) ) {
    7780//                                      printf( "match %d %d %d '%c' '%c' '%c' '%c' 'c'\n", c, i, lnths[i], match, ch, prev, label( fromInt( i ) )[c - 1] );
     
    9295//              fprintf( stderr, "finished2 %d\n", win );
    9396        } // for
    94   W :;
    95         for ( i; N ) {                                                                          // scan for winner, must succeed
     97  W: ;
     98        for ( i; N ) {                                                                          // scan enumeration strings for winner
    9699                if ( win == lnths[i] - 1 ) {
    97100                        char match = label( fromInt( i ) )[win];        // optimization
     
    100103                                e = fromInt( i );
    101104                                break;
    102                         }
     105                        } // if
    103106                } // if
    104107        } else {
  • libcfa/src/iostream.cfa

    r68ea8d2 r97f9619  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 12 05:45:45 2024
    13 // Update Count     : 2019
     12// Last Modified On : Mon Jul 15 08:16:48 2024
     13// Update Count     : 2020
    1414//
    1515
     
    781781                // Optional leading whitespace at start of strings.
    782782                fmt( is, " " FALSE "%n", &len );                                // try false
    783                 if ( len != sizeof( FALSE ) - 1 ) {                             // remove null terminate
     783                if ( len != sizeof( FALSE ) - 1 ) {                             // -1 removes null terminate
    784784                        fmt( is, " " TRUE "%n", &len );                         // try true
    785785                        if ( len != sizeof( TRUE ) - 1 ) throwResume ExceptionInst( missing_data );
Note: See TracChangeset for help on using the changeset viewer.