Changeset 2f34fde for libcfa/src/iostream.cfa
- Timestamp:
- Aug 14, 2023, 7:10:38 PM (12 months ago)
- Branches:
- master
- Children:
- 7baff35
- Parents:
- 3543e99
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
r3543e99 r2f34fde 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 10 18:15:44202313 // Update Count : 14 4212 // Last Modified On : Mon Aug 14 18:37:02 2023 13 // Update Count : 1460 14 14 // 15 15 … … 972 972 // getline 973 973 if ( f.flags.delimit ) { 974 char fmtstr[] = "%[^ ]s"; // delimit inserted into space 975 fmtstr[3] = f.delimit; 976 fmt( is, fmtstr, f.s ); // read upto delimiter 977 fmt( is, "%*c" ); // ignore delimiter 974 enum { size = 16 }; 975 char fmtstr[size]; 976 snprintf( fmtstr, size, "%%%d[^%c]s", f.wd, f.delimit ); 977 f.s[f.wd - 1] = '\0'; // insert sentinel 978 int len = fmt( is, fmtstr, f.s ); // read upto delimiter 979 if ( len == 0 ) f.s[0] = '\0'; // empty read => argument unchanged => set empty 980 if ( f.s[f.wd - 1] != '\0' ) // sentinel overwritten ? 981 throw (cstring_length){ &cstring_length_vt }; 982 if ( ! eof( is ) ) fmt( is, "%*c" ); // ignore delimiter 978 983 return is; 979 984 } // if 980 985 981 // incl/excl982 986 size_t len = 0; 983 987 if ( f.scanset ) len = strlen( f.scanset ); … … 987 991 if ( f.flags.ignore ) { fmtstr[1] = '*'; start += 1; } 988 992 if ( f.wd != -1 ) { start += sprintf( &fmtstr[start], "%d", f.wd ); } 989 // cstr %s, %*s, %ws, %*ws 993 990 994 if ( ! f.scanset ) { 995 // %s, %*s, %ws, %*ws 991 996 fmtstr[start] = 's'; fmtstr[start + 1] = '\0'; 992 997 // printf( "cstr %s\n", fmtstr ); 993 fmt( is, fmtstr, f.s ); 994 return is; 995 } // if 996 // incl %[xxx], %*[xxx], %w[xxx], %*w[xxx] 997 // excl %[^xxx], %*[^xxx], %w[^xxx], %*w[^xxx] 998 fmtstr[start] = '['; start += 1; 999 if ( f.flags.inex ) { fmtstr[start] = '^'; start += 1; } 1000 strcpy( &fmtstr[start], f.scanset ); // copy includes '\0' 1001 len += start; 1002 fmtstr[len] = ']'; fmtstr[len + 1] = '\0'; 1003 // printf( "incl/excl %s\n", fmtstr ); 998 } else { 999 // incl %[xxx], %*[xxx], %w[xxx], %*w[xxx] 1000 // excl %[^xxx], %*[^xxx], %w[^xxx], %*w[^xxx] 1001 fmtstr[start] = '['; start += 1; 1002 if ( f.flags.inex ) { fmtstr[start] = '^'; start += 1; } 1003 strcpy( &fmtstr[start], f.scanset ); // copy includes '\0' 1004 len += start; 1005 fmtstr[len] = ']'; fmtstr[len + 1] = '\0'; 1006 // printf( "incl/excl %s\n", fmtstr ); 1007 } // if 1008 1009 int check = f.wd - 1; 1010 if ( f.flags.rwd ) check += 1; // provide place for sentinel 1011 f.s[check] = '\0'; // insert sentinel 1004 1012 fmt( is, fmtstr, f.s ); 1013 if ( f.s[check] != '\0' ) // sentinel overwritten ? 1014 throw (cstring_length){ &cstring_length_vt }; 1005 1015 return is; 1006 1016 } // ?|? … … 1081 1091 } // distribution 1082 1092 1093 1083 1094 // Local Variables: // 1084 1095 // tab-width: 4 //
Note: See TracChangeset
for help on using the changeset viewer.