comparison src/fileio.c @ 372:481e29c1e27e

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Fri, 02 Aug 1991 02:24:35 +0000
parents 80a890dbbeb5
children 7812e9efc1af
comparison
equal deleted inserted replaced
371:54ac13a6f74e 372:481e29c1e27e
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19 19
20 20
21 #include <sys/types.h> 21 #include <sys/types.h>
22 #include <sys/stat.h> 22 #include <sys/stat.h>
23
24 #ifdef VMS
25 #include "pwd.h"
26 #else
23 #include <pwd.h> 27 #include <pwd.h>
28 #endif
29
24 #include <ctype.h> 30 #include <ctype.h>
31
32 #ifdef VMS
33 #include "dir.h"
34 #include <perror.h>
35 #include <stddef.h>
36 #include <string.h>
37 #else
25 #include <sys/dir.h> 38 #include <sys/dir.h>
39 #endif
40
26 #include <errno.h> 41 #include <errno.h>
27 42
28 #ifndef VMS 43 #ifndef vax11c
29 extern int errno; 44 extern int errno;
30 extern char *sys_errlist[]; 45 extern char *sys_errlist[];
31 extern int sys_nerr; 46 extern int sys_nerr;
32 #endif 47 #endif
33 48
44 #include "lisp.h" 59 #include "lisp.h"
45 #include "buffer.h" 60 #include "buffer.h"
46 #include "window.h" 61 #include "window.h"
47 62
48 #ifdef VMS 63 #ifdef VMS
49 #include <perror.h>
50 #include <file.h> 64 #include <file.h>
51 #include <rmsdef.h> 65 #include <rmsdef.h>
52 #include <fab.h> 66 #include <fab.h>
53 #include <nam.h> 67 #include <nam.h>
54 #endif 68 #endif
215 else 229 else
216 { 230 {
217 brack = ']'; 231 brack = ']';
218 strcpy (out, "[."); 232 strcpy (out, "[.");
219 } 233 }
220 if (dot = index (p, '.')) 234 dot = index (p, '.');
235 if (dot)
221 { 236 {
222 /* blindly remove any extension */ 237 /* blindly remove any extension */
223 size = strlen (out) + (dot - p); 238 size = strlen (out) + (dot - p);
224 strncat (out, p, dot - p); 239 strncat (out, p, dot - p);
225 } 240 }
346 } 361 }
347 bracket = src[slen - 1]; 362 bracket = src[slen - 1];
348 363
349 /* If bracket is ']' or '>', bracket - 2 is the corresponding 364 /* If bracket is ']' or '>', bracket - 2 is the corresponding
350 opening bracket. */ 365 opening bracket. */
351 if (!(ptr = index (src, bracket - 2))) 366 ptr = index (src, bracket - 2);
367 if (ptr == 0)
352 { /* no opening bracket */ 368 { /* no opening bracket */
353 strcpy (dst, src); 369 strcpy (dst, src);
354 return 0; 370 return 0;
355 } 371 }
356 if (!(rptr = rindex (src, '.'))) 372 if (!(rptr = rindex (src, '.')))
646 defalt = current_buffer->directory; 662 defalt = current_buffer->directory;
647 CHECK_STRING (defalt, 1); 663 CHECK_STRING (defalt, 1);
648 newdir = XSTRING (defalt)->data; 664 newdir = XSTRING (defalt)->data;
649 } 665 }
650 666
667 if (newdir != 0)
668 {
669 /* Get rid of any slash at the end of newdir. */
670 int length = strlen (newdir);
671 if (newdir[length - 1] == '/')
672 {
673 unsigned char *temp = (unsigned char *) alloca (length);
674 bcopy (newdir, temp, length - 1);
675 temp[length - 1] = 0;
676 newdir = temp;
677 }
678 tlen = length + 1;
679 }
680 else
681 tlen = 0;
682
651 /* Now concatenate the directory and name to new space in the stack frame */ 683 /* Now concatenate the directory and name to new space in the stack frame */
652 684 tlen += strlen (nm) + 1;
653 tlen = (newdir ? strlen (newdir) + 1 : 0) + strlen (nm) + 1;
654 target = (unsigned char *) alloca (tlen); 685 target = (unsigned char *) alloca (tlen);
655 *target = 0; 686 *target = 0;
656 687
657 if (newdir) 688 if (newdir)
658 { 689 {