aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog9
-rw-r--r--src/fileio.c150
2 files changed, 87 insertions, 72 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 84b32f3455e..883753d52e1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -19,6 +19,15 @@
19 Likewise. 19 Likewise.
20 * keymap.c (Ftext_char_description): Likewise. 20 * keymap.c (Ftext_char_description): Likewise.
21 * minibuf.c (Fread_buffer): Likewise. 21 * minibuf.c (Fread_buffer): Likewise.
22 * fileio.c (IS_DRIVE) [defined WINDOWSNT]:
23 (DRIVE_LETTER) [defined DOS_NT]:
24 (report_file_error, Ffile_name_directory, Ffile_name_nondirectory):
25 (make_temp_name, Fexpand_file_name, file_name_absolute_p):
26 (search_embedded_absfilename, Fsubstitute_in_file_name):
27 (barf_or_query_if_file_exists, Fmake_directory_internal):
28 (Fdelete_directory_internal, Ffile_name_absolute_p, read_non_regular):
29 (Finsert_file_contents, Fwrite_region):
30 Likewise.
22 * insdel.c (insert, insert_and_inherit, insert_before_markers): 31 * insdel.c (insert, insert_and_inherit, insert_before_markers):
23 (insert_before_markers_and_inherit, insert_1, insert_1_both): 32 (insert_before_markers_and_inherit, insert_1, insert_1_both):
24 Likewise. This changes these functions' signatures, which is 33 Likewise. This changes these functions' signatures, which is
diff --git a/src/fileio.c b/src/fileio.c
index 53732f7180f..429fce9f5a0 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -79,12 +79,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
79#define IS_DRIVE(x) ((x) >= 'A' && (x) <= 'z') 79#define IS_DRIVE(x) ((x) >= 'A' && (x) <= 'z')
80#endif 80#endif
81#ifdef WINDOWSNT 81#ifdef WINDOWSNT
82#define IS_DRIVE(x) isalpha (x) 82#define IS_DRIVE(x) isalpha ((unsigned char) (x))
83#endif 83#endif
84/* Need to lower-case the drive letter, or else expanded 84/* Need to lower-case the drive letter, or else expanded
85 filenames will sometimes compare inequal, because 85 filenames will sometimes compare inequal, because
86 `expand-file-name' doesn't always down-case the drive letter. */ 86 `expand-file-name' doesn't always down-case the drive letter. */
87#define DRIVE_LETTER(x) (tolower (x)) 87#define DRIVE_LETTER(x) (tolower ((unsigned char) (x)))
88#endif 88#endif
89 89
90#include "systime.h" 90#include "systime.h"
@@ -193,7 +193,7 @@ report_file_error (const char *string, Lisp_Object data)
193 int c; 193 int c;
194 194
195 str = SSDATA (errstring); 195 str = SSDATA (errstring);
196 c = STRING_CHAR (str); 196 c = STRING_CHAR ((unsigned char *) str);
197 Faset (errstring, make_number (0), make_number (DOWNCASE (c))); 197 Faset (errstring, make_number (0), make_number (DOWNCASE (c)));
198 } 198 }
199 199
@@ -324,11 +324,11 @@ Given a Unix syntax file name, returns a string ending in slash. */)
324 (Lisp_Object filename) 324 (Lisp_Object filename)
325{ 325{
326#ifndef DOS_NT 326#ifndef DOS_NT
327 register const unsigned char *beg; 327 register const char *beg;
328#else 328#else
329 register unsigned char *beg; 329 register char *beg;
330#endif 330#endif
331 register const unsigned char *p; 331 register const char *p;
332 Lisp_Object handler; 332 Lisp_Object handler;
333 333
334 CHECK_STRING (filename); 334 CHECK_STRING (filename);
@@ -341,10 +341,10 @@ Given a Unix syntax file name, returns a string ending in slash. */)
341 341
342 filename = FILE_SYSTEM_CASE (filename); 342 filename = FILE_SYSTEM_CASE (filename);
343#ifdef DOS_NT 343#ifdef DOS_NT
344 beg = (unsigned char *) alloca (SBYTES (filename) + 1); 344 beg = (char *) alloca (SBYTES (filename) + 1);
345 memcpy (beg, SDATA (filename), SBYTES (filename) + 1); 345 memcpy (beg, SSDATA (filename), SBYTES (filename) + 1);
346#else 346#else
347 beg = SDATA (filename); 347 beg = SSDATA (filename);
348#endif 348#endif
349 p = beg + SBYTES (filename); 349 p = beg + SBYTES (filename);
350 350
@@ -365,8 +365,8 @@ Given a Unix syntax file name, returns a string ending in slash. */)
365 if (p[-1] == ':') 365 if (p[-1] == ':')
366 { 366 {
367 /* MAXPATHLEN+1 is guaranteed to be enough space for getdefdir. */ 367 /* MAXPATHLEN+1 is guaranteed to be enough space for getdefdir. */
368 unsigned char *res = alloca (MAXPATHLEN + 1); 368 char *res = alloca (MAXPATHLEN + 1);
369 unsigned char *r = res; 369 char *r = res;
370 370
371 if (p == beg + 4 && IS_DIRECTORY_SEP (*beg) && beg[1] == ':') 371 if (p == beg + 4 && IS_DIRECTORY_SEP (*beg) && beg[1] == ':')
372 { 372 {
@@ -375,7 +375,7 @@ Given a Unix syntax file name, returns a string ending in slash. */)
375 r += 2; 375 r += 2;
376 } 376 }
377 377
378 if (getdefdir (toupper (*beg) - 'A' + 1, r)) 378 if (getdefdir (toupper ((unsigned char) *beg) - 'A' + 1, r))
379 { 379 {
380 if (!IS_DIRECTORY_SEP (res[strlen (res) - 1])) 380 if (!IS_DIRECTORY_SEP (res[strlen (res) - 1]))
381 strcat (res, "/"); 381 strcat (res, "/");
@@ -397,7 +397,7 @@ this is everything after the last slash,
397or the entire name if it contains no slash. */) 397or the entire name if it contains no slash. */)
398 (Lisp_Object filename) 398 (Lisp_Object filename)
399{ 399{
400 register const unsigned char *beg, *p, *end; 400 register const char *beg, *p, *end;
401 Lisp_Object handler; 401 Lisp_Object handler;
402 402
403 CHECK_STRING (filename); 403 CHECK_STRING (filename);
@@ -408,7 +408,7 @@ or the entire name if it contains no slash. */)
408 if (!NILP (handler)) 408 if (!NILP (handler))
409 return call2 (handler, Qfile_name_nondirectory, filename); 409 return call2 (handler, Qfile_name_nondirectory, filename);
410 410
411 beg = SDATA (filename); 411 beg = SSDATA (filename);
412 end = p = beg + SBYTES (filename); 412 end = p = beg + SBYTES (filename);
413 413
414 while (p != beg && !IS_DIRECTORY_SEP (p[-1]) 414 while (p != beg && !IS_DIRECTORY_SEP (p[-1])
@@ -600,7 +600,7 @@ make_temp_name (Lisp_Object prefix, int base64_p)
600 Lisp_Object val; 600 Lisp_Object val;
601 int len, clen; 601 int len, clen;
602 int pid; 602 int pid;
603 unsigned char *p, *data; 603 char *p, *data;
604 char pidbuf[20]; 604 char pidbuf[20];
605 int pidlen; 605 int pidlen;
606 606
@@ -637,8 +637,8 @@ make_temp_name (Lisp_Object prefix, int base64_p)
637 val = make_uninit_multibyte_string (clen + 3 + pidlen, len + 3 + pidlen); 637 val = make_uninit_multibyte_string (clen + 3 + pidlen, len + 3 + pidlen);
638 if (!STRING_MULTIBYTE (prefix)) 638 if (!STRING_MULTIBYTE (prefix))
639 STRING_SET_UNIBYTE (val); 639 STRING_SET_UNIBYTE (val);
640 data = SDATA (val); 640 data = SSDATA (val);
641 memcpy (data, SDATA (prefix), len); 641 memcpy (data, SSDATA (prefix), len);
642 p = data + len; 642 p = data + len;
643 643
644 memcpy (p, pidbuf, pidlen); 644 memcpy (p, pidbuf, pidlen);
@@ -744,9 +744,9 @@ filesystem tree, not (expand-file-name ".." dirname). */)
744{ 744{
745 /* These point to SDATA and need to be careful with string-relocation 745 /* These point to SDATA and need to be careful with string-relocation
746 during GC (via DECODE_FILE). */ 746 during GC (via DECODE_FILE). */
747 unsigned char *nm, *newdir; 747 char *nm, *newdir;
748 /* This should only point to alloca'd data. */ 748 /* This should only point to alloca'd data. */
749 unsigned char *target; 749 char *target;
750 750
751 int tlen; 751 int tlen;
752 struct passwd *pw; 752 struct passwd *pw;
@@ -796,7 +796,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
796 } 796 }
797 797
798 { 798 {
799 unsigned char *o = SDATA (default_directory); 799 char *o = SSDATA (default_directory);
800 800
801 /* Make sure DEFAULT_DIRECTORY is properly expanded. 801 /* Make sure DEFAULT_DIRECTORY is properly expanded.
802 It would be better to do this down below where we actually use 802 It would be better to do this down below where we actually use
@@ -848,8 +848,8 @@ filesystem tree, not (expand-file-name ".." dirname). */)
848 } 848 }
849 849
850 /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ 850 /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */
851 nm = (unsigned char *) alloca (SBYTES (name) + 1); 851 nm = (char *) alloca (SBYTES (name) + 1);
852 memcpy (nm, SDATA (name), SBYTES (name) + 1); 852 memcpy (nm, SSDATA (name), SBYTES (name) + 1);
853 853
854#ifdef DOS_NT 854#ifdef DOS_NT
855 /* Note if special escape prefix is present, but remove for now. */ 855 /* Note if special escape prefix is present, but remove for now. */
@@ -864,7 +864,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
864 drive specifier at the beginning. */ 864 drive specifier at the beginning. */
865 if (IS_DRIVE (nm[0]) && IS_DEVICE_SEP (nm[1])) 865 if (IS_DRIVE (nm[0]) && IS_DEVICE_SEP (nm[1]))
866 { 866 {
867 drive = nm[0]; 867 drive = (unsigned char) nm[0];
868 nm += 2; 868 nm += 2;
869 } 869 }
870 870
@@ -903,7 +903,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
903 non-zero value, that means we've discovered that we can't do 903 non-zero value, that means we've discovered that we can't do
904 that cool trick. */ 904 that cool trick. */
905 int lose = 0; 905 int lose = 0;
906 unsigned char *p = nm; 906 char *p = nm;
907 907
908 while (*p) 908 while (*p)
909 { 909 {
@@ -941,7 +941,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
941 else 941 else
942#endif 942#endif
943 /* drive must be set, so this is okay */ 943 /* drive must be set, so this is okay */
944 if (strcmp (nm - 2, SDATA (name)) != 0) 944 if (strcmp (nm - 2, SSDATA (name)) != 0)
945 { 945 {
946 char temp[] = " :"; 946 char temp[] = " :";
947 947
@@ -983,8 +983,8 @@ filesystem tree, not (expand-file-name ".." dirname). */)
983 { 983 {
984 Lisp_Object tem; 984 Lisp_Object tem;
985 985
986 if (!(newdir = (unsigned char *) egetenv ("HOME"))) 986 if (!(newdir = egetenv ("HOME")))
987 newdir = (unsigned char *) ""; 987 newdir = "";
988 nm++; 988 nm++;
989 /* egetenv may return a unibyte string, which will bite us since 989 /* egetenv may return a unibyte string, which will bite us since
990 we expect the directory to be multibyte. */ 990 we expect the directory to be multibyte. */
@@ -992,7 +992,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
992 if (!STRING_MULTIBYTE (tem)) 992 if (!STRING_MULTIBYTE (tem))
993 { 993 {
994 hdir = DECODE_FILE (tem); 994 hdir = DECODE_FILE (tem);
995 newdir = SDATA (hdir); 995 newdir = SSDATA (hdir);
996 } 996 }
997#ifdef DOS_NT 997#ifdef DOS_NT
998 collapse_newdir = 0; 998 collapse_newdir = 0;
@@ -1000,7 +1000,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1000 } 1000 }
1001 else /* ~user/filename */ 1001 else /* ~user/filename */
1002 { 1002 {
1003 unsigned char *o, *p; 1003 char *o, *p;
1004 for (p = nm; *p && (!IS_DIRECTORY_SEP (*p)); p++); 1004 for (p = nm; *p && (!IS_DIRECTORY_SEP (*p)); p++);
1005 o = alloca (p - nm + 1); 1005 o = alloca (p - nm + 1);
1006 memcpy (o, nm, p - nm); 1006 memcpy (o, nm, p - nm);
@@ -1011,7 +1011,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1011 UNBLOCK_INPUT; 1011 UNBLOCK_INPUT;
1012 if (pw) 1012 if (pw)
1013 { 1013 {
1014 newdir = (unsigned char *) pw -> pw_dir; 1014 newdir = pw->pw_dir;
1015 nm = p; 1015 nm = p;
1016#ifdef DOS_NT 1016#ifdef DOS_NT
1017 collapse_newdir = 0; 1017 collapse_newdir = 0;
@@ -1060,7 +1060,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1060#endif 1060#endif
1061 && !newdir) 1061 && !newdir)
1062 { 1062 {
1063 newdir = SDATA (default_directory); 1063 newdir = SSDATA (default_directory);
1064#ifdef DOS_NT 1064#ifdef DOS_NT
1065 /* Note if special escape prefix is present, but remove for now. */ 1065 /* Note if special escape prefix is present, but remove for now. */
1066 if (newdir[0] == '/' && newdir[1] == ':') 1066 if (newdir[0] == '/' && newdir[1] == ':')
@@ -1093,7 +1093,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1093 1093
1094 if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) 1094 if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1]))
1095 { 1095 {
1096 drive = newdir[0]; 1096 drive = (unsigned char) newdir[0];
1097 newdir += 2; 1097 newdir += 2;
1098 } 1098 }
1099 if (!IS_DIRECTORY_SEP (nm[0])) 1099 if (!IS_DIRECTORY_SEP (nm[0]))
@@ -1127,7 +1127,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1127#ifdef WINDOWSNT 1127#ifdef WINDOWSNT
1128 if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1])) 1128 if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1]))
1129 { 1129 {
1130 unsigned char *p; 1130 char *p;
1131 newdir = strcpy (alloca (strlen (newdir) + 1), newdir); 1131 newdir = strcpy (alloca (strlen (newdir) + 1), newdir);
1132 p = newdir + 2; 1132 p = newdir + 2;
1133 while (*p && !IS_DIRECTORY_SEP (*p)) p++; 1133 while (*p && !IS_DIRECTORY_SEP (*p)) p++;
@@ -1153,7 +1153,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1153#endif 1153#endif
1154 ) 1154 )
1155 { 1155 {
1156 unsigned char *temp = (unsigned char *) alloca (length); 1156 char *temp = (char *) alloca (length);
1157 memcpy (temp, newdir, length - 1); 1157 memcpy (temp, newdir, length - 1);
1158 temp[length - 1] = 0; 1158 temp[length - 1] = 0;
1159 newdir = temp; 1159 newdir = temp;
@@ -1169,10 +1169,10 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1169 /* Reserve space for drive specifier and escape prefix, since either 1169 /* Reserve space for drive specifier and escape prefix, since either
1170 or both may need to be inserted. (The Microsoft x86 compiler 1170 or both may need to be inserted. (The Microsoft x86 compiler
1171 produces incorrect code if the following two lines are combined.) */ 1171 produces incorrect code if the following two lines are combined.) */
1172 target = (unsigned char *) alloca (tlen + 4); 1172 target = (char *) alloca (tlen + 4);
1173 target += 4; 1173 target += 4;
1174#else /* not DOS_NT */ 1174#else /* not DOS_NT */
1175 target = (unsigned char *) alloca (tlen); 1175 target = (char *) alloca (tlen);
1176#endif /* not DOS_NT */ 1176#endif /* not DOS_NT */
1177 *target = 0; 1177 *target = 0;
1178 1178
@@ -1200,8 +1200,8 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1200 /* Now canonicalize by removing `//', `/.' and `/foo/..' if they 1200 /* Now canonicalize by removing `//', `/.' and `/foo/..' if they
1201 appear. */ 1201 appear. */
1202 { 1202 {
1203 unsigned char *p = target; 1203 char *p = target;
1204 unsigned char *o = target; 1204 char *o = target;
1205 1205
1206 while (*p) 1206 while (*p)
1207 { 1207 {
@@ -1233,7 +1233,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1233 && (IS_DIRECTORY_SEP (p[3]) || p[3] == 0)) 1233 && (IS_DIRECTORY_SEP (p[3]) || p[3] == 0))
1234 { 1234 {
1235#ifdef WINDOWSNT 1235#ifdef WINDOWSNT
1236 unsigned char *prev_o = o; 1236 char *prev_o = o;
1237#endif 1237#endif
1238 while (o != target && (--o) && !IS_DIRECTORY_SEP (*o)) 1238 while (o != target && (--o) && !IS_DIRECTORY_SEP (*o))
1239 ; 1239 ;
@@ -1460,7 +1460,7 @@ See also the function `substitute-in-file-name'.")
1460 1460
1461/* If /~ or // appears, discard everything through first slash. */ 1461/* If /~ or // appears, discard everything through first slash. */
1462static int 1462static int
1463file_name_absolute_p (const unsigned char *filename) 1463file_name_absolute_p (const char *filename)
1464{ 1464{
1465 return 1465 return
1466 (IS_DIRECTORY_SEP (*filename) || *filename == '~' 1466 (IS_DIRECTORY_SEP (*filename) || *filename == '~'
@@ -1471,10 +1471,10 @@ file_name_absolute_p (const unsigned char *filename)
1471 ); 1471 );
1472} 1472}
1473 1473
1474static unsigned char * 1474static char *
1475search_embedded_absfilename (unsigned char *nm, unsigned char *endp) 1475search_embedded_absfilename (char *nm, char *endp)
1476{ 1476{
1477 unsigned char *p, *s; 1477 char *p, *s;
1478 1478
1479 for (p = nm + 1; p < endp; p++) 1479 for (p = nm + 1; p < endp; p++)
1480 { 1480 {
@@ -1491,7 +1491,7 @@ search_embedded_absfilename (unsigned char *nm, unsigned char *endp)
1491 for (s = p; *s && (!IS_DIRECTORY_SEP (*s)); s++); 1491 for (s = p; *s && (!IS_DIRECTORY_SEP (*s)); s++);
1492 if (p[0] == '~' && s > p + 1) /* we've got "/~something/" */ 1492 if (p[0] == '~' && s > p + 1) /* we've got "/~something/" */
1493 { 1493 {
1494 unsigned char *o = alloca (s - p + 1); 1494 char *o = alloca (s - p + 1);
1495 struct passwd *pw; 1495 struct passwd *pw;
1496 memcpy (o, p, s - p); 1496 memcpy (o, p, s - p);
1497 o [s - p] = 0; 1497 o [s - p] = 0;
@@ -1525,14 +1525,14 @@ If `//' appears, everything up to and including the first of
1525those `/' is discarded. */) 1525those `/' is discarded. */)
1526 (Lisp_Object filename) 1526 (Lisp_Object filename)
1527{ 1527{
1528 unsigned char *nm; 1528 char *nm;
1529 1529
1530 register unsigned char *s, *p, *o, *x, *endp; 1530 register char *s, *p, *o, *x, *endp;
1531 unsigned char *target = NULL; 1531 char *target = NULL;
1532 int total = 0; 1532 int total = 0;
1533 int substituted = 0; 1533 int substituted = 0;
1534 int multibyte; 1534 int multibyte;
1535 unsigned char *xnm; 1535 char *xnm;
1536 Lisp_Object handler; 1536 Lisp_Object handler;
1537 1537
1538 CHECK_STRING (filename); 1538 CHECK_STRING (filename);
@@ -1548,7 +1548,7 @@ those `/' is discarded. */)
1548 /* Always work on a copy of the string, in case GC happens during 1548 /* Always work on a copy of the string, in case GC happens during
1549 decode of environment variables, causing the original Lisp_String 1549 decode of environment variables, causing the original Lisp_String
1550 data to be relocated. */ 1550 data to be relocated. */
1551 nm = (unsigned char *) alloca (SBYTES (filename) + 1); 1551 nm = (char *) alloca (SBYTES (filename) + 1);
1552 memcpy (nm, SDATA (filename), SBYTES (filename) + 1); 1552 memcpy (nm, SDATA (filename), SBYTES (filename) + 1);
1553 1553
1554#ifdef DOS_NT 1554#ifdef DOS_NT
@@ -1600,7 +1600,7 @@ those `/' is discarded. */)
1600 } 1600 }
1601 1601
1602 /* Copy out the variable name */ 1602 /* Copy out the variable name */
1603 target = (unsigned char *) alloca (s - o + 1); 1603 target = (char *) alloca (s - o + 1);
1604 strncpy (target, o, s - o); 1604 strncpy (target, o, s - o);
1605 target[s - o] = 0; 1605 target[s - o] = 0;
1606#ifdef DOS_NT 1606#ifdef DOS_NT
@@ -1608,7 +1608,7 @@ those `/' is discarded. */)
1608#endif /* DOS_NT */ 1608#endif /* DOS_NT */
1609 1609
1610 /* Get variable value */ 1610 /* Get variable value */
1611 o = (unsigned char *) egetenv (target); 1611 o = egetenv (target);
1612 if (o) 1612 if (o)
1613 { 1613 {
1614 /* Don't try to guess a maximum length - UTF8 can use up to 1614 /* Don't try to guess a maximum length - UTF8 can use up to
@@ -1631,7 +1631,7 @@ those `/' is discarded. */)
1631 1631
1632 /* If substitution required, recopy the string and do it */ 1632 /* If substitution required, recopy the string and do it */
1633 /* Make space in stack frame for the new copy */ 1633 /* Make space in stack frame for the new copy */
1634 xnm = (unsigned char *) alloca (SBYTES (filename) + total + 1); 1634 xnm = (char *) alloca (SBYTES (filename) + total + 1);
1635 x = xnm; 1635 x = xnm;
1636 1636
1637 /* Copy the rest of the name through, replacing $ constructs with values */ 1637 /* Copy the rest of the name through, replacing $ constructs with values */
@@ -1663,7 +1663,7 @@ those `/' is discarded. */)
1663 } 1663 }
1664 1664
1665 /* Copy out the variable name */ 1665 /* Copy out the variable name */
1666 target = (unsigned char *) alloca (s - o + 1); 1666 target = (char *) alloca (s - o + 1);
1667 strncpy (target, o, s - o); 1667 strncpy (target, o, s - o);
1668 target[s - o] = 0; 1668 target[s - o] = 0;
1669#ifdef DOS_NT 1669#ifdef DOS_NT
@@ -1671,7 +1671,7 @@ those `/' is discarded. */)
1671#endif /* DOS_NT */ 1671#endif /* DOS_NT */
1672 1672
1673 /* Get variable value */ 1673 /* Get variable value */
1674 o = (unsigned char *) egetenv (target); 1674 o = egetenv (target);
1675 if (!o) 1675 if (!o)
1676 { 1676 {
1677 *x++ = '$'; 1677 *x++ = '$';
@@ -1751,7 +1751,8 @@ expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir)
1751 If QUICK is nonzero, we ask for y or n, not yes or no. */ 1751 If QUICK is nonzero, we ask for y or n, not yes or no. */
1752 1752
1753void 1753void
1754barf_or_query_if_file_exists (Lisp_Object absname, const unsigned char *querystring, int interactive, struct stat *statptr, int quick) 1754barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring,
1755 int interactive, struct stat *statptr, int quick)
1755{ 1756{
1756 register Lisp_Object tem, encoded_filename; 1757 register Lisp_Object tem, encoded_filename;
1757 struct stat statbuf; 1758 struct stat statbuf;
@@ -2027,7 +2028,7 @@ DEFUN ("make-directory-internal", Fmake_directory_internal,
2027 doc: /* Create a new directory named DIRECTORY. */) 2028 doc: /* Create a new directory named DIRECTORY. */)
2028 (Lisp_Object directory) 2029 (Lisp_Object directory)
2029{ 2030{
2030 const unsigned char *dir; 2031 const char *dir;
2031 Lisp_Object handler; 2032 Lisp_Object handler;
2032 Lisp_Object encoded_dir; 2033 Lisp_Object encoded_dir;
2033 2034
@@ -2040,7 +2041,7 @@ DEFUN ("make-directory-internal", Fmake_directory_internal,
2040 2041
2041 encoded_dir = ENCODE_FILE (directory); 2042 encoded_dir = ENCODE_FILE (directory);
2042 2043
2043 dir = SDATA (encoded_dir); 2044 dir = SSDATA (encoded_dir);
2044 2045
2045#ifdef WINDOWSNT 2046#ifdef WINDOWSNT
2046 if (mkdir (dir) != 0) 2047 if (mkdir (dir) != 0)
@@ -2057,14 +2058,14 @@ DEFUN ("delete-directory-internal", Fdelete_directory_internal,
2057 doc: /* Delete the directory named DIRECTORY. Does not follow symlinks. */) 2058 doc: /* Delete the directory named DIRECTORY. Does not follow symlinks. */)
2058 (Lisp_Object directory) 2059 (Lisp_Object directory)
2059{ 2060{
2060 const unsigned char *dir; 2061 const char *dir;
2061 Lisp_Object handler; 2062 Lisp_Object handler;
2062 Lisp_Object encoded_dir; 2063 Lisp_Object encoded_dir;
2063 2064
2064 CHECK_STRING (directory); 2065 CHECK_STRING (directory);
2065 directory = Fdirectory_file_name (Fexpand_file_name (directory, Qnil)); 2066 directory = Fdirectory_file_name (Fexpand_file_name (directory, Qnil));
2066 encoded_dir = ENCODE_FILE (directory); 2067 encoded_dir = ENCODE_FILE (directory);
2067 dir = SDATA (encoded_dir); 2068 dir = SSDATA (encoded_dir);
2068 2069
2069 if (rmdir (dir) != 0) 2070 if (rmdir (dir) != 0)
2070 report_file_error ("Removing directory", list1 (directory)); 2071 report_file_error ("Removing directory", list1 (directory));
@@ -2371,7 +2372,7 @@ On Unix, this is a name starting with a `/' or a `~'. */)
2371 (Lisp_Object filename) 2372 (Lisp_Object filename)
2372{ 2373{
2373 CHECK_STRING (filename); 2374 CHECK_STRING (filename);
2374 return file_name_absolute_p (SDATA (filename)) ? Qt : Qnil; 2375 return file_name_absolute_p (SSDATA (filename)) ? Qt : Qnil;
2375} 2376}
2376 2377
2377/* Return nonzero if file FILENAME exists and can be executed. */ 2378/* Return nonzero if file FILENAME exists and can be executed. */
@@ -3142,7 +3143,8 @@ read_non_regular (Lisp_Object ignore)
3142 immediate_quit = 1; 3143 immediate_quit = 1;
3143 QUIT; 3144 QUIT;
3144 nbytes = emacs_read (non_regular_fd, 3145 nbytes = emacs_read (non_regular_fd,
3145 BEG_ADDR + PT_BYTE - BEG_BYTE + non_regular_inserted, 3146 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
3147 + non_regular_inserted),
3146 non_regular_nbytes); 3148 non_regular_nbytes);
3147 immediate_quit = 0; 3149 immediate_quit = 0;
3148 return make_number (nbytes); 3150 return make_number (nbytes);
@@ -3196,9 +3198,9 @@ variable `last-coding-system-used' to the coding system actually used. */)
3196 Lisp_Object p; 3198 Lisp_Object p;
3197 EMACS_INT total = 0; 3199 EMACS_INT total = 0;
3198 int not_regular = 0; 3200 int not_regular = 0;
3199 unsigned char read_buf[READ_BUF_SIZE]; 3201 char read_buf[READ_BUF_SIZE];
3200 struct coding_system coding; 3202 struct coding_system coding;
3201 unsigned char buffer[1 << 14]; 3203 char buffer[1 << 14];
3202 int replace_handled = 0; 3204 int replace_handled = 0;
3203 int set_coding_system = 0; 3205 int set_coding_system = 0;
3204 Lisp_Object coding_system; 3206 Lisp_Object coding_system;
@@ -3506,13 +3508,14 @@ variable `last-coding-system-used' to the coding system actually used. */)
3506 nread = emacs_read (fd, buffer, sizeof buffer); 3508 nread = emacs_read (fd, buffer, sizeof buffer);
3507 if (nread < 0) 3509 if (nread < 0)
3508 error ("IO error reading %s: %s", 3510 error ("IO error reading %s: %s",
3509 SDATA (orig_filename), emacs_strerror (errno)); 3511 SSDATA (orig_filename), emacs_strerror (errno));
3510 else if (nread == 0) 3512 else if (nread == 0)
3511 break; 3513 break;
3512 3514
3513 if (CODING_REQUIRE_DETECTION (&coding)) 3515 if (CODING_REQUIRE_DETECTION (&coding))
3514 { 3516 {
3515 coding_system = detect_coding_system (buffer, nread, nread, 1, 0, 3517 coding_system = detect_coding_system ((unsigned char *) buffer,
3518 nread, nread, 1, 0,
3516 coding_system); 3519 coding_system);
3517 setup_coding_system (coding_system, &coding); 3520 setup_coding_system (coding_system, &coding);
3518 } 3521 }
@@ -3714,8 +3717,8 @@ variable `last-coding-system-used' to the coding system actually used. */)
3714 3717
3715 BUF_TEMP_SET_PT (XBUFFER (conversion_buffer), 3718 BUF_TEMP_SET_PT (XBUFFER (conversion_buffer),
3716 BUF_Z (XBUFFER (conversion_buffer))); 3719 BUF_Z (XBUFFER (conversion_buffer)));
3717 decode_coding_c_string (&coding, read_buf, unprocessed + this, 3720 decode_coding_c_string (&coding, (unsigned char *) read_buf,
3718 conversion_buffer); 3721 unprocessed + this, conversion_buffer);
3719 unprocessed = coding.carryover_bytes; 3722 unprocessed = coding.carryover_bytes;
3720 if (coding.carryover_bytes > 0) 3723 if (coding.carryover_bytes > 0)
3721 memcpy (read_buf, coding.carryover, unprocessed); 3724 memcpy (read_buf, coding.carryover, unprocessed);
@@ -3738,8 +3741,8 @@ variable `last-coding-system-used' to the coding system actually used. */)
3738 if (unprocessed > 0) 3741 if (unprocessed > 0)
3739 { 3742 {
3740 coding.mode |= CODING_MODE_LAST_BLOCK; 3743 coding.mode |= CODING_MODE_LAST_BLOCK;
3741 decode_coding_c_string (&coding, read_buf, unprocessed, 3744 decode_coding_c_string (&coding, (unsigned char *) read_buf,
3742 conversion_buffer); 3745 unprocessed, conversion_buffer);
3743 coding.mode &= ~CODING_MODE_LAST_BLOCK; 3746 coding.mode &= ~CODING_MODE_LAST_BLOCK;
3744 } 3747 }
3745 3748
@@ -3941,7 +3944,10 @@ variable `last-coding-system-used' to the coding system actually used. */)
3941 here doesn't do any harm. */ 3944 here doesn't do any harm. */
3942 immediate_quit = 1; 3945 immediate_quit = 1;
3943 QUIT; 3946 QUIT;
3944 this = emacs_read (fd, BEG_ADDR + PT_BYTE - BEG_BYTE + inserted, trytry); 3947 this = emacs_read (fd,
3948 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
3949 + inserted),
3950 trytry);
3945 immediate_quit = 0; 3951 immediate_quit = 0;
3946 } 3952 }
3947 3953
@@ -4466,7 +4472,7 @@ This calls `write-region-annotate-functions' at the start, and
4466 register int desc; 4472 register int desc;
4467 int failure; 4473 int failure;
4468 int save_errno = 0; 4474 int save_errno = 0;
4469 const unsigned char *fn; 4475 const char *fn;
4470 struct stat st; 4476 struct stat st;
4471 int count = SPECPDL_INDEX (); 4477 int count = SPECPDL_INDEX ();
4472 int count1; 4478 int count1;
@@ -4586,7 +4592,7 @@ This calls `write-region-annotate-functions' at the start, and
4586 4592
4587 encoded_filename = ENCODE_FILE (filename); 4593 encoded_filename = ENCODE_FILE (filename);
4588 4594
4589 fn = SDATA (encoded_filename); 4595 fn = SSDATA (encoded_filename);
4590 desc = -1; 4596 desc = -1;
4591 if (!NILP (append)) 4597 if (!NILP (append))
4592#ifdef DOS_NT 4598#ifdef DOS_NT