Mercurial > hg > xemacs-beta
comparison src/fileio.c @ 280:7df0dd720c89 r21-0b38
Import from CVS: tag r21-0b38
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:32:22 +0200 |
parents | 90d73dddcdc4 |
children | 558f606b08ae |
comparison
equal
deleted
inserted
replaced
279:c20b2fb5bb0a | 280:7df0dd720c89 |
---|---|
131 | 131 |
132 Lisp_Object Qcar_less_than_car; | 132 Lisp_Object Qcar_less_than_car; |
133 | 133 |
134 Lisp_Object Qcompute_buffer_file_truename; | 134 Lisp_Object Qcompute_buffer_file_truename; |
135 | 135 |
136 EXFUN (Frunning_temacs_p, 0); | |
137 | |
136 /* signal a file error when errno contains a meaningful value. */ | 138 /* signal a file error when errno contains a meaningful value. */ |
137 | 139 |
138 DOESNT_RETURN | 140 DOESNT_RETURN |
139 report_file_error (CONST char *string, Lisp_Object data) | 141 report_file_error (CONST char *string, Lisp_Object data) |
140 { | 142 { |
258 | 260 |
259 return Qnil; | 261 return Qnil; |
260 } | 262 } |
261 | 263 |
262 static Lisp_Object | 264 static Lisp_Object |
263 close_stream_unwind (Lisp_Object stream) | 265 delete_stream_unwind (Lisp_Object stream) |
264 { | 266 { |
265 Lstream_close (XLSTREAM (stream)); | 267 Lstream_delete (XLSTREAM (stream)); |
266 return Qnil; | 268 return Qnil; |
267 } | 269 } |
268 | 270 |
269 /* Restore point, having saved it as a marker. */ | 271 /* Restore point, having saved it as a marker. */ |
270 | 272 |
714 this by initializing count to a random value, and incrementing it | 716 this by initializing count to a random value, and incrementing it |
715 afterwards. */ | 717 afterwards. */ |
716 if (!count_initialized_p) | 718 if (!count_initialized_p) |
717 { | 719 { |
718 count = (unsigned)time (NULL); | 720 count = (unsigned)time (NULL); |
719 count_initialized_p = 1; | 721 /* Dumping temacs with a non-zero count_initialized_p wouldn't |
722 make much sense. */ | |
723 if (NILP (Frunning_temacs_p ())) | |
724 count_initialized_p = 1; | |
720 } | 725 } |
721 | 726 |
722 while (1) | 727 while (1) |
723 { | 728 { |
724 struct stat ignored; | 729 struct stat ignored; |
725 unsigned num = count++; | 730 unsigned num = count; |
726 | 731 |
727 p[0] = tbl[num & 63], num >>= 6; | 732 p[0] = tbl[num & 63], num >>= 6; |
728 p[1] = tbl[num & 63], num >>= 6; | 733 p[1] = tbl[num & 63], num >>= 6; |
729 p[2] = tbl[num & 63], num >>= 6; | 734 p[2] = tbl[num & 63], num >>= 6; |
735 | |
736 /* Poor man's congruential RN generator. Replace with ++count | |
737 for debugging. */ | |
738 count += 25229; | |
739 count %= 225307; | |
730 | 740 |
731 if (stat ((CONST char *) data, &ignored) < 0) | 741 if (stat ((CONST char *) data, &ignored) < 0) |
732 { | 742 { |
733 /* We want to return only if errno is ENOENT. */ | 743 /* We want to return only if errno is ENOENT. */ |
734 if (errno == ENOENT) | 744 if (errno == ENOENT) |
736 else | 746 else |
737 /* The error here is dubious, but there is little else we | 747 /* The error here is dubious, but there is little else we |
738 can do. The alternatives are to return nil, which is | 748 can do. The alternatives are to return nil, which is |
739 as bad as (and in many cases worse than) throwing the | 749 as bad as (and in many cases worse than) throwing the |
740 error, or to ignore the error, which will likely result | 750 error, or to ignore the error, which will likely result |
741 in looping through 262144 stat's, which is not only | 751 in looping through 225307 stat's, which is not only |
742 dog-slow, but also useless since it will fallback to | 752 dog-slow, but also useless since it will fallback to |
743 the errow below, anyway. */ | 753 the errow below, anyway. */ |
744 report_file_error ("Cannot create temporary name for prefix", | 754 report_file_error ("Cannot create temporary name for prefix", |
745 list1 (prefix)); | 755 list1 (prefix)); |
746 /* not reached */ | 756 /* not reached */ |
747 } | 757 } |
748 } | 758 } |
749 signal_simple_error ("Cannot create temporary name for prefix", prefix); | 759 signal_simple_error ("Cannot create temporary name for prefix", prefix); |
750 RETURN_NOT_REACHED (Qnil); | 760 RETURN_NOT_REACHED (Qnil); |
751 } | 761 } |
762 | |
752 | 763 |
753 DEFUN ("expand-file-name", Fexpand_file_name, 1, 2, 0, /* | 764 DEFUN ("expand-file-name", Fexpand_file_name, 1, 2, 0, /* |
754 Convert filename NAME to absolute, and canonicalize it. | 765 Convert filename NAME to absolute, and canonicalize it. |
755 Second arg DEFAULT-DIRECTORY is directory to start with if NAME is relative | 766 Second arg DEFAULT-DIRECTORY is directory to start with if NAME is relative |
756 (does not start with slash); if DEFAULT-DIRECTORY is nil or missing, | 767 (does not start with slash); if DEFAULT-DIRECTORY is nil or missing, |
2632 | 2643 |
2633 /* Stack sizes > 2**16 is a good way to elicit compiler bugs */ | 2644 /* Stack sizes > 2**16 is a good way to elicit compiler bugs */ |
2634 /* #define READ_BUF_SIZE (2 << 16) */ | 2645 /* #define READ_BUF_SIZE (2 << 16) */ |
2635 #define READ_BUF_SIZE (1 << 15) | 2646 #define READ_BUF_SIZE (1 << 15) |
2636 | 2647 |
2637 DEFUN ("insert-file-contents-internal", Finsert_file_contents_internal, 1, 7, 0, /* | 2648 DEFUN ("insert-file-contents-internal", Finsert_file_contents_internal, |
2649 1, 7, 0, /* | |
2638 Insert contents of file FILENAME after point; no coding-system frobbing. | 2650 Insert contents of file FILENAME after point; no coding-system frobbing. |
2639 This function is identical to `insert-file-contents' except for the | 2651 This function is identical to `insert-file-contents' except for the |
2640 handling of the CODESYS and USED-CODESYS arguments under | 2652 handling of the CODESYS and USED-CODESYS arguments under |
2641 XEmacs/Mule. (When Mule support is not present, both functions are | 2653 XEmacs/Mule. (When Mule support is not present, both functions are |
2642 identical and ignore the CODESYS and USED-CODESYS arguments.) | 2654 identical and ignore the CODESYS and USED-CODESYS arguments.) |
2946 (XLSTREAM (stream), Fget_coding_system (codesys)); | 2958 (XLSTREAM (stream), Fget_coding_system (codesys)); |
2947 Lstream_set_character_mode (XLSTREAM (stream)); | 2959 Lstream_set_character_mode (XLSTREAM (stream)); |
2948 Lstream_set_buffering (XLSTREAM (stream), LSTREAM_BLOCKN_BUFFERED, 65536); | 2960 Lstream_set_buffering (XLSTREAM (stream), LSTREAM_BLOCKN_BUFFERED, 65536); |
2949 #endif /* FILE_CODING */ | 2961 #endif /* FILE_CODING */ |
2950 | 2962 |
2951 record_unwind_protect (close_stream_unwind, stream); | 2963 record_unwind_protect (delete_stream_unwind, stream); |
2952 | 2964 |
2953 /* No need to limit the amount of stuff we attempt to read. (It would | 2965 /* No need to limit the amount of stuff we attempt to read. (It would |
2954 be incorrect, anyway, when Mule is enabled.) Instead, the limiting | 2966 be incorrect, anyway, when Mule is enabled.) Instead, the limiting |
2955 occurs inside of the filedesc stream. */ | 2967 occurs inside of the filedesc stream. */ |
2956 while (1) | 2968 while (1) |
3318 | 3330 |
3319 (This has supposedly been fixed in Sunos 4, | 3331 (This has supposedly been fixed in Sunos 4, |
3320 but who knows about all the other machines with NFS?) */ | 3332 but who knows about all the other machines with NFS?) */ |
3321 /* On VMS and APOLLO, must do the stat after the close | 3333 /* On VMS and APOLLO, must do the stat after the close |
3322 since closing changes the modtime. */ | 3334 since closing changes the modtime. */ |
3323 #if 1 /* !defined (VMS) && !defined (APOLLO) */ | 3335 /* As it does on Windows too - kkm */ |
3336 #if !defined (WINDOWSNT) /* !defined (VMS) && !defined (APOLLO) */ | |
3324 fstat (desc, &st); | 3337 fstat (desc, &st); |
3325 #endif | 3338 #endif |
3326 | 3339 |
3327 /* NFS can report a write failure now. */ | 3340 /* NFS can report a write failure now. */ |
3328 if (close (desc) < 0) | 3341 if (close (desc) < 0) |
3336 as necessary). */ | 3349 as necessary). */ |
3337 XCAR (desc_locative) = Qnil; | 3350 XCAR (desc_locative) = Qnil; |
3338 unbind_to (speccount, Qnil); | 3351 unbind_to (speccount, Qnil); |
3339 } | 3352 } |
3340 | 3353 |
3341 | 3354 #if defined (WINDOWSNT) /* defined (VMS) || defined (APOLLO) */ |
3342 #if 0 /* defined (VMS) || defined (APOLLO) */ | |
3343 stat ((char *) XSTRING_DATA (fn), &st); | 3355 stat ((char *) XSTRING_DATA (fn), &st); |
3344 #endif | 3356 #endif |
3345 | 3357 |
3346 #ifdef CLASH_DETECTION | 3358 #ifdef CLASH_DETECTION |
3347 if (!auto_saving) | 3359 if (!auto_saving) |
3399 DEFUN ("car-less-than-car", Fcar_less_than_car, 2, 2, 0, /* | 3411 DEFUN ("car-less-than-car", Fcar_less_than_car, 2, 2, 0, /* |
3400 Return t if (car A) is numerically less than (car B). | 3412 Return t if (car A) is numerically less than (car B). |
3401 */ | 3413 */ |
3402 (a, b)) | 3414 (a, b)) |
3403 { | 3415 { |
3404 return Flss (Fcar (a), Fcar (b)); | 3416 return arithcompare (Fcar (a), Fcar (b), arith_less); |
3405 } | 3417 } |
3406 | 3418 |
3407 /* Heh heh heh, let's define this too, just to aggravate the person who | 3419 /* Heh heh heh, let's define this too, just to aggravate the person who |
3408 wrote the above comment. */ | 3420 wrote the above comment. */ |
3409 DEFUN ("cdr-less-than-cdr", Fcdr_less_than_cdr, 2, 2, 0, /* | 3421 DEFUN ("cdr-less-than-cdr", Fcdr_less_than_cdr, 2, 2, 0, /* |
3410 Return t if (cdr A) is numerically less than (cdr B). | 3422 Return t if (cdr A) is numerically less than (cdr B). |
3411 */ | 3423 */ |
3412 (a, b)) | 3424 (a, b)) |
3413 { | 3425 { |
3414 return Flss (Fcdr (a), Fcdr (b)); | 3426 return arithcompare (Fcdr (a), Fcdr (b), arith_less); |
3415 } | 3427 } |
3416 | 3428 |
3417 /* Build the complete list of annotations appropriate for writing out | 3429 /* Build the complete list of annotations appropriate for writing out |
3418 the text between START and END, by calling all the functions in | 3430 the text between START and END, by calling all the functions in |
3419 write-region-annotate-functions and merging the lists they return. | 3431 write-region-annotate-functions and merging the lists they return. |