]> git.eshelyaron.com Git - emacs.git/commitdiff
(wordify): Fix i_byte even in unibyte case for copy loop.
authorRichard M. Stallman <rms@gnu.org>
Mon, 29 Jun 1998 17:20:52 +0000 (17:20 +0000)
committerRichard M. Stallman <rms@gnu.org>
Mon, 29 Jun 1998 17:20:52 +0000 (17:20 +0000)
If input is unibyte, make the output unibyte.

src/search.c

index d7068547434fb0fffd67a5d1838360b52847eedc..29a6fe4ff4fb99cb3791a27ea2dca78ecaca3596 100644 (file)
@@ -1983,8 +1983,12 @@ wordify (string)
     return build_string ("");
 
   adjust = - punct_count + 5 * (word_count - 1) + 4;
-  val = make_uninit_multibyte_string (len + adjust,
-                                     STRING_BYTES (XSTRING (string)) + adjust);
+  if (STRING_MULTIBYTE (string))
+    val = make_uninit_multibyte_string (len + adjust,
+                                       STRING_BYTES (XSTRING (string))
+                                       + adjust);
+  else
+    val = make_uninit_string (len + adjust);
 
   o = XSTRING (val)->data;
   *o++ = '\\';
@@ -1999,7 +2003,10 @@ wordify (string)
       if (STRING_MULTIBYTE (string))
        FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);
       else
-       c = XSTRING (string)->data[i++];
+       {
+         c = XSTRING (string)->data[i++];
+         i_byte++;
+       }
 
       if (SYNTAX (c) == Sword)
        {