comparison src/filelock.c @ 40:7e54bd776075 r19-15b103

Import from CVS: tag r19-15b103
author cvs
date Mon, 13 Aug 2007 08:54:25 +0200
parents 859a2309aef8
children 131b0175ea99
comparison
equal deleted inserted replaced
39:06f275776fba 40:7e54bd776075
194 (ie., /ka/king/junk.tex -> /!/12a82c62f1c6da). */ 194 (ie., /ka/king/junk.tex -> /!/12a82c62f1c6da). */
195 195
196 void 196 void
197 lock_file (Lisp_Object fn) 197 lock_file (Lisp_Object fn)
198 { 198 {
199 /* This function can GC */ 199 /* This function can GC. */
200 /* dmoore - and can destroy current_buffer and all sorts of other
201 mean nasty things with pointy teeth. If you call this make sure
202 you protect things right. */
203
200 REGISTER Lisp_Object attack, orig_fn; 204 REGISTER Lisp_Object attack, orig_fn;
201 REGISTER char *lfname; 205 REGISTER char *lfname;
202 struct gcpro gcpro1, gcpro2; 206 struct gcpro gcpro1, gcpro2;
203 Lisp_Object subject_buf = Qnil; 207 Lisp_Object subject_buf = Qnil;
204 208
333 337
334 338
335 void 339 void
336 unlock_file (Lisp_Object fn) 340 unlock_file (Lisp_Object fn)
337 { 341 {
342 /* This function can GC. */
343 /* dmoore - and can destroy current_buffer and all sorts of other
344 mean nasty things with pointy teeth. If you call this make sure
345 you protect things right. */
346
338 REGISTER char *lfname; 347 REGISTER char *lfname;
339 if (NILP (Vlock_directory) || NILP (Vsuperlock_file)) return; 348 if (NILP (Vlock_directory) || NILP (Vsuperlock_file)) return;
340 CHECK_STRING (fn); 349 CHECK_STRING (fn);
341 CHECK_STRING (Vlock_directory); 350 CHECK_STRING (Vlock_directory);
342 CHECK_STRING (Vsuperlock_file); 351 CHECK_STRING (Vsuperlock_file);
389 } 398 }
390 399
391 void 400 void
392 unlock_all_files (void) 401 unlock_all_files (void)
393 { 402 {
394 REGISTER Lisp_Object tail; 403 /* This function can GC. */
404
405 Lisp_Object tail;
395 REGISTER struct buffer *b; 406 REGISTER struct buffer *b;
396 407 struct gcpro gcpro1;
408
409 GCPRO1 (tail);
397 for (tail = Vbuffer_alist; GC_CONSP (tail); 410 for (tail = Vbuffer_alist; GC_CONSP (tail);
398 tail = XCDR (tail)) 411 tail = XCDR (tail))
399 { 412 {
400 b = XBUFFER (XCDR (XCAR (tail))); 413 b = XBUFFER (XCDR (XCAR (tail)));
401 if (STRINGP (b->file_truename) && 414 if (STRINGP (b->file_truename) &&
402 BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) 415 BUF_SAVE_MODIFF (b) < BUF_MODIFF (b))
403 unlock_file (b->file_truename); 416 unlock_file (b->file_truename);
404 } 417 }
418 UNGCPRO;
405 } 419 }
406 420
407 421
408 DEFUN ("lock-buffer", Flock_buffer, 0, 1, 0, /* 422 DEFUN ("lock-buffer", Flock_buffer, 0, 1, 0, /*
409 Lock FILE, if current buffer is modified. 423 Lock FILE, if current buffer is modified.
411 or else nothing is done if current buffer isn't visiting a file. 425 or else nothing is done if current buffer isn't visiting a file.
412 */ 426 */
413 (fn)) 427 (fn))
414 { 428 {
415 /* This function can GC */ 429 /* This function can GC */
430 /* dmoore - and can destroy current_buffer and all sorts of other
431 mean nasty things with pointy teeth. If you call this make sure
432 you protect things right. */
433
416 if (NILP (fn)) 434 if (NILP (fn))
417 fn = current_buffer->file_truename; 435 fn = current_buffer->file_truename;
418 CHECK_STRING (fn); 436 CHECK_STRING (fn);
419 if (BUF_SAVE_MODIFF (current_buffer) < BUF_MODIFF (current_buffer) 437 if (BUF_SAVE_MODIFF (current_buffer) < BUF_MODIFF (current_buffer)
420 && !NILP (fn)) 438 && !NILP (fn))
426 Unlock the file visited in the current buffer, 444 Unlock the file visited in the current buffer,
427 if it should normally be locked. 445 if it should normally be locked.
428 */ 446 */
429 ()) 447 ())
430 { 448 {
449 /* This function can GC */
450 /* dmoore - and can destroy current_buffer and all sorts of other
451 mean nasty things with pointy teeth. If you call this make sure
452 you protect things right. */
453
431 if (BUF_SAVE_MODIFF (current_buffer) < BUF_MODIFF (current_buffer) 454 if (BUF_SAVE_MODIFF (current_buffer) < BUF_MODIFF (current_buffer)
432 && STRINGP (current_buffer->file_truename)) 455 && STRINGP (current_buffer->file_truename))
433 unlock_file (current_buffer->file_truename); 456 unlock_file (current_buffer->file_truename);
434 return Qnil; 457 return Qnil;
435 } 458 }
438 /* Unlock the file visited in buffer BUFFER. */ 461 /* Unlock the file visited in buffer BUFFER. */
439 462
440 void 463 void
441 unlock_buffer (struct buffer *buffer) 464 unlock_buffer (struct buffer *buffer)
442 { 465 {
466 /* This function can GC */
467 /* dmoore - and can destroy current_buffer and all sorts of other
468 mean nasty things with pointy teeth. If you call this make sure
469 you protect things right. */
443 if (BUF_SAVE_MODIFF (buffer) < BUF_MODIFF (buffer) 470 if (BUF_SAVE_MODIFF (buffer) < BUF_MODIFF (buffer)
444 && STRINGP (buffer->file_truename)) 471 && STRINGP (buffer->file_truename))
445 unlock_file (buffer->file_truename); 472 unlock_file (buffer->file_truename);
446 } 473 }
447 474