comparison src/fileio.c @ 867:804517e16990

[xemacs-hg @ 2002-06-05 09:54:39 by ben] Textual renaming: text/char names abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, charset.h, chartab.c, chartab.h, cmds.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console-x.h, console.h, data.c, device-msw.c, device-x.c, dialog-msw.c, dired-msw.c, dired.c, doc.c, doprnt.c, editfns.c, eldap.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-unixoid.c, events.c, events.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, glyphs-eimage.c, glyphs-msw.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-x.c, gui-x.h, gui.c, gui.h, hpplay.c, indent.c, insdel.c, insdel.h, intl-win32.c, keymap.c, line-number.c, line-number.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, md5.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, ndir.h, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, procimpl.h, realpath.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, search.c, select-common.h, select-gtk.c, select-x.c, sound.h, symbols.c, syntax.c, syntax.h, sysdep.c, sysdep.h, sysdir.h, sysfile.h, sysproc.h, syspwd.h, systime.h, syswindows.h, termcap.c, tests.c, text.c, text.h, toolbar-common.c, tooltalk.c, ui-gtk.c, unexnt.c, unicode.c, win32.c: Text/char naming rationalization. [a] distinguish between "charptr" when it refers to operations on the pointer itself and when it refers to operations on text; and [b] use consistent naming for everything referring to internal format, i.e. Itext == text in internal format Ibyte == a byte in such text Ichar == a char as represented in internal character format thus e.g. set_charptr_emchar -> set_itext_ichar The pre and post tags on either side of this change are: pre-internal-format-textual-renaming post-internal-format-textual-renaming See the Internals Manual for details of exactly how this was done, how to handle the change in your workspace, etc.
author ben
date Wed, 05 Jun 2002 09:58:45 +0000
parents 2b6fa2618f76
children 79c6ff3eef26
comparison
equal deleted inserted replaced
866:613552a02607 867:804517e16990
132 /* DATA can be anything acceptable to signal_error (). 132 /* DATA can be anything acceptable to signal_error ().
133 */ 133 */
134 134
135 DOESNT_RETURN 135 DOESNT_RETURN
136 report_file_type_error (Lisp_Object errtype, Lisp_Object oserrmess, 136 report_file_type_error (Lisp_Object errtype, Lisp_Object oserrmess,
137 const CIntbyte *string, Lisp_Object data) 137 const CIbyte *string, Lisp_Object data)
138 { 138 {
139 struct gcpro gcpro1; 139 struct gcpro gcpro1;
140 Lisp_Object errdata = build_error_data (NULL, data); 140 Lisp_Object errdata = build_error_data (NULL, data);
141 141
142 GCPRO1 (errdata); 142 GCPRO1 (errdata);
146 /* UNGCPRO; not reached */ 146 /* UNGCPRO; not reached */
147 } 147 }
148 148
149 DOESNT_RETURN 149 DOESNT_RETURN
150 report_error_with_errno (Lisp_Object errtype, 150 report_error_with_errno (Lisp_Object errtype,
151 const CIntbyte *string, Lisp_Object data) 151 const CIbyte *string, Lisp_Object data)
152 { 152 {
153 report_file_type_error (errtype, lisp_strerror (errno), string, data); 153 report_file_type_error (errtype, lisp_strerror (errno), string, data);
154 } 154 }
155 155
156 /* signal a file error when errno contains a meaningful value. */ 156 /* signal a file error when errno contains a meaningful value. */
157 157
158 DOESNT_RETURN 158 DOESNT_RETURN
159 report_file_error (const CIntbyte *string, Lisp_Object data) 159 report_file_error (const CIbyte *string, Lisp_Object data)
160 { 160 {
161 report_error_with_errno (Qfile_error, string, data); 161 report_error_with_errno (Qfile_error, string, data);
162 } 162 }
163 163
164 164
169 lisp_strerror (int errnum) 169 lisp_strerror (int errnum)
170 { 170 {
171 Extbyte *ret = strerror (errnum); 171 Extbyte *ret = strerror (errnum);
172 if (!ret) 172 if (!ret)
173 { 173 {
174 Intbyte ffff[99]; 174 Ibyte ffff[99];
175 qxesprintf (ffff, "Unknown error %d", errnum); 175 qxesprintf (ffff, "Unknown error %d", errnum);
176 return build_intstring (ffff); 176 return build_intstring (ffff);
177 } 177 }
178 return build_ext_string (ret, Qstrerror_encoding); 178 return build_ext_string (ret, Qstrerror_encoding);
179 } 179 }
330 */ 330 */
331 (filename)) 331 (filename))
332 { 332 {
333 /* This function can GC. GC checked 2000-07-28 ben */ 333 /* This function can GC. GC checked 2000-07-28 ben */
334 /* This function synched with Emacs 21.0.103. */ 334 /* This function synched with Emacs 21.0.103. */
335 Intbyte *beg; 335 Ibyte *beg;
336 Intbyte *p; 336 Ibyte *p;
337 Lisp_Object handler; 337 Lisp_Object handler;
338 338
339 CHECK_STRING (filename); 339 CHECK_STRING (filename);
340 340
341 /* If the file name has special constructs in it, 341 /* If the file name has special constructs in it,
365 return Qnil; 365 return Qnil;
366 #ifdef WIN32_NATIVE 366 #ifdef WIN32_NATIVE
367 /* Expansion of "c:" to drive and default directory. */ 367 /* Expansion of "c:" to drive and default directory. */
368 if (p[-1] == ':') 368 if (p[-1] == ':')
369 { 369 {
370 Intbyte *res; 370 Ibyte *res;
371 Intbyte *wd = mswindows_getdcwd (toupper (*beg) - 'A' + 1); 371 Ibyte *wd = mswindows_getdcwd (toupper (*beg) - 'A' + 1);
372 372
373 res = alloca_array (Intbyte, 373 res = alloca_array (Ibyte,
374 (wd ? qxestrlen (wd) : 0) + 10); /* go overboard */ 374 (wd ? qxestrlen (wd) : 0) + 10); /* go overboard */
375 if (p == beg + 4 && IS_DIRECTORY_SEP (*beg) && beg[1] == ':') 375 if (p == beg + 4 && IS_DIRECTORY_SEP (*beg) && beg[1] == ':')
376 { 376 {
377 qxestrncpy (res, beg, 2); 377 qxestrncpy (res, beg, 2);
378 beg += 2; 378 beg += 2;
380 380
381 if (wd) 381 if (wd)
382 { 382 {
383 qxestrcat (res, wd); 383 qxestrcat (res, wd);
384 if (!IS_DIRECTORY_SEP (res[qxestrlen (res) - 1])) 384 if (!IS_DIRECTORY_SEP (res[qxestrlen (res) - 1]))
385 qxestrcat (res, (Intbyte *) "/"); 385 qxestrcat (res, (Ibyte *) "/");
386 beg = res; 386 beg = res;
387 p = beg + qxestrlen (beg); 387 p = beg + qxestrlen (beg);
388 } 388 }
389 if (wd) 389 if (wd)
390 xfree (wd); 390 xfree (wd);
393 #if 0 /* No! This screws up efs, which calls file-name-directory on URL's 393 #if 0 /* No! This screws up efs, which calls file-name-directory on URL's
394 and expects the slashes to be left alone. This is here because of 394 and expects the slashes to be left alone. This is here because of
395 an analogous call in FSF 21. */ 395 an analogous call in FSF 21. */
396 { 396 {
397 Bytecount len = p - beg; 397 Bytecount len = p - beg;
398 Intbyte *newbeg = alloca_intbytes (len + 1); 398 Ibyte *newbeg = alloca_ibytes (len + 1);
399 Lisp_Object return_me; 399 Lisp_Object return_me;
400 400
401 qxestrncpy (newbeg, beg, len); 401 qxestrncpy (newbeg, beg, len);
402 newbeg[len] = '\0'; 402 newbeg[len] = '\0';
403 newbeg = mswindows_canonicalize_filename (newbeg); 403 newbeg = mswindows_canonicalize_filename (newbeg);
418 */ 418 */
419 (filename)) 419 (filename))
420 { 420 {
421 /* This function can GC. GC checked 2000-07-28 ben */ 421 /* This function can GC. GC checked 2000-07-28 ben */
422 /* This function synched with Emacs 21.0.103. */ 422 /* This function synched with Emacs 21.0.103. */
423 Intbyte *beg, *p, *end; 423 Ibyte *beg, *p, *end;
424 Lisp_Object handler; 424 Lisp_Object handler;
425 425
426 CHECK_STRING (filename); 426 CHECK_STRING (filename);
427 427
428 /* If the file name has special constructs in it, 428 /* If the file name has special constructs in it,
470 470
471 return Ffile_name_directory (filename); 471 return Ffile_name_directory (filename);
472 } 472 }
473 473
474 474
475 static Intbyte * 475 static Ibyte *
476 file_name_as_directory (Intbyte *out, Intbyte *in) 476 file_name_as_directory (Ibyte *out, Ibyte *in)
477 { 477 {
478 /* This function cannot GC */ 478 /* This function cannot GC */
479 int size = qxestrlen (in); 479 int size = qxestrlen (in);
480 480
481 if (size == 0) 481 if (size == 0)
507 except for (file-name-as-directory \"\") => \"./\". 507 except for (file-name-as-directory \"\") => \"./\".
508 */ 508 */
509 (filename)) 509 (filename))
510 { 510 {
511 /* This function can GC. GC checked 2000-07-28 ben */ 511 /* This function can GC. GC checked 2000-07-28 ben */
512 Intbyte *buf; 512 Ibyte *buf;
513 Lisp_Object handler; 513 Lisp_Object handler;
514 514
515 CHECK_STRING (filename); 515 CHECK_STRING (filename);
516 516
517 /* If the file name has special constructs in it, 517 /* If the file name has special constructs in it,
518 call the corresponding file handler. */ 518 call the corresponding file handler. */
519 handler = Ffind_file_name_handler (filename, Qfile_name_as_directory); 519 handler = Ffind_file_name_handler (filename, Qfile_name_as_directory);
520 if (!NILP (handler)) 520 if (!NILP (handler))
521 return call2_check_string (handler, Qfile_name_as_directory, filename); 521 return call2_check_string (handler, Qfile_name_as_directory, filename);
522 522
523 buf = alloca_intbytes (XSTRING_LENGTH (filename) + 10); 523 buf = alloca_ibytes (XSTRING_LENGTH (filename) + 10);
524 return build_intstring (file_name_as_directory (buf, XSTRING_DATA (filename))); 524 return build_intstring (file_name_as_directory (buf, XSTRING_DATA (filename)));
525 } 525 }
526 526
527 /* 527 /*
528 * Convert from directory name to filename. 528 * Convert from directory name to filename.
530 * 530 *
531 * Value is nonzero if the string output is different from the input. 531 * Value is nonzero if the string output is different from the input.
532 */ 532 */
533 533
534 static int 534 static int
535 directory_file_name (const Intbyte *src, Intbyte *dst) 535 directory_file_name (const Ibyte *src, Ibyte *dst)
536 { 536 {
537 /* This function cannot GC */ 537 /* This function cannot GC */
538 long slen = qxestrlen (src); 538 long slen = qxestrlen (src);
539 /* Process as Unix format: just remove any final slash. 539 /* Process as Unix format: just remove any final slash.
540 But leave "/" unchanged; do not change it to "". */ 540 But leave "/" unchanged; do not change it to "". */
557 In Unix-syntax, this function just removes the final slash. 557 In Unix-syntax, this function just removes the final slash.
558 */ 558 */
559 (directory)) 559 (directory))
560 { 560 {
561 /* This function can GC. GC checked 2000-07-28 ben */ 561 /* This function can GC. GC checked 2000-07-28 ben */
562 Intbyte *buf; 562 Ibyte *buf;
563 Lisp_Object handler; 563 Lisp_Object handler;
564 564
565 CHECK_STRING (directory); 565 CHECK_STRING (directory);
566 566
567 #if 0 /* #### WTF? */ 567 #if 0 /* #### WTF? */
572 /* If the file name has special constructs in it, 572 /* If the file name has special constructs in it,
573 call the corresponding file handler. */ 573 call the corresponding file handler. */
574 handler = Ffind_file_name_handler (directory, Qdirectory_file_name); 574 handler = Ffind_file_name_handler (directory, Qdirectory_file_name);
575 if (!NILP (handler)) 575 if (!NILP (handler))
576 return call2_check_string (handler, Qdirectory_file_name, directory); 576 return call2_check_string (handler, Qdirectory_file_name, directory);
577 buf = (Intbyte *) ALLOCA (XSTRING_LENGTH (directory) + 20); 577 buf = (Ibyte *) ALLOCA (XSTRING_LENGTH (directory) + 20);
578 directory_file_name (XSTRING_DATA (directory), buf); 578 directory_file_name (XSTRING_DATA (directory), buf);
579 return build_intstring (buf); 579 return build_intstring (buf);
580 } 580 }
581 581
582 /* Fmake_temp_name used to be a simple wrapper around mktemp(), but it 582 /* Fmake_temp_name used to be a simple wrapper around mktemp(), but it
615 'w','x','y','z','0','1','2','3', 615 'w','x','y','z','0','1','2','3',
616 '4','5','6','7','8','9','-','_' 616 '4','5','6','7','8','9','-','_'
617 }; 617 };
618 618
619 Bytecount len; 619 Bytecount len;
620 Intbyte *p, *data; 620 Ibyte *p, *data;
621 Lisp_Object handler; 621 Lisp_Object handler;
622 622
623 CHECK_STRING (prefix); 623 CHECK_STRING (prefix);
624 handler = Ffind_file_name_handler (prefix, Qmake_temp_name); 624 handler = Ffind_file_name_handler (prefix, Qmake_temp_name);
625 if (!NILP (handler)) 625 if (!NILP (handler))
639 [[ 3) It might yield unexpected (to stat(2)) results in the presence 639 [[ 3) It might yield unexpected (to stat(2)) results in the presence
640 of EFS and file name handlers.]] Now that we check for a handler, 640 of EFS and file name handlers.]] Now that we check for a handler,
641 that's less of a concern. --ben */ 641 that's less of a concern. --ben */
642 642
643 len = XSTRING_LENGTH (prefix); 643 len = XSTRING_LENGTH (prefix);
644 data = alloca_intbytes (len + 7); 644 data = alloca_ibytes (len + 7);
645 memcpy (data, XSTRING_DATA (prefix), len); 645 memcpy (data, XSTRING_DATA (prefix), len);
646 p = data + len; 646 p = data + len;
647 p[6] = '\0'; 647 p[6] = '\0';
648 648
649 /* VAL is created by adding 6 characters to PREFIX. The first three 649 /* VAL is created by adding 6 characters to PREFIX. The first three
713 */ 713 */
714 (name, default_directory)) 714 (name, default_directory))
715 { 715 {
716 /* This function can GC. GC-checked 2000-11-18. 716 /* This function can GC. GC-checked 2000-11-18.
717 This function synched with Emacs 21.0.103. */ 717 This function synched with Emacs 21.0.103. */
718 Intbyte *nm; 718 Ibyte *nm;
719 719
720 Intbyte *newdir, *p, *o; 720 Ibyte *newdir, *p, *o;
721 int tlen; 721 int tlen;
722 Intbyte *target; 722 Ibyte *target;
723 #ifdef WIN32_FILENAMES 723 #ifdef WIN32_FILENAMES
724 int drive = 0; 724 int drive = 0;
725 int collapse_newdir = 1; 725 int collapse_newdir = 1;
726 /* XEmacs note: This concerns the special '/:' syntax for preventing 726 /* XEmacs note: This concerns the special '/:' syntax for preventing
727 wildcards and such. We don't support this currently but I'm 727 wildcards and such. We don't support this currently but I'm
805 nm = XSTRING_DATA (name); 805 nm = XSTRING_DATA (name);
806 806
807 #ifdef WIN32_FILENAMES 807 #ifdef WIN32_FILENAMES
808 /* We will force directory separators to be either all \ or /, so make 808 /* We will force directory separators to be either all \ or /, so make
809 a local copy to modify, even if there ends up being no change. */ 809 a local copy to modify, even if there ends up being no change. */
810 nm = qxestrcpy (alloca_intbytes (qxestrlen (nm) + 1), nm); 810 nm = qxestrcpy (alloca_ibytes (qxestrlen (nm) + 1), nm);
811 811
812 /* Note if special escape prefix is present, but remove for now. */ 812 /* Note if special escape prefix is present, but remove for now. */
813 if (nm[0] == '/' && nm[1] == ':') 813 if (nm[0] == '/' && nm[1] == ':')
814 { 814 {
815 is_escaped = 1; 815 is_escaped = 1;
817 } 817 }
818 818
819 /* Find and remove drive specifier if present; this makes nm absolute 819 /* Find and remove drive specifier if present; this makes nm absolute
820 even if the rest of the name appears to be relative. */ 820 even if the rest of the name appears to be relative. */
821 { 821 {
822 Intbyte *colon = qxestrrchr (nm, ':'); 822 Ibyte *colon = qxestrrchr (nm, ':');
823 823
824 if (colon) 824 if (colon)
825 { 825 {
826 /* Only recognize colon as part of drive specifier if there is a 826 /* Only recognize colon as part of drive specifier if there is a
827 single alphabetic character preceding the colon (and if the 827 single alphabetic character preceding the colon (and if the
904 if (!lose) 904 if (!lose)
905 { 905 {
906 #ifdef WIN32_FILENAMES 906 #ifdef WIN32_FILENAMES
907 if (drive || IS_DIRECTORY_SEP (nm[1])) 907 if (drive || IS_DIRECTORY_SEP (nm[1]))
908 { 908 {
909 Intbyte *newnm; 909 Ibyte *newnm;
910 910
911 if (IS_DIRECTORY_SEP (nm[1])) 911 if (IS_DIRECTORY_SEP (nm[1]))
912 { 912 {
913 newnm = mswindows_canonicalize_filename (nm); 913 newnm = mswindows_canonicalize_filename (nm);
914 if (qxestrcmp (newnm, XSTRING_DATA (name)) != 0) 914 if (qxestrcmp (newnm, XSTRING_DATA (name)) != 0)
958 if (nm[0] == '~') /* prefix ~ */ 958 if (nm[0] == '~') /* prefix ~ */
959 { 959 {
960 if (IS_DIRECTORY_SEP (nm[1]) 960 if (IS_DIRECTORY_SEP (nm[1])
961 || nm[1] == 0) /* ~ by itself */ 961 || nm[1] == 0) /* ~ by itself */
962 { 962 {
963 Intbyte *homedir = get_home_directory (); 963 Ibyte *homedir = get_home_directory ();
964 964
965 if (!homedir) 965 if (!homedir)
966 newdir = (Intbyte *) ""; 966 newdir = (Ibyte *) "";
967 else 967 else
968 newdir = homedir; 968 newdir = homedir;
969 969
970 nm++; 970 nm++;
971 #ifdef WIN32_FILENAMES 971 #ifdef WIN32_FILENAMES
974 } 974 }
975 else /* ~user/filename */ 975 else /* ~user/filename */
976 { 976 {
977 for (p = nm; *p && (!IS_DIRECTORY_SEP (*p)); p++) 977 for (p = nm; *p && (!IS_DIRECTORY_SEP (*p)); p++)
978 DO_NOTHING; 978 DO_NOTHING;
979 o = (Intbyte *) ALLOCA (p - nm + 1); 979 o = (Ibyte *) ALLOCA (p - nm + 1);
980 memcpy (o, nm, p - nm); 980 memcpy (o, nm, p - nm);
981 o [p - nm] = 0; 981 o [p - nm] = 0;
982 982
983 /* #### While NT is single-user (for the moment) you still 983 /* #### While NT is single-user (for the moment) you still
984 can have multiple user profiles users defined, each with 984 can have multiple user profiles users defined, each with
985 its HOME. So maybe possibly we should think about handling 985 its HOME. So maybe possibly we should think about handling
986 ~user. --ben */ 986 ~user. --ben */
987 #ifndef WIN32_NATIVE 987 #ifndef WIN32_NATIVE
988 #ifdef CYGWIN 988 #ifdef CYGWIN
989 { 989 {
990 Intbyte *user; 990 Ibyte *user;
991 991
992 if ((user = user_login_name (NULL)) != NULL) 992 if ((user = user_login_name (NULL)) != NULL)
993 { 993 {
994 /* Does the user login name match the ~name? */ 994 /* Does the user login name match the ~name? */
995 if (qxestrcmp (user, o + 1) == 0) 995 if (qxestrcmp (user, o + 1) == 0)
1007 slow_down_interrupts (); 1007 slow_down_interrupts ();
1008 pw = (struct passwd *) qxe_getpwnam (o + 1); 1008 pw = (struct passwd *) qxe_getpwnam (o + 1);
1009 speed_up_interrupts (); 1009 speed_up_interrupts ();
1010 if (pw) 1010 if (pw)
1011 { 1011 {
1012 newdir = (Intbyte *) pw->pw_dir; 1012 newdir = (Ibyte *) pw->pw_dir;
1013 nm = p; 1013 nm = p;
1014 /* FSF: if WIN32_NATIVE, collapse_newdir = 0; 1014 /* FSF: if WIN32_NATIVE, collapse_newdir = 0;
1015 not possible here. */ 1015 not possible here. */
1016 } 1016 }
1017 #ifdef CYGWIN 1017 #ifdef CYGWIN
1031 { 1031 {
1032 #ifdef WIN32_NATIVE 1032 #ifdef WIN32_NATIVE
1033 /* Get default directory if needed to make nm absolute. */ 1033 /* Get default directory if needed to make nm absolute. */
1034 if (!IS_DIRECTORY_SEP (nm[0])) 1034 if (!IS_DIRECTORY_SEP (nm[0]))
1035 { 1035 {
1036 Intbyte *newcwd = mswindows_getdcwd (toupper (drive) - 'A' + 1); 1036 Ibyte *newcwd = mswindows_getdcwd (toupper (drive) - 'A' + 1);
1037 if (newcwd) 1037 if (newcwd)
1038 { 1038 {
1039 INTBYTE_STRING_TO_ALLOCA (newcwd, newdir); 1039 IBYTE_STRING_TO_ALLOCA (newcwd, newdir);
1040 xfree (newcwd); 1040 xfree (newcwd);
1041 } 1041 }
1042 else 1042 else
1043 newdir = NULL; 1043 newdir = NULL;
1044 } 1044 }
1045 #endif /* WIN32_NATIVE */ 1045 #endif /* WIN32_NATIVE */
1046 if (!newdir) 1046 if (!newdir)
1047 { 1047 {
1048 /* Either nm starts with /, or drive isn't mounted. */ 1048 /* Either nm starts with /, or drive isn't mounted. */
1049 newdir = (Intbyte *) ALLOCA (4); 1049 newdir = (Ibyte *) ALLOCA (4);
1050 newdir[0] = DRIVE_LETTER (drive); 1050 newdir[0] = DRIVE_LETTER (drive);
1051 newdir[1] = ':'; 1051 newdir[1] = ':';
1052 newdir[2] = '/'; 1052 newdir[2] = '/';
1053 newdir[3] = 0; 1053 newdir[3] = 0;
1054 } 1054 }
1108 drive = newdir[0]; 1108 drive = newdir[0];
1109 newdir += 2; 1109 newdir += 2;
1110 } 1110 }
1111 if (!IS_DIRECTORY_SEP (nm[0])) 1111 if (!IS_DIRECTORY_SEP (nm[0]))
1112 { 1112 {
1113 Intbyte *tmp = (Intbyte *) ALLOCA (qxestrlen (newdir) + 1113 Ibyte *tmp = (Ibyte *) ALLOCA (qxestrlen (newdir) +
1114 qxestrlen (nm) + 2); 1114 qxestrlen (nm) + 2);
1115 file_name_as_directory (tmp, newdir); 1115 file_name_as_directory (tmp, newdir);
1116 qxestrcat (tmp, nm); 1116 qxestrcat (tmp, nm);
1117 nm = tmp; 1117 nm = tmp;
1118 } 1118 }
1119 if (drive) 1119 if (drive)
1120 { 1120 {
1121 #ifdef WIN32_NATIVE 1121 #ifdef WIN32_NATIVE
1122 Intbyte *newcwd = mswindows_getdcwd (toupper (drive) - 'A' + 1); 1122 Ibyte *newcwd = mswindows_getdcwd (toupper (drive) - 'A' + 1);
1123 if (newcwd) 1123 if (newcwd)
1124 { 1124 {
1125 INTBYTE_STRING_TO_ALLOCA (newcwd, newdir); 1125 IBYTE_STRING_TO_ALLOCA (newcwd, newdir);
1126 xfree (newcwd); 1126 xfree (newcwd);
1127 } 1127 }
1128 else 1128 else
1129 #endif 1129 #endif
1130 INTBYTE_STRING_TO_ALLOCA ((Intbyte *) "/", newdir); 1130 IBYTE_STRING_TO_ALLOCA ((Ibyte *) "/", newdir);
1131 } 1131 }
1132 else 1132 else
1133 INTBYTE_STRING_TO_ALLOCA (get_initial_directory (0, 0), newdir); 1133 IBYTE_STRING_TO_ALLOCA (get_initial_directory (0, 0), newdir);
1134 } 1134 }
1135 1135
1136 /* Strip off drive name from prefix, if present. */ 1136 /* Strip off drive name from prefix, if present. */
1137 if (IS_DRIVE (newdir[0]) && newdir[1] == ':') 1137 if (IS_DRIVE (newdir[0]) && newdir[1] == ':')
1138 { 1138 {
1149 && collapse_newdir) 1149 && collapse_newdir)
1150 { 1150 {
1151 if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1])) 1151 if (IS_DIRECTORY_SEP (newdir[0]) && IS_DIRECTORY_SEP (newdir[1]))
1152 { 1152 {
1153 newdir = 1153 newdir =
1154 (Intbyte *) 1154 (Ibyte *)
1155 qxestrcpy ((Intbyte *) ALLOCA (qxestrlen (newdir) + 1), 1155 qxestrcpy ((Ibyte *) ALLOCA (qxestrlen (newdir) + 1),
1156 newdir); 1156 newdir);
1157 p = newdir + 2; 1157 p = newdir + 2;
1158 while (*p && !IS_DIRECTORY_SEP (*p)) p++; 1158 while (*p && !IS_DIRECTORY_SEP (*p)) p++;
1159 p++; 1159 p++;
1160 while (*p && !IS_DIRECTORY_SEP (*p)) p++; 1160 while (*p && !IS_DIRECTORY_SEP (*p)) p++;
1161 *p = 0; 1161 *p = 0;
1162 } 1162 }
1163 else 1163 else
1164 newdir = (Intbyte *) ""; 1164 newdir = (Ibyte *) "";
1165 } 1165 }
1166 } 1166 }
1167 #endif /* WIN32_FILENAMES */ 1167 #endif /* WIN32_FILENAMES */
1168 1168
1169 if (newdir) 1169 if (newdir)
1175 #ifdef WIN32_FILENAMES 1175 #ifdef WIN32_FILENAMES
1176 && !(length == 2 && IS_DIRECTORY_SEP (newdir[0])) 1176 && !(length == 2 && IS_DIRECTORY_SEP (newdir[0]))
1177 #endif 1177 #endif
1178 ) 1178 )
1179 { 1179 {
1180 Intbyte *temp = (Intbyte *) ALLOCA (length); 1180 Ibyte *temp = (Ibyte *) ALLOCA (length);
1181 memcpy (temp, newdir, length - 1); 1181 memcpy (temp, newdir, length - 1);
1182 temp[length - 1] = 0; 1182 temp[length - 1] = 0;
1183 newdir = temp; 1183 newdir = temp;
1184 } 1184 }
1185 tlen = length + 1; 1185 tlen = length + 1;
1191 tlen += qxestrlen (nm) + 1; 1191 tlen += qxestrlen (nm) + 1;
1192 #ifdef WIN32_FILENAMES 1192 #ifdef WIN32_FILENAMES
1193 /* Reserve space for drive specifier and escape prefix, since either 1193 /* Reserve space for drive specifier and escape prefix, since either
1194 or both may need to be inserted. (The Microsoft x86 compiler 1194 or both may need to be inserted. (The Microsoft x86 compiler
1195 produces incorrect code if the following two lines are combined.) */ 1195 produces incorrect code if the following two lines are combined.) */
1196 target = (Intbyte *) ALLOCA (tlen + 4); 1196 target = (Ibyte *) ALLOCA (tlen + 4);
1197 target += 4; 1197 target += 4;
1198 #else /* not WIN32_FILENAMES */ 1198 #else /* not WIN32_FILENAMES */
1199 target = (Intbyte *) ALLOCA (tlen); 1199 target = (Ibyte *) ALLOCA (tlen);
1200 #endif /* not WIN32_FILENAMES */ 1200 #endif /* not WIN32_FILENAMES */
1201 *target = 0; 1201 *target = 0;
1202 1202
1203 if (newdir) 1203 if (newdir)
1204 { 1204 {
1295 } 1295 }
1296 1296
1297 *o = '\0'; 1297 *o = '\0';
1298 1298
1299 { 1299 {
1300 Intbyte *newtarget = mswindows_canonicalize_filename (target); 1300 Ibyte *newtarget = mswindows_canonicalize_filename (target);
1301 Lisp_Object result = build_intstring (newtarget); 1301 Lisp_Object result = build_intstring (newtarget);
1302 xfree (newtarget); 1302 xfree (newtarget);
1303 1303
1304 RETURN_UNGCPRO (result); 1304 RETURN_UNGCPRO (result);
1305 } 1305 }
1339 RETURN_UNGCPRO 1339 RETURN_UNGCPRO
1340 (call2_check_string (handler, Qfile_truename, expanded_name)); 1340 (call2_check_string (handler, Qfile_truename, expanded_name));
1341 } 1341 }
1342 1342
1343 { 1343 {
1344 Intbyte resolved_path[PATH_MAX]; 1344 Ibyte resolved_path[PATH_MAX];
1345 Bytecount elen = XSTRING_LENGTH (expanded_name); 1345 Bytecount elen = XSTRING_LENGTH (expanded_name);
1346 Intbyte *path; 1346 Ibyte *path;
1347 Intbyte *p; 1347 Ibyte *p;
1348 1348
1349 LISP_STRING_TO_ALLOCA (expanded_name, path); 1349 LISP_STRING_TO_ALLOCA (expanded_name, path);
1350 p = path; 1350 p = path;
1351 1351
1352 /* Try doing it all at once. */ 1352 /* Try doing it all at once. */
1370 1370
1371 Since we depend on undocumented semantics of various system 1371 Since we depend on undocumented semantics of various system
1372 realpath()s, we just use our own version in realpath.c. */ 1372 realpath()s, we just use our own version in realpath.c. */
1373 for (;;) 1373 for (;;)
1374 { 1374 {
1375 Intbyte *pos; 1375 Ibyte *pos;
1376 1376
1377 #ifdef WIN32_FILENAMES 1377 #ifdef WIN32_FILENAMES
1378 if (IS_DRIVE (p[0]) && IS_DEVICE_SEP (p[1]) 1378 if (IS_DRIVE (p[0]) && IS_DEVICE_SEP (p[1])
1379 && IS_DIRECTORY_SEP (p[2])) 1379 && IS_DIRECTORY_SEP (p[2]))
1380 /* don't test c: on windows */ 1380 /* don't test c: on windows */
1464 If `/~' appears, all of FILENAME through that `/' is discarded. 1464 If `/~' appears, all of FILENAME through that `/' is discarded.
1465 */ 1465 */
1466 (filename)) 1466 (filename))
1467 { 1467 {
1468 /* This function can GC. GC checked 2000-07-28 ben. */ 1468 /* This function can GC. GC checked 2000-07-28 ben. */
1469 Intbyte *nm; 1469 Ibyte *nm;
1470 1470
1471 Intbyte *s, *p, *o, *x, *endp; 1471 Ibyte *s, *p, *o, *x, *endp;
1472 Intbyte *target = 0; 1472 Ibyte *target = 0;
1473 int total = 0; 1473 int total = 0;
1474 int substituted = 0; 1474 int substituted = 0;
1475 Intbyte *xnm; 1475 Ibyte *xnm;
1476 Lisp_Object handler; 1476 Lisp_Object handler;
1477 1477
1478 CHECK_STRING (filename); 1478 CHECK_STRING (filename);
1479 1479
1480 /* If the file name has special constructs in it, 1480 /* If the file name has special constructs in it,
1548 while (p != endp && (isalnum (*p) || *p == '_')) p++; 1548 while (p != endp && (isalnum (*p) || *p == '_')) p++;
1549 s = p; 1549 s = p;
1550 } 1550 }
1551 1551
1552 /* Copy out the variable name */ 1552 /* Copy out the variable name */
1553 target = (Intbyte *) ALLOCA (s - o + 1); 1553 target = (Ibyte *) ALLOCA (s - o + 1);
1554 qxestrncpy (target, o, s - o); 1554 qxestrncpy (target, o, s - o);
1555 target[s - o] = 0; 1555 target[s - o] = 0;
1556 #ifdef WIN32_NATIVE 1556 #ifdef WIN32_NATIVE
1557 strupr (target); /* $home == $HOME etc. */ 1557 strupr (target); /* $home == $HOME etc. */
1558 #endif /* WIN32_NATIVE */ 1558 #endif /* WIN32_NATIVE */
1559 1559
1560 /* Get variable value */ 1560 /* Get variable value */
1561 o = egetenv ((CIntbyte *) target); 1561 o = egetenv ((CIbyte *) target);
1562 if (!o) goto badvar; 1562 if (!o) goto badvar;
1563 total += qxestrlen (o); 1563 total += qxestrlen (o);
1564 substituted = 1; 1564 substituted = 1;
1565 } 1565 }
1566 1566
1567 if (!substituted) 1567 if (!substituted)
1568 return filename; 1568 return filename;
1569 1569
1570 /* If substitution required, recopy the filename and do it */ 1570 /* If substitution required, recopy the filename and do it */
1571 /* Make space in stack frame for the new copy */ 1571 /* Make space in stack frame for the new copy */
1572 xnm = (Intbyte *) ALLOCA (XSTRING_LENGTH (filename) + total + 1); 1572 xnm = (Ibyte *) ALLOCA (XSTRING_LENGTH (filename) + total + 1);
1573 x = xnm; 1573 x = xnm;
1574 1574
1575 /* Copy the rest of the name through, replacing $ constructs with values */ 1575 /* Copy the rest of the name through, replacing $ constructs with values */
1576 for (p = nm; *p;) 1576 for (p = nm; *p;)
1577 if (*p != '$') 1577 if (*p != '$')
1599 while (p != endp && (isalnum (*p) || *p == '_')) p++; 1599 while (p != endp && (isalnum (*p) || *p == '_')) p++;
1600 s = p; 1600 s = p;
1601 } 1601 }
1602 1602
1603 /* Copy out the variable name */ 1603 /* Copy out the variable name */
1604 target = (Intbyte *) ALLOCA (s - o + 1); 1604 target = (Ibyte *) ALLOCA (s - o + 1);
1605 qxestrncpy (target, o, s - o); 1605 qxestrncpy (target, o, s - o);
1606 target[s - o] = 0; 1606 target[s - o] = 0;
1607 #ifdef WIN32_NATIVE 1607 #ifdef WIN32_NATIVE
1608 strupr (target); /* $home == $HOME etc. */ 1608 strupr (target); /* $home == $HOME etc. */
1609 #endif /* WIN32_NATIVE */ 1609 #endif /* WIN32_NATIVE */
1610 1610
1611 /* Get variable value */ 1611 /* Get variable value */
1612 o = egetenv ((CIntbyte *) target); 1612 o = egetenv ((CIbyte *) target);
1613 if (!o) 1613 if (!o)
1614 goto badvar; 1614 goto badvar;
1615 1615
1616 qxestrcpy (x, o); 1616 qxestrcpy (x, o);
1617 x += qxestrlen (o); 1617 x += qxestrlen (o);
2202 On Unix, this is a name starting with a `/' or a `~'. 2202 On Unix, this is a name starting with a `/' or a `~'.
2203 */ 2203 */
2204 (filename)) 2204 (filename))
2205 { 2205 {
2206 /* This function does not GC */ 2206 /* This function does not GC */
2207 Intbyte *ptr; 2207 Ibyte *ptr;
2208 2208
2209 CHECK_STRING (filename); 2209 CHECK_STRING (filename);
2210 ptr = XSTRING_DATA (filename); 2210 ptr = XSTRING_DATA (filename);
2211 return (IS_DIRECTORY_SEP (*ptr) || *ptr == '~' 2211 return (IS_DIRECTORY_SEP (*ptr) || *ptr == '~'
2212 #ifdef WIN32_FILENAMES 2212 #ifdef WIN32_FILENAMES
2238 } 2238 }
2239 2239
2240 /* Return nonzero if file FILENAME exists and can be written. */ 2240 /* Return nonzero if file FILENAME exists and can be written. */
2241 2241
2242 static int 2242 static int
2243 check_writable (const Intbyte *filename) 2243 check_writable (const Ibyte *filename)
2244 { 2244 {
2245 #ifdef HAVE_EACCESS 2245 #ifdef HAVE_EACCESS
2246 return (qxe_eaccess (filename, W_OK) >= 0); 2246 return (qxe_eaccess (filename, W_OK) >= 0);
2247 #else 2247 #else
2248 /* Access isn't quite right because it uses the real uid 2248 /* Access isn't quite right because it uses the real uid
2377 2377
2378 2378
2379 GCPRO1 (abspath); 2379 GCPRO1 (abspath);
2380 dir = Ffile_name_directory (abspath); 2380 dir = Ffile_name_directory (abspath);
2381 UNGCPRO; 2381 UNGCPRO;
2382 return (check_writable (!NILP (dir) ? XSTRING_DATA (dir) : (Intbyte *) "") 2382 return (check_writable (!NILP (dir) ? XSTRING_DATA (dir) : (Ibyte *) "")
2383 ? Qt : Qnil); 2383 ? Qt : Qnil);
2384 } 2384 }
2385 2385
2386 DEFUN ("file-symlink-p", Ffile_symlink_p, 1, 1, 0, /* 2386 DEFUN ("file-symlink-p", Ffile_symlink_p, 1, 1, 0, /*
2387 Return non-nil if file FILENAME is the name of a symbolic link. 2387 Return non-nil if file FILENAME is the name of a symbolic link.
2391 (filename)) 2391 (filename))
2392 { 2392 {
2393 /* This function can GC. GC checked 1997.04.10. */ 2393 /* This function can GC. GC checked 1997.04.10. */
2394 /* XEmacs change: run handlers even if local machine doesn't have symlinks */ 2394 /* XEmacs change: run handlers even if local machine doesn't have symlinks */
2395 #ifdef HAVE_READLINK 2395 #ifdef HAVE_READLINK
2396 Intbyte *buf; 2396 Ibyte *buf;
2397 int bufsize; 2397 int bufsize;
2398 int valsize; 2398 int valsize;
2399 Lisp_Object val; 2399 Lisp_Object val;
2400 #endif 2400 #endif
2401 Lisp_Object handler; 2401 Lisp_Object handler;
2414 2414
2415 #ifdef HAVE_READLINK 2415 #ifdef HAVE_READLINK
2416 bufsize = 100; 2416 bufsize = 100;
2417 while (1) 2417 while (1)
2418 { 2418 {
2419 buf = xnew_array_and_zero (Intbyte, bufsize); 2419 buf = xnew_array_and_zero (Ibyte, bufsize);
2420 valsize = qxe_readlink (XSTRING_DATA (filename), 2420 valsize = qxe_readlink (XSTRING_DATA (filename),
2421 buf, bufsize); 2421 buf, bufsize);
2422 if (valsize < bufsize) break; 2422 if (valsize < bufsize) break;
2423 /* Buffer was not long enough */ 2423 /* Buffer was not long enough */
2424 xfree (buf); 2424 xfree (buf);
2728 Charcount inserted = 0; 2728 Charcount inserted = 0;
2729 int speccount; 2729 int speccount;
2730 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 2730 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
2731 Lisp_Object handler = Qnil, val; 2731 Lisp_Object handler = Qnil, val;
2732 int total; 2732 int total;
2733 Intbyte read_buf[READ_BUF_SIZE]; 2733 Ibyte read_buf[READ_BUF_SIZE];
2734 int mc_count; 2734 int mc_count;
2735 struct buffer *buf = current_buffer; 2735 struct buffer *buf = current_buffer;
2736 Lisp_Object curbuf; 2736 Lisp_Object curbuf;
2737 int not_regular = 0; 2737 int not_regular = 0;
2738 int do_speedy_insert = 2738 int do_speedy_insert =
3592 nextpos = XINT (tem); 3592 nextpos = XINT (tem);
3593 else 3593 else
3594 nextpos = INT_MAX; 3594 nextpos = INT_MAX;
3595 #ifdef MULE 3595 #ifdef MULE
3596 /* If there are annotations left and we have Mule, then we 3596 /* If there are annotations left and we have Mule, then we
3597 have to do the I/O one emchar at a time so we can 3597 have to do the I/O one ichar at a time so we can
3598 determine when to insert the annotation. */ 3598 determine when to insert the annotation. */
3599 if (!NILP (*annot)) 3599 if (!NILP (*annot))
3600 { 3600 {
3601 Emchar ch; 3601 Ichar ch;
3602 while (pos != nextpos && (ch = Lstream_get_emchar (instr)) != EOF) 3602 while (pos != nextpos && (ch = Lstream_get_ichar (instr)) != EOF)
3603 { 3603 {
3604 if (Lstream_put_emchar (outstr, ch) < 0) 3604 if (Lstream_put_ichar (outstr, ch) < 0)
3605 return -1; 3605 return -1;
3606 pos++; 3606 pos++;
3607 } 3607 }
3608 } 3608 }
3609 else 3609 else