Mercurial > hg > xemacs-beta
comparison src/print.c @ 665:fdefd0186b75
[xemacs-hg @ 2001-09-20 06:28:42 by ben]
The great integral types renaming.
The purpose of this is to rationalize the names used for various
integral types, so that they match their intended uses and follow
consist conventions, and eliminate types that were not semantically
different from each other.
The conventions are:
-- All integral types that measure quantities of anything are
signed. Some people disagree vociferously with this, but their
arguments are mostly theoretical, and are vastly outweighed by
the practical headaches of mixing signed and unsigned values,
and more importantly by the far increased likelihood of
inadvertent bugs: Because of the broken "viral" nature of
unsigned quantities in C (operations involving mixed
signed/unsigned are done unsigned, when exactly the opposite is
nearly always wanted), even a single error in declaring a
quantity unsigned that should be signed, or even the even more
subtle error of comparing signed and unsigned values and
forgetting the necessary cast, can be catastrophic, as
comparisons will yield wrong results. -Wsign-compare is turned
on specifically to catch this, but this tends to result in a
great number of warnings when mixing signed and unsigned, and
the casts are annoying. More has been written on this
elsewhere.
-- All such quantity types just mentioned boil down to EMACS_INT,
which is 32 bits on 32-bit machines and 64 bits on 64-bit
machines. This is guaranteed to be the same size as Lisp
objects of type `int', and (as far as I can tell) of size_t
(unsigned!) and ssize_t. The only type below that is not an
EMACS_INT is Hashcode, which is an unsigned value of the same
size as EMACS_INT.
-- Type names should be relatively short (no more than 10
characters or so), with the first letter capitalized and no
underscores if they can at all be avoided.
-- "count" == a zero-based measurement of some quantity. Includes
sizes, offsets, and indexes.
-- "bpos" == a one-based measurement of a position in a buffer.
"Charbpos" and "Bytebpos" count text in the buffer, rather than
bytes in memory; thus Bytebpos does not directly correspond to
the memory representation. Use "Membpos" for this.
-- "Char" refers to internal-format characters, not to the C type
"char", which is really a byte.
-- For the actual name changes, see the script below.
I ran the following script to do the conversion. (NOTE: This script
is idempotent. You can safely run it multiple times and it will
not screw up previous results -- in fact, it will do nothing if
nothing has changed. Thus, it can be run repeatedly as necessary
to handle patches coming in from old workspaces, or old branches.)
There are two tags, just before and just after the change:
`pre-integral-type-rename' and `post-integral-type-rename'. When
merging code from the main trunk into a branch, the best thing to
do is first merge up to `pre-integral-type-rename', then apply the
script and associated changes, then merge from
`post-integral-type-change' to the present. (Alternatively, just do
the merging in one operation; but you may then have a lot of
conflicts needing to be resolved by hand.)
Script `fixtypes.sh' follows:
----------------------------------- cut ------------------------------------
files="*.[ch] s/*.h m/*.h config.h.in ../configure.in Makefile.in.in ../lib-src/*.[ch] ../lwlib/*.[ch]"
gr Memory_Count Bytecount $files
gr Lstream_Data_Count Bytecount $files
gr Element_Count Elemcount $files
gr Hash_Code Hashcode $files
gr extcount bytecount $files
gr bufpos charbpos $files
gr bytind bytebpos $files
gr memind membpos $files
gr bufbyte intbyte $files
gr Extcount Bytecount $files
gr Bufpos Charbpos $files
gr Bytind Bytebpos $files
gr Memind Membpos $files
gr Bufbyte Intbyte $files
gr EXTCOUNT BYTECOUNT $files
gr BUFPOS CHARBPOS $files
gr BYTIND BYTEBPOS $files
gr MEMIND MEMBPOS $files
gr BUFBYTE INTBYTE $files
gr MEMORY_COUNT BYTECOUNT $files
gr LSTREAM_DATA_COUNT BYTECOUNT $files
gr ELEMENT_COUNT ELEMCOUNT $files
gr HASH_CODE HASHCODE $files
----------------------------------- cut ------------------------------------
`fixtypes.sh' is a Bourne-shell script; it uses 'gr':
----------------------------------- cut ------------------------------------
#!/bin/sh
# Usage is like this:
# gr FROM TO FILES ...
# globally replace FROM with TO in FILES. FROM and TO are regular expressions.
# backup files are stored in the `backup' directory.
from="$1"
to="$2"
shift 2
echo ${1+"$@"} | xargs global-replace "s/$from/$to/g"
----------------------------------- cut ------------------------------------
`gr' in turn uses a Perl script to do its real work,
`global-replace', which follows:
----------------------------------- cut ------------------------------------
: #-*- Perl -*-
### global-modify --- modify the contents of a file by a Perl expression
## Copyright (C) 1999 Martin Buchholz.
## Copyright (C) 2001 Ben Wing.
## Authors: Martin Buchholz <martin@xemacs.org>, Ben Wing <ben@xemacs.org>
## Maintainer: Ben Wing <ben@xemacs.org>
## Current Version: 1.0, May 5, 2001
# This program 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 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with XEmacs; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
eval 'exec perl -w -S $0 ${1+"$@"}'
if 0;
use strict;
use FileHandle;
use Carp;
use Getopt::Long;
use File::Basename;
(my $myName = $0) =~ s@.*/@@; my $usage="
Usage: $myName [--help] [--backup-dir=DIR] [--line-mode] [--hunk-mode]
PERLEXPR FILE ...
Globally modify a file, either line by line or in one big hunk.
Typical usage is like this:
[with GNU print, GNU xargs: guaranteed to handle spaces, quotes, etc.
in file names]
find . -name '*.[ch]' -print0 | xargs -0 $0 's/\bCONST\b/const/g'\n
[with non-GNU print, xargs]
find . -name '*.[ch]' -print | xargs $0 's/\bCONST\b/const/g'\n
The file is read in, either line by line (with --line-mode specified)
or in one big hunk (with --hunk-mode specified; it's the default), and
the Perl expression is then evalled with \$_ set to the line or hunk of
text, including the terminating newline if there is one. It should
destructively modify the value there, storing the changed result in \$_.
Files in which any modifications are made are backed up to the directory
specified using --backup-dir, or to `backup' by default. To disable this,
use --backup-dir= with no argument.
Hunk mode is the default because it is MUCH MUCH faster than line-by-line.
Use line-by-line only when it matters, e.g. you want to do a replacement
only once per line (the default without the `g' argument). Conversely,
when using hunk mode, *ALWAYS* use `g'; otherwise, you will only make one
replacement in the entire file!
";
my %options = ();
$Getopt::Long::ignorecase = 0;
&GetOptions (
\%options,
'help', 'backup-dir=s', 'line-mode', 'hunk-mode',
);
die $usage if $options{"help"} or @ARGV <= 1;
my $code = shift;
die $usage if grep (-d || ! -w, @ARGV);
sub SafeOpen {
open ((my $fh = new FileHandle), $_[0]);
confess "Can't open $_[0]: $!" if ! defined $fh;
return $fh;
}
sub SafeClose {
close $_[0] or confess "Can't close $_[0]: $!";
}
sub FileContents {
my $fh = SafeOpen ("< $_[0]");
my $olddollarslash = $/;
local $/ = undef;
my $contents = <$fh>;
$/ = $olddollarslash;
return $contents;
}
sub WriteStringToFile {
my $fh = SafeOpen ("> $_[0]");
binmode $fh;
print $fh $_[1] or confess "$_[0]: $!\n";
SafeClose $fh;
}
foreach my $file (@ARGV) {
my $changed_p = 0;
my $new_contents = "";
if ($options{"line-mode"}) {
my $fh = SafeOpen $file;
while (<$fh>) {
my $save_line = $_;
eval $code;
$changed_p = 1 if $save_line ne $_;
$new_contents .= $_;
}
} else {
my $orig_contents = $_ = FileContents $file;
eval $code;
if ($_ ne $orig_contents) {
$changed_p = 1;
$new_contents = $_;
}
}
if ($changed_p) {
my $backdir = $options{"backup-dir"};
$backdir = "backup" if !defined ($backdir);
if ($backdir) {
my ($name, $path, $suffix) = fileparse ($file, "");
my $backfulldir = $path . $backdir;
my $backfile = "$backfulldir/$name";
mkdir $backfulldir, 0755 unless -d $backfulldir;
print "modifying $file (original saved in $backfile)\n";
rename $file, $backfile;
}
WriteStringToFile ($file, $new_contents);
}
}
----------------------------------- cut ------------------------------------
In addition to those programs, I needed to fix up a few other
things, particularly relating to the duplicate definitions of
types, now that some types merged with others. Specifically:
1. in lisp.h, removed duplicate declarations of Bytecount. The
changed code should now look like this: (In each code snippet
below, the first and last lines are the same as the original, as
are all lines outside of those lines. That allows you to locate
the section to be replaced, and replace the stuff in that
section, verifying that there isn't anything new added that
would need to be kept.)
--------------------------------- snip -------------------------------------
/* Counts of bytes or chars */
typedef EMACS_INT Bytecount;
typedef EMACS_INT Charcount;
/* Counts of elements */
typedef EMACS_INT Elemcount;
/* Hash codes */
typedef unsigned long Hashcode;
/* ------------------------ dynamic arrays ------------------- */
--------------------------------- snip -------------------------------------
2. in lstream.h, removed duplicate declaration of Bytecount.
Rewrote the comment about this type. The changed code should
now look like this:
--------------------------------- snip -------------------------------------
#endif
/* The have been some arguments over the what the type should be that
specifies a count of bytes in a data block to be written out or read in,
using Lstream_read(), Lstream_write(), and related functions.
Originally it was long, which worked fine; Martin "corrected" these to
size_t and ssize_t on the grounds that this is theoretically cleaner and
is in keeping with the C standards. Unfortunately, this practice is
horribly error-prone due to design flaws in the way that mixed
signed/unsigned arithmetic happens. In fact, by doing this change,
Martin introduced a subtle but fatal error that caused the operation of
sending large mail messages to the SMTP server under Windows to fail.
By putting all values back to be signed, avoiding any signed/unsigned
mixing, the bug immediately went away. The type then in use was
Lstream_Data_Count, so that it be reverted cleanly if a vote came to
that. Now it is Bytecount.
Some earlier comments about why the type must be signed: This MUST BE
SIGNED, since it also is used in functions that return the number of
bytes actually read to or written from in an operation, and these
functions can return -1 to signal error.
Note that the standard Unix read() and write() functions define the
count going in as a size_t, which is UNSIGNED, and the count going
out as an ssize_t, which is SIGNED. This is a horrible design
flaw. Not only is it highly likely to lead to logic errors when a
-1 gets interpreted as a large positive number, but operations are
bound to fail in all sorts of horrible ways when a number in the
upper-half of the size_t range is passed in -- this number is
unrepresentable as an ssize_t, so code that checks to see how many
bytes are actually written (which is mandatory if you are dealing
with certain types of devices) will get completely screwed up.
--ben
*/
typedef enum lstream_buffering
--------------------------------- snip -------------------------------------
3. in dumper.c, there are four places, all inside of switch()
statements, where XD_BYTECOUNT appears twice as a case tag. In
each case, the two case blocks contain identical code, and you
should *REMOVE THE SECOND* and leave the first.
author | ben |
---|---|
date | Thu, 20 Sep 2001 06:31:11 +0000 |
parents | 1c880911c386 |
children | 943eaba38521 |
comparison
equal
deleted
inserted
replaced
664:6e99cc8c6ca5 | 665:fdefd0186b75 |
---|---|
109 | 109 |
110 int stdout_needs_newline; | 110 int stdout_needs_newline; |
111 | 111 |
112 static void | 112 static void |
113 std_handle_out_external (FILE *stream, Lisp_Object lstream, | 113 std_handle_out_external (FILE *stream, Lisp_Object lstream, |
114 const Extbyte *extptr, Extcount extlen, | 114 const Extbyte *extptr, Bytecount extlen, |
115 /* is this really stdout/stderr? | 115 /* is this really stdout/stderr? |
116 (controls termscript writing) */ | 116 (controls termscript writing) */ |
117 int output_is_std_handle, | 117 int output_is_std_handle, |
118 int must_flush) | 118 int must_flush) |
119 { | 119 { |
174 mswindows_output_console_string(). */ | 174 mswindows_output_console_string(). */ |
175 | 175 |
176 static int | 176 static int |
177 std_handle_out_va (FILE *stream, const char *fmt, va_list args) | 177 std_handle_out_va (FILE *stream, const char *fmt, va_list args) |
178 { | 178 { |
179 Bufbyte kludge[8192]; | 179 Intbyte kludge[8192]; |
180 Extbyte *extptr; | 180 Extbyte *extptr; |
181 Extcount extlen; | 181 Bytecount extlen; |
182 int retval; | 182 int retval; |
183 | 183 |
184 retval = vsprintf ((char *) kludge, fmt, args); | 184 retval = vsprintf ((char *) kludge, fmt, args); |
185 if (initialized && !fatal_error_in_progress) | 185 if (initialized && !fatal_error_in_progress) |
186 TO_EXTERNAL_FORMAT (DATA, (kludge, strlen ((char *) kludge)), | 186 TO_EXTERNAL_FORMAT (DATA, (kludge, strlen ((char *) kludge)), |
187 ALLOCA, (extptr, extlen), | 187 ALLOCA, (extptr, extlen), |
188 Qnative); | 188 Qnative); |
189 else | 189 else |
190 { | 190 { |
191 extptr = (Extbyte *) kludge; | 191 extptr = (Extbyte *) kludge; |
192 extlen = (Extcount) strlen ((char *) kludge); | 192 extlen = (Bytecount) strlen ((char *) kludge); |
193 } | 193 } |
194 | 194 |
195 std_handle_out_external (stream, Qnil, extptr, extlen, 1, 1); | 195 std_handle_out_external (stream, Qnil, extptr, extlen, 1, 1); |
196 return retval; | 196 return retval; |
197 } | 197 } |
246 | 246 |
247 /* Write a string (in internal format) to stdio stream STREAM. */ | 247 /* Write a string (in internal format) to stdio stream STREAM. */ |
248 | 248 |
249 void | 249 void |
250 write_string_to_stdio_stream (FILE *stream, struct console *con, | 250 write_string_to_stdio_stream (FILE *stream, struct console *con, |
251 const Bufbyte *str, | 251 const Intbyte *str, |
252 Bytecount offset, Bytecount len, | 252 Bytecount offset, Bytecount len, |
253 Lisp_Object coding_system, | 253 Lisp_Object coding_system, |
254 int must_flush) | 254 int must_flush) |
255 { | 255 { |
256 Extcount extlen; | 256 Bytecount extlen; |
257 const Extbyte *extptr; | 257 const Extbyte *extptr; |
258 | 258 |
259 /* #### yuck! sometimes this function is called with string data, | 259 /* #### yuck! sometimes this function is called with string data, |
260 and the following call may gc. */ | 260 and the following call may gc. */ |
261 { | 261 { |
262 Bufbyte *puta = (Bufbyte *) alloca (len); | 262 Intbyte *puta = (Intbyte *) alloca (len); |
263 memcpy (puta, str + offset, len); | 263 memcpy (puta, str + offset, len); |
264 TO_EXTERNAL_FORMAT (DATA, (puta, len), | 264 TO_EXTERNAL_FORMAT (DATA, (puta, len), |
265 ALLOCA, (extptr, extlen), | 265 ALLOCA, (extptr, extlen), |
266 coding_system); | 266 coding_system); |
267 } | 267 } |
281 /* Write a string to the output location specified in FUNCTION. | 281 /* Write a string to the output location specified in FUNCTION. |
282 Arguments NONRELOC, RELOC, OFFSET, and LEN are as in | 282 Arguments NONRELOC, RELOC, OFFSET, and LEN are as in |
283 buffer_insert_string_1() in insdel.c. */ | 283 buffer_insert_string_1() in insdel.c. */ |
284 | 284 |
285 static void | 285 static void |
286 output_string (Lisp_Object function, const Bufbyte *nonreloc, | 286 output_string (Lisp_Object function, const Intbyte *nonreloc, |
287 Lisp_Object reloc, Bytecount offset, Bytecount len) | 287 Lisp_Object reloc, Bytecount offset, Bytecount len) |
288 { | 288 { |
289 /* This function can GC */ | 289 /* This function can GC */ |
290 Charcount cclen; | 290 Charcount cclen; |
291 /* We change the value of nonreloc (fetching it from reloc as | 291 /* We change the value of nonreloc (fetching it from reloc as |
292 necessary), but we don't want to pass this changed value on to | 292 necessary), but we don't want to pass this changed value on to |
293 other functions that take both a nonreloc and a reloc, or things | 293 other functions that take both a nonreloc and a reloc, or things |
294 may get confused and an assertion failure in | 294 may get confused and an assertion failure in |
295 fixup_internal_substring() may get triggered. */ | 295 fixup_internal_substring() may get triggered. */ |
296 const Bufbyte *newnonreloc = nonreloc; | 296 const Intbyte *newnonreloc = nonreloc; |
297 struct gcpro gcpro1, gcpro2; | 297 struct gcpro gcpro1, gcpro2; |
298 | 298 |
299 /* Emacs won't print while GCing, but an external debugger might */ | 299 /* Emacs won't print while GCing, but an external debugger might */ |
300 if (gc_in_progress) return; | 300 if (gc_in_progress) return; |
301 | 301 |
317 relocating the string. For small strings, we do it by | 317 relocating the string. For small strings, we do it by |
318 alloc'ing the string and using a copy; for large strings, | 318 alloc'ing the string and using a copy; for large strings, |
319 we inhibit GC. */ | 319 we inhibit GC. */ |
320 if (len < 65536) | 320 if (len < 65536) |
321 { | 321 { |
322 Bufbyte *copied = alloca_array (Bufbyte, len); | 322 Intbyte *copied = alloca_array (Intbyte, len); |
323 memcpy (copied, newnonreloc + offset, len); | 323 memcpy (copied, newnonreloc + offset, len); |
324 Lstream_write (XLSTREAM (function), copied, len); | 324 Lstream_write (XLSTREAM (function), copied, len); |
325 } | 325 } |
326 else | 326 else |
327 { | 327 { |
345 buffer_insert_string (XBUFFER (function), nonreloc, reloc, offset, len); | 345 buffer_insert_string (XBUFFER (function), nonreloc, reloc, offset, len); |
346 } | 346 } |
347 else if (MARKERP (function)) | 347 else if (MARKERP (function)) |
348 { | 348 { |
349 /* marker_position() will err if marker doesn't point anywhere. */ | 349 /* marker_position() will err if marker doesn't point anywhere. */ |
350 Bufpos spoint = marker_position (function); | 350 Charbpos spoint = marker_position (function); |
351 | 351 |
352 buffer_insert_string_1 (XMARKER (function)->buffer, | 352 buffer_insert_string_1 (XMARKER (function)->buffer, |
353 spoint, nonreloc, reloc, offset, len, | 353 spoint, nonreloc, reloc, offset, len, |
354 0); | 354 0); |
355 Fset_marker (function, make_int (spoint + cclen), | 355 Fset_marker (function, make_int (spoint + cclen), |
476 } | 476 } |
477 } | 477 } |
478 | 478 |
479 /* Used for printing a single-byte character (*not* any Emchar). */ | 479 /* Used for printing a single-byte character (*not* any Emchar). */ |
480 #define write_char_internal(string_of_length_1, stream) \ | 480 #define write_char_internal(string_of_length_1, stream) \ |
481 output_string (stream, (const Bufbyte *) (string_of_length_1), \ | 481 output_string (stream, (const Intbyte *) (string_of_length_1), \ |
482 Qnil, 0, 1) | 482 Qnil, 0, 1) |
483 | 483 |
484 /* NOTE: Do not call this with the data of a Lisp_String, as | 484 /* NOTE: Do not call this with the data of a Lisp_String, as |
485 printcharfun might cause a GC, which might cause the string's data | 485 printcharfun might cause a GC, which might cause the string's data |
486 to be relocated. To princ a Lisp string, use: | 486 to be relocated. To princ a Lisp string, use: |
489 | 489 |
490 Also note that STREAM should be the result of | 490 Also note that STREAM should be the result of |
491 canonicalize_printcharfun() (i.e. Qnil means stdout, not | 491 canonicalize_printcharfun() (i.e. Qnil means stdout, not |
492 Vstandard_output, etc.) */ | 492 Vstandard_output, etc.) */ |
493 void | 493 void |
494 write_string_1 (const Bufbyte *str, Bytecount size, Lisp_Object stream) | 494 write_string_1 (const Intbyte *str, Bytecount size, Lisp_Object stream) |
495 { | 495 { |
496 /* This function can GC */ | 496 /* This function can GC */ |
497 #ifdef ERROR_CHECK_BUFPOS | 497 #ifdef ERROR_CHECK_CHARBPOS |
498 assert (size >= 0); | 498 assert (size >= 0); |
499 #endif | 499 #endif |
500 output_string (stream, str, Qnil, 0, size); | 500 output_string (stream, str, Qnil, 0, size); |
501 } | 501 } |
502 | 502 |
503 void | 503 void |
504 write_c_string (const char *str, Lisp_Object stream) | 504 write_c_string (const char *str, Lisp_Object stream) |
505 { | 505 { |
506 /* This function can GC */ | 506 /* This function can GC */ |
507 write_string_1 ((const Bufbyte *) str, strlen (str), stream); | 507 write_string_1 ((const Intbyte *) str, strlen (str), stream); |
508 } | 508 } |
509 | 509 |
510 | 510 |
511 DEFUN ("write-char", Fwrite_char, 1, 2, 0, /* | 511 DEFUN ("write-char", Fwrite_char, 1, 2, 0, /* |
512 Output character CHARACTER to stream STREAM. | 512 Output character CHARACTER to stream STREAM. |
513 STREAM defaults to the value of `standard-output' (which see). | 513 STREAM defaults to the value of `standard-output' (which see). |
514 */ | 514 */ |
515 (character, stream)) | 515 (character, stream)) |
516 { | 516 { |
517 /* This function can GC */ | 517 /* This function can GC */ |
518 Bufbyte str[MAX_EMCHAR_LEN]; | 518 Intbyte str[MAX_EMCHAR_LEN]; |
519 Bytecount len; | 519 Bytecount len; |
520 | 520 |
521 CHECK_CHAR_COERCE_INT (character); | 521 CHECK_CHAR_COERCE_INT (character); |
522 len = set_charptr_emchar (str, XCHAR (character)); | 522 len = set_charptr_emchar (str, XCHAR (character)); |
523 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, len); | 523 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, len); |
867 * -wsr | 867 * -wsr |
868 */ | 868 */ |
869 void | 869 void |
870 float_to_string (char *buf, double data) | 870 float_to_string (char *buf, double data) |
871 { | 871 { |
872 Bufbyte *cp, c; | 872 Intbyte *cp, c; |
873 int width; | 873 int width; |
874 | 874 |
875 if (NILP (Vfloat_output_format) | 875 if (NILP (Vfloat_output_format) |
876 || !STRINGP (Vfloat_output_format)) | 876 || !STRINGP (Vfloat_output_format)) |
877 lose: | 877 lose: |
912 the read-equivalence of lisp objects. (* x 1) and (* x 1.0) do | 912 the read-equivalence of lisp objects. (* x 1) and (* x 1.0) do |
913 not do the same thing, so it's important that the printed | 913 not do the same thing, so it's important that the printed |
914 representation of that form not be corrupted by the printer. | 914 representation of that form not be corrupted by the printer. |
915 */ | 915 */ |
916 { | 916 { |
917 Bufbyte *s = (Bufbyte *) buf; /* don't use signed chars here! | 917 Intbyte *s = (Intbyte *) buf; /* don't use signed chars here! |
918 isdigit() can't hack them! */ | 918 isdigit() can't hack them! */ |
919 if (*s == '-') s++; | 919 if (*s == '-') s++; |
920 for (; *s; s++) | 920 for (; *s; s++) |
921 /* if there's a non-digit, then there is a decimal point, or | 921 /* if there's a non-digit, then there is a decimal point, or |
922 it's in exponential notation, both of which are ok. */ | 922 it's in exponential notation, both of which are ok. */ |
1190 Bytecount i, last = 0; | 1190 Bytecount i, last = 0; |
1191 | 1191 |
1192 write_char_internal ("\"", printcharfun); | 1192 write_char_internal ("\"", printcharfun); |
1193 for (i = 0; i < bcmax; i++) | 1193 for (i = 0; i < bcmax; i++) |
1194 { | 1194 { |
1195 Bufbyte ch = string_byte (s, i); | 1195 Intbyte ch = string_byte (s, i); |
1196 if (ch == '\"' || ch == '\\' | 1196 if (ch == '\"' || ch == '\\' |
1197 || (ch == '\n' && print_escape_newlines)) | 1197 || (ch == '\n' && print_escape_newlines)) |
1198 { | 1198 { |
1199 if (i > last) | 1199 if (i > last) |
1200 { | 1200 { |
1364 *p++ = '\\', *p++ = '^', *p++ = '?'; | 1364 *p++ = '\\', *p++ = '^', *p++ = '?'; |
1365 } | 1365 } |
1366 else if (ch < 160) | 1366 else if (ch < 160) |
1367 { | 1367 { |
1368 *p++ = '\\', *p++ = '^'; | 1368 *p++ = '\\', *p++ = '^'; |
1369 p += set_charptr_emchar ((Bufbyte *) p, ch + 64); | 1369 p += set_charptr_emchar ((Intbyte *) p, ch + 64); |
1370 } | 1370 } |
1371 else | 1371 else |
1372 { | 1372 { |
1373 p += set_charptr_emchar ((Bufbyte *) p, ch); | 1373 p += set_charptr_emchar ((Intbyte *) p, ch); |
1374 } | 1374 } |
1375 | 1375 |
1376 output_string (printcharfun, (Bufbyte *) buf, Qnil, 0, p - buf); | 1376 output_string (printcharfun, (Intbyte *) buf, Qnil, 0, p - buf); |
1377 | 1377 |
1378 break; | 1378 break; |
1379 } | 1379 } |
1380 | 1380 |
1381 case Lisp_Type_Record: | 1381 case Lisp_Type_Record: |
1506 write_c_string ("#:", printcharfun); | 1506 write_c_string ("#:", printcharfun); |
1507 } | 1507 } |
1508 | 1508 |
1509 /* Does it look like an integer or a float? */ | 1509 /* Does it look like an integer or a float? */ |
1510 { | 1510 { |
1511 Bufbyte *data = string_data (name); | 1511 Intbyte *data = string_data (name); |
1512 Bytecount confusing = 0; | 1512 Bytecount confusing = 0; |
1513 | 1513 |
1514 if (size == 0) | 1514 if (size == 0) |
1515 goto not_yet_confused; /* Really confusing */ | 1515 goto not_yet_confused; /* Really confusing */ |
1516 else if (isdigit (data[0])) | 1516 else if (isdigit (data[0])) |
1589 to be passed to `print'. Before calling `print', set `alternate_do_pointer' | 1589 to be passed to `print'. Before calling `print', set `alternate_do_pointer' |
1590 to 0. | 1590 to 0. |
1591 */ | 1591 */ |
1592 (character)) | 1592 (character)) |
1593 { | 1593 { |
1594 Bufbyte str[MAX_EMCHAR_LEN]; | 1594 Intbyte str[MAX_EMCHAR_LEN]; |
1595 Bytecount len; | 1595 Bytecount len; |
1596 int extlen; | 1596 int extlen; |
1597 const Extbyte *extptr; | 1597 const Extbyte *extptr; |
1598 | 1598 |
1599 CHECK_CHAR_COERCE_INT (character); | 1599 CHECK_CHAR_COERCE_INT (character); |
1652 XSTRING_DATA (char_or_string), | 1652 XSTRING_DATA (char_or_string), |
1653 0, XSTRING_LENGTH (char_or_string), | 1653 0, XSTRING_LENGTH (char_or_string), |
1654 Qterminal, 1); | 1654 Qterminal, 1); |
1655 else | 1655 else |
1656 { | 1656 { |
1657 Bufbyte str[MAX_EMCHAR_LEN]; | 1657 Intbyte str[MAX_EMCHAR_LEN]; |
1658 Bytecount len; | 1658 Bytecount len; |
1659 | 1659 |
1660 CHECK_CHAR_COERCE_INT (char_or_string); | 1660 CHECK_CHAR_COERCE_INT (char_or_string); |
1661 len = set_charptr_emchar (str, XCHAR (char_or_string)); | 1661 len = set_charptr_emchar (str, XCHAR (char_or_string)); |
1662 write_string_to_stdio_stream (file, con, str, 0, len, Qterminal, 1); | 1662 write_string_to_stdio_stream (file, con, str, 0, len, Qterminal, 1); |