Ignore:
Timestamp:
Oct 20, 2021, 4:38:37 PM (3 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
4e8df745
Parents:
0ca15b7
Message:

Bug fixes for empty-string from no-arg ctor with sharing off

File:
1 edited

Legend:

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

    r0ca15b7 r2b30370  
    209209    // Store auto-newline state so it can be restored
    210210    bool anl = getANL$(out);
    211     nlOff(out);
    212     for (size_t i = 0; i < s.Handle.lnth; i++) {
    213         // Need to re-apply on the last output operator, for whole-statement version
    214         if (anl && i == s.Handle.lnth-1) nlOn(out);
    215         out | s[i];
    216     }
    217     return out;
     211    if( s.Handle.lnth == 0 ) {
     212        sout | "";
     213    } else {
     214        nlOff(out);
     215        for (size_t i = 0; i < s.Handle.lnth; i++) {
     216            // Need to re-apply on the last output operator, for whole-statement version
     217            if (anl && i == s.Handle.lnth-1) nlOn(out);
     218            out | s[i];
     219        }
     220    }
    218221}
    219222
     
    223226        (Handle){ * ambient_string_sharectx->activeHeap };
    224227        (shareEditSet_owns_ulink){ false };
     228        verify( Handle.s == 0p && Handle.lnth == 0 );
    225229    } else {
    226230        (Handle){ * new( (size_t) 10 ) };  // TODO: can I lazily avoid allocating for empty string
    227231        (shareEditSet_owns_ulink){ true };
     232        Handle.s = Handle.ulink->StartVbyte;
     233        verify( Handle.lnth == 0 );
    228234    }
    229235    s.shareEditSet_prev = &s;
Note: See TracChangeset for help on using the changeset viewer.