comparison src/buffer.c @ 46370:40db0673e6f0

Most uses of XSTRING combined with STRING_BYTES or indirection changed to SCHARS, SBYTES, STRING_INTERVALS, SREF, SDATA; explicit size_byte references left unchanged for now.
author Ken Raeburn <raeburn@raeburn.org>
date Mon, 15 Jul 2002 00:00:41 +0000
parents 1fb8f75062c6
children ef7dc46ecd0b
comparison
equal deleted inserted replaced
46369:dd1d3b1d0053 46370:40db0673e6f0
191 void 191 void
192 nsberror (spec) 192 nsberror (spec)
193 Lisp_Object spec; 193 Lisp_Object spec;
194 { 194 {
195 if (STRINGP (spec)) 195 if (STRINGP (spec))
196 error ("No buffer named %s", XSTRING (spec)->data); 196 error ("No buffer named %s", SDATA (spec));
197 error ("Invalid buffer argument"); 197 error ("Invalid buffer argument");
198 } 198 }
199 199
200 DEFUN ("buffer-live-p", Fbuffer_live_p, Sbuffer_live_p, 1, 1, 0, 200 DEFUN ("buffer-live-p", Fbuffer_live_p, Sbuffer_live_p, 1, 1, 0,
201 doc: /* Return non-nil if OBJECT is a buffer which has not been killed. 201 doc: /* Return non-nil if OBJECT is a buffer which has not been killed.
339 339
340 buf = Fget_buffer (name); 340 buf = Fget_buffer (name);
341 if (!NILP (buf)) 341 if (!NILP (buf))
342 return buf; 342 return buf;
343 343
344 if (XSTRING (name)->size == 0) 344 if (SCHARS (name) == 0)
345 error ("Empty string for buffer name is not allowed"); 345 error ("Empty string for buffer name is not allowed");
346 346
347 b = (struct buffer *) allocate_buffer (); 347 b = (struct buffer *) allocate_buffer ();
348 348
349 b->size = sizeof (struct buffer) / sizeof (EMACS_INT); 349 b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
395 b->pt_marker = Qnil; 395 b->pt_marker = Qnil;
396 b->begv_marker = Qnil; 396 b->begv_marker = Qnil;
397 b->zv_marker = Qnil; 397 b->zv_marker = Qnil;
398 398
399 name = Fcopy_sequence (name); 399 name = Fcopy_sequence (name);
400 XSTRING (name)->intervals = NULL_INTERVAL; 400 STRING_INTERVALS (name) = NULL_INTERVAL;
401 b->name = name; 401 b->name = name;
402 402
403 if (XSTRING (name)->data[0] != ' ') 403 if (SREF (name, 0) != ' ')
404 b->undo_list = Qnil; 404 b->undo_list = Qnil;
405 else 405 else
406 b->undo_list = Qt; 406 b->undo_list = Qt;
407 407
408 reset_buffer (b); 408 reset_buffer (b);
518 Lisp_Object buf; 518 Lisp_Object buf;
519 struct buffer *b; 519 struct buffer *b;
520 520
521 buf = Fget_buffer (name); 521 buf = Fget_buffer (name);
522 if (!NILP (buf)) 522 if (!NILP (buf))
523 error ("Buffer name `%s' is in use", XSTRING (name)->data); 523 error ("Buffer name `%s' is in use", SDATA (name));
524 524
525 base_buffer = Fget_buffer (base_buffer); 525 base_buffer = Fget_buffer (base_buffer);
526 if (NILP (base_buffer)) 526 if (NILP (base_buffer))
527 error ("No such buffer: `%s'", XSTRING (name)->data); 527 error ("No such buffer: `%s'", SDATA (name));
528 528
529 if (XSTRING (name)->size == 0) 529 if (SCHARS (name) == 0)
530 error ("Empty string for buffer name is not allowed"); 530 error ("Empty string for buffer name is not allowed");
531 531
532 b = (struct buffer *) allocate_buffer (); 532 b = (struct buffer *) allocate_buffer ();
533 b->size = sizeof (struct buffer) / sizeof (EMACS_INT); 533 b->size = sizeof (struct buffer) / sizeof (EMACS_INT);
534 534
554 /* Put this on the chain of all buffers including killed ones. */ 554 /* Put this on the chain of all buffers including killed ones. */
555 b->next = all_buffers; 555 b->next = all_buffers;
556 all_buffers = b; 556 all_buffers = b;
557 557
558 name = Fcopy_sequence (name); 558 name = Fcopy_sequence (name);
559 XSTRING (name)->intervals = NULL_INTERVAL; 559 STRING_INTERVALS (name) = NULL_INTERVAL;
560 b->name = name; 560 b->name = name;
561 561
562 reset_buffer (b); 562 reset_buffer (b);
563 reset_buffer_local_variables (b, 1); 563 reset_buffer_local_variables (b, 1);
564 564
1089 { 1089 {
1090 register Lisp_Object tem, buf; 1090 register Lisp_Object tem, buf;
1091 1091
1092 CHECK_STRING (newname); 1092 CHECK_STRING (newname);
1093 1093
1094 if (XSTRING (newname)->size == 0) 1094 if (SCHARS (newname) == 0)
1095 error ("Empty string is invalid as a buffer name"); 1095 error ("Empty string is invalid as a buffer name");
1096 1096
1097 tem = Fget_buffer (newname); 1097 tem = Fget_buffer (newname);
1098 if (!NILP (tem)) 1098 if (!NILP (tem))
1099 { 1099 {
1104 if (NILP (unique) && XBUFFER (tem) == current_buffer) 1104 if (NILP (unique) && XBUFFER (tem) == current_buffer)
1105 return current_buffer->name; 1105 return current_buffer->name;
1106 if (!NILP (unique)) 1106 if (!NILP (unique))
1107 newname = Fgenerate_new_buffer_name (newname, current_buffer->name); 1107 newname = Fgenerate_new_buffer_name (newname, current_buffer->name);
1108 else 1108 else
1109 error ("Buffer name `%s' is in use", XSTRING (newname)->data); 1109 error ("Buffer name `%s' is in use", SDATA (newname));
1110 } 1110 }
1111 1111
1112 current_buffer->name = newname; 1112 current_buffer->name = newname;
1113 1113
1114 /* Catch redisplay's attention. Unless we do this, the mode lines for 1114 /* Catch redisplay's attention. Unless we do this, the mode lines for
1161 for (; !NILP (tail); tail = Fcdr (tail)) 1161 for (; !NILP (tail); tail = Fcdr (tail))
1162 { 1162 {
1163 buf = Fcdr (Fcar (tail)); 1163 buf = Fcdr (Fcar (tail));
1164 if (EQ (buf, buffer)) 1164 if (EQ (buf, buffer))
1165 continue; 1165 continue;
1166 if (XSTRING (XBUFFER (buf)->name)->data[0] == ' ') 1166 if (SDATA (XBUFFER (buf)->name)[0] == ' ')
1167 continue; 1167 continue;
1168 /* If the selected frame has a buffer_predicate, 1168 /* If the selected frame has a buffer_predicate,
1169 disregard buffers that don't fit the predicate. */ 1169 disregard buffers that don't fit the predicate. */
1170 if (!NILP (pred)) 1170 if (!NILP (pred))
1171 { 1171 {
1287 if (INTERACTIVE && !NILP (b->filename) 1287 if (INTERACTIVE && !NILP (b->filename)
1288 && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b)) 1288 && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
1289 { 1289 {
1290 GCPRO1 (buf); 1290 GCPRO1 (buf);
1291 tem = do_yes_or_no_p (format1 ("Buffer %s modified; kill anyway? ", 1291 tem = do_yes_or_no_p (format1 ("Buffer %s modified; kill anyway? ",
1292 XSTRING (b->name)->data)); 1292 SDATA (b->name)));
1293 UNGCPRO; 1293 UNGCPRO;
1294 if (NILP (tem)) 1294 if (NILP (tem))
1295 return Qnil; 1295 return Qnil;
1296 } 1296 }
1297 1297
1533 { 1533 {
1534 int count; 1534 int count;
1535 Lisp_Object function; 1535 Lisp_Object function;
1536 1536
1537 if (STRINGP (XBUFFER (buffer)->name) 1537 if (STRINGP (XBUFFER (buffer)->name)
1538 && strcmp (XSTRING (XBUFFER (buffer)->name)->data, "*scratch*") == 0) 1538 && strcmp (SDATA (XBUFFER (buffer)->name), "*scratch*") == 0)
1539 function = find_symbol_value (intern ("initial-major-mode")); 1539 function = find_symbol_value (intern ("initial-major-mode"));
1540 else 1540 else
1541 { 1541 {
1542 function = buffer_defaults.major_mode; 1542 function = buffer_defaults.major_mode;
1543 if (NILP (function) 1543 if (NILP (function)
2881 ssl->buf[ssl->used].size = size; 2881 ssl->buf[ssl->used].size = size;
2882 ssl->buf[ssl->used].priority = (INTEGERP (pri) ? XINT (pri) : 0); 2882 ssl->buf[ssl->used].priority = (INTEGERP (pri) ? XINT (pri) : 0);
2883 ssl->used++; 2883 ssl->used++;
2884 2884
2885 if (NILP (current_buffer->enable_multibyte_characters)) 2885 if (NILP (current_buffer->enable_multibyte_characters))
2886 nbytes = XSTRING (str)->size; 2886 nbytes = SCHARS (str);
2887 else if (! STRING_MULTIBYTE (str)) 2887 else if (! STRING_MULTIBYTE (str))
2888 nbytes = count_size_as_multibyte (XSTRING (str)->data, 2888 nbytes = count_size_as_multibyte (SDATA (str),
2889 STRING_BYTES (XSTRING (str))); 2889 SBYTES (str));
2890 else 2890 else
2891 nbytes = STRING_BYTES (XSTRING (str)); 2891 nbytes = SBYTES (str);
2892 2892
2893 ssl->bytes += nbytes; 2893 ssl->bytes += nbytes;
2894 2894
2895 if (STRINGP (str2)) 2895 if (STRINGP (str2))
2896 { 2896 {
2897 if (NILP (current_buffer->enable_multibyte_characters)) 2897 if (NILP (current_buffer->enable_multibyte_characters))
2898 nbytes = XSTRING (str2)->size; 2898 nbytes = SCHARS (str2);
2899 else if (! STRING_MULTIBYTE (str2)) 2899 else if (! STRING_MULTIBYTE (str2))
2900 nbytes = count_size_as_multibyte (XSTRING (str2)->data, 2900 nbytes = count_size_as_multibyte (SDATA (str2),
2901 STRING_BYTES (XSTRING (str2))); 2901 SBYTES (str2));
2902 else 2902 else
2903 nbytes = STRING_BYTES (XSTRING (str2)); 2903 nbytes = SBYTES (str2);
2904 2904
2905 ssl->bytes += nbytes; 2905 ssl->bytes += nbytes;
2906 } 2906 }
2907 } 2907 }
2908 2908
3010 p = overlay_str_buf; 3010 p = overlay_str_buf;
3011 for (i = overlay_tails.used; --i >= 0;) 3011 for (i = overlay_tails.used; --i >= 0;)
3012 { 3012 {
3013 int nbytes; 3013 int nbytes;
3014 tem = overlay_tails.buf[i].string; 3014 tem = overlay_tails.buf[i].string;
3015 nbytes = copy_text (XSTRING (tem)->data, p, 3015 nbytes = copy_text (SDATA (tem), p,
3016 STRING_BYTES (XSTRING (tem)), 3016 SBYTES (tem),
3017 STRING_MULTIBYTE (tem), multibyte); 3017 STRING_MULTIBYTE (tem), multibyte);
3018 p += nbytes; 3018 p += nbytes;
3019 } 3019 }
3020 for (i = 0; i < overlay_heads.used; ++i) 3020 for (i = 0; i < overlay_heads.used; ++i)
3021 { 3021 {
3022 int nbytes; 3022 int nbytes;
3023 tem = overlay_heads.buf[i].string; 3023 tem = overlay_heads.buf[i].string;
3024 nbytes = copy_text (XSTRING (tem)->data, p, 3024 nbytes = copy_text (SDATA (tem), p,
3025 STRING_BYTES (XSTRING (tem)), 3025 SBYTES (tem),
3026 STRING_MULTIBYTE (tem), multibyte); 3026 STRING_MULTIBYTE (tem), multibyte);
3027 p += nbytes; 3027 p += nbytes;
3028 tem = overlay_heads.buf[i].string2; 3028 tem = overlay_heads.buf[i].string2;
3029 if (STRINGP (tem)) 3029 if (STRINGP (tem))
3030 { 3030 {
3031 nbytes = copy_text (XSTRING (tem)->data, p, 3031 nbytes = copy_text (SDATA (tem), p,
3032 STRING_BYTES (XSTRING (tem)), 3032 SBYTES (tem),
3033 STRING_MULTIBYTE (tem), multibyte); 3033 STRING_MULTIBYTE (tem), multibyte);
3034 p += nbytes; 3034 p += nbytes;
3035 } 3035 }
3036 } 3036 }
3037 if (p != overlay_str_buf + total) 3037 if (p != overlay_str_buf + total)
4280 abort (); 4280 abort ();
4281 } 4281 }
4282 4282
4283 sym = PER_BUFFER_SYMBOL (offset); 4283 sym = PER_BUFFER_SYMBOL (offset);
4284 error ("Only %s should be stored in the buffer-local variable %s", 4284 error ("Only %s should be stored in the buffer-local variable %s",
4285 type_name, XSTRING (SYMBOL_NAME (sym))->data); 4285 type_name, SDATA (SYMBOL_NAME (sym)));
4286 } 4286 }
4287 4287
4288 4288
4289 /*********************************************************************** 4289 /***********************************************************************
4290 Allocation with mmap 4290 Allocation with mmap
5064 if (! NILP (temp) 5064 if (! NILP (temp)
5065 /* If the default dir is just /, TEMP is non-nil 5065 /* If the default dir is just /, TEMP is non-nil
5066 because of the ange-ftp completion handler. 5066 because of the ange-ftp completion handler.
5067 However, it is not necessary to turn / into /:/. 5067 However, it is not necessary to turn / into /:/.
5068 So avoid doing that. */ 5068 So avoid doing that. */
5069 && strcmp ("/", XSTRING (current_buffer->directory)->data)) 5069 && strcmp ("/", SDATA (current_buffer->directory)))
5070 current_buffer->directory 5070 current_buffer->directory
5071 = concat2 (build_string ("/:"), current_buffer->directory); 5071 = concat2 (build_string ("/:"), current_buffer->directory);
5072 5072
5073 temp = get_minibuffer (0); 5073 temp = get_minibuffer (0);
5074 XBUFFER (temp)->directory = current_buffer->directory; 5074 XBUFFER (temp)->directory = current_buffer->directory;