- Timestamp:
- Aug 12, 2023, 3:49:57 PM (16 months ago)
- Branches:
- master
- Children:
- d32679d5
- Parents:
- 43109ce
- Location:
- libcfa/src/containers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/string.cfa
r43109ce r9ca5e56 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 7 10:07:26202313 // Update Count : 212 // Last Modified On : Sat Aug 12 15:24:18 2023 13 // Update Count : 6 14 14 // 15 15 … … 102 102 // Output 103 103 104 ofstream & ?|?( ofstream & fs, const string & this ) {105 return fs | (*this.inner);106 } 107 108 void ?|?( ofstream & fs, const string & this ) {109 fs | (*this.inner);104 ofstream & ?|?( ofstream & out, const string & this ) { 105 return out | (*this.inner); // print internal string_res 106 } 107 108 void ?|?( ofstream & out, const string & this ) { 109 (ofstream &)(out | (*this.inner)); ends( out ); 110 110 } 111 111 -
libcfa/src/containers/string_res.cfa
r43109ce r9ca5e56 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 29 09:29:06202313 // Update Count : 212 // Last Modified On : Sat Aug 12 15:37:47 2023 13 // Update Count : 10 14 14 // 15 15 … … 134 134 serr | nlOff; 135 135 serr | " lnth:" | lnth | " s:" | (void *)s | ",\""; 136 for ( i nt i = 0; i < lnth; i += 1) {136 for ( i; lnth ) { 137 137 serr | s[i]; 138 138 } // for … … 198 198 // Output operator 199 199 ofstream & ?|?(ofstream &out, const string_res &s) { 200 // Store auto-newline state so it can be restored 201 bool anl = getANL$(out); 202 nlOff(out); 203 for (size_t i = 0; i < s.Handle.lnth; i++) { 204 out | s[i]; 205 } 206 out | sepVal; 207 // Re-apply newlines after done, for chaining version 208 if (anl) nlOn(out); 200 // CFA string is NOT null terminated, so print exactly lnth characters in a minimum width of 0. 201 out | wd( 0, s.Handle.lnth, s.Handle.s ) | nonl; 209 202 return out; 210 203 } 211 204 212 205 void ?|?(ofstream &out, const string_res &s) { 213 // Store auto-newline state so it can be restored 214 bool anl = getANL$(out); 215 if( s.Handle.lnth == 0 ) { 216 sout | ""; 217 } else { 218 nlOff(out); 219 for (size_t i = 0; i < s.Handle.lnth; i++) { 220 // Need to re-apply on the last output operator, for whole-statement version 221 if (anl && i == s.Handle.lnth-1) nlOn(out); 222 out | s[i]; 223 } 224 } 206 (ofstream &)(out | s); ends( out ); 225 207 } 226 208 … … 338 320 // adjust all substring string and handle locations, and check if any substring strings are outside the new base string 339 321 char *limit = resultSesStart + resultSesLnth; 340 for ( string_res * p = this.shareEditSet_next; p != &this; p = p->shareEditSet_next) {322 for ( string_res * p = this.shareEditSet_next; p != &this; p = p->shareEditSet_next ) { 341 323 verify (p->Handle.s >= beforeBegin); 342 324 if ( p->Handle.s >= afterBegin ) { … … 396 378 string_res * shareEditSetStartPeer = & this; 397 379 string_res * shareEditSetEndPeer = & this; 398 for ( string_res * editPeer = this.shareEditSet_next; editPeer != &this; editPeer = editPeer->shareEditSet_next) {380 for ( string_res * editPeer = this.shareEditSet_next; editPeer != &this; editPeer = editPeer->shareEditSet_next ) { 399 381 if ( editPeer->Handle.s < shareEditSetStartPeer->Handle.s ) { 400 382 shareEditSetStartPeer = editPeer; … … 589 571 590 572 bool contains(const string_res &s, char ch) { 591 for ( i; size(s)) {573 for ( i; size(s) ) { 592 574 if (s[i] == ch) return true; 593 575 } … … 643 625 } 644 626 645 for ( size_t i = fromPos; i < s.Handle.lnth; i++) {627 for ( i; fromPos ~ s.Handle.lnth ) { 646 628 size_t remaining = s.Handle.lnth - i; 647 629 // Never going to find the search string if the remaining string is … … 652 634 653 635 bool matched = true; 654 for ( size_t j = 0; j < searchsize; j++) {636 for ( j; searchsize ) { 655 637 if (search[j] != s.Handle.s[i + j]) { 656 638 matched = false; … … 740 722 741 723 int exclude(const string_res &s, const charclass_res &mask) { 742 for ( int i = 0; i < size(s); i++) {724 for ( i; size(s) ) { 743 725 if ( test(mask, s[i]) ) return i; 744 726 } … … 747 729 748 730 int include(const string_res &s, const charclass_res &mask) { 749 for ( int i = 0; i < size(s); i++) {731 for ( i; size(s) ) { 750 732 if ( ! test(mask, s[i]) ) return i; 751 733 } … … 775 757 for ( HandleNode *ni = HeaderPtr->flink; ni != HeaderPtr; ni = ni->flink ) { 776 758 serr | "\tnode:" | ni | " lnth:" | ni->lnth | " s:" | (void *)ni->s | ",\""; 777 for ( i nt i = 0; i < ni->lnth; i += 1) {759 for ( i; ni->lnth ) { 778 760 serr | ni->s[i]; 779 761 } // for … … 881 863 for ( HandleNode *n = HeaderPtr->flink; n != HeaderPtr; n = n->flink ) { 882 864 serr | "\tnode:" | n | " lnth:" | n->lnth | " s:" | (void *)n->s | ",\""; 883 for ( i nt i = 0; i < n->lnth; i += 1) {884 serr | n->s[i];865 for ( i; n->lnth ) { 866 serr | n->s[i]; 885 867 } // for 886 868 serr | "\" flink:" | n->flink | " blink:" | n->blink | nl; … … 960 942 EndVbyte = StartVbyte; 961 943 h = Header.flink; // ignore header node 962 for ( ;;) {944 for () { 963 945 memmove( EndVbyte, h->s, h->lnth ); 964 946 obase = h->s; … … 971 953 // check if any substrings are allocated within a string 972 954 973 for ( ;;) {955 for () { 974 956 if ( h == &Header ) break; // end of header list ? 975 957 if ( h->s >= limit ) break; // outside of current string ? … … 1001 983 serr | nlOff; 1002 984 serr | "\tnode:" | n | " lnth:" | n->lnth | " s:" | (void *)n->s | ",\""; 1003 for ( i nt i = 0; i < n->lnth; i += 1) {985 for ( i; n->lnth ) { 1004 986 serr | n->s[i]; 1005 987 } // for … … 1036 1018 serr | nlOff; 1037 1019 serr | "\tnode:" | n | " lnth:" | n->lnth | " s:" | (void *)n->s | ",\""; 1038 for ( i nt i = 0; i < n->lnth; i += 1) {1020 for ( i; n->lnth ) { 1039 1021 serr | n->s[i]; 1040 1022 } // for -
libcfa/src/containers/string_res.hfa
r43109ce r9ca5e56 9 9 // Author : Michael L. Brooks 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 // Last Modified By : Michael L. Brooks12 // Last Modified On : Fri Sep 03 11:00:00 202113 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 12 15:45:47 2023 13 // Update Count : 2 14 14 // 15 15 … … 30 30 VbyteHeap *ulink; // upward link 31 31 32 char *s; // pointer to byte string32 char *s; // pointer to byte string 33 33 unsigned int lnth; // length of byte string 34 34 }; // HandleNode
Note: See TracChangeset
for help on using the changeset viewer.