1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

add_string_to_string: Don't fail if @from is empty.

Old versions of add_string_to_string returned the target string
unmodified if from->source pointed to a null character, which usually
meant that the source string was empty.  That was changed in commit
5e18576391f75ad84e04f9c8a30b93d08f0b92ab on 2004-11-03 so that
add_string_to_string instead returned NULL in that situation.  The
change seems to have been inadvertent.

I'm now reverting that change and also making add_string_to_string
check the emptiness of the source string based on the stored length
only, rather than on any null characters.  So the function can now
also be used with non-C strings containing embedded null characters.
Note that the previous version did not completely prevent embedded
null characters either, because it checked only the first character.

[ From commit 4a23d7fd82 in ELinks
  0.12.GIT.  --KON ]
This commit is contained in:
Kalle Olavi Niemitalo 2007-03-18 20:11:46 +02:00 committed by Kalle Olavi Niemitalo
parent fd70a5b352
commit f135339a1a

View File

@ -325,7 +325,7 @@ add_string_to_string(struct string *string, struct string *from)
check_string_magic(string);
check_string_magic(from);
if (!*from->source) return NULL;
if (!from->length) return string; /* optimization only */
return add_bytes_to_string(string, from->source, from->length);
}