emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r110729: 2012-10-29 Daniel Colascione


From: Daniel Colascione
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110729: 2012-10-29 Daniel Colascione <address@hidden>
Date: Mon, 29 Oct 2012 09:24:29 -0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110729
committer: Daniel Colascione <address@hidden>
branch nick: trunk
timestamp: Mon 2012-10-29 09:24:29 -0800
message:
  2012-10-29  Daniel Colascione  <address@hidden>
  
  cygw32.h, cygw32.c (Qutf_16le, from_unicode, to_unicode): In
  preparation for fixing bug#12739, move these functions from
  here...
  
  * coding.h, coding.c: ... to here, and compile them only when
  WINDOWSNT or HAVE_NTGUI.  Moving these functions out of cygw32
  proper lets us write cygw32-agnostic code for the HAVE_NTGUI case.
modified:
  src/ChangeLog
  src/coding.c
  src/coding.h
  src/cygw32.c
  src/cygw32.h
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-10-28 17:42:52 +0000
+++ b/src/ChangeLog     2012-10-29 17:24:29 +0000
@@ -1,3 +1,13 @@
+2012-10-29  Daniel Colascione  <address@hidden>
+
+       * cygw32.h, cygw32.c (Qutf_16le, from_unicode, to_unicode): In
+       preparation for fixing bug#12739, move these functions from
+       here...
+
+       * coding.h, coding.c: ... to here, and compile them only when
+       WINDOWSNT or HAVE_NTGUI.  Moving these functions out of cygw32
+       proper lets us write cygw32-agnostic code for the HAVE_NTGUI case.
+
 2012-10-28  Eli Zaretskii  <address@hidden>
 
        * w32proc.c (TIMER_TICKS_PER_SEC): New macro.

=== modified file 'src/coding.c'
--- a/src/coding.c      2012-10-19 12:59:42 +0000
+++ b/src/coding.c      2012-10-29 17:24:29 +0000
@@ -343,6 +343,10 @@
 Lisp_Object Qemacs_mule, Qraw_text;
 Lisp_Object Qutf_8_emacs;
 
+#if defined (WINDOWSNT) || defined (HAVE_NTGUI)
+static Lisp_Object Qutf_16le;
+#endif
+
 /* Coding-systems are handed between Emacs Lisp programs and C internal
    routines by the following three variables.  */
 /* Coding system to be used to encode text for terminal display when
@@ -7971,6 +7975,39 @@
   return CODING_ID_NAME (id);
 }
 
+#if defined (WINDOWSNT) || defined (HAVE_NTGUI)
+
+Lisp_Object
+from_unicode (Lisp_Object str)
+{
+  CHECK_STRING (str);
+  if (!STRING_MULTIBYTE (str) &&
+      SBYTES (str) & 1)
+    {
+      str = Fsubstring (str, make_number (0), make_number (-1));
+    }
+
+  return code_convert_string_norecord (str, Qutf_16le, 0);
+}
+
+wchar_t *
+to_unicode (Lisp_Object str, Lisp_Object *buf)
+{
+  *buf = code_convert_string_norecord (str, Qutf_16le, 1);
+  /* We need to make a another copy (in addition to the one made by
+     code_convert_string_norecord) to ensure that the final string is
+     _doubly_ zero terminated --- that is, that the string is
+     terminated by two zero bytes and one utf-16le null character.
+     Because strings are already terminated with a single zero byte,
+     we just add one additional zero. */
+  str = make_uninit_string (SBYTES (*buf) + 1);
+  memcpy (SDATA (str), SDATA (*buf), SBYTES (*buf));
+  SDATA (str) [SBYTES (*buf)] = '\0';
+  *buf = str;
+  return WCSDATA (*buf);
+}
+#endif /* WINDOWSNT || HAVE_NTGUI */
+
 
 #ifdef emacs
 /*** 8. Emacs Lisp library functions ***/
@@ -10284,6 +10321,11 @@
   DEFSYM (Qutf_8, "utf-8");
   DEFSYM (Qutf_8_emacs, "utf-8-emacs");
 
+#if defined (WINDOWSNT) || defined (HAVE_NTGUI)
+  /* No, not utf-16-le: that one has a BOM.  */
+  DEFSYM (Qutf_16le, "utf-16le");
+#endif
+
   DEFSYM (Qutf_16, "utf-16");
   DEFSYM (Qbig, "big");
   DEFSYM (Qlittle, "little");

