summaryrefslogtreecommitdiff
path: root/sed
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2009-10-15 19:56:12 +0200
committerPaolo Bonzini <bonzini@gnu.org>2009-10-15 19:59:10 +0200
commit20f68fb1abe862a98bc0378e5bb54d94bb98b8fe (patch)
tree5a34f906a086987efb7a7b666e3f6d47f54adb3a /sed
parentdb462e54660d43aa3f744ef4f4ca062e2eb644af (diff)
downloadsed-20f68fb1abe862a98bc0378e5bb54d94bb98b8fe.tar.gz
handle incomplete sequences as if they were invalid
2009-10-15 Paolo Bonzini <bonzini@gnu.org> WANG Yunfeng <uhuruh@gmail.com> * sed/execute.c (str_append, str_append_modified): Handle incomplete sequences as if they were invalid.
Diffstat (limited to 'sed')
-rw-r--r--sed/execute.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sed/execute.c b/sed/execute.c
index 66cb809..d5903be 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -254,8 +254,8 @@ str_append(to, string, length)
{
size_t n = MBRLEN (string, length, &to->mbstate);
- /* An invalid sequence is treated like a singlebyte character. */
- if (n == (size_t) -1)
+ /* An invalid or imcomplete sequence is treated like a singlebyte character. */
+ if (n == (size_t) -1 || n == (size_t) -2)
{
memset (&to->mbstate, 0, sizeof (to->mbstate));
n = 1;
@@ -341,7 +341,7 @@ str_append_modified(to, string, length, type)
/* Copy the new wide character to the end of the string. */
n = WCRTOMB (to->active + to->length, wc, &to->mbstate);
to->length += n;
- if (n == -1)
+ if (n == -1 || n == -2)
{
fprintf (stderr, "Case conversion produced an invalid character!");
abort ();