Changeset 4363

Show
Ignore:
Timestamp:
08/25/06 12:58:35 (2 years ago)
Author:
morris
Message:

Fix a problem with reading back long lines, affected news postings among other things

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libwired/trunk/libwired/file/wi-file.c

    r4289 r4363  
    791791 
    792792wi_string_t * wi_file_read_to_string(wi_file_t *file, wi_string_t *separator) { 
    793         wi_string_t             *string
     793        wi_string_t             *string, *totalstring = NULL
    794794        uint32_t                index, length; 
    795795         
    796796        _WI_FILE_ASSERT_OPEN(file); 
    797  
     797         
    798798        while((string = wi_file_read(file, WI_FILE_BUFFER_SIZE))) { 
    799                 length = wi_string_length(string); 
     799                if(!totalstring) 
     800                        totalstring = wi_string_init(wi_string_alloc()); 
     801                 
    800802                index = wi_string_index_of_string(string, separator, 0); 
    801803                 
    802804                if(index == WI_NOT_FOUND) { 
    803                         if(length < WI_FILE_BUFFER_SIZE) 
    804                                 return string; 
     805                        wi_string_append_string(totalstring, string); 
    805806                } else { 
     807                        length = wi_string_length(string); 
     808                         
    806809                        wi_string_delete_characters_from_index(string, index); 
    807                          
     810                        wi_string_append_string(totalstring, string); 
     811 
    808812                        wi_file_seek(file, wi_file_offset(file) - length + index + 1); 
    809813                         
    810                         return string
     814                        break
    811815                } 
    812816        } 
    813817         
    814         return NULL
     818        return wi_autorelease(totalstring)
    815819} 
    816820