Mercurial > hg > xemacs-beta
comparison src/filelock.c @ 114:8619ce7e4c50 r20-1b9
Import from CVS: tag r20-1b9
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:21:54 +0200 |
parents | 4be1180a9e89 |
children | 3bb7ccffb0c0 |
comparison
equal
deleted
inserted
replaced
113:2ec2fe4a4c89 | 114:8619ce7e4c50 |
---|---|
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 |
335 | 339 |
336 | 340 |
337 void | 341 void |
338 unlock_file (Lisp_Object fn) | 342 unlock_file (Lisp_Object fn) |
339 { | 343 { |
344 /* This function can GC. */ | |
345 /* dmoore - and can destroy current_buffer and all sorts of other | |
346 mean nasty things with pointy teeth. If you call this make sure | |
347 you protect things right. */ | |
348 | |
340 REGISTER char *lfname; | 349 REGISTER char *lfname; |
341 if (NILP (Vlock_directory) || NILP (Vsuperlock_file)) return; | 350 if (NILP (Vlock_directory) || NILP (Vsuperlock_file)) return; |
342 CHECK_STRING (fn); | 351 CHECK_STRING (fn); |
343 CHECK_STRING (Vlock_directory); | 352 CHECK_STRING (Vlock_directory); |
344 CHECK_STRING (Vsuperlock_file); | 353 CHECK_STRING (Vsuperlock_file); |
393 } | 402 } |
394 | 403 |
395 void | 404 void |
396 unlock_all_files (void) | 405 unlock_all_files (void) |
397 { | 406 { |
398 REGISTER Lisp_Object tail; | 407 /* This function can GC. */ |
408 | |
409 Lisp_Object tail; | |
399 REGISTER struct buffer *b; | 410 REGISTER struct buffer *b; |
400 | 411 struct gcpro gcpro1; |
412 | |
413 GCPRO1 (tail); | |
401 for (tail = Vbuffer_alist; GC_CONSP (tail); | 414 for (tail = Vbuffer_alist; GC_CONSP (tail); |
402 tail = XCDR (tail)) | 415 tail = XCDR (tail)) |
403 { | 416 { |
404 b = XBUFFER (XCDR (XCAR (tail))); | 417 b = XBUFFER (XCDR (XCAR (tail))); |
405 if (STRINGP (b->file_truename) && | 418 if (STRINGP (b->file_truename) && |
406 BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) | 419 BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) |
407 unlock_file (b->file_truename); | 420 unlock_file (b->file_truename); |
408 } | 421 } |
422 UNGCPRO; | |
409 } | 423 } |
410 | 424 |
411 | 425 |
412 DEFUN ("lock-buffer", Flock_buffer, 0, 1, 0, /* | 426 DEFUN ("lock-buffer", Flock_buffer, 0, 1, 0, /* |
413 Lock FILE, if current buffer is modified. | 427 Lock FILE, if current buffer is modified. |
415 or else nothing is done if current buffer isn't visiting a file. | 429 or else nothing is done if current buffer isn't visiting a file. |
416 */ | 430 */ |
417 (fn)) | 431 (fn)) |
418 { | 432 { |
419 /* This function can GC */ | 433 /* This function can GC */ |
434 /* dmoore - and can destroy current_buffer and all sorts of other | |
435 mean nasty things with pointy teeth. If you call this make sure | |
436 you protect things right. */ | |
437 | |
420 if (NILP (fn)) | 438 if (NILP (fn)) |
421 fn = current_buffer->file_truename; | 439 fn = current_buffer->file_truename; |
422 CHECK_STRING (fn); | 440 CHECK_STRING (fn); |
423 if (BUF_SAVE_MODIFF (current_buffer) < BUF_MODIFF (current_buffer) | 441 if (BUF_SAVE_MODIFF (current_buffer) < BUF_MODIFF (current_buffer) |
424 && !NILP (fn)) | 442 && !NILP (fn)) |
430 Unlock the file visited in the current buffer, | 448 Unlock the file visited in the current buffer, |
431 if it should normally be locked. | 449 if it should normally be locked. |
432 */ | 450 */ |
433 ()) | 451 ()) |
434 { | 452 { |
453 /* This function can GC */ | |
454 /* dmoore - and can destroy current_buffer and all sorts of other | |
455 mean nasty things with pointy teeth. If you call this make sure | |
456 you protect things right. */ | |
457 | |
435 if (BUF_SAVE_MODIFF (current_buffer) < BUF_MODIFF (current_buffer) | 458 if (BUF_SAVE_MODIFF (current_buffer) < BUF_MODIFF (current_buffer) |
436 && STRINGP (current_buffer->file_truename)) | 459 && STRINGP (current_buffer->file_truename)) |
437 unlock_file (current_buffer->file_truename); | 460 unlock_file (current_buffer->file_truename); |
438 return Qnil; | 461 return Qnil; |
439 } | 462 } |
442 /* Unlock the file visited in buffer BUFFER. */ | 465 /* Unlock the file visited in buffer BUFFER. */ |
443 | 466 |
444 void | 467 void |
445 unlock_buffer (struct buffer *buffer) | 468 unlock_buffer (struct buffer *buffer) |
446 { | 469 { |
470 /* This function can GC */ | |
471 /* dmoore - and can destroy current_buffer and all sorts of other | |
472 mean nasty things with pointy teeth. If you call this make sure | |
473 you protect things right. */ | |
447 if (BUF_SAVE_MODIFF (buffer) < BUF_MODIFF (buffer) | 474 if (BUF_SAVE_MODIFF (buffer) < BUF_MODIFF (buffer) |
448 && STRINGP (buffer->file_truename)) | 475 && STRINGP (buffer->file_truename)) |
449 unlock_file (buffer->file_truename); | 476 unlock_file (buffer->file_truename); |
450 } | 477 } |
451 | 478 |