Changeset bf1cbde for libcfa


Ignore:
Timestamp:
Oct 5, 2023, 1:50:35 PM (7 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
8cffa4f
Parents:
04db9f6
Message:

Implement "scanset" semantics for manipulator skip, in place of exact-match.

That is, sin | skip("abc") now consumes all input before the "+" on input "cccccb+".

Exact-match semantics is available with just sin | "abc".

(Prior exact-match semantics was discovered by surprise, while debugging a test program for an upcoming commit.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.cfa

    r04db9f6 rbf1cbde  
    960960        istype & ?|?( istype & is, _Istream_Cskip f ) {
    961961                // printf( "skip %s %d\n", f.scanset, f.wd );
    962                 if ( f.scanset ) fmt( is, f.scanset, "" );              // no input arguments
     962                if ( f.scanset ) {
     963                        int nscanset = strlen(f.scanset);
     964                        char fmtstr[ sizeof("%*[]") + nscanset ];
     965                        int pos = 0;
     966                        fmtstr[pos] = '%';                  pos += 1;
     967                        fmtstr[pos] = '*';                  pos += 1;
     968                        fmtstr[pos] = '[';                  pos += 1;
     969                        strcpy( &fmtstr[pos], f.scanset );  pos += nscanset;
     970                        fmtstr[pos] = ']';                  pos += 1;
     971                        fmtstr[pos] = '\0';
     972                        fmt( is, fmtstr, (void*)0 );  // last arg is dummy: suppress gcc warning
     973                }
    963974                else for ( f.wd ) fmt( is, "%*c" );
    964975                return is;
Note: See TracChangeset for help on using the changeset viewer.