Ignore:
Timestamp:
Jul 3, 2024, 5:32:06 PM (4 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
39cf5cc
Parents:
597f284
Message:

Change (enum) range loop so that it works on any type that define succ() and upperBound()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.cfa

    r597f284 r6d2b3dc  
    11#include "enum.hfa"
    22#include "fstream.hfa"
     3#include <string.h>
    34
    45#pragma GCC visibility push(default)
     
    1011        int args = fmt( is, "%255s", val );
    1112        if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
    12         // for ( s; E ) {
    13         //      if ( val == label( s ) ) { e = s; break; }
    14         // } else {
    15         //      fprintf( stderr, "invalid enumeration constant\n" );
    16         //      abort();                                                                        // cannot use abort stream
    17         // } // for
     13        for ( s; E ) {
     14                if ( strcmp(val, label( s )) == 0 ) { e = s; break; }
     15        } else {
     16                fprintf( stderr, "invalid enumeration constant\n" );
     17                abort();                                                                        // cannot use abort stream
     18        } // for
    1819        return is;
    1920}
Note: See TracChangeset for help on using the changeset viewer.