comparison src/fileio.c @ 25662:0a7261c1d487

Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
author Ken Raeburn <raeburn@raeburn.org>
date Mon, 13 Sep 1999 02:23:04 +0000
parents c60d7a800e9c
children 3258c12243e2
comparison
equal deleted inserted replaced
25661:a6e2ae7964fb 25662:0a7261c1d487
342 inhibited_handlers = Vinhibit_file_name_handlers; 342 inhibited_handlers = Vinhibit_file_name_handlers;
343 else 343 else
344 inhibited_handlers = Qnil; 344 inhibited_handlers = Qnil;
345 345
346 for (chain = Vfile_name_handler_alist; CONSP (chain); 346 for (chain = Vfile_name_handler_alist; CONSP (chain);
347 chain = XCONS (chain)->cdr) 347 chain = XCDR (chain))
348 { 348 {
349 Lisp_Object elt; 349 Lisp_Object elt;
350 elt = XCONS (chain)->car; 350 elt = XCAR (chain);
351 if (CONSP (elt)) 351 if (CONSP (elt))
352 { 352 {
353 Lisp_Object string; 353 Lisp_Object string;
354 string = XCONS (elt)->car; 354 string = XCAR (elt);
355 if (STRINGP (string) && fast_string_match (string, filename) >= 0) 355 if (STRINGP (string) && fast_string_match (string, filename) >= 0)
356 { 356 {
357 Lisp_Object handler, tem; 357 Lisp_Object handler, tem;
358 358
359 handler = XCONS (elt)->cdr; 359 handler = XCDR (elt);
360 tem = Fmemq (handler, inhibited_handlers); 360 tem = Fmemq (handler, inhibited_handlers);
361 if (NILP (tem)) 361 if (NILP (tem))
362 return handler; 362 return handler;
363 } 363 }
364 } 364 }
3373 handler = Ffind_file_name_handler (filename, Qinsert_file_contents); 3373 handler = Ffind_file_name_handler (filename, Qinsert_file_contents);
3374 if (!NILP (handler)) 3374 if (!NILP (handler))
3375 { 3375 {
3376 val = call6 (handler, Qinsert_file_contents, filename, 3376 val = call6 (handler, Qinsert_file_contents, filename,
3377 visit, beg, end, replace); 3377 visit, beg, end, replace);
3378 if (CONSP (val) && CONSP (XCONS (val)->cdr)) 3378 if (CONSP (val) && CONSP (XCDR (val)))
3379 inserted = XINT (XCONS (XCONS (val)->cdr)->car); 3379 inserted = XINT (XCAR (XCDR (val)));
3380 goto handled; 3380 goto handled;
3381 } 3381 }
3382 3382
3383 orig_filename = filename; 3383 orig_filename = filename;
3384 filename = ENCODE_FILE (filename); 3384 filename = ENCODE_FILE (filename);
3548 3548
3549 args[0] = Qinsert_file_contents, args[1] = orig_filename; 3549 args[0] = Qinsert_file_contents, args[1] = orig_filename;
3550 args[2] = visit, args[3] = beg, args[4] = end, args[5] = replace; 3550 args[2] = visit, args[3] = beg, args[4] = end, args[5] = replace;
3551 coding_systems = Ffind_operation_coding_system (6, args); 3551 coding_systems = Ffind_operation_coding_system (6, args);
3552 if (CONSP (coding_systems)) 3552 if (CONSP (coding_systems))
3553 val = XCONS (coding_systems)->car; 3553 val = XCAR (coding_systems);
3554 } 3554 }
3555 } 3555 }
3556 3556
3557 setup_coding_system (Fcheck_coding_system (val), &coding); 3557 setup_coding_system (Fcheck_coding_system (val), &coding);
3558 3558
4081 4081
4082 args[0] = Qinsert_file_contents, args[1] = orig_filename; 4082 args[0] = Qinsert_file_contents, args[1] = orig_filename;
4083 args[2] = visit, args[3] = beg, args[4] = end, args[5] = Qnil; 4083 args[2] = visit, args[3] = beg, args[4] = end, args[5] = Qnil;
4084 coding_systems = Ffind_operation_coding_system (6, args); 4084 coding_systems = Ffind_operation_coding_system (6, args);
4085 if (CONSP (coding_systems)) 4085 if (CONSP (coding_systems))
4086 val = XCONS (coding_systems)->car; 4086 val = XCAR (coding_systems);
4087 } 4087 }
4088 } 4088 }
4089 4089
4090 /* The following kludgy code is to avoid some compiler bug. 4090 /* The following kludgy code is to avoid some compiler bug.
4091 We can't simply do 4091 We can't simply do
4355 4355
4356 args[0] = Qwrite_region; args[1] = start; args[2] = end; 4356 args[0] = Qwrite_region; args[1] = start; args[2] = end;
4357 args[3] = filename; args[4] = append; args[5] = visit; 4357 args[3] = filename; args[4] = append; args[5] = visit;
4358 args[6] = lockname; 4358 args[6] = lockname;
4359 coding_systems = Ffind_operation_coding_system (7, args); 4359 coding_systems = Ffind_operation_coding_system (7, args);
4360 if (CONSP (coding_systems) && !NILP (XCONS (coding_systems)->cdr)) 4360 if (CONSP (coding_systems) && !NILP (XCDR (coding_systems)))
4361 val = XCONS (coding_systems)->cdr; 4361 val = XCDR (coding_systems);
4362 } 4362 }
4363 4363
4364 if (NILP (val) 4364 if (NILP (val)
4365 && !NILP (current_buffer->buffer_file_coding_system)) 4365 && !NILP (current_buffer->buffer_file_coding_system))
4366 { 4366 {
5077 do_auto_save_unwind (stream) /* used as unwind-protect function */ 5077 do_auto_save_unwind (stream) /* used as unwind-protect function */
5078 Lisp_Object stream; 5078 Lisp_Object stream;
5079 { 5079 {
5080 auto_saving = 0; 5080 auto_saving = 0;
5081 if (!NILP (stream)) 5081 if (!NILP (stream))
5082 fclose ((FILE *) (XFASTINT (XCONS (stream)->car) << 16 5082 fclose ((FILE *) (XFASTINT (XCAR (stream)) << 16
5083 | XFASTINT (XCONS (stream)->cdr))); 5083 | XFASTINT (XCDR (stream))));
5084 return Qnil; 5084 return Qnil;
5085 } 5085 }
5086 5086
5087 static Lisp_Object 5087 static Lisp_Object
5088 do_auto_save_unwind_1 (value) /* used as unwind-protect function */ 5088 do_auto_save_unwind_1 (value) /* used as unwind-protect function */
5139 if (stream != NULL) 5139 if (stream != NULL)
5140 { 5140 {
5141 /* Arrange to close that file whether or not we get an error. 5141 /* Arrange to close that file whether or not we get an error.
5142 Also reset auto_saving to 0. */ 5142 Also reset auto_saving to 0. */
5143 lispstream = Fcons (Qnil, Qnil); 5143 lispstream = Fcons (Qnil, Qnil);
5144 XSETFASTINT (XCONS (lispstream)->car, (EMACS_UINT)stream >> 16); 5144 XSETFASTINT (XCAR (lispstream), (EMACS_UINT)stream >> 16);
5145 XSETFASTINT (XCONS (lispstream)->cdr, (EMACS_UINT)stream & 0xffff); 5145 XSETFASTINT (XCDR (lispstream), (EMACS_UINT)stream & 0xffff);
5146 } 5146 }
5147 else 5147 else
5148 lispstream = Qnil; 5148 lispstream = Qnil;
5149 } 5149 }
5150 else 5150 else
5163 crashing, the handlers may tweak what is causing Emacs to crash 5163 crashing, the handlers may tweak what is causing Emacs to crash
5164 in the first place, and it would be a shame if Emacs failed to 5164 in the first place, and it would be a shame if Emacs failed to
5165 autosave perfectly ordinary files because it couldn't handle some 5165 autosave perfectly ordinary files because it couldn't handle some
5166 ange-ftp'd file. */ 5166 ange-ftp'd file. */
5167 for (do_handled_files = 0; do_handled_files < 2; do_handled_files++) 5167 for (do_handled_files = 0; do_handled_files < 2; do_handled_files++)
5168 for (tail = Vbuffer_alist; GC_CONSP (tail); tail = XCONS (tail)->cdr) 5168 for (tail = Vbuffer_alist; GC_CONSP (tail); tail = XCDR (tail))
5169 { 5169 {
5170 buf = XCONS (XCONS (tail)->car)->cdr; 5170 buf = XCDR (XCAR (tail));
5171 b = XBUFFER (buf); 5171 b = XBUFFER (buf);
5172 5172
5173 /* Record all the buffers that have auto save mode 5173 /* Record all the buffers that have auto save mode
5174 in the special file that lists them. For each of these buffers, 5174 in the special file that lists them. For each of these buffers,
5175 Record visited name (if any) and auto save name. */ 5175 Record visited name (if any) and auto save name. */
5522 val = Fcompleting_read (prompt, intern ("read-file-name-internal"), 5522 val = Fcompleting_read (prompt, intern ("read-file-name-internal"),
5523 dir, mustmatch, insdef, 5523 dir, mustmatch, insdef,
5524 Qfile_name_history, default_filename, Qnil); 5524 Qfile_name_history, default_filename, Qnil);
5525 5525
5526 tem = Fsymbol_value (Qfile_name_history); 5526 tem = Fsymbol_value (Qfile_name_history);
5527 if (CONSP (tem) && EQ (XCONS (tem)->car, val)) 5527 if (CONSP (tem) && EQ (XCAR (tem), val))
5528 replace_in_history = 1; 5528 replace_in_history = 1;
5529 5529
5530 /* If Fcompleting_read returned the inserted default string itself 5530 /* If Fcompleting_read returned the inserted default string itself
5531 (rather than a new string with the same contents), 5531 (rather than a new string with the same contents),
5532 it has to mean that the user typed RET with the minibuffer empty. 5532 it has to mean that the user typed RET with the minibuffer empty.
5561 val = Fsubstitute_in_file_name (val); 5561 val = Fsubstitute_in_file_name (val);
5562 5562
5563 if (replace_in_history) 5563 if (replace_in_history)
5564 /* Replace what Fcompleting_read added to the history 5564 /* Replace what Fcompleting_read added to the history
5565 with what we will actually return. */ 5565 with what we will actually return. */
5566 XCONS (Fsymbol_value (Qfile_name_history))->car = double_dollars (val); 5566 XCAR (Fsymbol_value (Qfile_name_history)) = double_dollars (val);
5567 else if (add_to_history) 5567 else if (add_to_history)
5568 { 5568 {
5569 /* Add the value to the history--but not if it matches 5569 /* Add the value to the history--but not if it matches
5570 the last value already there. */ 5570 the last value already there. */
5571 Lisp_Object val1 = double_dollars (val); 5571 Lisp_Object val1 = double_dollars (val);
5572 tem = Fsymbol_value (Qfile_name_history); 5572 tem = Fsymbol_value (Qfile_name_history);
5573 if (! CONSP (tem) || NILP (Fequal (XCONS (tem)->car, val1))) 5573 if (! CONSP (tem) || NILP (Fequal (XCAR (tem), val1)))
5574 Fset (Qfile_name_history, 5574 Fset (Qfile_name_history,
5575 Fcons (val1, tem)); 5575 Fcons (val1, tem));
5576 } 5576 }
5577 5577
5578 return val; 5578 return val;