/[emacs]/emacs/src/buffer.c
ViewVC logotype

Diff of /emacs/src/buffer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.435 by monnier, Tue Jul 22 19:02:11 2003 UTC revision 1.435.2.1 by handa, Mon Sep 8 12:48:09 2003 UTC
# Line 45  extern int errno; Line 45  extern int errno;
45  #include "window.h"  #include "window.h"
46  #include "commands.h"  #include "commands.h"
47  #include "buffer.h"  #include "buffer.h"
48  #include "charset.h"  #include "character.h"
49  #include "region-cache.h"  #include "region-cache.h"
50  #include "indent.h"  #include "indent.h"
51  #include "blockinput.h"  #include "blockinput.h"
# Line 186  static void free_buffer_text P_ ((struct Line 186  static void free_buffer_text P_ ((struct
186  static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct Lisp_Overlay *));  static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct Lisp_Overlay *));
187  static void modify_overlay P_ ((struct buffer *, EMACS_INT, EMACS_INT));  static void modify_overlay P_ ((struct buffer *, EMACS_INT, EMACS_INT));
188    
189    extern char * emacs_strerror P_ ((int));
190    
191  /* For debugging; temporary.  See set_buffer_internal.  */  /* For debugging; temporary.  See set_buffer_internal.  */
192  /* Lisp_Object Qlisp_mode, Vcheck_symbol; */  /* Lisp_Object Qlisp_mode, Vcheck_symbol; */
# Line 2078  DEFUN ("set-buffer-multibyte", Fset_buff Line 2079  DEFUN ("set-buffer-multibyte", Fset_buff
2079         doc: /* Set the multibyte flag of the current buffer to FLAG.         doc: /* Set the multibyte flag of the current buffer to FLAG.
2080  If FLAG is t, this makes the buffer a multibyte buffer.  If FLAG is t, this makes the buffer a multibyte buffer.
2081  If FLAG is nil, this makes the buffer a single-byte buffer.  If FLAG is nil, this makes the buffer a single-byte buffer.
2082  The buffer contents remain unchanged as a sequence of bytes  In these cases, the buffer contents remain unchanged as a sequence of
2083  but the contents viewed as characters do change.  */)  bytes but the contents viewed as characters do change.
2084    If FLAG is `to', this makes the buffer a multibyte buffer by changing
2085    all eight-bit bytes to eight-bit characters.  */)
2086       (flag)       (flag)
2087       Lisp_Object flag;       Lisp_Object flag;
2088  {  {
# Line 2149  but the contents viewed as characters do Line 2152  but the contents viewed as characters do
2152                p = GAP_END_ADDR;                p = GAP_END_ADDR;
2153                stop = Z;                stop = Z;
2154              }              }
2155            if (MULTIBYTE_STR_AS_UNIBYTE_P (p, bytes))            if (ASCII_BYTE_P (*p))
2156              p += bytes, pos += bytes;              p++, pos++;
2157            else            else if (CHAR_BYTE8_HEAD_P (*p))
2158              {              {
2159                c = STRING_CHAR (p, stop - pos);                c = STRING_CHAR_AND_LENGTH (p, stop - pos, bytes);
2160                /* Delete all bytes for this 8-bit character but the                /* Delete all bytes for this 8-bit character but the
2161                   last one, and change the last one to the charcter                   last one, and change the last one to the charcter
2162                   code.  */                   code.  */
# Line 2168  but the contents viewed as characters do Line 2171  but the contents viewed as characters do
2171                  zv -= bytes;                  zv -= bytes;
2172                stop = Z;                stop = Z;
2173              }              }
2174              else
2175                {
2176                  bytes = BYTES_BY_CHAR_HEAD (*p);
2177                  p += bytes, pos += bytes;
2178                }
2179          }          }
2180        if (narrowed)        if (narrowed)
2181          Fnarrow_to_region (make_number (begv), make_number (zv));          Fnarrow_to_region (make_number (begv), make_number (zv));
# Line 2176  but the contents viewed as characters do Line 2184  but the contents viewed as characters do
2184      {      {
2185        int pt = PT;        int pt = PT;
2186        int pos, stop;        int pos, stop;
2187        unsigned char *p;        unsigned char *p, *pend;
2188    
2189        /* Be sure not to have a multibyte sequence striding over the GAP.        /* Be sure not to have a multibyte sequence striding over the GAP.
2190           Ex: We change this: "...abc\201 _GAP_ \241def..."           Ex: We change this: "...abc\302 _GAP_ \241def..."
2191               to: "...abc _GAP_ \201\241def..."  */               to: "...abc _GAP_ \302\241def..."  */
2192    
2193        if (GPT_BYTE > 1 && GPT_BYTE < Z_BYTE        if (EQ (flag, Qt)
2194              && GPT_BYTE > 1 && GPT_BYTE < Z_BYTE
2195            && ! CHAR_HEAD_P (*(GAP_END_ADDR)))            && ! CHAR_HEAD_P (*(GAP_END_ADDR)))
2196          {          {
2197            unsigned char *p = GPT_ADDR - 1;            unsigned char *p = GPT_ADDR - 1;
# Line 2201  but the contents viewed as characters do Line 2210  but the contents viewed as characters do
2210        pos = BEG;        pos = BEG;
2211        stop = GPT;        stop = GPT;
2212        p = BEG_ADDR;        p = BEG_ADDR;
2213          pend = GPT_ADDR;
2214        while (1)        while (1)
2215          {          {
2216            int bytes;            int bytes;
# Line 2210  but the contents viewed as characters do Line 2220  but the contents viewed as characters do
2220                if (pos == Z)                if (pos == Z)
2221                  break;                  break;
2222                p = GAP_END_ADDR;                p = GAP_END_ADDR;
2223                  pend = Z_ADDR;
2224                stop = Z;                stop = Z;
2225              }              }
2226    
2227            if (UNIBYTE_STR_AS_MULTIBYTE_P (p, stop - pos, bytes))            if (ASCII_BYTE_P (*p))
2228                p++, pos++;
2229              else if (EQ (flag, Qt) && (bytes = MULTIBYTE_LENGTH (p, pend)) > 0)
2230              p += bytes, pos += bytes;              p += bytes, pos += bytes;
2231            else            else
2232              {              {
2233                unsigned char tmp[MAX_MULTIBYTE_LENGTH];                unsigned char tmp[MAX_MULTIBYTE_LENGTH];
2234                  int c;
2235    
2236                bytes = CHAR_STRING (*p, tmp);                c = BYTE8_TO_CHAR (*p);
2237                  bytes = CHAR_STRING (c, tmp);
2238                *p = tmp[0];                *p = tmp[0];
2239                TEMP_SET_PT_BOTH (pos + 1, pos + 1);                TEMP_SET_PT_BOTH (pos + 1, pos + 1);
2240                bytes--;                bytes--;
# Line 2233  but the contents viewed as characters do Line 2248  but the contents viewed as characters do
2248                  zv += bytes;                  zv += bytes;
2249                if (pos <= pt)                if (pos <= pt)
2250                  pt += bytes;                  pt += bytes;
2251                  pend = Z_ADDR;
2252                stop = Z;                stop = Z;
2253              }              }
2254          }          }
# Line 3741  buffer.  */) Line 3757  buffer.  */)
3757    end = OVERLAY_END (overlay);    end = OVERLAY_END (overlay);
3758    if (OVERLAY_POSITION (end) < b->overlay_center)    if (OVERLAY_POSITION (end) < b->overlay_center)
3759      {      {
3760        if (b->overlays_after)        XOVERLAY (overlay)->next = b->overlays_after;
3761          XOVERLAY (overlay)->next = b->overlays_after;        b->overlays_after = XOVERLAY (overlay);
     b->overlays_after = XOVERLAY (overlay);  
3762      }      }
3763    else    else
3764      {      {
3765        if (b->overlays_before)        XOVERLAY (overlay)->next = b->overlays_before;
3766          XOVERLAY (overlay)->next = b->overlays_before;        b->overlays_before = XOVERLAY (overlay);
     b->overlays_before = XOVERLAY (overlay);  
3767      }      }
3768    
3769    /* This puts it in the right list, and in the right order.  */    /* This puts it in the right list, and in the right order.  */

Legend:
Removed from v.1.435  
changed lines
  Added in v.1.435.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26