Changes in / [9eb7a532:266ecf1]
- Files:
-
- 6 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/fstream.cfa
r9eb7a532 r266ecf1 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 19 16:24:54 202013 // Update Count : 38412 // Last Modified On : Mon Mar 1 21:12:15 2021 13 // Update Count : 424 14 14 // 15 15 … … 25 25 #include <errno.h> // errno 26 26 27 28 27 // *********************************** ofstream *********************************** 29 28 … … 38 37 os.$prt = false; 39 38 os.$sawNL = false; 39 os.$acquired = false; 40 40 $sepSetCur( os, sepGet( os ) ); 41 41 sepSet( os, " " ); … … 109 109 if ( &os == &exit ) exit( EXIT_FAILURE ); 110 110 if ( &os == &abort ) abort(); 111 if ( os.$acquired ) { os.$acquired = false; release( os ); } 111 112 } // ends 112 113 … … 171 172 } // fmt 172 173 174 inline void acquire( ofstream & os ) { 175 lock( os.$lock ); 176 if ( ! os.$acquired ) os.$acquired = true; 177 else unlock( os.$lock ); 178 } // acquire 179 180 inline void release( ofstream & os ) { 181 unlock( os.$lock ); 182 } // release 183 184 void ?{}( osacquire & acq, ofstream & os ) { &acq.os = &os; lock( os.$lock ); } 185 void ^?{}( osacquire & acq ) { release( acq.os ); } 186 173 187 static ofstream soutFile = { (FILE *)stdout }; 174 188 ofstream & sout = soutFile, & stdout = soutFile; … … 176 190 ofstream & serr = serrFile, & stderr = serrFile; 177 191 192 static ofstream lsoutFile = { (FILE *)stdout }; 193 ofstream & lsout = lsoutFile; 194 178 195 static ofstream exitFile = { (FILE *)stdout }; 179 196 ofstream & exit = exitFile; … … 189 206 is.$file = file; 190 207 is.$nlOnOff = false; 208 is.$acquired = false; 191 209 } // ?{} 192 210 … … 213 231 return is.$file == 0p || ferror( (FILE *)(is.$file) ); 214 232 } // fail 233 234 void ends( ifstream & is ) { 235 if ( is.$acquired ) { is.$acquired = false; release( is ); } 236 } // ends 215 237 216 238 int eof( ifstream & is ) { … … 279 301 } // fmt 280 302 303 inline void acquire( ifstream & is ) { 304 lock( is.$lock ); 305 if ( ! is.$acquired ) is.$acquired = true; 306 else unlock( is.$lock ); 307 } // acquire 308 309 inline void release( ifstream & is ) { 310 unlock( is.$lock ); 311 } // release 312 313 void ?{}( isacquire & acq, ifstream & is ) { &acq.is = &is; lock( is.$lock ); } 314 void ^?{}( isacquire & acq ) { release( acq.is ); } 315 281 316 static ifstream sinFile = { (FILE *)stdin }; 282 317 ifstream & sin = sinFile, & stdin = sinFile; -
libcfa/src/fstream.hfa
r9eb7a532 r266ecf1 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 19 16:29:17 202013 // Update Count : 18912 // Last Modified On : Mon Mar 1 22:45:08 2021 13 // Update Count : 217 14 14 // 15 15 16 16 #pragma once 17 17 18 #include "bits/weakso_locks.hfa" 18 #include "bits/weakso_locks.hfa" // mutex_lock 19 19 #include "iostream.hfa" 20 20 #include <exception.hfa> … … 35 35 char $separator[sepSize]; 36 36 char $tupleSeparator[sepSize]; 37 // multiple_acquisition_lock lock; 37 multiple_acquisition_lock $lock; 38 bool $acquired; 38 39 }; // ofstream 39 40 … … 71 72 ofstream & write( ofstream &, const char data[], size_t size ); 72 73 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 74 void acquire( ofstream & os ); 75 void release( ofstream & os ); 76 77 struct osacquire { 78 ofstream & os; 79 }; 80 void ?{}( osacquire & acq, ofstream & os ); 81 void ^?{}( osacquire & acq ); 73 82 74 83 void ?{}( ofstream & os ); … … 87 96 void * $file; 88 97 bool $nlOnOff; 98 multiple_acquisition_lock $lock; 99 bool $acquired; 89 100 }; // ifstream 90 101 … … 93 104 void nlOff( ifstream & ); 94 105 bool getANL( ifstream & ); 106 void ends( ifstream & ); 95 107 int fail( ifstream & is ); 96 108 int eof( ifstream & is ); … … 101 113 ifstream & ungetc( ifstream & is, char c ); 102 114 int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) )); 115 void acquire( ifstream & is ); 116 void release( ifstream & is ); 117 118 struct isacquire { 119 ifstream & is; 120 }; 121 void ?{}( isacquire & acq, ifstream & is ); 122 void ^?{}( isacquire & acq ); 103 123 104 124 void ?{}( ifstream & is ); -
libcfa/src/iostream.cfa
r9eb7a532 r266ecf1 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 24 08:31:35 202013 // Update Count : 11 3012 // Last Modified On : Tue Mar 2 14:51:30 2021 13 // Update Count : 1151 14 14 // 15 15 … … 266 266 } // ?|? 267 267 268 ostype & ?|?( ostype & os, const char s tr[] ) {268 ostype & ?|?( ostype & os, const char s[] ) { 269 269 enum { Open = 1, Close, OpenClose }; 270 270 static const unsigned char mask[256] @= { … … 282 282 }; // mask 283 283 284 if ( s tr[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator284 if ( s[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator 285 285 286 286 // first character IS NOT spacing or closing punctuation => add left separator 287 unsigned char ch = s tr[0]; // must make unsigned287 unsigned char ch = s[0]; // must make unsigned 288 288 if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) { 289 289 fmt( os, "%s", $sepGetCur( os ) ); … … 294 294 295 295 // last character IS spacing or opening punctuation => turn off separator for next item 296 size_t len = strlen( s tr);297 ch = s tr[len - 1]; // must make unsigned296 size_t len = strlen( s ); 297 ch = s[len - 1]; // must make unsigned 298 298 if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 299 299 sepOn( os ); … … 302 302 } // if 303 303 if ( ch == '\n' ) $setNL( os, true ); // check *AFTER* $sepPrt call above as it resets NL flag 304 return write( os, str, len ); 305 } // ?|? 306 307 void ?|?( ostype & os, const char str[] ) { 308 (ostype &)(os | str); ends( os ); 309 } // ?|? 310 311 // ostype & ?|?( ostype & os, const char16_t * str ) { 304 return write( os, s, len ); 305 } // ?|? 306 void ?|?( ostype & os, const char s[] ) { 307 (ostype &)(os | s); ends( os ); 308 } // ?|? 309 310 // ostype & ?|?( ostype & os, const char16_t * s ) { 312 311 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 313 // fmt( os, "%ls", s tr);312 // fmt( os, "%ls", s ); 314 313 // return os; 315 314 // } // ?|? 316 315 317 316 // #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 318 // ostype & ?|?( ostype & os, const char32_t * s tr) {317 // ostype & ?|?( ostype & os, const char32_t * s ) { 319 318 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 320 // fmt( os, "%ls", s tr);319 // fmt( os, "%ls", s ); 321 320 // return os; 322 321 // } // ?|? 323 322 // #endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) 324 323 325 // ostype & ?|?( ostype & os, const wchar_t * s tr) {324 // ostype & ?|?( ostype & os, const wchar_t * s ) { 326 325 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 327 // fmt( os, "%ls", s tr);326 // fmt( os, "%ls", s ); 328 327 // return os; 329 328 // } // ?|? … … 340 339 // manipulators 341 340 ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 342 (ostype &)(manip( os )); 343 return os; 341 return manip( os ); 344 342 } // ?|? 345 343 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 346 (ostype &)(manip( os ));344 manip( os ); 347 345 if ( $getPrt( os ) ) ends( os ); // something printed ? 348 346 $setPrt( os, false ); // turn off … … 399 397 return os; 400 398 } // nlOff 399 400 ostype & acquire( ostype & os ) { 401 acquire( os ); // call void returning 402 return os; 403 } // acquire 401 404 } // distribution 402 405 … … 517 520 return os; \ 518 521 } /* ?|? */ \ 519 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \ 522 void ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 523 (ostype &)(os | f); ends( os ); \ 524 } /* ?|? */ \ 520 525 } // distribution 521 526 … … 894 899 return is; 895 900 } // ?|? 901 void ?|?( istype & is, bool & b ) { 902 (istype &)(is | b); ends( is ); 903 } // ?|? 896 904 897 905 istype & ?|?( istype & is, char & c ) { … … 905 913 return is; 906 914 } // ?|? 915 void ?|?( istype & is, char & c ) { 916 (istype &)(is | c); ends( is ); 917 } // ?|? 907 918 908 919 istype & ?|?( istype & is, signed char & sc ) { … … 910 921 return is; 911 922 } // ?|? 923 void ?|?( istype & is, signed char & sc ) { 924 (istype &)(is | sc); ends( is ); 925 } // ?|? 912 926 913 927 istype & ?|?( istype & is, unsigned char & usc ) { … … 915 929 return is; 916 930 } // ?|? 931 void ?|?( istype & is, unsigned char & usc ) { 932 (istype &)(is | usc); ends( is ); 933 } // ?|? 917 934 918 935 istype & ?|?( istype & is, short int & si ) { … … 920 937 return is; 921 938 } // ?|? 939 void ?|?( istype & is, short int & si ) { 940 (istype &)(is | si); ends( is ); 941 } // ?|? 922 942 923 943 istype & ?|?( istype & is, unsigned short int & usi ) { … … 925 945 return is; 926 946 } // ?|? 947 void ?|?( istype & is, unsigned short int & usi ) { 948 (istype &)(is | usi); ends( is ); 949 } // ?|? 927 950 928 951 istype & ?|?( istype & is, int & i ) { … … 930 953 return is; 931 954 } // ?|? 955 void ?|?( istype & is, int & i ) { 956 (istype &)(is | i); ends( is ); 957 } // ?|? 932 958 933 959 istype & ?|?( istype & is, unsigned int & ui ) { … … 935 961 return is; 936 962 } // ?|? 963 void ?|?( istype & is, unsigned int & ui ) { 964 (istype &)(is | ui); ends( is ); 965 } // ?|? 937 966 938 967 istype & ?|?( istype & is, long int & li ) { … … 940 969 return is; 941 970 } // ?|? 971 void ?|?( istype & is, long int & li ) { 972 (istype &)(is | li); ends( is ); 973 } // ?|? 942 974 943 975 istype & ?|?( istype & is, unsigned long int & ulli ) { … … 945 977 return is; 946 978 } // ?|? 979 void ?|?( istype & is, unsigned long int & ulli ) { 980 (istype &)(is | ulli); ends( is ); 981 } // ?|? 947 982 948 983 istype & ?|?( istype & is, long long int & lli ) { … … 950 985 return is; 951 986 } // ?|? 987 void ?|?( istype & is, long long int & lli ) { 988 (istype &)(is | lli); ends( is ); 989 } // ?|? 952 990 953 991 istype & ?|?( istype & is, unsigned long long int & ulli ) { … … 955 993 return is; 956 994 } // ?|? 995 void & ?|?( istype & is, unsigned long long int & ulli ) { 996 (istype &)(is | ulli); ends( is ); 997 } // ?|? 957 998 958 999 #if defined( __SIZEOF_INT128__ ) 959 istype & ?|?( istype & is, int128 & i128 ) { 960 return (istype &)(is | (unsigned int128 &)i128); 961 } // ?|? 962 963 istype & ?|?( istype & is, unsigned int128 & ui128 ) { 1000 istype & ?|?( istype & is, int128 & llli ) { 1001 return (istype &)(is | (unsigned int128 &)llli); 1002 } // ?|? 1003 void ?|?( istype & is, int128 & llli ) { 1004 (istype &)(is | llli); ends( is ); 1005 } // ?|? 1006 1007 istype & ?|?( istype & is, unsigned int128 & ullli ) { 964 1008 char s[40]; 965 1009 bool sign = false; … … 968 1012 // If the input is too large, the value returned is undefined. If there is no input, no value is returned 969 1013 if ( fmt( is, "%39[0-9]%*[0-9]", s ) == 1 ) { // take first 39 characters, ignore remaining 970 u i128= 0;1014 ullli = 0; 971 1015 for ( unsigned int i = 0; s[i] != '\0'; i += 1 ) { 972 u i128 = ui128* 10 + s[i] - '0';1016 ullli = ullli * 10 + s[i] - '0'; 973 1017 } // for 974 if ( sign ) u i128 = -ui128;1018 if ( sign ) ullli = -ullli; 975 1019 } else if ( sign ) ungetc( is, '-' ); // return minus when no digits 976 1020 return is; 1021 } // ?|? 1022 void ?|?( istype & is, unsigned int128 & ullli ) { 1023 (istype &)(is | ullli); ends( is ); 977 1024 } // ?|? 978 1025 #endif // __SIZEOF_INT128__ … … 982 1029 return is; 983 1030 } // ?|? 1031 void ?|?( istype & is, float & f ) { 1032 (istype &)(is | f); ends( is ); 1033 } // ?|? 984 1034 985 1035 istype & ?|?( istype & is, double & d ) { … … 987 1037 return is; 988 1038 } // ?|? 1039 void ?|?( istype & is, double & d ) { 1040 (istype &)(is | d); ends( is ); 1041 } // ?|? 989 1042 990 1043 istype & ?|?( istype & is, long double & ld ) { … … 992 1045 return is; 993 1046 } // ?|? 994 1047 void ?|?( istype & is, long double & ld ) { 1048 (istype &)(is | ld); ends( is ); 1049 } // ?|? 995 1050 996 1051 istype & ?|?( istype & is, float _Complex & fc ) { … … 1000 1055 return is; 1001 1056 } // ?|? 1057 void ?|?( istype & is, float _Complex & fc ) { 1058 (istype &)(is | fc); ends( is ); 1059 } // ?|? 1002 1060 1003 1061 istype & ?|?( istype & is, double _Complex & dc ) { … … 1007 1065 return is; 1008 1066 } // ?|? 1067 void ?|?( istype & is, double _Complex & dc ) { 1068 (istype &)(is | dc); ends( is ); 1069 } // ?|? 1009 1070 1010 1071 istype & ?|?( istype & is, long double _Complex & ldc ) { … … 1014 1075 return is; 1015 1076 } // ?|? 1077 void ?|?( istype & is, long double _Complex & ldc ) { 1078 (istype &)(is | ldc); ends( is ); 1079 } // ?|? 1016 1080 1017 1081 // istype & ?|?( istype & is, const char fmt[] ) { … … 1020 1084 // } // ?|? 1021 1085 1022 istype & ?|?( istype & is, char * s) {1086 istype & ?|?( istype & is, char s[] ) { 1023 1087 fmt( is, "%s", s ); 1024 1088 return is; 1089 } // ?|? 1090 void ?|?( istype & is, char s[] ) { 1091 (istype &)(is | s); ends( is ); 1025 1092 } // ?|? 1026 1093 … … 1029 1096 return manip( is ); 1030 1097 } // ?|? 1098 void ?|?( istype & is, istype & (* manip)( istype & ) ) { 1099 manip( is ); ends( is ); 1100 } // ?|? 1031 1101 1032 1102 istype & nl( istype & is ) { … … 1044 1114 return is; 1045 1115 } // nlOff 1116 1117 istype & acquire( istype & is ) { 1118 acquire( is ); // call void returning 1119 return is; 1120 } // acquire 1046 1121 } // distribution 1047 1122 1048 1123 // *********************************** manipulators *********************************** 1049 1124 1050 forall( istype & | istream( istype ) ) 1051 istype & ?|?( istype & is, _Istream_Cstr f ) { 1052 // skip xxx 1053 if ( ! f.s ) { 1054 // printf( "skip %s %d\n", f.scanset, f.wd ); 1055 if ( f.wd == -1 ) fmt( is, f.scanset, "" ); // no input arguments 1056 else for ( f.wd ) fmt( is, "%*c" ); 1057 return is; 1058 } // if 1059 size_t len = 0; 1060 if ( f.scanset ) len = strlen( f.scanset ); 1061 char fmtstr[len + 16]; 1062 int start = 1; 1063 fmtstr[0] = '%'; 1064 if ( f.flags.ignore ) { fmtstr[1] = '*'; start += 1; } 1065 if ( f.wd != -1 ) { start += sprintf( &fmtstr[start], "%d", f.wd ); } 1066 // cstr %s, %*s, %ws, %*ws 1067 if ( ! f.scanset ) { 1068 fmtstr[start] = 's'; fmtstr[start + 1] = '\0'; 1069 // printf( "cstr %s\n", fmtstr ); 1125 forall( istype & | istream( istype ) ) { 1126 istype & ?|?( istype & is, _Istream_Cstr f ) { 1127 // skip xxx 1128 if ( ! f.s ) { 1129 // printf( "skip %s %d\n", f.scanset, f.wd ); 1130 if ( f.wd == -1 ) fmt( is, f.scanset, "" ); // no input arguments 1131 else for ( f.wd ) fmt( is, "%*c" ); 1132 return is; 1133 } // if 1134 size_t len = 0; 1135 if ( f.scanset ) len = strlen( f.scanset ); 1136 char fmtstr[len + 16]; 1137 int start = 1; 1138 fmtstr[0] = '%'; 1139 if ( f.flags.ignore ) { fmtstr[1] = '*'; start += 1; } 1140 if ( f.wd != -1 ) { start += sprintf( &fmtstr[start], "%d", f.wd ); } 1141 // cstr %s, %*s, %ws, %*ws 1142 if ( ! f.scanset ) { 1143 fmtstr[start] = 's'; fmtstr[start + 1] = '\0'; 1144 // printf( "cstr %s\n", fmtstr ); 1145 fmt( is, fmtstr, f.s ); 1146 return is; 1147 } // if 1148 // incl %[xxx], %*[xxx], %w[xxx], %*w[xxx] 1149 // excl %[^xxx], %*[^xxx], %w[^xxx], %*w[^xxx] 1150 fmtstr[start] = '['; start += 1; 1151 if ( f.flags.inex ) { fmtstr[start] = '^'; start += 1; } 1152 strcpy( &fmtstr[start], f.scanset ); // copy includes '\0' 1153 len += start; 1154 fmtstr[len] = ']'; fmtstr[len + 1] = '\0'; 1155 // printf( "incl/excl %s\n", fmtstr ); 1070 1156 fmt( is, fmtstr, f.s ); 1071 1157 return is; 1072 } // if 1073 // incl %[xxx], %*[xxx], %w[xxx], %*w[xxx] 1074 // excl %[^xxx], %*[^xxx], %w[^xxx], %*w[^xxx] 1075 fmtstr[start] = '['; start += 1; 1076 if ( f.flags.inex ) { fmtstr[start] = '^'; start += 1; } 1077 strcpy( &fmtstr[start], f.scanset ); // copy includes '\0' 1078 len += start; 1079 fmtstr[len] = ']'; fmtstr[len + 1] = '\0'; 1080 // printf( "incl/excl %s\n", fmtstr ); 1081 fmt( is, fmtstr, f.s ); 1082 return is; 1083 } // ?|? 1084 1085 forall( istype & | istream( istype ) ) 1086 istype & ?|?( istype & is, _Istream_Char f ) { 1087 fmt( is, "%*c" ); // argument variable unused 1088 return is; 1089 } // ?|? 1158 } // ?|? 1159 void ?|?( istype & is, _Istream_Cstr f ) { 1160 (istype &)(is | f); ends( is ); 1161 } // ?|? 1162 1163 istype & ?|?( istype & is, _Istream_Char f ) { 1164 fmt( is, "%*c" ); // argument variable unused 1165 return is; 1166 } // ?|? 1167 void ?|?( istype & is, _Istream_Char f ) { 1168 (istype &)(is | f); ends( is ); 1169 } // ?|? 1170 } // distribution 1090 1171 1091 1172 #define InputFMTImpl( T, CODE ) \ 1092 forall( istype & | istream( istype ) ) \ 1093 istype & ?|?( istype & is, _Istream_Manip(T) f ) { \ 1094 enum { size = 16 }; \ 1095 char fmtstr[size]; \ 1096 if ( f.wd == -1 ) { \ 1097 snprintf( fmtstr, size, "%%%s%s", f.ignore ? "*" : "", CODE ); \ 1098 } else { \ 1099 snprintf( fmtstr, size, "%%%s%d%s", f.ignore ? "*" : "", f.wd, CODE ); \ 1100 } /* if */ \ 1101 /* printf( "%d %s %p\n", f.wd, fmtstr, &f.val ); */ \ 1102 fmt( is, fmtstr, &f.val ); \ 1103 return is; \ 1104 } // ?|? 1173 forall( istype & | istream( istype ) ) { \ 1174 istype & ?|?( istype & is, _Istream_Manip(T) f ) { \ 1175 enum { size = 16 }; \ 1176 char fmtstr[size]; \ 1177 if ( f.wd == -1 ) { \ 1178 snprintf( fmtstr, size, "%%%s%s", f.ignore ? "*" : "", CODE ); \ 1179 } else { \ 1180 snprintf( fmtstr, size, "%%%s%d%s", f.ignore ? "*" : "", f.wd, CODE ); \ 1181 } /* if */ \ 1182 /* printf( "%d %s %p\n", f.wd, fmtstr, &f.val ); */ \ 1183 fmt( is, fmtstr, &f.val ); \ 1184 return is; \ 1185 } /* ?|? */ \ 1186 void ?|?( istype & is, _Istream_Manip(T) f ) { \ 1187 (istype &)(is | f); ends( is ); \ 1188 } /* ?|? */ \ 1189 } // distribution 1105 1190 1106 1191 InputFMTImpl( signed char, "hhi" ) … … 1119 1204 InputFMTImpl( long double, "Lf" ) 1120 1205 1121 forall( istype & | istream( istype ) ) 1122 istype & ?|?( istype & is, _Istream_Manip(float _Complex) fc ) { 1123 float re, im; 1124 _Istream_Manip(float) fmtuc @= { re, fc.wd, fc.ignore }; 1125 is | fmtuc; 1126 &fmtuc.val = &im; 1127 is | fmtuc; 1128 if ( ! fc.ignore ) fc.val = re + im * _Complex_I; // re/im are uninitialized for ignore 1129 return is; 1130 } // ?|? 1131 1132 forall( istype & | istream( istype ) ) 1133 istype & ?|?( istype & is, _Istream_Manip(double _Complex) dc ) { 1134 double re, im; 1135 _Istream_Manip(double) fmtuc @= { re, dc.wd, dc.ignore }; 1136 is | fmtuc; 1137 &fmtuc.val = &im; 1138 is | fmtuc; 1139 if ( ! dc.ignore ) dc.val = re + im * _Complex_I; // re/im are uninitialized for ignore 1140 return is; 1141 } // ?|? 1142 1143 forall( istype & | istream( istype ) ) 1144 istype & ?|?( istype & is, _Istream_Manip(long double _Complex) ldc ) { 1145 long double re, im; 1146 _Istream_Manip(long double) fmtuc @= { re, ldc.wd, ldc.ignore }; 1147 is | fmtuc; 1148 &fmtuc.val = &im; 1149 is | fmtuc; 1150 if ( ! ldc.ignore ) ldc.val = re + im * _Complex_I; // re/im are uninitialized for ignore 1151 return is; 1152 } // ?|? 1206 forall( istype & | istream( istype ) ) { 1207 istype & ?|?( istype & is, _Istream_Manip(float _Complex) fc ) { 1208 float re, im; 1209 _Istream_Manip(float) fmtuc @= { re, fc.wd, fc.ignore }; 1210 is | fmtuc; 1211 &fmtuc.val = &im; 1212 is | fmtuc; 1213 if ( ! fc.ignore ) fc.val = re + im * _Complex_I; // re/im are uninitialized for ignore 1214 return is; 1215 } // ?|? 1216 void ?|?( istype & is, _Istream_Manip(float _Complex) fc ) { 1217 (istype &)(is | fc); ends( is ); 1218 } // ?|? 1219 1220 istype & ?|?( istype & is, _Istream_Manip(double _Complex) dc ) { 1221 double re, im; 1222 _Istream_Manip(double) fmtuc @= { re, dc.wd, dc.ignore }; 1223 is | fmtuc; 1224 &fmtuc.val = &im; 1225 is | fmtuc; 1226 if ( ! dc.ignore ) dc.val = re + im * _Complex_I; // re/im are uninitialized for ignore 1227 return is; 1228 } // ?|? 1229 void ?|?( istype & is, _Istream_Manip(double _Complex) dc ) { 1230 (istype &)(is | dc); ends( is ); 1231 } // ?|? 1232 1233 istype & ?|?( istype & is, _Istream_Manip(long double _Complex) ldc ) { 1234 long double re, im; 1235 _Istream_Manip(long double) fmtuc @= { re, ldc.wd, ldc.ignore }; 1236 is | fmtuc; 1237 &fmtuc.val = &im; 1238 is | fmtuc; 1239 if ( ! ldc.ignore ) ldc.val = re + im * _Complex_I; // re/im are uninitialized for ignore 1240 return is; 1241 } // ?|? 1242 void ?|?( istype & is, _Istream_Manip(long double _Complex) ldc ) { 1243 (istype &)(is | ldc); ends( is ); 1244 } // ?|? 1245 } // distribution 1153 1246 1154 1247 // Local Variables: // -
libcfa/src/iostream.hfa
r9eb7a532 r266ecf1 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Aug 11 22:16:14 202013 // Update Count : 3 5012 // Last Modified On : Tue Mar 2 14:05:08 2021 13 // Update Count : 369 14 14 // 15 15 … … 54 54 ostype & write( ostype &, const char [], size_t ); 55 55 int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 56 void acquire( ostype & ); 56 57 }; // ostream 57 58 … … 137 138 ostype & nlOn( ostype & ); 138 139 ostype & nlOff( ostype & ); 140 ostype & acquire( ostype & ); 139 141 } // distribution 140 142 … … 285 287 void nlOff( istype & ); // scan newline 286 288 bool getANL( istype & ); // get scan newline (on/off) 289 290 void ends( istype & os ); // end of output statement 287 291 int fail( istype & ); 288 292 int eof( istype & ); … … 292 296 istype & ungetc( istype &, char ); 293 297 int fmt( istype &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) )); 298 void acquire( istype & ); 294 299 }; // istream 295 300 … … 300 305 forall( istype & | istream( istype ) ) { 301 306 istype & ?|?( istype &, bool & ); 307 void ?|?( istype &, bool & ); 302 308 303 309 istype & ?|?( istype &, char & ); 310 void ?|?( istype &, char & ); 304 311 istype & ?|?( istype &, signed char & ); 312 void ?|?( istype &, signed char & ); 305 313 istype & ?|?( istype &, unsigned char & ); 314 void ?|?( istype &, unsigned char & ); 306 315 307 316 istype & ?|?( istype &, short int & ); 317 void ?|?( istype &, short int & ); 308 318 istype & ?|?( istype &, unsigned short int & ); 319 void ?|?( istype &, unsigned short int & ); 309 320 istype & ?|?( istype &, int & ); 321 void ?|?( istype &, int & ); 310 322 istype & ?|?( istype &, unsigned int & ); 323 void ?|?( istype &, unsigned int & ); 311 324 istype & ?|?( istype &, long int & ); 325 void ?|?( istype &, long int & ); 312 326 istype & ?|?( istype &, unsigned long int & ); 327 void ?|?( istype &, unsigned long int & ); 313 328 istype & ?|?( istype &, long long int & ); 329 void ?|?( istype &, long long int & ); 314 330 istype & ?|?( istype &, unsigned long long int & ); 331 void ?|?( istype &, unsigned long long int & ); 315 332 #if defined( __SIZEOF_INT128__ ) 316 333 istype & ?|?( istype &, int128 & ); 334 void ?|?( istype &, int128 & ); 317 335 istype & ?|?( istype &, unsigned int128 & ); 336 void ?|?( istype &, unsigned int128 & ); 318 337 #endif // __SIZEOF_INT128__ 319 338 320 339 istype & ?|?( istype &, float & ); 340 void ?|?( istype &, float & ); 321 341 istype & ?|?( istype &, double & ); 342 void ?|?( istype &, double & ); 322 343 istype & ?|?( istype &, long double & ); 344 void ?|?( istype &, long double & ); 323 345 324 346 istype & ?|?( istype &, float _Complex & ); 347 void ?|?( istype &, float _Complex & ); 325 348 istype & ?|?( istype &, double _Complex & ); 349 void ?|?( istype &, double _Complex & ); 326 350 istype & ?|?( istype &, long double _Complex & ); 351 void ?|?( istype &, long double _Complex & ); 327 352 328 353 // istype & ?|?( istype &, const char [] ); 329 istype & ?|?( istype &, char * ); 354 istype & ?|?( istype &, char [] ); 355 void ?|?( istype &, char [] ); 330 356 331 357 // manipulators 332 358 istype & ?|?( istype &, istype & (*)( istype & ) ); 359 void ?|?( istype &, istype & (*)( istype & ) ); 333 360 istype & nl( istype & is ); 334 361 istype & nlOn( istype & ); 335 362 istype & nlOff( istype & ); 363 istype & acquire( istype & ); 336 364 } // distribution 337 365 … … 363 391 _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; } 364 392 } // distribution 365 forall( istype & | istream( istype ) ) istype & ?|?( istype & is, _Istream_Cstr f ); 393 forall( istype & | istream( istype ) ) { 394 istype & ?|?( istype & is, _Istream_Cstr f ); 395 void ?|?( istype & is, _Istream_Cstr f ); 396 } 366 397 367 398 struct _Istream_Char { … … 373 404 _Istream_Char & ignore( _Istream_Char & fmt ) { fmt.ignore = true; return fmt; } 374 405 } // distribution 375 forall( istype & | istream( istype ) ) istype & ?|?( istype & is, _Istream_Char f ); 406 forall( istype & | istream( istype ) ) { 407 istype & ?|?( istype & is, _Istream_Char f ); 408 void ?|?( istype & is, _Istream_Char f ); 409 } 376 410 377 411 forall( T & | sized( T ) ) … … 391 425 forall( istype & | istream( istype ) ) { \ 392 426 istype & ?|?( istype & is, _Istream_Manip(T) f ); \ 427 void ?|?( istype & is, _Istream_Manip(T) f ); \ 393 428 } // ?|? 394 429 -
tests/Includes.cfa
r9eb7a532 r266ecf1 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 25 14:00:36202113 // Update Count : 6 8912 // Last Modified On : Tue Mar 2 15:03:40 2021 13 // Update Count : 690 14 14 // 15 15 … … 83 83 #include <locale.h> 84 84 //#include <ltdl.h> 85 #include <lzma.h> 85 //#include <lzma.h> // may not be installed 86 86 //#include <malloc.h> // CFA #include_next 87 87 #include <math.h> -
tests/linking/weakso_nothd.cfa
r9eb7a532 r266ecf1 6 6 // 7 7 // weakso_nothd.cfa -- 8 // test whether or not usin da weakso locks pulls in threads8 // test whether or not using a weakso locks pulls in threads 9 9 // 10 10 // Author : Thierry Delisle
Note: See TracChangeset
for help on using the changeset viewer.