Mercurial > hg > xemacs-beta
diff src/insdel.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 | b39c14581166 |
children | 760db937b9ee |
line wrap: on
line diff
--- a/src/insdel.c Tue Sep 18 05:06:57 2001 +0000 +++ b/src/insdel.c Thu Sep 20 06:31:11 2001 +0000 @@ -31,7 +31,7 @@ of these are one-based: the beginning of the buffer is position or index 1, and 0 is not a valid position. - As a "buffer position" (typedef Bufpos): + As a "buffer position" (typedef Charbpos): This is an index specifying an offset in characters from the beginning of the buffer. Note that buffer positions are @@ -40,7 +40,7 @@ characters between those positions. Buffer positions are the only kind of position externally visible to the user. - As a "byte index" (typedef Bytind): + As a "byte index" (typedef Bytebpos): This is an index over the bytes used to represent the characters in the buffer. If there is no Mule support, this is identical @@ -50,7 +50,7 @@ byte index may be greater than the corresponding buffer position. - As a "memory index" (typedef Memind): + As a "memory index" (typedef Membpos): This is the byte index adjusted for the gap. For positions before the gap, this is identical to the byte index. For @@ -91,19 +91,19 @@ This means that Emchar values are upwardly compatible with the standard 8-bit representation of ASCII/ISO-8859-1. - Bufbyte: + Intbyte: -------- - The data in a buffer or string is logically made up of Bufbyte - objects, where a Bufbyte takes up the same amount of space as a + The data in a buffer or string is logically made up of Intbyte + objects, where a Intbyte takes up the same amount of space as a char. (It is declared differently, though, to catch invalid - usages.) Strings stored using Bufbytes are said to be in + usages.) Strings stored using Intbytes are said to be in "internal format". The important characteristics of internal format are - -- ASCII characters are represented as a single Bufbyte, + -- ASCII characters are represented as a single Intbyte, in the range 0 - 0x7f. - -- All other characters are represented as a Bufbyte in - the range 0x80 - 0x9f followed by one or more Bufbytes + -- All other characters are represented as a Intbyte in + the range 0x80 - 0x9f followed by one or more Intbytes in the range 0xa0 to 0xff. This leads to a number of desirable properties: @@ -152,14 +152,14 @@ This typedef represents a count of characters, such as a character offset into a string or the number of characters between two positions in a buffer. The - difference between two Bufpos's is a Charcount, and + difference between two Charbpos's is a Charcount, and character positions in a string are represented using a Charcount. Bytecount: ---------- Similar to a Charcount but represents a count of bytes. - The difference between two Bytind's is a Bytecount. + The difference between two Bytebpos's is a Bytecount. Usage of the various representations: @@ -211,14 +211,14 @@ #include "line-number.h" /* We write things this way because it's very important the - MAX_BYTIND_GAP_SIZE_3 is a multiple of 3. (As it happens, + MAX_BYTEBPOS_GAP_SIZE_3 is a multiple of 3. (As it happens, 65535 is a multiple of 3, but this may not always be the case.) */ -#define MAX_BUFPOS_GAP_SIZE_3 (65535/3) -#define MAX_BYTIND_GAP_SIZE_3 (3 * MAX_BUFPOS_GAP_SIZE_3) - -short three_to_one_table[1 + MAX_BYTIND_GAP_SIZE_3]; +#define MAX_CHARBPOS_GAP_SIZE_3 (65535/3) +#define MAX_BYTEBPOS_GAP_SIZE_3 (3 * MAX_CHARBPOS_GAP_SIZE_3) + +short three_to_one_table[1 + MAX_BYTEBPOS_GAP_SIZE_3]; /* Various macros modelled along the lines of those in buffer.h. Purposefully omitted from buffer.h because files other than this @@ -303,10 +303,10 @@ the equivalent length in characters. */ Charcount -bytecount_to_charcount (const Bufbyte *ptr, Bytecount len) +bytecount_to_charcount (const Intbyte *ptr, Bytecount len) { Charcount count = 0; - const Bufbyte *end = ptr + len; + const Intbyte *end = ptr + len; #if SIZEOF_LONG == 8 # define STRIDE_TYPE long @@ -339,29 +339,29 @@ (const unsigned STRIDE_TYPE *) ptr; /* This loop screams, because we can typically detect ASCII characters 8 at a time. */ - while ((const Bufbyte *) ascii_end + STRIDE <= end + while ((const Intbyte *) ascii_end + STRIDE <= end && !(*ascii_end & HIGH_BIT_MASK)) ascii_end++; - if ((Bufbyte *) ascii_end == ptr) + if ((Intbyte *) ascii_end == ptr) ptr++, count++; else { - count += (Bufbyte *) ascii_end - ptr; - ptr = (Bufbyte *) ascii_end; + count += (Intbyte *) ascii_end - ptr; + ptr = (Intbyte *) ascii_end; } } } else { /* optimize for successive characters from the same charset */ - Bufbyte leading_byte = *ptr; - Memory_Count bytes = REP_BYTES_BY_FIRST_BYTE (leading_byte); + Intbyte leading_byte = *ptr; + Bytecount bytes = REP_BYTES_BY_FIRST_BYTE (leading_byte); while ((ptr < end) && (*ptr == leading_byte)) ptr += bytes, count++; } } -#ifdef ERROR_CHECK_BUFPOS +#ifdef ERROR_CHECK_CHARBPOS /* Bomb out if the specified substring ends in the middle of a character. Note that we might have already gotten a core dump above from an invalid reference, but at least @@ -376,9 +376,9 @@ the equivalent length in bytes. */ Bytecount -charcount_to_bytecount (const Bufbyte *ptr, Charcount len) +charcount_to_bytecount (const Intbyte *ptr, Charcount len) { - const Bufbyte *newptr = ptr; + const Intbyte *newptr = ptr; while (len > 0) { @@ -389,14 +389,14 @@ } /* The next two functions are the actual meat behind the - bufpos-to-bytind and bytind-to-bufpos conversions. Currently + charbpos-to-bytebpos and bytebpos-to-charbpos conversions. Currently the method they use is fairly unsophisticated; see buffer.h. - Note that bufpos_to_bytind_func() is probably the most-called + Note that charbpos_to_bytebpos_func() is probably the most-called function in all of XEmacs. Therefore, it must be FAST FAST FAST. This is the reason why so much of the code is duplicated. - Similar considerations apply to bytind_to_bufpos_func(), although + Similar considerations apply to bytebpos_to_charbpos_func(), although less so because the function is not called so often. #### At some point this should use a more sophisticated method; @@ -404,16 +404,16 @@ static int not_very_random_number; -Bytind -bufpos_to_bytind_func (struct buffer *buf, Bufpos x) +Bytebpos +charbpos_to_bytebpos_func (struct buffer *buf, Charbpos x) { - Bufpos bufmin; - Bufpos bufmax; - Bytind bytmin; - Bytind bytmax; + Charbpos bufmin; + Charbpos bufmax; + Bytebpos bytmin; + Bytebpos bytmax; int size; int forward_p; - Bytind retval; + Bytebpos retval; int diff_so_far; int add_to_cache = 0; @@ -445,9 +445,9 @@ if (x > bufmax) { - Bufpos diffmax = x - bufmax; - Bufpos diffpt = x - BUF_PT (buf); - Bufpos diffzv = BUF_ZV (buf) - x; + Charbpos diffmax = x - bufmax; + Charbpos diffpt = x - BUF_PT (buf); + Charbpos diffzv = BUF_ZV (buf) - x; /* #### This value could stand some more exploration. */ Charcount heuristic_hack = (bufmax - bufmin) >> 2; @@ -487,15 +487,15 @@ size = 1; } } -#ifdef ERROR_CHECK_BUFPOS +#ifdef ERROR_CHECK_CHARBPOS else if (x >= bufmin) abort (); #endif else { - Bufpos diffmin = bufmin - x; - Bufpos diffpt = BUF_PT (buf) - x; - Bufpos diffbegv = x - BUF_BEGV (buf); + Charbpos diffmin = bufmin - x; + Charbpos diffpt = BUF_PT (buf) - x; + Charbpos diffbegv = x - BUF_BEGV (buf); /* #### This value could stand some more exploration. */ Charcount heuristic_hack = (bufmax - bufmin) >> 2; @@ -545,7 +545,7 @@ it doesn't seem like it would really matter. */ for (i = 0; i < 16; i++) { - int diff = buf->text->mule_bufpos_cache[i] - x; + int diff = buf->text->mule_charbpos_cache[i] - x; if (diff < 0) diff = -diff; @@ -558,8 +558,8 @@ if (minval < diff_so_far) { - bufmax = bufmin = buf->text->mule_bufpos_cache[found]; - bytmax = bytmin = buf->text->mule_bytind_cache[found]; + bufmax = bufmin = buf->text->mule_charbpos_cache[found]; + bytmax = bytmin = buf->text->mule_bytebpos_cache[found]; size = 1; } } @@ -568,7 +568,7 @@ the same as one of the range edges. */ if (x >= bufmax) { - Bytind newmax; + Bytebpos newmax; Bytecount newsize; forward_p = 1; @@ -576,7 +576,7 @@ { newmax = bytmax; - INC_BYTIND (buf, newmax); + INC_BYTEBPOS (buf, newmax); newsize = newmax - bytmax; if (newsize != size) { @@ -594,7 +594,7 @@ } else /* x < bufmin */ { - Bytind newmin; + Bytebpos newmin; Bytecount newsize; forward_p = 0; @@ -602,7 +602,7 @@ { newmin = bytmin; - DEC_BYTIND (buf, newmin); + DEC_BYTEBPOS (buf, newmin); newsize = bytmin - newmin; if (newsize != size) { @@ -630,17 +630,17 @@ buf->text->mule_three_p = 1; buf->text->mule_shifter = 1; - if (gap > MAX_BYTIND_GAP_SIZE_3) + if (gap > MAX_BYTEBPOS_GAP_SIZE_3) { if (forward_p) { - bytmin = bytmax - MAX_BYTIND_GAP_SIZE_3; - bufmin = bufmax - MAX_BUFPOS_GAP_SIZE_3; + bytmin = bytmax - MAX_BYTEBPOS_GAP_SIZE_3; + bufmin = bufmax - MAX_CHARBPOS_GAP_SIZE_3; } else { - bytmax = bytmin + MAX_BYTIND_GAP_SIZE_3; - bufmax = bufmin + MAX_BUFPOS_GAP_SIZE_3; + bytmax = bytmin + MAX_BYTEBPOS_GAP_SIZE_3; + bufmax = bufmin + MAX_CHARBPOS_GAP_SIZE_3; } } } @@ -671,8 +671,8 @@ it's worth it to go to the trouble of maintaining that. */ not_very_random_number += 621; replace_loc = not_very_random_number & 15; - buf->text->mule_bufpos_cache[replace_loc] = x; - buf->text->mule_bytind_cache[replace_loc] = retval; + buf->text->mule_charbpos_cache[replace_loc] = x; + buf->text->mule_bytebpos_cache[replace_loc] = retval; } return retval; @@ -681,16 +681,16 @@ /* The logic in this function is almost identical to the logic in the previous function. */ -Bufpos -bytind_to_bufpos_func (struct buffer *buf, Bytind x) +Charbpos +bytebpos_to_charbpos_func (struct buffer *buf, Bytebpos x) { - Bufpos bufmin; - Bufpos bufmax; - Bytind bytmin; - Bytind bytmax; + Charbpos bufmin; + Charbpos bufmax; + Bytebpos bytmin; + Bytebpos bytmax; int size; int forward_p; - Bufpos retval; + Charbpos retval; int diff_so_far; int add_to_cache = 0; @@ -722,9 +722,9 @@ if (x > bytmax) { - Bytind diffmax = x - bytmax; - Bytind diffpt = x - BI_BUF_PT (buf); - Bytind diffzv = BI_BUF_ZV (buf) - x; + Bytebpos diffmax = x - bytmax; + Bytebpos diffpt = x - BI_BUF_PT (buf); + Bytebpos diffzv = BI_BUF_ZV (buf) - x; /* #### This value could stand some more exploration. */ Bytecount heuristic_hack = (bytmax - bytmin) >> 2; @@ -764,15 +764,15 @@ size = 1; } } -#ifdef ERROR_CHECK_BUFPOS +#ifdef ERROR_CHECK_CHARBPOS else if (x >= bytmin) abort (); #endif else { - Bytind diffmin = bytmin - x; - Bytind diffpt = BI_BUF_PT (buf) - x; - Bytind diffbegv = x - BI_BUF_BEGV (buf); + Bytebpos diffmin = bytmin - x; + Bytebpos diffpt = BI_BUF_PT (buf) - x; + Bytebpos diffbegv = x - BI_BUF_BEGV (buf); /* #### This value could stand some more exploration. */ Bytecount heuristic_hack = (bytmax - bytmin) >> 2; @@ -822,7 +822,7 @@ it doesn't seem like it would really matter. */ for (i = 0; i < 16; i++) { - int diff = buf->text->mule_bytind_cache[i] - x; + int diff = buf->text->mule_bytebpos_cache[i] - x; if (diff < 0) diff = -diff; @@ -835,8 +835,8 @@ if (minval < diff_so_far) { - bufmax = bufmin = buf->text->mule_bufpos_cache[found]; - bytmax = bytmin = buf->text->mule_bytind_cache[found]; + bufmax = bufmin = buf->text->mule_charbpos_cache[found]; + bytmax = bytmin = buf->text->mule_bytebpos_cache[found]; size = 1; } } @@ -845,7 +845,7 @@ the same as one of the range edges. */ if (x >= bytmax) { - Bytind newmax; + Bytebpos newmax; Bytecount newsize; forward_p = 1; @@ -853,7 +853,7 @@ { newmax = bytmax; - INC_BYTIND (buf, newmax); + INC_BYTEBPOS (buf, newmax); newsize = newmax - bytmax; if (newsize != size) { @@ -871,7 +871,7 @@ } else /* x <= bytmin */ { - Bytind newmin; + Bytebpos newmin; Bytecount newsize; forward_p = 0; @@ -879,7 +879,7 @@ { newmin = bytmin; - DEC_BYTIND (buf, newmin); + DEC_BYTEBPOS (buf, newmin); newsize = bytmin - newmin; if (newsize != size) { @@ -907,17 +907,17 @@ buf->text->mule_three_p = 1; buf->text->mule_shifter = 1; - if (gap > MAX_BYTIND_GAP_SIZE_3) + if (gap > MAX_BYTEBPOS_GAP_SIZE_3) { if (forward_p) { - bytmin = bytmax - MAX_BYTIND_GAP_SIZE_3; - bufmin = bufmax - MAX_BUFPOS_GAP_SIZE_3; + bytmin = bytmax - MAX_BYTEBPOS_GAP_SIZE_3; + bufmin = bufmax - MAX_CHARBPOS_GAP_SIZE_3; } else { - bytmax = bytmin + MAX_BYTIND_GAP_SIZE_3; - bufmax = bufmin + MAX_BUFPOS_GAP_SIZE_3; + bytmax = bytmin + MAX_BYTEBPOS_GAP_SIZE_3; + bufmax = bufmin + MAX_CHARBPOS_GAP_SIZE_3; } } } @@ -948,18 +948,18 @@ it's worth it to go to the trouble of maintaining that. */ not_very_random_number += 621; replace_loc = not_very_random_number & 15; - buf->text->mule_bufpos_cache[replace_loc] = retval; - buf->text->mule_bytind_cache[replace_loc] = x; + buf->text->mule_charbpos_cache[replace_loc] = retval; + buf->text->mule_bytebpos_cache[replace_loc] = x; } return retval; } /* Text of length BYTELENGTH and CHARLENGTH (in different units) - was inserted at bufpos START. */ + was inserted at charbpos START. */ static void -buffer_mule_signal_inserted_region (struct buffer *buf, Bufpos start, +buffer_mule_signal_inserted_region (struct buffer *buf, Charbpos start, Bytecount bytelength, Charcount charlength) { @@ -970,10 +970,10 @@ for (i = 0; i < 16; i++) { - if (buf->text->mule_bufpos_cache[i] > start) + if (buf->text->mule_charbpos_cache[i] > start) { - buf->text->mule_bufpos_cache[i] += charlength; - buf->text->mule_bytind_cache[i] += bytelength; + buf->text->mule_charbpos_cache[i] += charlength; + buf->text->mule_bytebpos_cache[i] += bytelength; } } @@ -994,21 +994,21 @@ } else { - Bufpos end = start + charlength; + Charbpos end = start + charlength; /* the insertion point divides the known region in two. Keep the longer half, at least, and expand into the inserted chunk as much as possible. */ if (start - buf->text->mule_bufmin > buf->text->mule_bufmax - start) { - Bytind bytestart = (buf->text->mule_bytmin + Bytebpos bytestart = (buf->text->mule_bytmin + size * (start - buf->text->mule_bufmin)); - Bytind bytenew; + Bytebpos bytenew; while (start < end) { bytenew = bytestart; - INC_BYTIND (buf, bytenew); + INC_BYTEBPOS (buf, bytenew); if (bytenew - bytestart != size) break; start++; @@ -1027,10 +1027,10 @@ } else { - Bytind byteend = (buf->text->mule_bytmin + Bytebpos byteend = (buf->text->mule_bytmin + size * (start - buf->text->mule_bufmin) + bytelength); - Bytind bytenew; + Bytebpos bytenew; buf->text->mule_bufmax += charlength; buf->text->mule_bytmax += bytelength; @@ -1038,7 +1038,7 @@ while (end > start) { bytenew = byteend; - DEC_BYTIND (buf, bytenew); + DEC_BYTEBPOS (buf, bytenew); if (byteend - bytenew != size) break; end--; @@ -1053,13 +1053,13 @@ } } -/* Text from START to END (equivalent in Bytinds: from BI_START to +/* Text from START to END (equivalent in Bytebposs: from BI_START to BI_END) was deleted. */ static void -buffer_mule_signal_deleted_region (struct buffer *buf, Bufpos start, - Bufpos end, Bytind bi_start, - Bytind bi_end) +buffer_mule_signal_deleted_region (struct buffer *buf, Charbpos start, + Charbpos end, Bytebpos bi_start, + Bytebpos bi_end) { int i; @@ -1067,16 +1067,16 @@ for (i = 0; i < 16; i++) { /* After the end; gets shoved backward */ - if (buf->text->mule_bufpos_cache[i] > end) + if (buf->text->mule_charbpos_cache[i] > end) { - buf->text->mule_bufpos_cache[i] -= end - start; - buf->text->mule_bytind_cache[i] -= bi_end - bi_start; + buf->text->mule_charbpos_cache[i] -= end - start; + buf->text->mule_bytebpos_cache[i] -= bi_end - bi_start; } /* In the range; moves to start of range */ - else if (buf->text->mule_bufpos_cache[i] > start) + else if (buf->text->mule_charbpos_cache[i] > start) { - buf->text->mule_bufpos_cache[i] = start; - buf->text->mule_bytind_cache[i] = bi_start; + buf->text->mule_charbpos_cache[i] = start; + buf->text->mule_bytebpos_cache[i] = bi_start; } } @@ -1106,24 +1106,24 @@ #endif /* MULE */ -#ifdef ERROR_CHECK_BUFPOS - -Bytind -bufpos_to_bytind (struct buffer *buf, Bufpos x) +#ifdef ERROR_CHECK_CHARBPOS + +Bytebpos +charbpos_to_bytebpos (struct buffer *buf, Charbpos x) { - Bytind retval = real_bufpos_to_bytind (buf, x); - ASSERT_VALID_BYTIND_UNSAFE (buf, retval); + Bytebpos retval = real_charbpos_to_bytebpos (buf, x); + ASSERT_VALID_BYTEBPOS_UNSAFE (buf, retval); return retval; } -Bufpos -bytind_to_bufpos (struct buffer *buf, Bytind x) +Charbpos +bytebpos_to_charbpos (struct buffer *buf, Bytebpos x) { - ASSERT_VALID_BYTIND_UNSAFE (buf, x); - return real_bytind_to_bufpos (buf, x); + ASSERT_VALID_BYTEBPOS_UNSAFE (buf, x); + return real_bytebpos_to_charbpos (buf, x); } -#endif /* ERROR_CHECK_BUFPOS */ +#endif /* ERROR_CHECK_CHARBPOS */ /************************************************************************/ @@ -1132,7 +1132,7 @@ /* Functions below are tagged with either _byte or _char indicating whether they return byte or character positions. For a buffer, - a character position is a "Bufpos" and a byte position is a "Bytind". + a character position is a "Charbpos" and a byte position is a "Bytebpos". For strings, these are sometimes typed using "Charcount" and "Bytecount". */ @@ -1191,12 +1191,12 @@ */ -Bufpos +Charbpos get_buffer_pos_char (struct buffer *b, Lisp_Object pos, unsigned int flags) { /* Does not GC */ - Bufpos ind; - Bufpos min_allowed, max_allowed; + Charbpos ind; + Charbpos min_allowed, max_allowed; CHECK_INT_COERCE_MARKER (pos); ind = XINT (pos); @@ -1220,13 +1220,13 @@ return ind; } -Bytind +Bytebpos get_buffer_pos_byte (struct buffer *b, Lisp_Object pos, unsigned int flags) { - Bufpos bpos = get_buffer_pos_char (b, pos, flags); + Charbpos bpos = get_buffer_pos_char (b, pos, flags); if (bpos < 0) /* could happen with GB_NO_ERROR_IF_BAD */ return -1; - return bufpos_to_bytind (b, bpos); + return charbpos_to_bytebpos (b, bpos); } /* Return a pair of buffer positions representing a range of text, @@ -1242,10 +1242,10 @@ void get_buffer_range_char (struct buffer *b, Lisp_Object from, Lisp_Object to, - Bufpos *from_out, Bufpos *to_out, unsigned int flags) + Charbpos *from_out, Charbpos *to_out, unsigned int flags) { /* Does not GC */ - Bufpos min_allowed, max_allowed; + Charbpos min_allowed, max_allowed; min_allowed = (flags & GB_ALLOW_PAST_ACCESSIBLE) ? BUF_BEG (b) : BUF_BEGV (b); @@ -1275,7 +1275,7 @@ invalid_argument_2 ("start greater than end", from, to); else { - Bufpos temp = *from_out; + Charbpos temp = *from_out; *from_out = *to_out; *to_out = temp; } @@ -1284,17 +1284,17 @@ void get_buffer_range_byte (struct buffer *b, Lisp_Object from, Lisp_Object to, - Bytind *from_out, Bytind *to_out, unsigned int flags) + Bytebpos *from_out, Bytebpos *to_out, unsigned int flags) { - Bufpos s, e; + Charbpos s, e; get_buffer_range_char (b, from, to, &s, &e, flags); if (s >= 0) - *from_out = bufpos_to_bytind (b, s); + *from_out = charbpos_to_bytebpos (b, s); else /* could happen with GB_NO_ERROR_IF_BAD */ *from_out = -1; if (e >= 0) - *to_out = bufpos_to_bytind (b, e); + *to_out = charbpos_to_bytebpos (b, e); else *to_out = -1; } @@ -1374,7 +1374,7 @@ invalid_argument_2 ("start greater than end", from, to); else { - Bufpos temp = *from_out; + Charbpos temp = *from_out; *from_out = *to_out; *to_out = temp; } @@ -1400,7 +1400,7 @@ } -Bufpos +Charbpos get_buffer_or_string_pos_char (Lisp_Object object, Lisp_Object pos, unsigned int flags) { @@ -1409,7 +1409,7 @@ get_buffer_pos_char (XBUFFER (object), pos, flags); } -Bytind +Bytebpos get_buffer_or_string_pos_byte (Lisp_Object object, Lisp_Object pos, unsigned int flags) { @@ -1420,8 +1420,8 @@ void get_buffer_or_string_range_char (Lisp_Object object, Lisp_Object from, - Lisp_Object to, Bufpos *from_out, - Bufpos *to_out, unsigned int flags) + Lisp_Object to, Charbpos *from_out, + Charbpos *to_out, unsigned int flags) { if (STRINGP (object)) get_string_range_char (object, from, to, from_out, to_out, flags); @@ -1431,8 +1431,8 @@ void get_buffer_or_string_range_byte (Lisp_Object object, Lisp_Object from, - Lisp_Object to, Bytind *from_out, - Bytind *to_out, unsigned int flags) + Lisp_Object to, Bytebpos *from_out, + Bytebpos *to_out, unsigned int flags) { if (STRINGP (object)) get_string_range_byte (object, from, to, from_out, to_out, flags); @@ -1440,52 +1440,52 @@ get_buffer_range_byte (XBUFFER (object), from, to, from_out, to_out, flags); } -Bufpos +Charbpos buffer_or_string_accessible_begin_char (Lisp_Object object) { return STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object)); } -Bufpos +Charbpos buffer_or_string_accessible_end_char (Lisp_Object object) { return STRINGP (object) ? XSTRING_CHAR_LENGTH (object) : BUF_ZV (XBUFFER (object)); } -Bytind +Bytebpos buffer_or_string_accessible_begin_byte (Lisp_Object object) { return STRINGP (object) ? 0 : BI_BUF_BEGV (XBUFFER (object)); } -Bytind +Bytebpos buffer_or_string_accessible_end_byte (Lisp_Object object) { return STRINGP (object) ? XSTRING_LENGTH (object) : BI_BUF_ZV (XBUFFER (object)); } -Bufpos +Charbpos buffer_or_string_absolute_begin_char (Lisp_Object object) { return STRINGP (object) ? 0 : BUF_BEG (XBUFFER (object)); } -Bufpos +Charbpos buffer_or_string_absolute_end_char (Lisp_Object object) { return STRINGP (object) ? XSTRING_CHAR_LENGTH (object) : BUF_Z (XBUFFER (object)); } -Bytind +Bytebpos buffer_or_string_absolute_begin_byte (Lisp_Object object) { return STRINGP (object) ? 0 : BI_BUF_BEG (XBUFFER (object)); } -Bytind +Bytebpos buffer_or_string_absolute_end_byte (Lisp_Object object) { return STRINGP (object) ? @@ -1514,26 +1514,26 @@ /* This gets called more than enough to make the function call overhead a significant factor so we've turned it into a macro. */ -#define JUST_SET_POINT(buf, bufpos, ind) \ +#define JUST_SET_POINT(buf, charbpos, ind) \ do \ { \ - buf->bufpt = (bufpos); \ + buf->bufpt = (charbpos); \ buf->pt = (ind); \ } while (0) /* Set a buffer's point. */ void -set_buffer_point (struct buffer *buf, Bufpos bufpos, Bytind bytpos) +set_buffer_point (struct buffer *buf, Charbpos charbpos, Bytebpos bytpos) { assert (bytpos >= BI_BUF_BEGV (buf) && bytpos <= BI_BUF_ZV (buf)); if (bytpos == BI_BUF_PT (buf)) return; - JUST_SET_POINT (buf, bufpos, bytpos); + JUST_SET_POINT (buf, charbpos, bytpos); MARK_POINT_CHANGED; assert (MARKERP (buf->point_marker)); - XMARKER (buf->point_marker)->memind = - bytind_to_memind (buf, bytpos); + XMARKER (buf->point_marker)->membpos = + bytebpos_to_membpos (buf, bytpos); /* FSF makes sure that PT is not being set within invisible text. However, this is the wrong place for that check. The check @@ -1558,9 +1558,9 @@ /* Do the correct marker-like adjustment on MPOS (see below). FROM, TO, and AMOUNT are as in adjust_markers(). If MPOS doesn't need to be adjusted, nothing will happen. */ -Memind -do_marker_adjustment (Memind mpos, Memind from, - Memind to, Bytecount amount) +Membpos +do_marker_adjustment (Membpos mpos, Membpos from, + Membpos to, Bytecount amount) { if (amount > 0) { @@ -1602,27 +1602,27 @@ */ static void -adjust_markers (struct buffer *buf, Memind from, Memind to, +adjust_markers (struct buffer *buf, Membpos from, Membpos to, Bytecount amount) { Lisp_Marker *m; for (m = BUF_MARKERS (buf); m; m = marker_next (m)) - m->memind = do_marker_adjustment (m->memind, from, to, amount); + m->membpos = do_marker_adjustment (m->membpos, from, to, amount); } /* Adjust markers whose insertion-type is t for an insertion of AMOUNT characters at POS. */ static void -adjust_markers_for_insert (struct buffer *buf, Memind ind, Bytecount amount) +adjust_markers_for_insert (struct buffer *buf, Membpos ind, Bytecount amount) { Lisp_Marker *m; for (m = BUF_MARKERS (buf); m; m = marker_next (m)) { - if (m->insertion_type && m->memind == ind) - m->memind += amount; + if (m->insertion_type && m->membpos == ind) + m->membpos += amount; } } @@ -1640,11 +1640,11 @@ /* Move the gap to POS, which is less than the current GPT. */ static void -gap_left (struct buffer *buf, Bytind pos) +gap_left (struct buffer *buf, Bytebpos pos) { - Bufbyte *to, *from; + Intbyte *to, *from; Bytecount i; - Bytind new_s1; + Bytebpos new_s1; struct buffer *mbuf; Lisp_Object bufcons; @@ -1711,11 +1711,11 @@ } static void -gap_right (struct buffer *buf, Bytind pos) +gap_right (struct buffer *buf, Bytebpos pos) { - Bufbyte *to, *from; + Intbyte *to, *from; Bytecount i; - Bytind new_s1; + Bytebpos new_s1; struct buffer *mbuf; Lisp_Object bufcons; @@ -1794,7 +1794,7 @@ Note that this can quit! */ static void -move_gap (struct buffer *buf, Bytind pos) +move_gap (struct buffer *buf, Bytebpos pos) { if (! BUF_BEG_ADDR (buf)) abort (); @@ -1810,7 +1810,7 @@ merge_gap_with_end_gap (struct buffer *buf) { Lisp_Object tem; - Bytind real_gap_loc; + Bytebpos real_gap_loc; Bytecount old_gap_size; Bytecount increment; @@ -1852,9 +1852,9 @@ static void make_gap (struct buffer *buf, Bytecount increment) { - Bufbyte *result; + Intbyte *result; Lisp_Object tem; - Bytind real_gap_loc; + Bytebpos real_gap_loc; Bytecount old_gap_size; /* If we have to get more space, get enough to last a while. We use @@ -1920,8 +1920,8 @@ /* Those magic changes ... */ static void -buffer_signal_changed_region (struct buffer *buf, Bufpos start, - Bufpos end) +buffer_signal_changed_region (struct buffer *buf, Charbpos start, + Charbpos end) { /* The changed region is recorded as the number of unchanged characters from the beginning and from the end of the @@ -1937,8 +1937,8 @@ } void -buffer_extent_signal_changed_region (struct buffer *buf, Bufpos start, - Bufpos end) +buffer_extent_signal_changed_region (struct buffer *buf, Charbpos start, + Charbpos end) { if (buf->changes->begin_extent_unchanged < 0 || buf->changes->begin_extent_unchanged > start - BUF_BEG (buf)) @@ -1959,8 +1959,8 @@ } static void -signal_after_change (struct buffer *buf, Bufpos start, Bufpos orig_end, - Bufpos new_end); +signal_after_change (struct buffer *buf, Charbpos start, Charbpos orig_end, + Charbpos new_end); /* Call the after-change-functions according to the changes made so far @@ -1984,7 +1984,7 @@ if (buf->text->changes->mc_begin != 0 && buf->text->changes->mc_begin_signaled) { - Bufpos real_mc_begin = buf->text->changes->mc_begin; + Charbpos real_mc_begin = buf->text->changes->mc_begin; buf->text->changes->mc_begin = 0; signal_after_change (buf, real_mc_begin, buf->text->changes->mc_orig_end, @@ -2037,7 +2037,7 @@ whether we want to introduce a similar Lisp form. */ int -begin_multiple_change (struct buffer *buf, Bufpos start, Bufpos end) +begin_multiple_change (struct buffer *buf, Charbpos start, Charbpos end) { /* This function can GC */ int count = -1; @@ -2124,7 +2124,7 @@ START and END are the bounds of the text to be changed. */ static void -signal_before_change (struct buffer *buf, Bufpos start, Bufpos end) +signal_before_change (struct buffer *buf, Charbpos start, Charbpos end) { /* This function can GC */ struct buffer *mbuf; @@ -2212,14 +2212,14 @@ } /* Signal a change immediately after it happens. - START is the bufpos of the start of the changed text. - ORIG_END is the bufpos of the end of the before-changed text. - NEW_END is the bufpos of the end of the after-changed text. + START is the charbpos of the start of the changed text. + ORIG_END is the charbpos of the end of the before-changed text. + NEW_END is the charbpos of the end of the after-changed text. */ static void -signal_after_change (struct buffer *buf, Bufpos start, Bufpos orig_end, - Bufpos new_end) +signal_after_change (struct buffer *buf, Charbpos start, Charbpos orig_end, + Charbpos new_end) { /* This function can GC */ struct buffer *mbuf; @@ -2301,7 +2301,7 @@ it should pay attention to that area. */ static void -prepare_to_modify_buffer (struct buffer *buf, Bufpos start, Bufpos end, +prepare_to_modify_buffer (struct buffer *buf, Charbpos start, Charbpos end, int lockit) { /* This function can GC */ @@ -2370,7 +2370,7 @@ /************************************************************************/ void -fixup_internal_substring (const Bufbyte *nonreloc, Lisp_Object reloc, +fixup_internal_substring (const Intbyte *nonreloc, Lisp_Object reloc, Bytecount offset, Bytecount *len) { assert ((nonreloc && NILP (reloc)) || (!nonreloc && STRINGP (reloc))); @@ -2382,7 +2382,7 @@ else *len = XSTRING_LENGTH (reloc) - offset; } -#ifdef ERROR_CHECK_BUFPOS +#ifdef ERROR_CHECK_CHARBPOS assert (*len >= 0); if (STRINGP (reloc)) { @@ -2392,7 +2392,7 @@ #endif } -/* Insert a string into BUF at Bufpos POS. The string data comes +/* Insert a string into BUF at Charbpos POS. The string data comes from one of two sources: constant, non-relocatable data (specified in NONRELOC), or a Lisp string object (specified in RELOC), which is relocatable and may have extent data that needs to be copied @@ -2411,14 +2411,14 @@ in the higher-level Lisp functions calling insert-file-contents. */ Charcount -buffer_insert_string_1 (struct buffer *buf, Bufpos pos, - const Bufbyte *nonreloc, Lisp_Object reloc, +buffer_insert_string_1 (struct buffer *buf, Charbpos pos, + const Intbyte *nonreloc, Lisp_Object reloc, Bytecount offset, Bytecount length, int flags) { /* This function can GC */ struct gcpro gcpro1; - Bytind ind; + Bytebpos ind; Charcount cclen; int move_point = 0; struct buffer *mbuf; @@ -2472,7 +2472,7 @@ if (STRINGP (reloc)) nonreloc = XSTRING_DATA (reloc); - ind = bufpos_to_bytind (buf, pos); + ind = charbpos_to_bytebpos (buf, pos); cclen = bytecount_to_charcount (nonreloc + offset, length); if (ind != BI_BUF_GPT (buf)) @@ -2525,7 +2525,7 @@ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons) { /* We know the gap is at IND so the cast is OK. */ - adjust_markers_for_insert (mbuf, (Memind) ind, length); + adjust_markers_for_insert (mbuf, (Membpos) ind, length); } /* Point logically doesn't move, but may need to be adjusted because @@ -2555,7 +2555,7 @@ MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons) { /* ind - 1 is correct because the FROM argument is exclusive. - I formerly used DEC_BYTIND() but that caused problems at the + I formerly used DEC_BYTEBPOS() but that caused problems at the beginning of the buffer. */ adjust_markers (mbuf, ind - 1, ind, length); } @@ -2576,8 +2576,8 @@ moves forward past the text.) FLAGS is as above. */ Charcount -buffer_insert_raw_string_1 (struct buffer *buf, Bufpos pos, - const Bufbyte *nonreloc, Bytecount length, +buffer_insert_raw_string_1 (struct buffer *buf, Charbpos pos, + const Intbyte *nonreloc, Bytecount length, int flags) { /* This function can GC */ @@ -2586,7 +2586,7 @@ } Charcount -buffer_insert_lisp_string_1 (struct buffer *buf, Bufpos pos, Lisp_Object str, +buffer_insert_lisp_string_1 (struct buffer *buf, Charbpos pos, Lisp_Object str, int flags) { /* This function can GC */ @@ -2601,27 +2601,27 @@ /* Insert the null-terminated string S (in external format). */ Charcount -buffer_insert_c_string_1 (struct buffer *buf, Bufpos pos, const char *s, +buffer_insert_c_string_1 (struct buffer *buf, Charbpos pos, const char *s, int flags) { /* This function can GC */ const char *translated = GETTEXT (s); - return buffer_insert_string_1 (buf, pos, (const Bufbyte *) translated, Qnil, + return buffer_insert_string_1 (buf, pos, (const Intbyte *) translated, Qnil, 0, strlen (translated), flags); } Charcount -buffer_insert_emacs_char_1 (struct buffer *buf, Bufpos pos, Emchar ch, +buffer_insert_emacs_char_1 (struct buffer *buf, Charbpos pos, Emchar ch, int flags) { /* This function can GC */ - Bufbyte str[MAX_EMCHAR_LEN]; + Intbyte str[MAX_EMCHAR_LEN]; Bytecount len = set_charptr_emchar (str, ch); return buffer_insert_string_1 (buf, pos, str, Qnil, 0, len, flags); } Charcount -buffer_insert_c_char_1 (struct buffer *buf, Bufpos pos, char c, +buffer_insert_c_char_1 (struct buffer *buf, Charbpos pos, char c, int flags) { /* This function can GC */ @@ -2630,8 +2630,8 @@ } Charcount -buffer_insert_from_buffer_1 (struct buffer *buf, Bufpos pos, - struct buffer *buf2, Bufpos pos2, +buffer_insert_from_buffer_1 (struct buffer *buf, Charbpos pos, + struct buffer *buf2, Charbpos pos2, Charcount length, int flags) { /* This function can GC */ @@ -2648,11 +2648,11 @@ /* Delete characters in buffer from FROM up to (but not including) TO. */ void -buffer_delete_range (struct buffer *buf, Bufpos from, Bufpos to, int flags) +buffer_delete_range (struct buffer *buf, Charbpos from, Charbpos to, int flags) { /* This function can GC */ Charcount numdel; - Bytind bi_from, bi_to; + Bytebpos bi_from, bi_to; Bytecount bc_numdel; EMACS_INT shortage; struct buffer *mbuf; @@ -2702,8 +2702,8 @@ } } - bi_from = bufpos_to_bytind (buf, from); - bi_to = bufpos_to_bytind (buf, to); + bi_from = charbpos_to_bytebpos (buf, from); + bi_to = charbpos_to_bytebpos (buf, to); bc_numdel = bi_to - bi_from; delete_invalidate_line_number_cache (buf, from, to); @@ -2721,10 +2721,10 @@ MARK_BUFFERS_CHANGED; /* #### Point used to be modified here, but this causes problems - with MULE, as point is used to calculate bytinds, and if the + with MULE, as point is used to calculate bytebposs, and if the offset in bc_numdel causes point to move to a non first-byte location, causing some other function to throw an assertion - in ASSERT_VALID_BYTIND. I've moved the code to right after + in ASSERT_VALID_BYTEBPOS. I've moved the code to right after the other movements and adjustments, but before the gap is moved. -- jh 970813 */ @@ -2796,10 +2796,10 @@ MARK_BUFFERS_CHANGED; /* #### Point used to be modified here, but this causes problems - with MULE, as point is used to calculate bytinds, and if the + with MULE, as point is used to calculate bytebposs, and if the offset in bc_numdel causes point to move to a non first-byte location, causing some other function to throw an assertion - in ASSERT_VALID_BYTIND. I've moved the code to right after + in ASSERT_VALID_BYTEBPOS. I've moved the code to right after the other movements and adjustments, but before the gap is moved. -- jh 970813 */ @@ -2878,12 +2878,12 @@ /* Replace the character at POS in buffer B with CH. */ void -buffer_replace_char (struct buffer *buf, Bufpos pos, Emchar ch, +buffer_replace_char (struct buffer *buf, Charbpos pos, Emchar ch, int not_real_change, int force_lock_check) { /* This function can GC */ - Bufbyte curstr[MAX_EMCHAR_LEN]; - Bufbyte newstr[MAX_EMCHAR_LEN]; + Intbyte curstr[MAX_EMCHAR_LEN]; + Intbyte newstr[MAX_EMCHAR_LEN]; Bytecount curlen, newlen; /* Defensive steps just in case a buffer gets deleted and a calling @@ -2986,12 +2986,12 @@ and add any necessary extents from the buffer. */ static Lisp_Object -make_string_from_buffer_1 (struct buffer *buf, Bufpos pos, Charcount length, +make_string_from_buffer_1 (struct buffer *buf, Charbpos pos, Charcount length, int no_extents) { /* This function can GC */ - Bytind bi_ind = bufpos_to_bytind (buf, pos); - Bytecount bi_len = bufpos_to_bytind (buf, pos + length) - bi_ind; + Bytebpos bi_ind = charbpos_to_bytebpos (buf, pos); + Bytecount bi_len = charbpos_to_bytebpos (buf, pos + length) - bi_ind; Lisp_Object val = make_uninit_string (bi_len); struct gcpro gcpro1; @@ -3002,8 +3002,8 @@ { Bytecount len1 = BI_BUF_GPT (buf) - bi_ind; - Bufbyte *start1 = BI_BUF_BYTE_ADDRESS (buf, bi_ind); - Bufbyte *dest = XSTRING_DATA (val); + Intbyte *start1 = BI_BUF_BYTE_ADDRESS (buf, bi_ind); + Intbyte *dest = XSTRING_DATA (val); if (len1 < 0) { @@ -3018,8 +3018,8 @@ else { /* Spans gap */ - Bytind pos2 = bi_ind + len1; - Bufbyte *start2 = BI_BUF_BYTE_ADDRESS (buf, pos2); + Bytebpos pos2 = bi_ind + len1; + Intbyte *start2 = BI_BUF_BYTE_ADDRESS (buf, pos2); memcpy (dest, start1, len1); memcpy (dest + len1, start2, bi_len - len1); @@ -3031,20 +3031,20 @@ } Lisp_Object -make_string_from_buffer (struct buffer *buf, Bufpos pos, Charcount length) +make_string_from_buffer (struct buffer *buf, Charbpos pos, Charcount length) { return make_string_from_buffer_1 (buf, pos, length, 0); } Lisp_Object -make_string_from_buffer_no_extents (struct buffer *buf, Bufpos pos, +make_string_from_buffer_no_extents (struct buffer *buf, Charbpos pos, Charcount length) { return make_string_from_buffer_1 (buf, pos, length, 1); } void -barf_if_buffer_read_only (struct buffer *buf, Bufpos from, Bufpos to) +barf_if_buffer_read_only (struct buffer *buf, Charbpos from, Charbpos to) { Lisp_Object buffer; Lisp_Object iro; @@ -3065,21 +3065,21 @@ if (to < 0) to = from; verify_extent_modification (buffer, - bufpos_to_bytind (buf, from), - bufpos_to_bytind (buf, to), + charbpos_to_bytebpos (buf, from), + charbpos_to_bytebpos (buf, to), iro); } } void -find_charsets_in_bufbyte_string (unsigned char *charsets, const Bufbyte *str, +find_charsets_in_intbyte_string (unsigned char *charsets, const Intbyte *str, Bytecount len) { #ifndef MULE /* Telescope this. */ charsets[0] = 1; #else - const Bufbyte *strend = str + len; + const Intbyte *strend = str + len; memset (charsets, 0, NUM_LEADING_BYTES); /* #### SJT doesn't like this. */ @@ -3124,10 +3124,10 @@ } int -bufbyte_string_displayed_columns (const Bufbyte *str, Bytecount len) +intbyte_string_displayed_columns (const Intbyte *str, Bytecount len) { int cols = 0; - const Bufbyte *end = str + len; + const Intbyte *end = str + len; while (str < end) { @@ -3162,10 +3162,10 @@ /* NOTE: Does not reset the Dynarr. */ void -convert_bufbyte_string_into_emchar_dynarr (const Bufbyte *str, Bytecount len, +convert_intbyte_string_into_emchar_dynarr (const Intbyte *str, Bytecount len, Emchar_dynarr *dyn) { - const Bufbyte *strend = str + len; + const Intbyte *strend = str + len; while (str < strend) { @@ -3176,10 +3176,10 @@ } Charcount -convert_bufbyte_string_into_emchar_string (const Bufbyte *str, Bytecount len, +convert_intbyte_string_into_emchar_string (const Intbyte *str, Bytecount len, Emchar *arr) { - const Bufbyte *strend = str + len; + const Intbyte *strend = str + len; Charcount newlen = 0; while (str < strend) { @@ -3191,14 +3191,14 @@ } /* Convert an array of Emchars into the equivalent string representation. - Store into the given Bufbyte dynarr. Does not reset the dynarr. + Store into the given Intbyte dynarr. Does not reset the dynarr. Does not add a terminating zero. */ void -convert_emchar_string_into_bufbyte_dynarr (Emchar *arr, int nels, - Bufbyte_dynarr *dyn) +convert_emchar_string_into_intbyte_dynarr (Emchar *arr, int nels, + Intbyte_dynarr *dyn) { - Bufbyte str[MAX_EMCHAR_LEN]; + Intbyte str[MAX_EMCHAR_LEN]; int i; for (i = 0; i < nels; i++) @@ -3210,17 +3210,17 @@ /* Convert an array of Emchars into the equivalent string representation. Malloc the space needed for this and return it. If LEN_OUT is not a - NULL pointer, store into LEN_OUT the number of Bufbytes in the - malloc()ed string. Note that the actual number of Bufbytes allocated + NULL pointer, store into LEN_OUT the number of Intbytes in the + malloc()ed string. Note that the actual number of Intbytes allocated is one more than this: the returned string is zero-terminated. */ -Bufbyte * +Intbyte * convert_emchar_string_into_malloced_string (Emchar *arr, int nels, Bytecount *len_out) { /* Damn zero-termination. */ - Bufbyte *str = (Bufbyte *) alloca (nels * MAX_EMCHAR_LEN + 1); - Bufbyte *strorig = str; + Intbyte *str = (Intbyte *) alloca (nels * MAX_EMCHAR_LEN + 1); + Intbyte *strorig = str; Bytecount len; int i; @@ -3229,7 +3229,7 @@ str += set_charptr_emchar (str, arr[i]); *str = '\0'; len = str - strorig; - str = (Bufbyte *) xmalloc (1 + len); + str = (Intbyte *) xmalloc (1 + len); memcpy (str, strorig, 1 + len); if (len_out) *len_out = len; @@ -3249,7 +3249,7 @@ inside_change_hook = 0; in_first_change = 0; - for (i = 0; i <= MAX_BYTIND_GAP_SIZE_3; i++) + for (i = 0; i <= MAX_BYTEBPOS_GAP_SIZE_3; i++) three_to_one_table[i] = i / 3; } @@ -3285,8 +3285,8 @@ for (i = 0; i < 16; i++) { - b->text->mule_bufpos_cache[i] = 1; - b->text->mule_bytind_cache[i] = 1; + b->text->mule_charbpos_cache[i] = 1; + b->text->mule_bytebpos_cache[i] = 1; } } #endif /* MULE */