Changeset 38de914 for libcfa/src/containers/string.cfa
- Timestamp:
- Aug 30, 2023, 11:20:14 AM (10 months ago)
- Branches:
- master
- Children:
- 55b060d
- Parents:
- 7e1dbd7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/string.cfa
r7e1dbd7 r38de914 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 28 19:00:45202313 // Update Count : 1 4612 // Last Modified On : Tue Aug 29 18:32:34 2023 13 // Update Count : 153 14 14 // 15 15 … … 118 118 } 119 119 120 static void readstr( ifstream & is, _Istream_str f, char fmtstr[], char cstr[] ) {121 int check = f.rwd - 1;122 123 if ( ! f.flags.rwd ) cstr[check] = '\0'; // insert sentinel124 int len = fmt( is, fmtstr, cstr );125 // fprintf( stderr, "KK %s %zd %d %c %s\n", fmtstr, len, check, cstr[check], cstr );126 127 if ( ! f.flags.rwd && cstr[check] != '\0' ) // sentinel overwritten ?128 throw (cstring_length){ &cstring_length_vt };129 130 if ( f.flags.delimit ) { // getline ?131 if ( len == 0 ) cstr[0] = '\0'; // empty read => argument unchanged => set empty132 if ( ! eof( is ) ) fmt( is, "%*c" ); // ignore delimiter133 } //if134 } // readstr135 136 120 ifstream & ?|?( ifstream & is, _Istream_str f ) { 137 121 // skip, same as for char * 138 122 if ( ! &f.s ) { 139 123 // fprintf( stderr, "skip %s %d\n", f.scanset, f.wd ); 140 if ( f. rwd == -1 ) fmt( is, f.scanset, "" ); // no input arguments141 else for ( f. rwd ) fmt( is, "%*c" );124 if ( f.wd == -1 ) fmt( is, f.scanset, "" ); // no input arguments 125 else for ( f.wd ) fmt( is, "%*c" ); 142 126 return is; 143 127 } // if 144 128 145 enum { gwd = 1 6+ 2, wd = gwd - 1 }; // guarded and unguarded width129 enum { gwd = 128 + 2, wd = gwd - 1 }; // guarded and unguarded width 146 130 char cstr[gwd]; // read in chunks 147 131 bool cont = false;; 148 132 149 if ( f. rwd == -1 ) f.rwd = wd;133 if ( f.wd == -1 ) f.wd = wd; 150 134 const char * scanset = f.scanset;; 151 135 if ( f.flags.delimit ) scanset = f.delimit; // getline ? … … 157 141 fmtstr[0] = '%'; 158 142 if ( f.flags.ignore ) { fmtstr[1] = '*'; start += 1; } 159 if ( f. rwd != -1 ) { start += sprintf( &fmtstr[start], "%d", f.rwd ); }143 if ( f.wd != -1 ) { start += sprintf( &fmtstr[start], "%d", f.wd ); } 160 144 161 145 if ( ! scanset ) {
Note: See TracChangeset
for help on using the changeset viewer.