emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/character.c,v


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/src/character.c,v
Date: Fri, 18 Apr 2008 03:26:56 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        08/04/18 03:26:55

Index: character.c
===================================================================
RCS file: /sources/emacs/emacs/src/character.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- character.c 16 Apr 2008 11:36:29 -0000      1.8
+++ character.c 18 Apr 2008 03:26:55 -0000      1.9
@@ -326,9 +326,7 @@
 
 DEFUN ("unibyte-char-to-multibyte", Funibyte_char_to_multibyte,
        Sunibyte_char_to_multibyte, 1, 1, 0,
-       doc: /* Convert the unibyte character CH to multibyte character.
-The multibyte character is a result of decoding CH by
-the current unibyte charset (see `unibyte-charset').  */)
+       doc: /* Convert the byte CH to multibyte character.  */)
      (ch)
      Lisp_Object ch;
 {
@@ -348,18 +346,24 @@
 
 DEFUN ("multibyte-char-to-unibyte", Fmultibyte_char_to_unibyte,
        Smultibyte_char_to_unibyte, 1, 1, 0,
-       doc: /* Convert the multibyte character CH to unibyte character.\n\
-The unibyte character is a result of encoding CH by
-the current primary charset (value of `charset-primary').  */)
+       doc: /* Convert the multibyte character CH to a byte.
+If the multibyte character does not represent a byte, return -1.  */)
      (ch)
      Lisp_Object ch;
 {
-  int c;
+  int cm;
 
   CHECK_CHARACTER (ch);
-  c = XFASTINT (ch);
-  c = CHAR_TO_BYTE8 (c);
-  return make_number (c);
+  cm = XFASTINT (ch);
+  if (cm < 256)
+    /* Can't distinguish a byte read from a unibyte buffer from
+       a latin1 char, so let's let it slide.  */
+    return ch;
+  else
+    {
+      int cu = CHAR_TO_BYTE8 (cm);
+      return make_number (cu);
+    }
 }
 
 DEFUN ("char-bytes", Fchar_bytes, Schar_bytes, 1, 1, 0,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]