Changeset 0860d9c for libcfa/src/iostream.cfa
- Timestamp:
- Oct 5, 2023, 4:17:14 PM (12 months ago)
- Branches:
- master
- Children:
- 4d860ea3
- Parents:
- b67b632
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
rb67b632 r0860d9c 22 22 #include <float.h> // DBL_DIG, LDBL_DIG 23 23 #include <complex.h> // creal, cimag 24 #include <ctype.h> // isspace 24 25 //#include <stdio.h> 25 26 … … 29 30 extern char *strcpy (char *__restrict __dest, const char *__restrict __src) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); 30 31 extern void *memcpy (void *__restrict __dest, const void *__restrict __src, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); 32 extern char *strchr(const char *str, int ch); 31 33 } // extern "C" 32 34 … … 991 993 // wd is buffer bytes available (for input chars + null terminator) 992 994 // rwd is count of input chars 993 int rwd = f.flags.rwd ? f.wd : (f.wd - 1); 995 int rwd; 996 if (f.flags.rwd) { 997 verify (f.wd >= 0); 998 rwd = f.wd; 999 } else { 1000 verify (f.wd >= 1); 1001 rwd = f.wd - 1; 1002 } // if 994 1003 start += sprintf( &fmtstr[start], "%d", rwd ); 995 1004 } … … 1018 1027 //fprintf( stderr, "KK %s %zd %d %c %s\n", fmtstr, len, check, f.s[check], f.s ); 1019 1028 1020 if (! f.flags.ignore && ! f.flags.rwd && f.s[check] != '\0' ) // sentinel overwritten ? 1021 throw (cstring_length){ &cstring_length_vt }; 1029 if ( ! f.flags.ignore && ! f.flags.rwd && f.s[check] != '\0' ) { // sentinel overwritten ? 1030 // buffer filled, but would we have kept going? 1031 if ( ! eof( is ) ) { 1032 char peek; 1033 fmt( is, "%c", &peek ); 1034 ungetc( is, peek ); 1035 bool hasMore; 1036 if (f.flags.delimiter) { // getline 1037 hasMore = (peek != f.delimiter[0]); 1038 } else if (f.scanset) { // incl/excl 1039 bool peekMatch = strchr(f.scanset, peek) != 0p; 1040 hasMore = f.flags.inex ? (!peekMatch) : (peekMatch); 1041 } else { // %s 1042 hasMore = !isspace(peek); 1043 } 1044 if (hasMore) throw (cstring_length){ &cstring_length_vt }; 1045 } // if 1046 } // if 1022 1047 1023 1048 if ( f.flags.delimiter ) { // getline ?
Note: See TracChangeset
for help on using the changeset viewer.