changeset 20861:9f9937a74050

(Fformat): Handle a symbol of which name contains multibyte characters correctly.
author Richard M. Stallman <rms@gnu.org>
date Sun, 08 Feb 1998 08:26:52 +0000
parents 1432a2b3c44e
children f4efe8aa6133
files src/editfns.c
diffstat 1 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/editfns.c	Sun Feb 08 07:34:28 1998 +0000
+++ b/src/editfns.c	Sun Feb 08 08:26:52 1998 +0000
@@ -455,6 +455,14 @@
   return buildmark (ZV, ZV_BYTE);
 }
 
+DEFUN ("position-bytes", Fposition_bytes, Sposition_bytes, 1, 1, 0,
+  "Return the byte position for character position POSITION.")
+  (position)
+{
+  CHECK_NUMBER (position, 1);
+  return make_number (CHAR_TO_BYTE (position));
+}
+
 DEFUN ("following-char", Ffollowing_char, Sfollowing_char, 0, 0, 0,
   "Return the character following point, as a number.\n\
 At the end of the buffer or accessible region, return 0.\n\
@@ -2268,6 +2276,11 @@
 	else if (SYMBOLP (args[n]))
 	  {
 	    XSETSTRING (args[n], XSYMBOL (args[n])->name);
+	    if (STRING_MULTIBYTE (args[n]) && ! multibyte)
+	      {
+		multibyte = 1;
+		goto retry;
+	      }
 	    goto string;
 	  }
 	else if (STRINGP (args[n]))
@@ -2396,7 +2409,14 @@
 	      nchars += this_nchars;
 	    }
 	}
-      else if (multibyte && !STRING_MULTIBYTE (args[0]))
+      else if (STRING_MULTIBYTE (args[0]))
+	{
+	  /* Copy a whole multibyte character.  */
+	  *p++ = *format++;
+	  while (! CHAR_HEAD_P (*format)) *p++ = *format++;
+	  nchars++;
+	}
+      else if (multibyte)
 	{
 	  /* Convert a single-byte character to multibyte.  */
 	  int len = copy_text (format, p, 1, 0, 1);
@@ -2890,6 +2910,10 @@
   defsubr (&Spoint);
   defsubr (&Sregion_beginning);
   defsubr (&Sregion_end);
+
+  defsubr (&Sline_beginning_position);
+  defsubr (&Sline_end_position);
+
 /*  defsubr (&Smark); */
 /*  defsubr (&Sset_mark); */
   defsubr (&Ssave_excursion);
@@ -2900,9 +2924,7 @@
   defsubr (&Spoint_min);
   defsubr (&Spoint_min_marker);
   defsubr (&Spoint_max_marker);
-
-  defsubr (&Sline_beginning_position);
-  defsubr (&Sline_end_position);
+  defsubr (&Sposition_bytes);
 
   defsubr (&Sbobp);
   defsubr (&Seobp);