=== modified file 'src/coding.h'
--- a/src/coding.h      2012-10-02 00:31:56 +0000
+++ b/src/coding.h      2012-10-29 17:24:29 +0000
@@ -701,6 +701,28 @@
                                   Lisp_Object, ptrdiff_t, ptrdiff_t,
                                   ptrdiff_t, ptrdiff_t, Lisp_Object);
 
+#if defined (WINDOWSNT) || defined (HAVE_NTGUI)
+
+/* These functions use Lisp string objects to store the UTF-16LE
+   strings that modern versions of Windows expect.  These strings are
+   not particularly useful to Lisp, and all Lisp strings should be
+   native Emacs multibyte.  */
+
+/* Access the wide-character string stored in a Lisp string object.  */
+#define WCSDATA(x) ((wchar_t *) SDATA (x))
+
+/* Convert the multi-byte string in STR to UTF-16LE encoded unibyte
+   string, and store it in *BUF.  BUF may safely point to STR on entry.  */
+extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf);
+
+/* Convert STR, a UTF-16LE encoded string embedded in a unibyte string
+   object, to a multi-byte Emacs string and return it.  This function
+   calls code_convert_string_norecord internally and has all its
+   failure modes.  STR itself is not modified.  */
+extern Lisp_Object from_unicode (Lisp_Object str);
+
+#endif /* WINDOWSNT || HAVE_NTGUI */
+
 /* Macros for backward compatibility.  */
 
 #define decode_coding_region(coding, from, to)         \

=== modified file 'src/cygw32.c'
--- a/src/cygw32.c      2012-10-17 15:37:55 +0000
+++ b/src/cygw32.c      2012-10-29 17:24:29 +0000
@@ -22,7 +22,6 @@
 #include "buffer.h"
 #include <unistd.h>
 #include <fcntl.h>
-static Lisp_Object Qutf_16le;
 
 static Lisp_Object
 fchdir_unwind (Lisp_Object dir_fd)
@@ -107,36 +106,6 @@
   return unbind_to (count, DECODE_FILE (converted));
 }
 
-Lisp_Object
-from_unicode (Lisp_Object str)
-{
-  CHECK_STRING (str);
-  if (!STRING_MULTIBYTE (str) &&
-      SBYTES (str) & 1)
-    {
-      str = Fsubstring (str, make_number (0), make_number (-1));
-    }
-
-  return code_convert_string_norecord (str, Qutf_16le, 0);
-}
-
-wchar_t *
-to_unicode (Lisp_Object str, Lisp_Object *buf)
-{
-  *buf = code_convert_string_norecord (str, Qutf_16le, 1);
-  /* We need to make a another copy (in addition to the one made by
-     code_convert_string_norecord) to ensure that the final string is
-     _doubly_ zero terminated --- that is, that the string is
-     terminated by two zero bytes and one utf-16le null character.
-     Because strings are already terminated with a single zero byte,
-     we just add one additional zero. */
-  str = make_uninit_string (SBYTES (*buf) + 1);
-  memcpy (SDATA (str), SDATA (*buf), SBYTES (*buf));
-  SDATA (str) [SBYTES (*buf)] = '\0';
-  *buf = str;
-  return WCSDATA (*buf);
-}
-
 DEFUN ("cygwin-convert-path-to-windows",
        Fcygwin_convert_path_to_windows, Scygwin_convert_path_to_windows,
        1, 2, 0,
@@ -162,8 +131,6 @@
 void
 syms_of_cygw32 (void)
 {
-  /* No, not utf-16-le: that one has a BOM.  */
-  DEFSYM (Qutf_16le, "utf-16le");
   defsubr (&Scygwin_convert_path_from_windows);
   defsubr (&Scygwin_convert_path_to_windows);
 }

=== modified file 'src/cygw32.h'
--- a/src/cygw32.h      2012-10-08 12:53:18 +0000
+++ b/src/cygw32.h      2012-10-29 17:24:29 +0000
@@ -33,20 +33,6 @@
 #include "lisp.h"
 #include "coding.h"
 
-/* *** Character conversion *** */
-
-/* Access the wide-character string stored in a Lisp string object.  */
-#define WCSDATA(x) ((wchar_t *) SDATA (x))
-
-/* Convert the multi-byte string in STR to UTF-16LE encoded unibyte
-   string, and store it in *BUF.  BUF may safely point to STR on entry.  */
-extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf);
-
-/* Convert STR, a UTF-16LE encoded string embedded in a unibyte string
-   object, to a multi-byte Emacs string, and return it.  */
-extern Lisp_Object from_unicode (Lisp_Object str);
-
-/* *** Misc *** */
 extern void syms_of_cygw32 (void);
 extern char * w32_strerror (int error_no);
 


reply via email to

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