Changeset bf1cbde


Ignore:
Timestamp:
Oct 5, 2023, 1:50:35 PM (14 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.)

Files:
4 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;
  • tests/collections/.in/string-istream-manip.txt

    r04db9f6 rbf1cbde  
    11abc
    2 abc
     2cccccb
    33xx
    44abcxxx
     
    66aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww
    77abc
    8 abc
     8cccccb
    99xx
    1010abcxxx
  • tests/io/.in/manipulatorsInput.txt

    r04db9f6 rbf1cbde  
    22123456789
    33abc
    4 abc
     4cccccb
    55xx
    66abcxxx
     
    88aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww
    99abc
    10 abc
     10cccccb
    1111xx
    1212abcxxx
  • tests/io/manipulatorsInput.cfa

    r04db9f6 rbf1cbde  
    5252        {
    5353                char s[] = "yyyyyyyyyyyyyyyyyyyy";
    54                 const char sk[] = "abc";
    55                 scanf( "abc " ); scanf( sk ); for ( 5 ) scanf( "%*c" ); printf( "1 %s\n", s );
     54                const char sk_fmt[] = "%*[abc]";
     55                scanf( "abc " ); scanf( sk_fmt ); for ( 5 ) scanf( "%*c" ); printf( "1 %s\n", s );
    5656                scanf( "%s", s );                                                               printf( "2 %s\n", s );
    5757                scanf( "%*s" );                                                                 printf( "3 %s\n", s );
Note: See TracChangeset for help on using the changeset viewer.