Ignore:
Timestamp:
Nov 13, 2023, 3:43:43 AM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
25f2798
Parents:
0030b508 (diff), 2174191 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/collections/string_res.cfa

    r0030b508 rfc12f05  
    1010// Created On       : Fri Sep 03 11:00:00 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 14 18:06:01 2023
    13 // Update Count     : 12
     12// Last Modified On : Wed Oct 18 21:54:54 2023
     13// Update Count     : 15
    1414//
    1515
     
    236236        // get bytes
    237237        try {
     238                        *(temp.Handle.ulink->EndVbyte) = '\0';   // pre-assign empty cstring
    238239            in | wdi( lenReadable, temp.Handle.ulink->EndVbyte );
    239240        } catch (cstring_length*) {
     
    247248    }
    248249
    249     s = temp;
     250        if ( temp.Handle.lnth > 0 ) s = temp;
    250251    return in;
    251252}
    252253
    253254void ?|?( ifstream & in, string_res & this ) {
    254     (ifstream &)(in | this); ends( in );
     255    (ifstream &)(in | this);
    255256}
    256257
     
    268269        cstr[wd] = '\0';                                                                        // guard null terminate string
    269270        try {
     271                cstr[0] = '\0';                                                                 // pre-assign as empty cstring
    270272                is | cf;
    271273        } catch( cstring_length * ) {
    272274                cont = true;
    273275        } finally {
    274         if ( ! cf.flags.ignore ) *(f.s) = cstr;                 // ok to initialize string
     276                if ( ! cf.flags.ignore &&                                               // ok to initialize string
     277                                cstr[0] != '\0' ) {                                             // something was read
     278                        *(f.s) = cstr;
     279                }
    275280        } // try
    276281        for ( ; cont; )  {                                                                      // overflow read ?
    277282                cont = false;
    278283                try {
     284                        cstr[0] = '\0';                                                         // pre-assign as empty cstring
    279285                        is | cf;
    280286                } catch( cstring_length * ) {
    281287                        cont = true;                                                            // continue not allowed
    282288                } finally {
    283                         if ( ! cf.flags.ignore ) *(f.s) += cstr;        // build string chunk at a time
     289                        if ( ! cf.flags.ignore &&
     290                                        cstr[0] != '\0' ) {                                     // something was read
     291                                *(f.s) += cstr;                                                 // build string chunk at a time
     292                        }
    284293                } // try
    285294        } // for
     
    288297
    289298void ?|?( ifstream & in, _Istream_Rstr f ) {
    290     (ifstream &)(in | f); ends( in );
     299    (ifstream &)(in | f);
    291300}
    292301
Note: See TracChangeset for help on using the changeset viewer.