]> code.delx.au - gnu-emacs/blobdiff - src/print.c
Rework C source files to avoid ^(
[gnu-emacs] / src / print.c
index d3b1a927b2267966fc02c023ef34caab6a82083d..2b53d7580b1a089ff6e9eb66b9493b27eddbf575 100644 (file)
@@ -1,14 +1,14 @@
 /* Lisp object printing and output streams.
 
-Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2015 Free Software
+Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2016 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,24 +24,22 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "character.h"
+#include "coding.h"
 #include "buffer.h"
 #include "charset.h"
-#include "keyboard.h"
 #include "frame.h"
-#include "window.h"
 #include "process.h"
-#include "dispextern.h"
 #include "disptab.h"
-#include "termchar.h"
 #include "intervals.h"
 #include "blockinput.h"
-#include "termhooks.h"         /* For struct terminal.  */
-#include "font.h"
+#include "xwidget.h"
 
 #include <c-ctype.h>
 #include <float.h>
 #include <ftoastr.h>
 
+struct terminal;
+
 /* Avoid actual stack overflow in print.  */
 static ptrdiff_t print_depth;
 
@@ -203,6 +201,13 @@ printchar_to_stream (unsigned int ch, FILE *stream)
 {
   Lisp_Object dv IF_LINT (= Qnil);
   ptrdiff_t i = 0, n = 1;
+  Lisp_Object coding_system = Vlocale_coding_system;
+  bool encode_p = false;
+
+  if (!NILP (Vcoding_system_for_write))
+    coding_system = Vcoding_system_for_write;
+  if (!NILP (coding_system))
+    encode_p = true;
 
   if (CHAR_VALID_P (ch) && DISP_TABLE_P (Vstandard_display_table))
     {
@@ -231,8 +236,11 @@ printchar_to_stream (unsigned int ch, FILE *stream)
          unsigned char mbstr[MAX_MULTIBYTE_LENGTH];
          int len = CHAR_STRING (ch, mbstr);
          Lisp_Object encoded_ch =
-           ENCODE_SYSTEM (make_multibyte_string ((char *) mbstr, 1, len));
+           make_multibyte_string ((char *) mbstr, 1, len);
 
+         if (encode_p)
+           encoded_ch = code_convert_string_norecord (encoded_ch,
+                                                      coding_system, true);
          fwrite (SSDATA (encoded_ch), 1, SBYTES (encoded_ch), stream);
 #ifdef WINDOWSNT
          if (print_output_debug_flag && stream == stderr)
@@ -1729,6 +1737,11 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
          print_c_string (XSUBR (obj)->symbol_name, printcharfun);
          printchar ('>', printcharfun);
        }
+      else if (XWIDGETP (obj) || XWIDGET_VIEW_P (obj))
+       {
+         print_c_string ("#<xwidget ", printcharfun);
+         printchar ('>', printcharfun);
+       }
       else if (WINDOWP (obj))
        {
          int len = sprintf (buf, "#<window %"pI"d",
@@ -1993,6 +2006,19 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
          printchar ('>', printcharfun);
           break;
 
+#ifdef HAVE_MODULES
+       case Lisp_Misc_User_Ptr:
+         {
+           print_c_string ("#<user-ptr ", printcharfun);
+           int i = sprintf (buf, "ptr=%p finalizer=%p",
+                            XUSER_PTR (obj)->p,
+                            XUSER_PTR (obj)->finalizer);
+           strout (buf, i, i, printcharfun);
+           printchar ('>', printcharfun);
+           break;
+         }
+#endif
+
         case Lisp_Misc_Finalizer:
           print_c_string ("#<finalizer", printcharfun);
           if (NILP (XFINALIZER (obj)->function))
@@ -2212,7 +2238,7 @@ This affects only `prin1'.  */);
 
   DEFVAR_BOOL ("print-quoted", print_quoted,
               doc: /* Non-nil means print quoted forms with reader syntax.
-I.e., (quote foo) prints as 'foo, (function foo) as #'foo.  */);
+I.e., (quote foo) prints as \\='foo, (function foo) as #\\='foo.  */);
   print_quoted = 0;
 
   DEFVAR_LISP ("print-gensym", Vprint_gensym,