Changeset 38de914 for libcfa/src/iostream.cfa
- Timestamp:
- Aug 30, 2023, 11:20:14 AM (11 months ago)
- Branches:
- master
- Children:
- 55b060d
- Parents:
- 7e1dbd7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
r7e1dbd7 r38de914 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 28 13:36:16202313 // Update Count : 15 2712 // Last Modified On : Wed Aug 30 10:56:08 2023 13 // Update Count : 1541 14 14 // 15 15 … … 962 962 963 963 forall( istype & | basic_istream( istype ) ) { 964 void readstr( istype & is, _Istream_str_base f, char fmtstr[], char cstr[] ) { 965 int check = f.wd - 1; 966 967 if ( ! f.flags.rwd ) cstr[check] = '\0'; // insert sentinel 968 int len = fmt( is, fmtstr, cstr ); 969 // fprintf( stderr, "KK %s %zd %d %c %s\n", fmtstr, len, check, cstr[check], cstr ); 970 971 if ( ! f.flags.rwd && cstr[check] != '\0' ) // sentinel overwritten ? 972 throw (cstring_length){ &cstring_length_vt }; 973 974 if ( f.flags.delimit ) { // getline ? 975 if ( len == 0 ) cstr[0] = '\0'; // empty read => argument unchanged => set empty 976 if ( ! eof( is ) ) fmt( is, "%*c" ); // ignore delimiter 977 } //if 978 } // readstr 979 964 980 istype & ?|?( istype & is, _Istream_Cstr f ) { 965 981 // skip … … 971 987 } // if 972 988 973 int check = f.wd - 1; 974 const char * scanset = f.scanset;; 989 const char * scanset = f.scanset; 975 990 if ( f.flags.delimit ) scanset = f.delimit; // getline ? 976 977 // getline978 // if ( f.flags.delimit ) {979 // enum { size = 32 };980 // char fmtstr[size];981 // snprintf( fmtstr, size, "%%%d[^%c]s", f.wd, f.delimit );982 // if ( ! f.flags.rwd ) f.s[check] = '\0'; // insert sentinel983 // int len = fmt( is, fmtstr, f.s ); // read upto delimiter984 // if ( ! f.flags.rwd && f.s[check] != '\0' ) // sentinel overwritten ?985 // throw (cstring_length){ &cstring_length_vt };986 // if ( len == 0 ) f.s[0] = '\0'; // empty read => argument unchanged => set empty987 // // fprintf( stderr, "getline %s %s %d %d %d '%c'\n", fmtstr, f.s, len, f.wd, check, f.s[check] );988 // if ( ! eof( is ) ) fmt( is, "%*c" ); // ignore delimiter989 // return is;990 // } // if991 991 992 992 size_t len = 0; … … 1013 1013 } // if 1014 1014 1015 if ( ! f.flags.rwd ) f.s[check] = '\0'; // insert sentinel 1016 len = fmt( is, fmtstr, f.s ); 1017 //fprintf( stderr, "KK %s %zd %d %c %s\n", fmtstr, len, check, f.s[check], f.s ); 1018 if ( ! f.flags.rwd && f.s[check] != '\0' ) // sentinel overwritten ? 1019 throw (cstring_length){ &cstring_length_vt }; 1020 1021 if ( f.flags.delimit ) { // getline ? 1022 if ( len == 0 ) f.s[0] = '\0'; // empty read => argument unchanged => set empty 1023 if ( ! eof( is ) ) fmt( is, "%*c" ); // ignore delimiter 1024 } //if 1015 readstr( is, f, fmtstr, f.s ); 1016 // int check = f.wd - 1; 1017 1018 // if ( ! f.flags.rwd ) f.s[check] = '\0'; // insert sentinel 1019 // len = fmt( is, fmtstr, f.s ); 1020 // //fprintf( stderr, "KK %s %zd %d %c %s\n", fmtstr, len, check, f.s[check], f.s ); 1021 // if ( ! f.flags.rwd && f.s[check] != '\0' ) // sentinel overwritten ? 1022 // throw (cstring_length){ &cstring_length_vt }; 1023 1024 // if ( f.flags.delimit ) { // getline ? 1025 // if ( len == 0 ) f.s[0] = '\0'; // empty read => argument unchanged => set empty 1026 // if ( ! eof( is ) ) fmt( is, "%*c" ); // ignore delimiter 1027 // } //if 1025 1028 return is; 1026 1029 } // ?|?
Note: See TracChangeset
for help on using the changeset viewer.