comparison src/fileio.c @ 1333:1b0339b048ce

[xemacs-hg @ 2003-03-02 09:38:37 by ben] To: xemacs-patches@xemacs.org PROBLEMS: Include nt/PROBLEMS and update. Add note about incremental linking badness. cmdloop.el, custom.el, dumped-lisp.el, files.el, keydefs.el, keymap.el, lisp-mode.el, make-docfile.el, replace.el, simple.el, subr.el, view-less.el, wid-edit.el: Lots of syncing with FSF 21.2. Use if-fboundp in wid-edit.el. New file newcomment.el from FSF. internals/internals.texi: Fix typo. (Build-Time Dependencies): New node. PROBLEMS: Delete. config.inc.samp, xemacs.mak: Eliminate HAVE_VC6, use SUPPORT_EDIT_AND_CONTINUE in its place. No incremental linking unless SUPPORT_EDIT_AND_CONTINUE, since it can cause nasty crashes in pdump. Put warnings about this in config.inc.samp. Report the full compile flags used for src and lib-src in the Installation output. alloc.c, lisp.h, ralloc.c, regex.c: Use ALLOCA() in regex.c to avoid excessive stack allocation. Also fix subtle problem with REL_ALLOC() -- any call to malloc() (direct or indirect) may relocate rel-alloced data, causing buffer text to shift. After any such call, regex must update all its pointers to such data. Add a system, when ERROR_CHECK_MALLOC, whereby regex.c indicates all the places it is prepared to handle malloc()/realloc()/free(), and any calls anywhere in XEmacs outside of this will trigger an abort. alloc.c, dialog-msw.c, eval.c, event-stream.c, general-slots.h, insdel.c, lisp.h, menubar-msw.c, menubar-x.c: Change *run_hook*_trapping_problems to take a warning class, not a string. Factor out code to issue warnings, add flag to call_trapping_problems() to postpone warning issue, and make *run_hook*_trapping_problems issue their own warnings tailored to the hook, postponed in the case of safe_run_hook_trapping_problems() so that the appropriate message can be issued about resetting to nil only when not `quit'. Make record_unwind_protect_restoring_int() non-static. dumper.c: Issue notes about incremental linking problems under Windows. fileio.c: Mule-ize encrypt/decrypt-string code. text.h: Spacing changes.
author ben
date Sun, 02 Mar 2003 09:38:54 +0000
parents 70921960b980
children a8d8f419b459
comparison
equal deleted inserted replaced
1332:6aa23bb3da6b 1333:1b0339b048ce
1 /* File IO for XEmacs. 1 /* File IO for XEmacs.
2 Copyright (C) 1985-1988, 1992-1995 Free Software Foundation, Inc. 2 Copyright (C) 1985-1988, 1992-1995 Free Software Foundation, Inc.
3 Copyright (C) 1996, 2001, 2002 Ben Wing. 3 Copyright (C) 1996, 2001, 2002, 2003 Ben Wing.
4 4
5 This file is part of XEmacs. 5 This file is part of XEmacs.
6 6
7 XEmacs is free software; you can redistribute it and/or modify it 7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
23 /* More syncing: FSF Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> 23 /* More syncing: FSF Emacs 19.34.6 by Marc Paquette <marcpa@cam.org>
24 (Note: Sync messages from Marc Paquette may indicate 24 (Note: Sync messages from Marc Paquette may indicate
25 incomplete synching, so beware.) */ 25 incomplete synching, so beware.) */
26 /* Mule-ized completely except for the #if 0-code including decrypt-string 26 /* Mule-ized completely except for the #if 0-code including decrypt-string
27 and encrypt-string. --ben 7-2-00 */ 27 and encrypt-string. --ben 7-2-00 */
28 /* #if 0-code Mule-ized, 2-22-03. --ben */
28 29
29 30
30 #include <config.h> 31 #include <config.h>
31 #include "lisp.h" 32 #include "lisp.h"
32 33
1696 to alter the file. 1697 to alter the file.
1697 *STATPTR is used to store the stat information if the file exists. 1698 *STATPTR is used to store the stat information if the file exists.
1698 If the file does not exist, STATPTR->st_mode is set to 0. */ 1699 If the file does not exist, STATPTR->st_mode is set to 0. */
1699 1700
1700 static void 1701 static void
1701 barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring, 1702 barf_or_query_if_file_exists (Lisp_Object absname, const CIbyte *querystring,
1702 int interactive, struct stat *statptr) 1703 int interactive, struct stat *statptr)
1703 { 1704 {
1704 /* This function can call Lisp. GC checked 2000-07-28 ben */ 1705 /* This function can call Lisp. GC checked 2000-07-28 ben */
1705 struct stat statbuf; 1706 struct stat statbuf;
1706 1707
2191 Open a network connection to PATH using LOGIN as the login string. 2192 Open a network connection to PATH using LOGIN as the login string.
2192 */ 2193 */
2193 (path, login)) 2194 (path, login))
2194 { 2195 {
2195 int netresult; 2196 int netresult;
2196 const char *path_ext; 2197 const Extbyte *path_ext;
2197 const char *login_ext; 2198 const Extbyte *login_ext;
2198 2199
2199 CHECK_STRING (path); 2200 CHECK_STRING (path);
2200 CHECK_STRING (login); 2201 CHECK_STRING (login);
2201 2202
2202 /* netunam, being a strange-o system call only used once, is not 2203 /* netunam, being a strange-o system call only used once, is not
3665 DEFUN ("encrypt-string", Fencrypt_string, 2, 2, 0, /* 3666 DEFUN ("encrypt-string", Fencrypt_string, 2, 2, 0, /*
3666 Encrypt STRING using KEY. 3667 Encrypt STRING using KEY.
3667 */ 3668 */
3668 (string, key)) 3669 (string, key))
3669 { 3670 {
3670 char *encrypted_string, *raw_key; 3671 Extbyte *encrypted_string, *raw_key;
3671 int rounded_size, extra, key_size; 3672 Extbyte *string_ext, *key_ext;
3672 3673 Bytecount string_size_ext, key_size_ext, rounded_size, extra, key_size;
3673 /* !!#### May produce bogus data under Mule. */ 3674
3674 CHECK_STRING (string); 3675 CHECK_STRING (string);
3675 CHECK_STRING (key); 3676 CHECK_STRING (key);
3676 3677
3677 extra = XSTRING_LENGTH (string) % CRYPT_BLOCK_SIZE; 3678 LISP_STRING_TO_SIZED_EXTERNAL (string, string_ext, string_size_ext, Qbinary);
3678 rounded_size = XSTRING_LENGTH (string) + extra; 3679 LISP_STRING_TO_SIZED_EXTERNAL (key, key_ext, key_size_ext, Qbinary);
3680
3681 extra = string_size_ext % CRYPT_BLOCK_SIZE;
3682 rounded_size = string_size_ext + extra;
3679 encrypted_string = ALLOCA (rounded_size + 1); 3683 encrypted_string = ALLOCA (rounded_size + 1);
3680 memcpy (encrypted_string, XSTRING_DATA (string), XSTRING_LENGTH (string)); 3684 memcpy (encrypted_string, string_ext, string_size_ext);
3681 memset (encrypted_string + rounded_size - extra, 0, extra + 1); 3685 memset (encrypted_string + rounded_size - extra, 0, extra + 1);
3682 3686
3683 key_size = min (CRYPT_KEY_SIZE, XSTRING_LENGTH (key)) 3687 key_size = min (CRYPT_KEY_SIZE, key_size_ext);
3684 3688
3685 raw_key = ALLOCA (CRYPT_KEY_SIZE + 1); 3689 raw_key = ALLOCA (CRYPT_KEY_SIZE + 1);
3686 memcpy (raw_key, XSTRING_DATA (key), key_size); 3690 memcpy (raw_key, key_ext, key_size);
3687 memset (raw_key + key_size, 0, (CRYPT_KEY_SIZE + 1) - key_size); 3691 memset (raw_key + key_size, 0, (CRYPT_KEY_SIZE + 1) - key_size);
3688 3692
3689 ecb_crypt (raw_key, encrypted_string, rounded_size, 3693 ecb_crypt (raw_key, encrypted_string, rounded_size,
3690 DES_ENCRYPT | DES_SW); 3694 DES_ENCRYPT | DES_SW);
3691 return make_string (encrypted_string, rounded_size); 3695 return make_ext_string (encrypted_string, rounded_size, Qbinary);
3692 } 3696 }
3693 3697
3694 DEFUN ("decrypt-string", Fdecrypt_string, 2, 2, 0, /* 3698 DEFUN ("decrypt-string", Fdecrypt_string, 2, 2, 0, /*
3695 Decrypt STRING using KEY. 3699 Decrypt STRING using KEY.
3696 */ 3700 */
3697 (string, key)) 3701 (string, key))
3698 { 3702 {
3699 /* !!#### May produce bogus data under Mule. */ 3703 Extbyte *decrypted_string, *raw_key;
3700 char *decrypted_string, *raw_key; 3704 Extbyte *string_ext, *key_ext;
3701 int string_size, key_size; 3705 Bytecount string_size_ext, key_size_ext, string_size, key_size;
3702 3706
3703 CHECK_STRING (string); 3707 CHECK_STRING (string);
3704 CHECK_STRING (key); 3708 CHECK_STRING (key);
3705 3709
3706 string_size = XSTRING_LENGTH (string) + 1; 3710 LISP_STRING_TO_SIZED_EXTERNAL (string, string_ext, string_size_ext, Qbinary);
3711 LISP_STRING_TO_SIZED_EXTERNAL (key, key_ext, key_size_ext, Qbinary);
3712
3713 string_size = string_size_ext + 1;
3707 decrypted_string = ALLOCA (string_size); 3714 decrypted_string = ALLOCA (string_size);
3708 memcpy (decrypted_string, XSTRING_DATA (string), string_size); 3715 memcpy (decrypted_string, string_ext, string_size);
3709 decrypted_string[string_size - 1] = '\0'; 3716 decrypted_string[string_size - 1] = '\0';
3710 3717
3711 key_size = min (CRYPT_KEY_SIZE, XSTRING_LENGTH (key)) 3718 key_size = min (CRYPT_KEY_SIZE, key_size_ext);
3712 3719
3713 raw_key = ALLOCA (CRYPT_KEY_SIZE + 1); 3720 raw_key = ALLOCA (CRYPT_KEY_SIZE + 1);
3714 memcpy (raw_key, XSTRING_DATA (key), key_size); 3721 memcpy (raw_key, key_ext, key_size);
3715 memset (raw_key + key_size, 0, (CRYPT_KEY_SIZE + 1) - key_size); 3722 memset (raw_key + key_size, 0, (CRYPT_KEY_SIZE + 1) - key_size);
3716 3723
3717 3724
3718 ecb_crypt (raw_key, decrypted_string, string_size, D | DES_SW); 3725 ecb_crypt (raw_key, decrypted_string, string_size, D | DES_SW);
3719 return make_string (decrypted_string, string_size - 1); 3726 return make_ext_string (decrypted_string, string_size - 1, Qbinary);
3720 } 3727 }
3721 #endif /* 0 */ 3728 #endif /* 0 */
3722 3729
3723 3730
3724 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime, 1, 1, 0, /* 3731 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime, 1, 1, 0, /*
4038 continue; 4045 continue;
4039 } 4046 }
4040 set_buffer_internal (b); 4047 set_buffer_internal (b);
4041 if (!auto_saved && NILP (no_message)) 4048 if (!auto_saved && NILP (no_message))
4042 { 4049 {
4043 static const unsigned char *msg 4050 static const Ibyte *msg = (const Ibyte *) "Auto-saving...";
4044 = (const unsigned char *) "Auto-saving...";
4045 echo_area_message (selected_frame (), msg, Qnil, 4051 echo_area_message (selected_frame (), msg, Qnil,
4046 0, strlen ((const char *) msg), 4052 0, qxestrlen (msg),
4047 Qauto_saving); 4053 Qauto_saving);
4048 } 4054 }
4049 4055
4050 /* Open the auto-save list file, if necessary. 4056 /* Open the auto-save list file, if necessary.
4051 We only do this now so that the file only exists 4057 We only do this now so that the file only exists
4148 4154
4149 /* Show "...done" only if the echo area would otherwise be empty. */ 4155 /* Show "...done" only if the echo area would otherwise be empty. */
4150 if (auto_saved && NILP (no_message) 4156 if (auto_saved && NILP (no_message)
4151 && NILP (clear_echo_area (selected_frame (), Qauto_saving, 0))) 4157 && NILP (clear_echo_area (selected_frame (), Qauto_saving, 0)))
4152 { 4158 {
4153 static const unsigned char *msg 4159 static const Ibyte *msg = (const Ibyte *)"Auto-saving...done";
4154 = (const unsigned char *)"Auto-saving...done";
4155 echo_area_message (selected_frame (), msg, Qnil, 0, 4160 echo_area_message (selected_frame (), msg, Qnil, 0,
4156 strlen ((const char *) msg), Qauto_saving); 4161 qxestrlen (msg), Qauto_saving);
4157 } 4162 }
4158 4163
4159 Vquit_flag = oquit; 4164 Vquit_flag = oquit;
4160 4165
4161 RETURN_UNGCPRO (unbind_to (speccount)); 4166 RETURN_UNGCPRO (unbind_to (speccount));