Mercurial > hg > xemacs-beta
diff src/extents.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 | 943eaba38521 |
line wrap: on
line diff
--- a/src/extents.c Tue Sep 18 05:06:57 2001 +0000 +++ b/src/extents.c Thu Sep 20 06:31:11 2001 +0000 @@ -265,7 +265,7 @@ /* Convert a "memory position" (i.e. taking the gap into account) into the address of the element at (i.e. after) that position. "Memory - positions" are only used internally and are of type Memind. + positions" are only used internally and are of type Membpos. "Array positions" are used externally and are of type int. */ #define GAP_ARRAY_MEMEL_ADDR(ga, memel) ((ga)->array + (ga)->elsize*(memel)) @@ -358,7 +358,7 @@ typedef struct stack_of_extents { Extent_List *extents; - Memind pos; /* Position of stack of extents. EXTENTS is the list of + Membpos pos; /* Position of stack of extents. EXTENTS is the list of all extents that overlap this position. This position can be -1 if the stack of extents is invalid (this happens when a buffer is first created or a string's @@ -372,29 +372,29 @@ typedef int Endpoint_Index; -#define memind_to_startind(x, start_open) \ +#define membpos_to_startind(x, start_open) \ ((Endpoint_Index) (((x) << 1) + !!(start_open))) -#define memind_to_endind(x, end_open) \ +#define membpos_to_endind(x, end_open) \ ((Endpoint_Index) (((x) << 1) - !!(end_open))) /* Combination macros */ -#define bytind_to_startind(buf, x, start_open) \ - memind_to_startind (bytind_to_memind (buf, x), start_open) -#define bytind_to_endind(buf, x, end_open) \ - memind_to_endind (bytind_to_memind (buf, x), end_open) +#define bytebpos_to_startind(buf, x, start_open) \ + membpos_to_startind (bytebpos_to_membpos (buf, x), start_open) +#define bytebpos_to_endind(buf, x, end_open) \ + membpos_to_endind (bytebpos_to_membpos (buf, x), end_open) /* ------------------------------- */ /* buffer-or-string primitives */ /* ------------------------------- */ -/* Similar for Bytinds and start/end indices. */ - -#define buffer_or_string_bytind_to_startind(obj, ind, start_open) \ - memind_to_startind (buffer_or_string_bytind_to_memind (obj, ind), \ +/* Similar for Bytebposs and start/end indices. */ + +#define buffer_or_string_bytebpos_to_startind(obj, ind, start_open) \ + membpos_to_startind (buffer_or_string_bytebpos_to_membpos (obj, ind), \ start_open) -#define buffer_or_string_bytind_to_endind(obj, ind, end_open) \ - memind_to_endind (buffer_or_string_bytind_to_memind (obj, ind), \ +#define buffer_or_string_bytebpos_to_endind(obj, ind, end_open) \ + membpos_to_endind (buffer_or_string_bytebpos_to_membpos (obj, ind), \ end_open) /* ------------------------------- */ @@ -487,8 +487,8 @@ adjust_markers() in insdel.c. */ static void -gap_array_adjust_markers (Gap_Array *ga, Memind from, - Memind to, int amount) +gap_array_adjust_markers (Gap_Array *ga, Membpos from, + Membpos to, int amount) { Gap_Array_Marker *m; @@ -511,7 +511,7 @@ memmove (GAP_ARRAY_MEMEL_ADDR (ga, pos + gapsize), GAP_ARRAY_MEMEL_ADDR (ga, pos), (gap - pos)*ga->elsize); - gap_array_adjust_markers (ga, (Memind) pos, (Memind) gap, + gap_array_adjust_markers (ga, (Membpos) pos, (Membpos) gap, gapsize); } else if (pos > gap) @@ -519,8 +519,8 @@ memmove (GAP_ARRAY_MEMEL_ADDR (ga, gap), GAP_ARRAY_MEMEL_ADDR (ga, gap + gapsize), (pos - gap)*ga->elsize); - gap_array_adjust_markers (ga, (Memind) (gap + gapsize), - (Memind) (pos + gapsize), - gapsize); + gap_array_adjust_markers (ga, (Membpos) (gap + gapsize), + (Membpos) (pos + gapsize), - gapsize); } ga->gap = pos; } @@ -775,7 +775,7 @@ position at the beginning or end of the extent list is returned. */ static int -extent_list_locate_from_pos (Extent_List *el, Memind pos, int endp) +extent_list_locate_from_pos (Extent_List *el, Membpos pos, int endp) { struct extent fake_extent; /* @@ -799,7 +799,7 @@ /* Return the extent at POS. */ static EXTENT -extent_list_at (Extent_List *el, Memind pos, int endp) +extent_list_at (Extent_List *el, Membpos pos, int endp) { Gap_Array *ga = endp ? el->end : el->start; @@ -1298,9 +1298,9 @@ return; } sel = soe->extents; - printf ("SOE pos is %d (memind %d)\n", + printf ("SOE pos is %d (membpos %d)\n", soe->pos < 0 ? soe->pos : - buffer_or_string_memind_to_bytind (obj, soe->pos), + buffer_or_string_membpos_to_bytebpos (obj, soe->pos), soe->pos); for (endp = 0; endp < 2; endp++) { @@ -1375,7 +1375,7 @@ /* Move OBJ's stack of extents to lie over the specified position. */ static void -soe_move (Lisp_Object obj, Memind pos) +soe_move (Lisp_Object obj, Membpos pos) { Stack_Of_Extents *soe = buffer_or_string_stack_of_extents_force (obj); Extent_List *sel = soe->extents; @@ -1389,10 +1389,10 @@ #endif #ifdef SOE_DEBUG - printf ("Moving SOE from %d (memind %d) to %d (memind %d)\n", + printf ("Moving SOE from %d (membpos %d) to %d (membpos %d)\n", soe->pos < 0 ? soe->pos : - buffer_or_string_memind_to_bytind (obj, soe->pos), soe->pos, - buffer_or_string_memind_to_bytind (obj, pos), pos); + buffer_or_string_membpos_to_bytebpos (obj, soe->pos), soe->pos, + buffer_or_string_membpos_to_bytebpos (obj, pos), pos); #endif if (soe->pos < pos) { @@ -1533,29 +1533,29 @@ /* Return the start (endp == 0) or end (endp == 1) of an extent as a byte index. If you want the value as a memory index, use extent_endpoint(). If you want the value as a buffer position, - use extent_endpoint_bufpos(). */ - -static Bytind -extent_endpoint_bytind (EXTENT extent, int endp) + use extent_endpoint_charbpos(). */ + +static Bytebpos +extent_endpoint_bytebpos (EXTENT extent, int endp) { assert (EXTENT_LIVE_P (extent)); assert (!extent_detached_p (extent)); { - Memind i = endp ? extent_end (extent) : extent_start (extent); + Membpos i = endp ? extent_end (extent) : extent_start (extent); Lisp_Object obj = extent_object (extent); - return buffer_or_string_memind_to_bytind (obj, i); + return buffer_or_string_membpos_to_bytebpos (obj, i); } } -static Bufpos -extent_endpoint_bufpos (EXTENT extent, int endp) +static Charbpos +extent_endpoint_charbpos (EXTENT extent, int endp) { assert (EXTENT_LIVE_P (extent)); assert (!extent_detached_p (extent)); { - Memind i = endp ? extent_end (extent) : extent_start (extent); + Membpos i = endp ? extent_end (extent) : extent_start (extent); Lisp_Object obj = extent_object (extent); - return buffer_or_string_memind_to_bufpos (obj, i); + return buffer_or_string_membpos_to_charbpos (obj, i); } } @@ -1619,8 +1619,8 @@ if (!in_modeline_generation) MARK_EXTENTS_CHANGED; gutter_extent_signal_changed_region_maybe (object, - extent_endpoint_bufpos (extent, 0), - extent_endpoint_bufpos (extent, 1)); + extent_endpoint_charbpos (extent, 0), + extent_endpoint_charbpos (extent, 1)); } else if (BUFFERP (object)) { @@ -1631,8 +1631,8 @@ if (invisibility_change) MARK_CLIP_CHANGED; buffer_extent_signal_changed_region (b, - extent_endpoint_bufpos (extent, 0), - extent_endpoint_bufpos (extent, 1)); + extent_endpoint_charbpos (extent, 0), + extent_endpoint_charbpos (extent, 1)); } } @@ -1827,7 +1827,7 @@ already been performed (see Fextent_in_region_p ()). */ static int -extent_in_region_p (EXTENT extent, Bytind from, Bytind to, +extent_in_region_p (EXTENT extent, Bytebpos from, Bytebpos to, unsigned int flags) { Lisp_Object obj = extent_object (extent); @@ -1863,11 +1863,11 @@ default: abort(); return 0; } - start = buffer_or_string_bytind_to_startind (obj, from, + start = buffer_or_string_bytebpos_to_startind (obj, from, flags & ME_START_OPEN); - end = buffer_or_string_bytind_to_endind (obj, to, ! (flags & ME_END_CLOSED)); - exs = memind_to_startind (extent_start (extent), start_open); - exe = memind_to_endind (extent_end (extent), end_open); + end = buffer_or_string_bytebpos_to_endind (obj, to, ! (flags & ME_END_CLOSED)); + exs = membpos_to_startind (extent_start (extent), start_open); + exe = membpos_to_endind (extent_end (extent), end_open); /* It's easy to determine whether an extent lies *outside* the region -- just determine whether it's completely before @@ -1947,10 +1947,10 @@ static void -map_extents_bytind (Bytind from, Bytind to, map_extents_fun fn, void *arg, +map_extents_bytebpos (Bytebpos from, Bytebpos to, map_extents_fun fn, void *arg, Lisp_Object obj, EXTENT after, unsigned int flags) { - Memind st, en; /* range we're mapping over */ + Membpos st, en; /* range we're mapping over */ EXTENT range = 0; /* extent for this, if ME_MIGHT_MODIFY_TEXT */ Extent_List *el = 0; /* extent list we're iterating over */ Extent_List_Marker *posm = 0; /* marker for extent list, @@ -1978,8 +1978,8 @@ return; el = 0; - st = buffer_or_string_bytind_to_memind (obj, from); - en = buffer_or_string_bytind_to_memind (obj, to); + st = buffer_or_string_bytebpos_to_membpos (obj, from); + en = buffer_or_string_bytebpos_to_membpos (obj, to); if (flags & ME_MIGHT_MODIFY_TEXT) { @@ -2248,9 +2248,9 @@ obj2 = extent_object (e); if (extent_in_region_p (e, - buffer_or_string_memind_to_bytind (obj2, + buffer_or_string_membpos_to_bytebpos (obj2, st), - buffer_or_string_memind_to_bytind (obj2, + buffer_or_string_membpos_to_bytebpos (obj2, en), flags)) { @@ -2280,11 +2280,11 @@ } void -map_extents (Bufpos from, Bufpos to, map_extents_fun fn, +map_extents (Charbpos from, Charbpos to, map_extents_fun fn, void *arg, Lisp_Object obj, EXTENT after, unsigned int flags) { - map_extents_bytind (buffer_or_string_bufpos_to_bytind (obj, from), - buffer_or_string_bufpos_to_bytind (obj, to), fn, arg, + map_extents_bytebpos (buffer_or_string_charbpos_to_bytebpos (obj, from), + buffer_or_string_charbpos_to_bytebpos (obj, to), fn, arg, obj, after, flags); } @@ -2309,7 +2309,7 @@ so for safety we make it just look at the extent lists directly. */ void -adjust_extents (Lisp_Object obj, Memind from, Memind to, int amount) +adjust_extents (Lisp_Object obj, Membpos from, Membpos to, int amount) { int endp; int pos; @@ -2385,15 +2385,15 @@ */ void -adjust_extents_for_deletion (Lisp_Object object, Bytind from, - Bytind to, int gapsize, int numdel, +adjust_extents_for_deletion (Lisp_Object object, Bytebpos from, + Bytebpos to, int gapsize, int numdel, int movegapsize) { struct adjust_extents_for_deletion_arg closure; int i; - Memind adjust_to = (Memind) (to + gapsize); + Membpos adjust_to = (Membpos) (to + gapsize); Bytecount amount = - numdel - movegapsize; - Memind oldsoe = 0, newsoe = 0; + Membpos oldsoe = 0, newsoe = 0; Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (object); #ifdef ERROR_CHECK_EXTENTS @@ -2406,7 +2406,7 @@ to muck with. If we do the mapping and adjusting together, things can get all screwed up. */ - map_extents_bytind (from, to, adjust_extents_for_deletion_mapper, + map_extents_bytebpos (from, to, adjust_extents_for_deletion_mapper, (void *) &closure, object, 0, /* extent endpoints move like markers regardless of their open/closeness. */ @@ -2432,8 +2432,8 @@ for (i = 0; i < Dynarr_length (closure.list); i++) { EXTENT extent = Dynarr_at (closure.list, i); - Memind new_start = extent_start (extent); - Memind new_end = extent_end (extent); + Membpos new_start = extent_start (extent); + Membpos new_end = extent_end (extent); /* do_marker_adjustment() will not adjust values that should not be adjusted. We're passing the same funky arguments to @@ -2513,15 +2513,15 @@ the first run that begins after POS, or returns POS if there are no such runs. */ -static Bytind -extent_find_end_of_run (Lisp_Object obj, Bytind pos, int outside_accessible) +static Bytebpos +extent_find_end_of_run (Lisp_Object obj, Bytebpos pos, int outside_accessible) { Extent_List *sel; Extent_List *bel = buffer_or_string_extent_list (obj); - Bytind pos1, pos2; + Bytebpos pos1, pos2; int elind1, elind2; - Memind mempos = buffer_or_string_bytind_to_memind (obj, pos); - Bytind limit = outside_accessible ? + Membpos mempos = buffer_or_string_bytebpos_to_membpos (obj, pos); + Bytebpos limit = outside_accessible ? buffer_or_string_absolute_end_byte (obj) : buffer_or_string_accessible_end_byte (obj); @@ -2534,7 +2534,7 @@ /* Find the first start position after POS. */ elind1 = extent_list_locate_from_pos (bel, mempos+1, 0); if (elind1 < extent_list_num_els (bel)) - pos1 = buffer_or_string_memind_to_bytind + pos1 = buffer_or_string_membpos_to_bytebpos (obj, extent_start (extent_list_at (bel, elind1, 0))); else pos1 = limit; @@ -2544,7 +2544,7 @@ equal to POS1, so we just have to look in the SOE. */ elind2 = extent_list_locate_from_pos (sel, mempos+1, 1); if (elind2 < extent_list_num_els (sel)) - pos2 = buffer_or_string_memind_to_bytind + pos2 = buffer_or_string_membpos_to_bytebpos (obj, extent_end (extent_list_at (sel, elind2, 1))); else pos2 = limit; @@ -2552,16 +2552,16 @@ return min (min (pos1, pos2), limit); } -static Bytind -extent_find_beginning_of_run (Lisp_Object obj, Bytind pos, +static Bytebpos +extent_find_beginning_of_run (Lisp_Object obj, Bytebpos pos, int outside_accessible) { Extent_List *sel; Extent_List *bel = buffer_or_string_extent_list (obj); - Bytind pos1, pos2; + Bytebpos pos1, pos2; int elind1, elind2; - Memind mempos = buffer_or_string_bytind_to_memind (obj, pos); - Bytind limit = outside_accessible ? + Membpos mempos = buffer_or_string_bytebpos_to_membpos (obj, pos); + Bytebpos limit = outside_accessible ? buffer_or_string_absolute_begin_byte (obj) : buffer_or_string_accessible_begin_byte (obj); @@ -2574,7 +2574,7 @@ /* Find the first end position before POS. */ elind1 = extent_list_locate_from_pos (bel, mempos, 1); if (elind1 > 0) - pos1 = buffer_or_string_memind_to_bytind + pos1 = buffer_or_string_membpos_to_bytebpos (obj, extent_end (extent_list_at (bel, elind1 - 1, 1))); else pos1 = limit; @@ -2584,7 +2584,7 @@ equal to POS1, so we just have to look in the SOE. */ elind2 = extent_list_locate_from_pos (sel, mempos, 0); if (elind2 > 0) - pos2 = buffer_or_string_memind_to_bytind + pos2 = buffer_or_string_membpos_to_bytebpos (obj, extent_start (extent_list_at (sel, elind2 - 1, 0))); else pos2 = limit; @@ -2753,14 +2753,14 @@ face_index extent_fragment_update (struct window *w, struct extent_fragment *ef, - Bytind pos) + Bytebpos pos) { int i; Extent_List *sel = buffer_or_string_stack_of_extents_force (ef->object)->extents; EXTENT lhe = 0; struct extent dummy_lhe_extent; - Memind mempos = buffer_or_string_bytind_to_memind (ef->object, pos); + Membpos mempos = buffer_or_string_bytebpos_to_membpos (ef->object, pos); #ifdef ERROR_CHECK_EXTENTS assert (pos >= buffer_or_string_accessible_begin_byte (ef->object) @@ -3104,7 +3104,7 @@ depth)); } -static Hash_Code +static Hashcode extent_hash (Lisp_Object obj, int depth) { struct extent *e = XEXTENT (obj); @@ -3262,7 +3262,7 @@ if (extent_detached_p (extent)) return Qnil; else - return make_int (extent_endpoint_bufpos (extent, endp)); + return make_int (extent_endpoint_charbpos (extent, endp)); } DEFUN ("extentp", Fextentp, 1, 1, 0, /* @@ -3319,8 +3319,8 @@ (extent)) { EXTENT e = decode_extent (extent, DE_MUST_BE_ATTACHED); - return make_int (extent_endpoint_bufpos (e, 1) - - extent_endpoint_bufpos (e, 0)); + return make_int (extent_endpoint_charbpos (e, 1) + - extent_endpoint_charbpos (e, 0)); } DEFUN ("next-extent", Fnext_extent, 1, 1, 0, /* @@ -3431,11 +3431,11 @@ (pos, object)) { Lisp_Object obj = decode_buffer_or_string (object); - Bytind bpos; + Bytebpos bpos; bpos = get_buffer_or_string_pos_byte (obj, pos, GB_ALLOW_PAST_ACCESSIBLE); bpos = extent_find_end_of_run (obj, bpos, 1); - return make_int (buffer_or_string_bytind_to_bufpos (obj, bpos)); + return make_int (buffer_or_string_bytebpos_to_charbpos (obj, bpos)); } DEFUN ("previous-extent-change", Fprevious_extent_change, 1, 2, 0, /* @@ -3447,11 +3447,11 @@ (pos, object)) { Lisp_Object obj = decode_buffer_or_string (object); - Bytind bpos; + Bytebpos bpos; bpos = get_buffer_or_string_pos_byte (obj, pos, GB_ALLOW_PAST_ACCESSIBLE); bpos = extent_find_beginning_of_run (obj, bpos, 1); - return make_int (buffer_or_string_bytind_to_bufpos (obj, bpos)); + return make_int (buffer_or_string_bytebpos_to_charbpos (obj, bpos)); } @@ -3575,7 +3575,7 @@ */ static void -set_extent_endpoints_1 (EXTENT extent, Memind start, Memind end) +set_extent_endpoints_1 (EXTENT extent, Membpos start, Membpos end) { #ifdef ERROR_CHECK_EXTENTS Lisp_Object obj = extent_object (extent); @@ -3583,8 +3583,8 @@ assert (start <= end); if (BUFFERP (obj)) { - assert (valid_memind_p (XBUFFER (obj), start)); - assert (valid_memind_p (XBUFFER (obj), end)); + assert (valid_membpos_p (XBUFFER (obj), start)); + assert (valid_membpos_p (XBUFFER (obj), end)); } #endif @@ -3615,9 +3615,9 @@ OBJECT. (If OBJECT is nil, do not change the extent's object.) */ void -set_extent_endpoints (EXTENT extent, Bytind s, Bytind e, Lisp_Object object) -{ - Memind start, end; +set_extent_endpoints (EXTENT extent, Bytebpos s, Bytebpos e, Lisp_Object object) +{ + Membpos start, end; if (NILP (object)) { @@ -3631,9 +3631,9 @@ } start = s < 0 ? extent_start (extent) : - buffer_or_string_bytind_to_memind (object, s); + buffer_or_string_bytebpos_to_membpos (object, s); end = e < 0 ? extent_end (extent) : - buffer_or_string_bytind_to_memind (object, e); + buffer_or_string_bytebpos_to_membpos (object, e); set_extent_endpoints_1 (extent, start, end); } @@ -3649,7 +3649,7 @@ } static EXTENT -make_extent_internal (Lisp_Object object, Bytind from, Bytind to) +make_extent_internal (Lisp_Object object, Bytebpos from, Bytebpos to) { EXTENT extent; @@ -3659,7 +3659,7 @@ } static EXTENT -copy_extent (EXTENT original, Bytind from, Bytind to, Lisp_Object object) +copy_extent (EXTENT original, Bytebpos from, Bytebpos to, Lisp_Object object) { EXTENT e; @@ -3741,7 +3741,7 @@ } else { - Bytind start, end; + Bytebpos start, end; get_buffer_or_string_range_byte (obj, from, to, &start, &end, GB_ALLOW_PAST_ACCESSIBLE); @@ -3824,7 +3824,7 @@ (extent, start, end, buffer_or_string)) { EXTENT ext; - Bytind s, e; + Bytebpos s, e; ext = decode_extent (extent, 0); @@ -3916,7 +3916,7 @@ */ (extent, from, to, flags)) { - Bytind start, end; + Bytebpos start, end; EXTENT ext = decode_extent (extent, DE_MUST_BE_ATTACHED); Lisp_Object obj = extent_object (ext); @@ -4040,7 +4040,7 @@ /* This function can GC */ struct slow_map_extents_arg closure; unsigned int me_flags; - Bytind start, end; + Bytebpos start, end; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; EXTENT after = 0; @@ -4075,7 +4075,7 @@ closure.property = property; closure.value = value; - map_extents_bytind (start, end, slow_map_extents_function, + map_extents_bytebpos (start, end, slow_map_extents_function, (void *) &closure, object, after, /* You never know what the user might do ... */ me_flags | ME_MIGHT_CALL_ELISP); @@ -4100,9 +4100,9 @@ Lisp_Object result; Lisp_Object property; Lisp_Object value; - Bytind start_min; - Bytind prev_start; - Bytind prev_end; + Bytebpos start_min; + Bytebpos prev_start; + Bytebpos prev_end; }; static int @@ -4112,8 +4112,8 @@ struct slow_map_extent_children_arg *closure = (struct slow_map_extent_children_arg *) arg; Lisp_Object extent_obj; - Bytind start = extent_endpoint_bytind (extent, 0); - Bytind end = extent_endpoint_bytind (extent, 1); + Bytebpos start = extent_endpoint_bytebpos (extent, 0); + Bytebpos end = extent_endpoint_bytebpos (extent, 1); /* Make sure the extent starts inside the region of interest, rather than just overlaps it. */ @@ -4156,8 +4156,8 @@ buffer positions here. */ closure->start_min = -1; /* no need for this any more */ - closure->prev_start = extent_endpoint_bytind (extent, 0); - closure->prev_end = extent_endpoint_bytind (extent, 1); + closure->prev_start = extent_endpoint_bytebpos (extent, 0); + closure->prev_end = extent_endpoint_bytebpos (extent, 1); return !NILP (closure->result); } @@ -4181,7 +4181,7 @@ /* This function can GC */ struct slow_map_extent_children_arg closure; unsigned int me_flags; - Bytind start, end; + Bytebpos start, end; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; EXTENT after = 0; @@ -4218,7 +4218,7 @@ closure.start_min = start; closure.prev_start = -1; closure.prev_end = -1; - map_extents_bytind (start, end, slow_map_extent_children_function, + map_extents_bytebpos (start, end, slow_map_extent_children_function, (void *) &closure, object, after, /* You never know what the user might do ... */ me_flags | ME_MIGHT_CALL_ELISP); @@ -4241,8 +4241,8 @@ struct extent_at_arg { Lisp_Object best_match; /* or list of extents */ - Memind best_start; - Memind best_end; + Membpos best_start; + Membpos best_end; Lisp_Object prop; EXTENT before; int all_extents; @@ -4325,7 +4325,7 @@ } static Lisp_Object -extent_at_bytind (Bytind position, Lisp_Object object, Lisp_Object property, +extent_at_bytebpos (Bytebpos position, Lisp_Object object, Lisp_Object property, EXTENT before, enum extent_at_flag at_flag, int all_extents) { struct extent_at_arg closure; @@ -4353,7 +4353,7 @@ closure.all_extents = all_extents; GCPRO1 (closure.best_match); - map_extents_bytind (at_flag == EXTENT_AT_BEFORE ? position - 1 : position, + map_extents_bytebpos (at_flag == EXTENT_AT_BEFORE ? position - 1 : position, at_flag == EXTENT_AT_AFTER ? position + 1 : position, extent_at_mapper, (void *) &closure, object, 0, ME_START_OPEN | ME_ALL_EXTENTS_CLOSED); @@ -4394,7 +4394,7 @@ */ (pos, object, property, before, at_flag)) { - Bytind position; + Bytebpos position; EXTENT before_extent; enum extent_at_flag fl; @@ -4408,7 +4408,7 @@ invalid_argument ("extent not in specified buffer or string", object); fl = decode_extent_at_flag (at_flag); - return extent_at_bytind (position, object, property, before_extent, fl, 0); + return extent_at_bytebpos (position, object, property, before_extent, fl, 0); } DEFUN ("extents-at", Fextents_at, 1, 5, 0, /* @@ -4444,7 +4444,7 @@ */ (pos, object, property, before, at_flag)) { - Bytind position; + Bytebpos position; EXTENT before_extent; enum extent_at_flag fl; @@ -4458,7 +4458,7 @@ invalid_argument ("extent not in specified buffer or string", object); fl = decode_extent_at_flag (at_flag); - return extent_at_bytind (position, object, property, before_extent, fl, 1); + return extent_at_bytebpos (position, object, property, before_extent, fl, 1); } /* ------------------------------- */ @@ -4473,8 +4473,8 @@ struct verify_extents_arg { Lisp_Object object; - Memind start; - Memind end; + Membpos start; + Membpos end; Lisp_Object iro; /* value of inhibit-read-only */ }; @@ -4514,7 +4514,7 @@ efficiency */ void -verify_extent_modification (Lisp_Object object, Bytind from, Bytind to, +verify_extent_modification (Lisp_Object object, Bytebpos from, Bytebpos to, Lisp_Object inhibit_read_only_value) { int closed; @@ -4529,11 +4529,11 @@ As far as I know, this doesn't currently occur in XEmacs. --ben */ closed = (from==to); closure.object = object; - closure.start = buffer_or_string_bytind_to_memind (object, from); - closure.end = buffer_or_string_bytind_to_memind (object, to); + closure.start = buffer_or_string_bytebpos_to_membpos (object, from); + closure.end = buffer_or_string_bytebpos_to_membpos (object, to); closure.iro = inhibit_read_only_value; - map_extents_bytind (from, to, verify_extent_mapper, (void *) &closure, + map_extents_bytebpos (from, to, verify_extent_mapper, (void *) &closure, object, 0, closed ? ME_END_CLOSED : ME_START_OPEN); } @@ -4543,7 +4543,7 @@ struct process_extents_for_insertion_arg { - Bytind opoint; + Bytebpos opoint; int length; Lisp_Object object; }; @@ -4558,7 +4558,7 @@ { struct process_extents_for_insertion_arg *closure = (struct process_extents_for_insertion_arg *) arg; - Memind indice = buffer_or_string_bytind_to_memind (closure->object, + Membpos indice = buffer_or_string_bytebpos_to_membpos (closure->object, closure->opoint); /* When this function is called, one end of the newly-inserted text should @@ -4594,8 +4594,8 @@ it. */ { - Memind new_start = extent_start (extent); - Memind new_end = extent_end (extent); + Membpos new_start = extent_start (extent); + Membpos new_end = extent_end (extent); if (indice == extent_start (extent) && extent_start_open_p (extent) /* zero-length () extents are exempt; see comment above. */ @@ -4612,7 +4612,7 @@ } void -process_extents_for_insertion (Lisp_Object object, Bytind opoint, +process_extents_for_insertion (Lisp_Object object, Bytebpos opoint, Bytecount length) { struct process_extents_for_insertion_arg closure; @@ -4621,7 +4621,7 @@ closure.length = length; closure.object = object; - map_extents_bytind (opoint, opoint + length, + map_extents_bytebpos (opoint, opoint + length, process_extents_for_insertion_mapper, (void *) &closure, object, 0, ME_END_CLOSED | ME_MIGHT_MODIFY_EXTENTS | @@ -4634,7 +4634,7 @@ struct process_extents_for_deletion_arg { - Memind start, end; + Membpos start, end; int destroy_included_extents; }; @@ -4672,16 +4672,16 @@ be a function process_extents_for_destruction(), #if 0'd out, that did the equivalent). */ void -process_extents_for_deletion (Lisp_Object object, Bytind from, - Bytind to, int destroy_them) +process_extents_for_deletion (Lisp_Object object, Bytebpos from, + Bytebpos to, int destroy_them) { struct process_extents_for_deletion_arg closure; - closure.start = buffer_or_string_bytind_to_memind (object, from); - closure.end = buffer_or_string_bytind_to_memind (object, to); + closure.start = buffer_or_string_bytebpos_to_membpos (object, from); + closure.end = buffer_or_string_bytebpos_to_membpos (object, to); closure.destroy_included_extents = destroy_them; - map_extents_bytind (from, to, process_extents_for_deletion_mapper, + map_extents_bytebpos (from, to, process_extents_for_deletion_mapper, (void *) &closure, object, 0, ME_END_CLOSED | ME_MIGHT_MODIFY_EXTENTS); } @@ -4691,7 +4691,7 @@ /* ------------------------------- */ struct report_extent_modification_closure { Lisp_Object buffer; - Bufpos start, end; + Charbpos start, end; int afterp; int speccount; }; @@ -4727,7 +4727,7 @@ One confusing thing here is that our caller never actually calls unbind_to (closure.speccount, Qnil). This is because - map_extents_bytind() unbinds before, and with a smaller + map_extents_bytebpos() unbinds before, and with a smaller speccount. The additional unbind_to() in report_extent_modification() would cause XEmacs to abort. */ if (closure->speccount == -1) @@ -4764,7 +4764,7 @@ } void -report_extent_modification (Lisp_Object buffer, Bufpos start, Bufpos end, +report_extent_modification (Lisp_Object buffer, Charbpos start, Charbpos end, int afterp) { struct report_extent_modification_closure closure; @@ -5670,7 +5670,7 @@ /* copy/paste hooks */ static int -run_extent_copy_paste_internal (EXTENT e, Bufpos from, Bufpos to, +run_extent_copy_paste_internal (EXTENT e, Charbpos from, Charbpos to, Lisp_Object object, Lisp_Object prop) { @@ -5697,29 +5697,29 @@ } static int -run_extent_copy_function (EXTENT e, Bytind from, Bytind to) +run_extent_copy_function (EXTENT e, Bytebpos from, Bytebpos to) { Lisp_Object object = extent_object (e); /* This function can GC */ return run_extent_copy_paste_internal - (e, buffer_or_string_bytind_to_bufpos (object, from), - buffer_or_string_bytind_to_bufpos (object, to), object, + (e, buffer_or_string_bytebpos_to_charbpos (object, from), + buffer_or_string_bytebpos_to_charbpos (object, to), object, Qcopy_function); } static int -run_extent_paste_function (EXTENT e, Bytind from, Bytind to, +run_extent_paste_function (EXTENT e, Bytebpos from, Bytebpos to, Lisp_Object object) { /* This function can GC */ return run_extent_copy_paste_internal - (e, buffer_or_string_bytind_to_bufpos (object, from), - buffer_or_string_bytind_to_bufpos (object, to), object, + (e, buffer_or_string_bytebpos_to_charbpos (object, from), + buffer_or_string_bytebpos_to_charbpos (object, to), object, Qpaste_function); } static void -update_extent (EXTENT extent, Bytind from, Bytind to) +update_extent (EXTENT extent, Bytebpos from, Bytebpos to) { set_extent_endpoints (extent, from, to, Qnil); } @@ -5729,7 +5729,7 @@ This code does not handle the case of undo. */ static Lisp_Object -insert_extent (EXTENT extent, Bytind new_start, Bytind new_end, +insert_extent (EXTENT extent, Bytebpos new_start, Bytebpos new_end, Lisp_Object object, int run_hooks) { /* This function can GC */ @@ -5749,8 +5749,8 @@ } else { - Bytind exstart = extent_endpoint_bytind (extent, 0); - Bytind exend = extent_endpoint_bytind (extent, 1); + Bytebpos exstart = extent_endpoint_bytebpos (extent, 0); + Bytebpos exend = extent_endpoint_bytebpos (extent, 1); if (exend < new_start || exstart > new_end) goto copy_it; @@ -5793,7 +5793,7 @@ { EXTENT ext = decode_extent (extent, 0); Lisp_Object copy; - Bytind s, e; + Bytebpos s, e; buffer_or_string = decode_buffer_or_string (buffer_or_string); get_buffer_or_string_range_byte (buffer_or_string, start, end, &s, &e, @@ -5813,7 +5813,7 @@ struct add_string_extents_arg { - Bytind from; + Bytebpos from; Bytecount length; Lisp_Object string; }; @@ -5824,8 +5824,8 @@ /* This function can GC */ struct add_string_extents_arg *closure = (struct add_string_extents_arg *) arg; - Bytecount start = extent_endpoint_bytind (extent, 0) - closure->from; - Bytecount end = extent_endpoint_bytind (extent, 1) - closure->from; + Bytecount start = extent_endpoint_bytebpos (extent, 0) - closure->from; + Bytecount end = extent_endpoint_bytebpos (extent, 1) - closure->from; if (extent_duplicable_p (extent)) { @@ -5848,7 +5848,7 @@ /* Add the extents in buffer BUF from OPOINT to OPOINT+LENGTH to the string STRING. */ void -add_string_extents (Lisp_Object string, struct buffer *buf, Bytind opoint, +add_string_extents (Lisp_Object string, struct buffer *buf, Bytebpos opoint, Bytecount length) { /* This function can GC */ @@ -5861,7 +5861,7 @@ closure.string = string; buffer = make_buffer (buf); GCPRO2 (buffer, string); - map_extents_bytind (opoint, opoint + length, add_string_extents_mapper, + map_extents_bytebpos (opoint, opoint + length, add_string_extents_mapper, (void *) &closure, buffer, 0, /* ignore extents that just abut the region */ ME_END_CLOSED | ME_ALL_EXTENTS_OPEN | @@ -5875,7 +5875,7 @@ { Bytecount pos; Bytecount length; - Bytind opoint; + Bytebpos opoint; Lisp_Object buffer; }; @@ -5890,11 +5890,11 @@ NEW_START and NEW_END are the prospective buffer positions of the extent that is going into the buffer. */ - Bytind base_start = closure->opoint; - Bytind base_end = base_start + closure->length; - Bytind new_start = (base_start + extent_endpoint_bytind (extent, 0) - + Bytebpos base_start = closure->opoint; + Bytebpos base_end = base_start + closure->length; + Bytebpos new_start = (base_start + extent_endpoint_bytebpos (extent, 0) - closure->pos); - Bytind new_end = (base_start + extent_endpoint_bytind (extent, 1) - + Bytebpos new_end = (base_start + extent_endpoint_bytebpos (extent, 1) - closure->pos); if (new_start < base_start) @@ -5922,7 +5922,7 @@ void splice_in_string_extents (Lisp_Object string, struct buffer *buf, - Bytind opoint, Bytecount length, Bytecount pos) + Bytebpos opoint, Bytecount length, Bytecount pos) { struct splice_in_string_extents_arg closure; struct gcpro gcpro1, gcpro2; @@ -5934,7 +5934,7 @@ closure.length = length; closure.buffer = buffer; GCPRO2 (buffer, string); - map_extents_bytind (pos, pos + length, + map_extents_bytebpos (pos, pos + length, splice_in_string_extents_mapper, (void *) &closure, string, 0, /* ignore extents that just abut the region */ @@ -5966,8 +5966,8 @@ (struct copy_string_extents_arg *) arg; Bytecount old_start, old_end, new_start, new_end; - old_start = extent_endpoint_bytind (extent, 0); - old_end = extent_endpoint_bytind (extent, 1); + old_start = extent_endpoint_bytebpos (extent, 0); + old_end = extent_endpoint_bytebpos (extent, 1); old_start = max (closure->old_pos, old_start); old_end = min (closure->old_pos + closure->length, old_end); @@ -6000,7 +6000,7 @@ closure.new_string = new_string; closure.length = length; GCPRO2 (new_string, old_string); - map_extents_bytind (old_pos, old_pos + length, + map_extents_bytebpos (old_pos, old_pos + length, copy_string_extents_mapper, (void *) &closure, old_string, 0, /* ignore extents that just abut the region */ @@ -6030,7 +6030,7 @@ Lisp_Object Qtext_prop_extent_paste_function; static Lisp_Object -get_text_property_bytind (Bytind position, Lisp_Object prop, +get_text_property_bytebpos (Bytebpos position, Lisp_Object prop, Lisp_Object object, enum extent_at_flag fl, int text_props_only) { @@ -6039,13 +6039,13 @@ /* text_props_only specifies whether we only consider text-property extents (those with the 'text-prop property set) or all extents. */ if (!text_props_only) - extent = extent_at_bytind (position, object, prop, 0, fl, 0); + extent = extent_at_bytebpos (position, object, prop, 0, fl, 0); else { EXTENT prior = 0; while (1) { - extent = extent_at_bytind (position, object, Qtext_prop, prior, + extent = extent_at_bytebpos (position, object, Qtext_prop, prior, fl, 0); if (NILP (extent)) return Qnil; @@ -6066,7 +6066,7 @@ get_text_property_1 (Lisp_Object pos, Lisp_Object prop, Lisp_Object object, Lisp_Object at_flag, int text_props_only) { - Bytind position; + Bytebpos position; int invert = 0; object = decode_buffer_or_string (object); @@ -6090,7 +6090,7 @@ { Lisp_Object val = - get_text_property_bytind (position, prop, object, + get_text_property_bytebpos (position, prop, object, decode_extent_at_flag (at_flag), text_props_only); if (invert) @@ -6156,7 +6156,7 @@ struct put_text_prop_arg { Lisp_Object prop, value; /* The property and value we are storing */ - Bytind start, end; /* The region into which we are storing it */ + Bytebpos start, end; /* The region into which we are storing it */ Lisp_Object object; Lisp_Object the_extent; /* Our chosen extent; this is used for communication between subsequent passes. */ @@ -6170,9 +6170,9 @@ Lisp_Object object = closure->object; Lisp_Object value = closure->value; - Bytind e_start, e_end; - Bytind start = closure->start; - Bytind end = closure->end; + Bytebpos e_start, e_end; + Bytebpos start = closure->start; + Bytebpos end = closure->end; Lisp_Object extent, e_val; int is_eq; @@ -6186,8 +6186,8 @@ /* It's not for this property; do nothing. */ return 0; - e_start = extent_endpoint_bytind (e, 0); - e_end = extent_endpoint_bytind (e, 1); + e_start = extent_endpoint_bytebpos (e, 0); + e_end = extent_endpoint_bytebpos (e, 1); e_val = Fextent_property (extent, closure->prop, Qnil); is_eq = EQ (value, e_val); @@ -6201,17 +6201,17 @@ */ if (e_start != start || e_end != end) { - Bytind new_start = min (e_start, start); - Bytind new_end = max (e_end, end); + Bytebpos new_start = min (e_start, start); + Bytebpos new_end = max (e_end, end); set_extent_endpoints (e, new_start, new_end, Qnil); /* If we changed the endpoint, then we need to set its openness. */ set_extent_openness (e, new_start != e_start - ? !NILP (get_text_property_bytind + ? !NILP (get_text_property_bytebpos (start, Qstart_open, object, EXTENT_AT_AFTER, 1)) : -1, new_end != e_end - ? NILP (get_text_property_bytind + ? NILP (get_text_property_bytebpos (end - 1, Qend_closed, object, EXTENT_AT_AFTER, 1)) : -1); @@ -6253,8 +6253,8 @@ the-extent to cover it, resulting in the minimum number of extents in the buffer. */ - Bytind the_start = extent_endpoint_bytind (te, 0); - Bytind the_end = extent_endpoint_bytind (te, 1); + Bytebpos the_start = extent_endpoint_bytebpos (te, 0); + Bytebpos the_end = extent_endpoint_bytebpos (te, 1); if (e_start != the_start && /* note AND not OR -- hmm, why is this the case? I think it's because the assumption that the text-property @@ -6264,8 +6264,8 @@ falsely marked. Is this bad? */ e_end != the_end) { - Bytind new_start = min (e_start, the_start); - Bytind new_end = max (e_end, the_end); + Bytebpos new_start = min (e_start, the_start); + Bytebpos new_end = max (e_end, the_end); set_extent_endpoints (te, new_start, new_end, Qnil); /* If we changed the endpoint, then we need to set its openness. We are setting the endpoint to be the same as @@ -6288,7 +6288,7 @@ if (e_end != start) { set_extent_endpoints (e, e_start, start, Qnil); - set_extent_openness (e, -1, NILP (get_text_property_bytind + set_extent_openness (e, -1, NILP (get_text_property_bytebpos (start - 1, Qend_closed, object, EXTENT_AT_AFTER, 1))); closure->changed_p = 1; @@ -6302,7 +6302,7 @@ if (e_start != end) { set_extent_endpoints (e, end, e_end, Qnil); - set_extent_openness (e, !NILP (get_text_property_bytind + set_extent_openness (e, !NILP (get_text_property_bytebpos (end, Qstart_open, object, EXTENT_AT_AFTER, 1)), -1); closure->changed_p = 1; @@ -6313,11 +6313,11 @@ /* Otherwise, `extent' straddles the region. We need to split it. */ set_extent_endpoints (e, e_start, start, Qnil); - set_extent_openness (e, -1, NILP (get_text_property_bytind + set_extent_openness (e, -1, NILP (get_text_property_bytebpos (start - 1, Qend_closed, object, EXTENT_AT_AFTER, 1))); set_extent_openness (copy_extent (e, end, e_end, extent_object (e)), - !NILP (get_text_property_bytind + !NILP (get_text_property_bytebpos (end, Qstart_open, object, EXTENT_AT_AFTER, 1)), -1); closure->changed_p = 1; @@ -6330,13 +6330,13 @@ put_text_prop_openness_mapper (EXTENT e, void *arg) { struct put_text_prop_arg *closure = (struct put_text_prop_arg *) arg; - Bytind e_start, e_end; - Bytind start = closure->start; - Bytind end = closure->end; + Bytebpos e_start, e_end; + Bytebpos start = closure->start; + Bytebpos end = closure->end; Lisp_Object extent; XSETEXTENT (extent, e); - e_start = extent_endpoint_bytind (e, 0); - e_end = extent_endpoint_bytind (e, 1); + e_start = extent_endpoint_bytebpos (e, 0); + e_end = extent_endpoint_bytebpos (e, 1); if (NILP (Fextent_property (extent, Qtext_prop, Qnil))) { @@ -6355,7 +6355,7 @@ } static int -put_text_prop (Bytind start, Bytind end, Lisp_Object object, +put_text_prop (Bytebpos start, Bytebpos end, Lisp_Object object, Lisp_Object prop, Lisp_Object value, int duplicable_p) { @@ -6388,7 +6388,7 @@ closure.changed_p = 0; closure.the_extent = Qnil; - map_extents_bytind (start, end, + map_extents_bytebpos (start, end, put_text_prop_mapper, (void *) &closure, object, 0, /* get all extents that abut the region */ @@ -6397,7 +6397,7 @@ fucked with the extent plist. */ /* #### dmoore - I think this should include ME_MIGHT_MOVE_SOE, since the callback function - might recurse back into map_extents_bytind. */ + might recurse back into map_extents_bytebpos. */ ME_MIGHT_THROW | ME_MIGHT_MODIFY_EXTENTS); @@ -6419,17 +6419,17 @@ Qtext_prop_extent_paste_function); } set_extent_openness (XEXTENT (extent), - !NILP (get_text_property_bytind + !NILP (get_text_property_bytebpos (start, Qstart_open, object, EXTENT_AT_AFTER, 1)), - NILP (get_text_property_bytind + NILP (get_text_property_bytebpos (end - 1, Qend_closed, object, EXTENT_AT_AFTER, 1))); } if (EQ (prop, Qstart_open) || EQ (prop, Qend_closed)) { - map_extents_bytind (start, end, + map_extents_bytebpos (start, end, put_text_prop_openness_mapper, (void *) &closure, object, 0, /* get all extents that abut the region */ @@ -6450,7 +6450,7 @@ (start, end, prop, value, object)) { /* This function can GC */ - Bytind s, e; + Bytebpos s, e; object = decode_buffer_or_string (object); get_buffer_or_string_range_byte (object, start, end, &s, &e, 0); @@ -6470,7 +6470,7 @@ (start, end, prop, value, object)) { /* This function can GC */ - Bytind s, e; + Bytebpos s, e; object = decode_buffer_or_string (object); get_buffer_or_string_range_byte (object, start, end, &s, &e, 0); @@ -6489,7 +6489,7 @@ { /* This function can GC */ int changed = 0; - Bytind s, e; + Bytebpos s, e; object = decode_buffer_or_string (object); get_buffer_or_string_range_byte (object, start, end, &s, &e, 0); @@ -6517,7 +6517,7 @@ { /* This function can GC */ int changed = 0; - Bytind s, e; + Bytebpos s, e; object = decode_buffer_or_string (object); get_buffer_or_string_range_byte (object, start, end, &s, &e, 0); @@ -6542,7 +6542,7 @@ { /* This function can GC */ int changed = 0; - Bytind s, e; + Bytebpos s, e; object = decode_buffer_or_string (object); get_buffer_or_string_range_byte (object, start, end, &s, &e, 0); @@ -6619,8 +6619,8 @@ */ (pos, prop, object, limit)) { - Bufpos bpos; - Bufpos blim; + Charbpos bpos; + Charbpos blim; Lisp_Object extent, value; int limit_was_nil; @@ -6686,8 +6686,8 @@ */ (pos, prop, object, limit)) { - Bufpos bpos; - Bufpos blim; + Charbpos bpos; + Charbpos blim; Lisp_Object extent, value; int limit_was_nil;