aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-01-01 06:45:08 +0000
committerRichard M. Stallman1998-01-01 06:45:08 +0000
commitd8a2934ed2d860a369a860bc3bceabe2f688fe07 (patch)
treec489dbadbe9ff98b1ffe0fe9790e55d0a617bb98
parentfdccf4469e51347792f99c02e5a063145ada7276 (diff)
downloademacs-d8a2934ed2d860a369a860bc3bceabe2f688fe07.tar.gz
emacs-d8a2934ed2d860a369a860bc3bceabe2f688fe07.zip
(status_notify): Use byte and char pointers.
(Fprocess_send_region): Make bytepos for send_process. (read_process_output): Save, restore, and update both kinds of ptrs. (send_process): OFFSET is now in bytes.
-rw-r--r--src/process.c72
1 files changed, 47 insertions, 25 deletions
diff --git a/src/process.c b/src/process.c
index ef0cd07d883..d2779dd3517 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1159,8 +1159,9 @@ Remaining arguments are strings to give program as arguments.")
1159 1159
1160 /* Make the process marker point into the process buffer (if any). */ 1160 /* Make the process marker point into the process buffer (if any). */
1161 if (!NILP (buffer)) 1161 if (!NILP (buffer))
1162 Fset_marker (XPROCESS (proc)->mark, 1162 set_marker_both (XPROCESS (proc)->mark, buffer,
1163 make_number (BUF_ZV (XBUFFER (buffer))), buffer); 1163 BUF_ZV (XBUFFER (buffer)),
1164 BUF_ZV_BYTE (XBUFFER (buffer)));
1164 1165
1165 if (!NILP (buffer) && NILP (XBUFFER (buffer)->enable_multibyte_characters) 1166 if (!NILP (buffer) && NILP (XBUFFER (buffer)->enable_multibyte_characters)
1166 || NILP (buffer) && NILP (buffer_defaults.enable_multibyte_characters)) 1167 || NILP (buffer) && NILP (buffer_defaults.enable_multibyte_characters))
@@ -2928,16 +2929,21 @@ read_process_output (proc, channel)
2928 { 2929 {
2929 Lisp_Object old_read_only; 2930 Lisp_Object old_read_only;
2930 int old_begv, old_zv; 2931 int old_begv, old_zv;
2932 int old_begv_byte, old_zv_byte;
2931 Lisp_Object odeactivate; 2933 Lisp_Object odeactivate;
2932 int before; 2934 int before, before_byte;
2935 int opoint_byte;
2933 2936
2934 odeactivate = Vdeactivate_mark; 2937 odeactivate = Vdeactivate_mark;
2935 2938
2936 Fset_buffer (p->buffer); 2939 Fset_buffer (p->buffer);
2937 opoint = PT; 2940 opoint = PT;
2941 opoint_byte = PT_BYTE;
2938 old_read_only = current_buffer->read_only; 2942 old_read_only = current_buffer->read_only;
2939 old_begv = BEGV; 2943 old_begv = BEGV;
2940 old_zv = ZV; 2944 old_zv = ZV;
2945 old_begv_byte = BEGV_BYTE;
2946 old_zv_byte = ZV_BYTE;
2941 2947
2942 current_buffer->read_only = Qnil; 2948 current_buffer->read_only = Qnil;
2943 2949
@@ -2945,10 +2951,13 @@ read_process_output (proc, channel)
2945 at the current end-of-output marker, 2951 at the current end-of-output marker,
2946 thus preserving logical ordering of input and output. */ 2952 thus preserving logical ordering of input and output. */
2947 if (XMARKER (p->mark)->buffer) 2953 if (XMARKER (p->mark)->buffer)
2948 SET_PT (clip_to_bounds (BEGV, marker_position (p->mark), ZV)); 2954 SET_PT_BOTH (clip_to_bounds (BEGV, marker_position (p->mark), ZV),
2955 clip_to_bounds (BEGV_BYTE, marker_byte_position (p->mark),
2956 ZV_BYTE));
2949 else 2957 else
2950 SET_PT (ZV); 2958 SET_PT_BOTH (ZV, ZV_BYTE);
2951 before = PT; 2959 before = PT;
2960 before_byte = PT_BYTE;
2952 2961
2953 /* If the output marker is outside of the visible region, save 2962 /* If the output marker is outside of the visible region, save
2954 the restriction and widen. */ 2963 the restriction and widen. */
@@ -2961,18 +2970,27 @@ read_process_output (proc, channel)
2961 insert_from_string_before_markers (p->decoding_buf, 0, nchars, 0); 2970 insert_from_string_before_markers (p->decoding_buf, 0, nchars, 0);
2962 else 2971 else
2963 insert_before_markers (chars, nchars); 2972 insert_before_markers (chars, nchars);
2964 Fset_marker (p->mark, make_number (PT), p->buffer); 2973 set_marker_both (p->mark, p->buffer, PT, PT_BYTE);
2965 2974
2966 update_mode_lines++; 2975 update_mode_lines++;
2967 2976
2968 /* Make sure opoint and the old restrictions 2977 /* Make sure opoint and the old restrictions
2969 float ahead of any new text just as point would. */ 2978 float ahead of any new text just as point would. */
2970 if (opoint >= before) 2979 if (opoint >= before)
2971 opoint += PT - before; 2980 {
2981 opoint += PT - before;
2982 opoint_byte += PT_BYTE - before_byte;
2983 }
2972 if (old_begv > before) 2984 if (old_begv > before)
2973 old_begv += PT - before; 2985 {
2986 old_begv += PT - before;
2987 old_begv_byte += PT_BYTE - before_byte;
2988 }
2974 if (old_zv >= before) 2989 if (old_zv >= before)
2975 old_zv += PT - before; 2990 {
2991 old_zv += PT - before;
2992 old_zv_byte += PT_BYTE - before_byte;
2993 }
2976 2994
2977 /* If the restriction isn't what it should be, set it. */ 2995 /* If the restriction isn't what it should be, set it. */
2978 if (old_begv != BEGV || old_zv != ZV) 2996 if (old_begv != BEGV || old_zv != ZV)
@@ -2982,7 +3000,7 @@ read_process_output (proc, channel)
2982 Vdeactivate_mark = odeactivate; 3000 Vdeactivate_mark = odeactivate;
2983 3001
2984 current_buffer->read_only = old_read_only; 3002 current_buffer->read_only = old_read_only;
2985 SET_PT (opoint); 3003 SET_PT_BOTH (opoint, opoint_byte);
2986 set_buffer_internal (old); 3004 set_buffer_internal (old);
2987 } 3005 }
2988#ifdef VMS 3006#ifdef VMS
@@ -3063,7 +3081,7 @@ send_process (proc, buf, len, object)
3063 be relocated. Setting OFFSET to -1 means we don't have to 3081 be relocated. Setting OFFSET to -1 means we don't have to
3064 care relocation. */ 3082 care relocation. */
3065 offset = (BUFFERP (object) 3083 offset = (BUFFERP (object)
3066 ? BUF_PTR_CHAR_POS (XBUFFER (object), buf) 3084 ? BUF_PTR_BYTE_POS (XBUFFER (object), buf)
3067 : (STRINGP (object) 3085 : (STRINGP (object)
3068 ? offset = buf - XSTRING (object)->data 3086 ? offset = buf - XSTRING (object)->data
3069 : -1)); 3087 : -1));
@@ -3075,7 +3093,7 @@ send_process (proc, buf, len, object)
3075 if (offset >= 0) 3093 if (offset >= 0)
3076 { 3094 {
3077 if (BUFFERP (object)) 3095 if (BUFFERP (object))
3078 buf = BUF_CHAR_ADDRESS (XBUFFER (object), offset); 3096 buf = BUF_BYTE_ADDRESS (XBUFFER (object), offset);
3079 else if (STRINGP (object)) 3097 else if (STRINGP (object))
3080 buf = offset + XSTRING (object)->data; 3098 buf = offset + XSTRING (object)->data;
3081 /* Now we don't have to care relocation. */ 3099 /* Now we don't have to care relocation. */
@@ -3093,7 +3111,7 @@ send_process (proc, buf, len, object)
3093 if (offset >= 0) 3111 if (offset >= 0)
3094 { 3112 {
3095 if (BUFFERP (object)) 3113 if (BUFFERP (object))
3096 buf = BUF_CHAR_ADDRESS (XBUFFER (object), offset); 3114 buf = BUF_BYTE_ADDRESS (XBUFFER (object), offset);
3097 else if (STRINGP (object)) 3115 else if (STRINGP (object))
3098 buf = offset + XSTRING (object)->data; 3116 buf = offset + XSTRING (object)->data;
3099 } 3117 }
@@ -3190,7 +3208,7 @@ send_process (proc, buf, len, object)
3190 /* Running filters might relocate buffers or strings. 3208 /* Running filters might relocate buffers or strings.
3191 Arrange to relocate BUF. */ 3209 Arrange to relocate BUF. */
3192 if (BUFFERP (object)) 3210 if (BUFFERP (object))
3193 offset = BUF_PTR_CHAR_POS (XBUFFER (object), buf); 3211 offset = BUF_PTR_BYTE_POS (XBUFFER (object), buf);
3194 else if (STRINGP (object)) 3212 else if (STRINGP (object))
3195 offset = buf - XSTRING (object)->data; 3213 offset = buf - XSTRING (object)->data;
3196 3214
@@ -3202,7 +3220,7 @@ send_process (proc, buf, len, object)
3202#endif 3220#endif
3203 3221
3204 if (BUFFERP (object)) 3222 if (BUFFERP (object))
3205 buf = BUF_CHAR_ADDRESS (XBUFFER (object), offset); 3223 buf = BUF_BYTE_ADDRESS (XBUFFER (object), offset);
3206 else if (STRINGP (object)) 3224 else if (STRINGP (object))
3207 buf = offset + XSTRING (object)->data; 3225 buf = offset + XSTRING (object)->data;
3208 3226
@@ -3253,7 +3271,7 @@ Output from processes can arrive in between bunches.")
3253 Lisp_Object process, start, end; 3271 Lisp_Object process, start, end;
3254{ 3272{
3255 Lisp_Object proc; 3273 Lisp_Object proc;
3256 int start1; 3274 int start1, end1;
3257 3275
3258 proc = get_process (process); 3276 proc = get_process (process);
3259 validate_region (&start, &end); 3277 validate_region (&start, &end);
@@ -3261,8 +3279,9 @@ Output from processes can arrive in between bunches.")
3261 if (XINT (start) < GPT && XINT (end) > GPT) 3279 if (XINT (start) < GPT && XINT (end) > GPT)
3262 move_gap (XINT (start)); 3280 move_gap (XINT (start));
3263 3281
3264 start1 = XINT (start); 3282 start1 = CHAR_TO_BYTE (XINT (start));
3265 send_process (proc, POS_ADDR (start1), XINT (end) - XINT (start), 3283 end1 = CHAR_TO_BYTE (XINT (end));
3284 send_process (proc, BYTE_POS_ADDR (start1), end1 - start1,
3266 Fcurrent_buffer ()); 3285 Fcurrent_buffer ());
3267 3286
3268 return Qnil; 3287 return Qnil;
@@ -4099,8 +4118,8 @@ status_notify ()
4099 { 4118 {
4100 Lisp_Object ro, tem; 4119 Lisp_Object ro, tem;
4101 struct buffer *old = current_buffer; 4120 struct buffer *old = current_buffer;
4102 int opoint; 4121 int opoint, opoint_byte;
4103 int before; 4122 int before, before_byte;
4104 4123
4105 ro = XBUFFER (buffer)->read_only; 4124 ro = XBUFFER (buffer)->read_only;
4106 4125
@@ -4111,15 +4130,17 @@ status_notify ()
4111 Fset_buffer (buffer); 4130 Fset_buffer (buffer);
4112 4131
4113 opoint = PT; 4132 opoint = PT;
4133 opoint_byte = PT_BYTE;
4114 /* Insert new output into buffer 4134 /* Insert new output into buffer
4115 at the current end-of-output marker, 4135 at the current end-of-output marker,
4116 thus preserving logical ordering of input and output. */ 4136 thus preserving logical ordering of input and output. */
4117 if (XMARKER (p->mark)->buffer) 4137 if (XMARKER (p->mark)->buffer)
4118 SET_PT (marker_position (p->mark)); 4138 Fgoto_char (p->mark);
4119 else 4139 else
4120 SET_PT (ZV); 4140 SET_PT_BOTH (ZV, ZV_BYTE);
4121 4141
4122 before = PT; 4142 before = PT;
4143 before_byte = PT_BYTE;
4123 4144
4124 tem = current_buffer->read_only; 4145 tem = current_buffer->read_only;
4125 current_buffer->read_only = Qnil; 4146 current_buffer->read_only = Qnil;
@@ -4128,12 +4149,13 @@ status_notify ()
4128 insert_string (" "); 4149 insert_string (" ");
4129 Finsert (1, &msg); 4150 Finsert (1, &msg);
4130 current_buffer->read_only = tem; 4151 current_buffer->read_only = tem;
4131 Fset_marker (p->mark, make_number (PT), p->buffer); 4152 set_marker_both (p->mark, p->buffer, PT, PT_BYTE);
4132 4153
4133 if (opoint >= before) 4154 if (opoint >= before)
4134 SET_PT (opoint + (PT - before)); 4155 SET_PT_BOTH (opoint + (PT - before),
4156 opoint_byte + (PT_BYTE - before_byte));
4135 else 4157 else
4136 SET_PT (opoint); 4158 SET_PT_BOTH (opoint, opoint_byte);
4137 4159
4138 set_buffer_internal (old); 4160 set_buffer_internal (old);
4139 } 4161 }