comparison src/sysdep.c @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents bcdc7deadc19
children 4103f0995bd7
comparison
equal deleted inserted replaced
15:ad457d5f7d04 16:0293115a14e9
37 /* ------------------------------- */ 37 /* ------------------------------- */
38 38
39 #ifdef HAVE_TTY 39 #ifdef HAVE_TTY
40 #include "console-tty.h" 40 #include "console-tty.h"
41 #else 41 #else
42 #include "syssignal.h" /* Always include before systty.h */ 42 #include "syssignal.h"
43 #include "systty.h" 43 #include "systty.h"
44 #endif /* HAVE_TTY */ 44 #endif /* HAVE_TTY */
45 45
46 #include "console-stream.h" 46 #include "console-stream.h"
47 47
600 dir = Fsymbol_value (Qdefault_directory); 600 dir = Fsymbol_value (Qdefault_directory);
601 if (!STRINGP (dir)) 601 if (!STRINGP (dir))
602 goto xyzzy; 602 goto xyzzy;
603 603
604 dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil); 604 dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil);
605 str = (unsigned char *) alloca (string_length (XSTRING (dir)) + 2); 605 str = (unsigned char *) alloca (XSTRING_LENGTH (dir) + 2);
606 len = string_length (XSTRING (dir)); 606 len = XSTRING_LENGTH (dir);
607 memcpy (str, string_data (XSTRING (dir)), len); 607 memcpy (str, XSTRING_DATA (dir), len);
608 /* #### Unix specific */ 608 /* #### Unix specific */
609 if (str[len - 1] != '/') str[len++] = '/'; 609 if (str[len - 1] != '/') str[len++] = '/';
610 str[len] = 0; 610 str[len] = 0;
611 xyzzy: 611 xyzzy:
612 612
2536 #endif /* HAVE_GETHOSTNAME and not VMS */ 2536 #endif /* HAVE_GETHOSTNAME and not VMS */
2537 { 2537 {
2538 Bufbyte *p; 2538 Bufbyte *p;
2539 Bytecount i; 2539 Bytecount i;
2540 2540
2541 for (i = 0, p = string_data (XSTRING (Vsystem_name)); 2541 for (i = 0, p = XSTRING_DATA (Vsystem_name);
2542 i < string_length (XSTRING (Vsystem_name)); 2542 i < XSTRING_LENGTH (Vsystem_name);
2543 i++, p++) 2543 i++, p++)
2544 { 2544 {
2545 if (*p == ' ' || *p == '\t') 2545 if (*p == ' ' || *p == '\t')
2546 *p = '-'; 2546 *p = '-';
2547 } 2547 }
2763 approach to programming and its connection to the silly 2763 approach to programming and its connection to the silly
2764 interruptible-system-call business. To find it, look at 2764 interruptible-system-call business. To find it, look at
2765 Jamie's home page (http://www.netscape.com/people/jwz). */ 2765 Jamie's home page (http://www.netscape.com/people/jwz). */
2766 2766
2767 #ifdef ENCAPSULATE_OPEN 2767 #ifdef ENCAPSULATE_OPEN
2768
2769 int 2768 int
2770 sys_open (CONST char *path, int oflag, ...) 2769 sys_open (CONST char *path, int oflag, ...)
2771 { 2770 {
2772 int mode; 2771 int mode;
2773 va_list ap; 2772 va_list ap;
2786 } 2785 }
2787 #else 2786 #else
2788 return open (path, oflag, mode); 2787 return open (path, oflag, mode);
2789 #endif 2788 #endif
2790 } 2789 }
2791
2792 #endif /* ENCAPSULATE_OPEN */ 2790 #endif /* ENCAPSULATE_OPEN */
2793 2791
2792
2794 #ifdef ENCAPSULATE_CLOSE 2793 #ifdef ENCAPSULATE_CLOSE
2795
2796 int 2794 int
2797 sys_close (int fd) 2795 sys_close (int fd)
2798 { 2796 {
2799 #ifdef INTERRUPTIBLE_CLOSE 2797 #ifdef INTERRUPTIBLE_CLOSE
2800 int did_retry = 0; 2798 int did_retry = 0;
2813 return rtnval; 2811 return rtnval;
2814 #else 2812 #else
2815 return close (fd); 2813 return close (fd);
2816 #endif 2814 #endif
2817 } 2815 }
2818
2819 #endif /* ENCAPSULATE_CLOSE */ 2816 #endif /* ENCAPSULATE_CLOSE */
2820 2817
2821 int 2818 int
2822 sys_read_1 (int fildes, void *buf, unsigned int nbyte, int allow_quit) 2819 sys_read_1 (int fildes, void *buf, unsigned int nbyte, int allow_quit)
2823 { 2820 {
2836 return rtnval; 2833 return rtnval;
2837 #endif 2834 #endif
2838 } 2835 }
2839 2836
2840 #ifdef ENCAPSULATE_READ 2837 #ifdef ENCAPSULATE_READ
2841
2842 int 2838 int
2843 sys_read (int fildes, void *buf, unsigned int nbyte) 2839 sys_read (int fildes, void *buf, unsigned int nbyte)
2844 { 2840 {
2845 return sys_read_1 (fildes, buf, nbyte, 0); 2841 return sys_read_1 (fildes, buf, nbyte, 0);
2846 } 2842 }
2847
2848 #endif /* ENCAPSULATE_READ */ 2843 #endif /* ENCAPSULATE_READ */
2849 2844
2850 int 2845 int
2851 sys_write_1 (int fildes, CONST void *buf, unsigned int nbyte, int allow_quit) 2846 sys_write_1 (int fildes, CONST void *buf, unsigned int nbyte, int allow_quit)
2852 { 2847 {
2879 return (bytes_written); 2874 return (bytes_written);
2880 #endif 2875 #endif
2881 } 2876 }
2882 2877
2883 #ifdef ENCAPSULATE_WRITE 2878 #ifdef ENCAPSULATE_WRITE
2884
2885 int 2879 int
2886 sys_write (int fildes, CONST void *buf, unsigned int nbyte) 2880 sys_write (int fildes, CONST void *buf, unsigned int nbyte)
2887 { 2881 {
2888 return sys_write_1 (fildes, buf, nbyte, 0); 2882 return sys_write_1 (fildes, buf, nbyte, 0);
2889 } 2883 }
2890
2891 #endif /* ENCAPSULATE_WRITE */ 2884 #endif /* ENCAPSULATE_WRITE */
2892 2885
2893 2886
2894 /**************** stdio calls ****************/ 2887 /**************** stdio calls ****************/
2895 2888
2899 2892
2900 /* #### Should also encapsulate fflush(). 2893 /* #### Should also encapsulate fflush().
2901 #### Should conceivably encapsulate getchar() etc. What a pain! */ 2894 #### Should conceivably encapsulate getchar() etc. What a pain! */
2902 2895
2903 #ifdef ENCAPSULATE_FOPEN 2896 #ifdef ENCAPSULATE_FOPEN
2904
2905 FILE * 2897 FILE *
2906 sys_fopen (CONST char *path, CONST char *type) 2898 sys_fopen (CONST char *path, CONST char *type)
2907 { 2899 {
2908 PATHNAME_CONVERT_OUT (path); 2900 PATHNAME_CONVERT_OUT (path);
2909 #ifdef INTERRUPTIBLE_OPEN 2901 #ifdef INTERRUPTIBLE_OPEN
2914 } 2906 }
2915 #else 2907 #else
2916 return fopen (path, type); 2908 return fopen (path, type);
2917 #endif 2909 #endif
2918 } 2910 }
2919
2920 #endif /* ENCAPSULATE_FOPEN */ 2911 #endif /* ENCAPSULATE_FOPEN */
2921 2912
2913
2922 #ifdef ENCAPSULATE_FCLOSE 2914 #ifdef ENCAPSULATE_FCLOSE
2923
2924 int 2915 int
2925 sys_fclose (FILE *stream) 2916 sys_fclose (FILE *stream)
2926 { 2917 {
2927 #ifdef INTERRUPTIBLE_CLOSE 2918 #ifdef INTERRUPTIBLE_CLOSE
2928 int rtnval; 2919 int rtnval;
2933 return rtnval; 2924 return rtnval;
2934 #else 2925 #else
2935 return fclose (stream); 2926 return fclose (stream);
2936 #endif 2927 #endif
2937 } 2928 }
2938
2939 #endif /* ENCAPSULATE_FCLOSE */ 2929 #endif /* ENCAPSULATE_FCLOSE */
2940 2930
2931
2941 #ifdef ENCAPSULATE_FREAD 2932 #ifdef ENCAPSULATE_FREAD
2942
2943 size_t 2933 size_t
2944 sys_fread (void *ptr, size_t size, size_t nitem, FILE *stream) 2934 sys_fread (void *ptr, size_t size, size_t nitem, FILE *stream)
2945 { 2935 {
2946 #ifdef INTERRUPTIBLE_IO 2936 #ifdef INTERRUPTIBLE_IO
2947 size_t rtnval; 2937 size_t rtnval;
2965 return (items_read); 2955 return (items_read);
2966 #else 2956 #else
2967 return fread (ptr, size, nitem, stream); 2957 return fread (ptr, size, nitem, stream);
2968 #endif 2958 #endif
2969 } 2959 }
2970
2971 #endif /* ENCAPSULATE_FREAD */ 2960 #endif /* ENCAPSULATE_FREAD */
2972 2961
2962
2973 #ifdef ENCAPSULATE_FWRITE 2963 #ifdef ENCAPSULATE_FWRITE
2974
2975 size_t 2964 size_t
2976 sys_fwrite (CONST void *ptr, size_t size, size_t nitem, FILE *stream) 2965 sys_fwrite (CONST void *ptr, size_t size, size_t nitem, FILE *stream)
2977 { 2966 {
2978 #ifdef INTERRUPTIBLE_IO 2967 #ifdef INTERRUPTIBLE_IO
2979 size_t rtnval; 2968 size_t rtnval;
2999 return vms_fwrite (ptr, size, nitem, stream); 2988 return vms_fwrite (ptr, size, nitem, stream);
3000 #else 2989 #else
3001 return fwrite (ptr, size, nitem, stream); 2990 return fwrite (ptr, size, nitem, stream);
3002 #endif 2991 #endif
3003 } 2992 }
3004
3005 #endif /* ENCAPSULATE_FWRITE */ 2993 #endif /* ENCAPSULATE_FWRITE */
3006 2994
3007 2995
3008 /********************* directory calls *******************/ 2996 /********************* directory calls *******************/
3009 2997
3010 #ifdef ENCAPSULATE_CHDIR 2998 #ifdef ENCAPSULATE_CHDIR
3011
3012 int 2999 int
3013 sys_chdir (CONST char *path) 3000 sys_chdir (CONST char *path)
3014 { 3001 {
3015 PATHNAME_CONVERT_OUT (path); 3002 PATHNAME_CONVERT_OUT (path);
3016 #ifdef MSDOS 3003 #ifdef MSDOS
3017 return dos_chdir (path); 3004 return dos_chdir (path);
3018 #else 3005 #else
3019 return chdir (path); 3006 return chdir (path);
3020 #endif 3007 #endif
3021 } 3008 }
3022
3023 #endif /* ENCAPSULATE_CHDIR */ 3009 #endif /* ENCAPSULATE_CHDIR */
3024 3010
3011
3025 #ifdef ENCAPSULATE_MKDIR 3012 #ifdef ENCAPSULATE_MKDIR
3026
3027 int 3013 int
3028 sys_mkdir (CONST char *path, int mode) 3014 sys_mkdir (CONST char *path, int mode)
3029 { 3015 {
3030 PATHNAME_CONVERT_OUT (path); 3016 PATHNAME_CONVERT_OUT (path);
3031 return mkdir (path, mode); 3017 return mkdir (path, mode);
3032 } 3018 }
3033
3034 #endif /* ENCAPSULATE_MKDIR */ 3019 #endif /* ENCAPSULATE_MKDIR */
3035 3020
3021
3036 #ifdef ENCAPSULATE_OPENDIR 3022 #ifdef ENCAPSULATE_OPENDIR
3037
3038 DIR * 3023 DIR *
3039 sys_opendir (CONST char *filename) 3024 sys_opendir (CONST char *filename)
3040 { 3025 {
3041 DIR *rtnval; 3026 DIR *rtnval;
3042 PATHNAME_CONVERT_OUT (filename); 3027 PATHNAME_CONVERT_OUT (filename);
3044 while (!(rtnval = opendir (filename)) 3029 while (!(rtnval = opendir (filename))
3045 && (errno == EINTR)) 3030 && (errno == EINTR))
3046 ; 3031 ;
3047 return rtnval; 3032 return rtnval;
3048 } 3033 }
3049
3050 #endif /* ENCAPSULATE_OPENDIR */ 3034 #endif /* ENCAPSULATE_OPENDIR */
3051 3035
3036
3052 #ifdef ENCAPSULATE_READDIR 3037 #ifdef ENCAPSULATE_READDIR
3053
3054 DIRENTRY * 3038 DIRENTRY *
3055 sys_readdir (DIR *dirp) 3039 sys_readdir (DIR *dirp)
3056 { 3040 {
3057 DIRENTRY *rtnval; 3041 DIRENTRY *rtnval;
3058 3042
3061 while (!(errno = 0, rtnval = readdir (dirp)) 3045 while (!(errno = 0, rtnval = readdir (dirp))
3062 && (errno == EINTR)) 3046 && (errno == EINTR))
3063 ; 3047 ;
3064 return rtnval; 3048 return rtnval;
3065 } 3049 }
3066
3067 #endif /* ENCAPSULATE_READDIR */ 3050 #endif /* ENCAPSULATE_READDIR */
3068 3051
3052
3069 #ifdef ENCAPSULATE_CLOSEDIR 3053 #ifdef ENCAPSULATE_CLOSEDIR
3070
3071 int 3054 int
3072 sys_closedir (DIR *dirp) 3055 sys_closedir (DIR *dirp)
3073 { 3056 {
3074 int rtnval; 3057 int rtnval;
3075 3058
3076 while ((rtnval = closedir (dirp)) == -1 3059 while ((rtnval = closedir (dirp)) == -1
3077 && (errno == EINTR)) 3060 && (errno == EINTR))
3078 ; 3061 ;
3079 return rtnval; 3062 return rtnval;
3080 } 3063 }
3081
3082 #endif /* ENCAPSULATE_CLOSEDIR */ 3064 #endif /* ENCAPSULATE_CLOSEDIR */
3083 3065
3066
3084 #ifdef ENCAPSULATE_RMDIR 3067 #ifdef ENCAPSULATE_RMDIR
3085
3086 int 3068 int
3087 sys_rmdir (CONST char *path) 3069 sys_rmdir (CONST char *path)
3088 { 3070 {
3089 PATHNAME_CONVERT_OUT (path); 3071 PATHNAME_CONVERT_OUT (path);
3090 return rmdir (path); 3072 return rmdir (path);
3091 } 3073 }
3092
3093 #endif /* ENCAPSULATE_RMDIR */ 3074 #endif /* ENCAPSULATE_RMDIR */
3094 3075
3095 3076
3096 /***************** file-information calls ******************/ 3077 /***************** file-information calls ******************/
3097 3078
3098 #ifdef ENCAPSULATE_ACCESS 3079 #ifdef ENCAPSULATE_ACCESS
3099
3100 int 3080 int
3101 sys_access (CONST char *path, int mode) 3081 sys_access (CONST char *path, int mode)
3102 { 3082 {
3103 PATHNAME_CONVERT_OUT (path); 3083 PATHNAME_CONVERT_OUT (path);
3104 #ifdef VMS 3084 #ifdef VMS
3105 return vms_access (path, mode); 3085 return vms_access (path, mode);
3106 #else 3086 #else
3107 return access (path, mode); 3087 return access (path, mode);
3108 #endif 3088 #endif
3109 } 3089 }
3110
3111 #endif /* ENCAPSULATE_ACCESS */ 3090 #endif /* ENCAPSULATE_ACCESS */
3091
3112 3092
3113 #ifdef HAVE_EACCESS 3093 #ifdef HAVE_EACCESS
3114 #ifdef ENCAPSULATE_EACCESS 3094 #ifdef ENCAPSULATE_EACCESS
3115
3116 int 3095 int
3117 sys_eaccess (CONST char *path, int mode) 3096 sys_eaccess (CONST char *path, int mode)
3118 { 3097 {
3119 PATHNAME_CONVERT_OUT (path); 3098 PATHNAME_CONVERT_OUT (path);
3120 return eaccess (path, mode); 3099 return eaccess (path, mode);
3121 } 3100 }
3122
3123 #endif /* ENCAPSULATE_EACCESS */ 3101 #endif /* ENCAPSULATE_EACCESS */
3124 #endif /* HAVE_EACCESS */ 3102 #endif /* HAVE_EACCESS */
3125 3103
3126 3104
3127 #ifdef ENCAPSULATE_LSTAT 3105 #ifdef ENCAPSULATE_LSTAT
3128
3129 int 3106 int
3130 sys_lstat (CONST char *path, struct stat *buf) 3107 sys_lstat (CONST char *path, struct stat *buf)
3131 { 3108 {
3132 PATHNAME_CONVERT_OUT (path); 3109 PATHNAME_CONVERT_OUT (path);
3133 return lstat (path, buf); 3110 return lstat (path, buf);
3134 } 3111 }
3135
3136 #endif /* ENCAPSULATE_LSTAT */ 3112 #endif /* ENCAPSULATE_LSTAT */
3137 3113
3114
3138 #ifdef ENCAPSULATE_READLINK 3115 #ifdef ENCAPSULATE_READLINK
3139
3140 int 3116 int
3141 sys_readlink (CONST char *path, char *buf, int bufsiz) 3117 sys_readlink (CONST char *path, char *buf, int bufsiz)
3142 { 3118 {
3143 PATHNAME_CONVERT_OUT (path); 3119 PATHNAME_CONVERT_OUT (path);
3144 /* #### currently we don't do conversions on the incoming data */ 3120 /* #### currently we don't do conversions on the incoming data */
3145 return readlink (path, buf, bufsiz); 3121 return readlink (path, buf, bufsiz);
3146 } 3122 }
3147
3148 #endif /* ENCAPSULATE_READLINK */ 3123 #endif /* ENCAPSULATE_READLINK */
3149 3124
3125
3150 #ifdef ENCAPSULATE_STAT 3126 #ifdef ENCAPSULATE_STAT
3151
3152 int 3127 int
3153 sys_stat (CONST char *path, struct stat *buf) 3128 sys_stat (CONST char *path, struct stat *buf)
3154 { 3129 {
3155 PATHNAME_CONVERT_OUT (path); 3130 PATHNAME_CONVERT_OUT (path);
3156 return stat (path, buf); 3131 return stat (path, buf);
3157 } 3132 }
3158
3159 #endif /* ENCAPSULATE_STAT */ 3133 #endif /* ENCAPSULATE_STAT */
3160 3134
3161 3135
3162 /****************** file-manipulation calls *****************/ 3136 /****************** file-manipulation calls *****************/
3163 3137
3164 #ifdef ENCAPSULATE_CHMOD 3138 #ifdef ENCAPSULATE_CHMOD
3165
3166 int 3139 int
3167 sys_chmod (CONST char *path, int mode) 3140 sys_chmod (CONST char *path, int mode)
3168 { 3141 {
3169 PATHNAME_CONVERT_OUT (path); 3142 PATHNAME_CONVERT_OUT (path);
3170 return chmod (path, mode); 3143 return chmod (path, mode);
3171 } 3144 }
3172
3173 #endif /* ENCAPSULATE_CHMOD */ 3145 #endif /* ENCAPSULATE_CHMOD */
3174 3146
3147
3175 #ifdef ENCAPSULATE_CREAT 3148 #ifdef ENCAPSULATE_CREAT
3176
3177 int 3149 int
3178 sys_creat (CONST char *path, int mode) 3150 sys_creat (CONST char *path, int mode)
3179 { 3151 {
3180 PATHNAME_CONVERT_OUT (path); 3152 PATHNAME_CONVERT_OUT (path);
3181 return creat (path, mode); 3153 return creat (path, mode);
3182 } 3154 }
3183
3184 #endif /* ENCAPSULATE_CREAT */ 3155 #endif /* ENCAPSULATE_CREAT */
3185 3156
3157
3186 #ifdef ENCAPSULATE_LINK 3158 #ifdef ENCAPSULATE_LINK
3187
3188 int 3159 int
3189 sys_link (CONST char *existing, CONST char *new) 3160 sys_link (CONST char *existing, CONST char *new)
3190 { 3161 {
3191 PATHNAME_CONVERT_OUT (existing); 3162 PATHNAME_CONVERT_OUT (existing);
3192 PATHNAME_CONVERT_OUT (new); 3163 PATHNAME_CONVERT_OUT (new);
3193 return link (existing, new); 3164 return link (existing, new);
3194 } 3165 }
3195
3196 #endif /* ENCAPSULATE_LINK */ 3166 #endif /* ENCAPSULATE_LINK */
3197 3167
3168
3198 #ifdef ENCAPSULATE_RENAME 3169 #ifdef ENCAPSULATE_RENAME
3199
3200 int 3170 int
3201 sys_rename (CONST char *old, CONST char *new) 3171 sys_rename (CONST char *old, CONST char *new)
3202 { 3172 {
3203 PATHNAME_CONVERT_OUT (old); 3173 PATHNAME_CONVERT_OUT (old);
3204 PATHNAME_CONVERT_OUT (new); 3174 PATHNAME_CONVERT_OUT (new);
3205 return rename (old, new); 3175 return rename (old, new);
3206 } 3176 }
3207
3208 #endif /* ENCAPSULATE_RENAME */ 3177 #endif /* ENCAPSULATE_RENAME */
3209 3178
3179
3210 #ifdef ENCAPSULATE_SYMLINK 3180 #ifdef ENCAPSULATE_SYMLINK
3211
3212 int 3181 int
3213 sys_symlink (CONST char *name1, CONST char *name2) 3182 sys_symlink (CONST char *name1, CONST char *name2)
3214 { 3183 {
3215 PATHNAME_CONVERT_OUT (name1); 3184 PATHNAME_CONVERT_OUT (name1);
3216 PATHNAME_CONVERT_OUT (name2); 3185 PATHNAME_CONVERT_OUT (name2);
3217 return symlink (name1, name2); 3186 return symlink (name1, name2);
3218 } 3187 }
3219
3220 #endif /* ENCAPSULATE_SYMLINK */ 3188 #endif /* ENCAPSULATE_SYMLINK */
3221 3189
3190
3222 #ifdef ENCAPSULATE_UNLINK 3191 #ifdef ENCAPSULATE_UNLINK
3223
3224 int 3192 int
3225 sys_unlink (CONST char *path) 3193 sys_unlink (CONST char *path)
3226 { 3194 {
3227 PATHNAME_CONVERT_OUT (path); 3195 PATHNAME_CONVERT_OUT (path);
3228 return unlink (path); 3196 return unlink (path);
3229 } 3197 }
3230
3231 #endif /* ENCAPSULATE_UNLINK */ 3198 #endif /* ENCAPSULATE_UNLINK */
3199
3200
3201 #ifdef ENCAPSULATE_EXECVP
3202 int
3203 sys_execvp (CONST char *path, char * CONST argv[])
3204 {
3205 int i;
3206 PATHNAME_CONVERT_OUT (path);
3207 for (i = 0; argv[i]; i++)
3208 PATHNAME_CONVERT_OUT (argv[i]);
3209 return execvp (path, argv);
3210 }
3211 #endif /* ENCAPSULATE_EXECVP */
3232 3212
3233 3213
3234 /************************************************************************/ 3214 /************************************************************************/
3235 /* Emulations of missing system calls */ 3215 /* Emulations of missing system calls */
3236 /************************************************************************/ 3216 /************************************************************************/
3237 3217
3238 /***** (these are primarily required for USG, it seems) *****/ 3218 /***** (these are primarily required for USG, it seems) *****/
3239 3219
3240 /* 3220 /*
3241 * Warning, this function may not duplicate 4.2 action properly 3221 * Warning, this function may not duplicate BSD 4.2 action properly
3242 * under error conditions. 3222 * under error conditions.
3243 */ 3223 */
3244 3224
3245 #ifndef HAVE_GETWD 3225 #ifndef HAVE_GETWD
3246
3247 char * 3226 char *
3248 getwd (char *pathname) 3227 getwd (char *pathname)
3249 { 3228 {
3250 char *npath, *spath; 3229 char *npath, *spath;
3251 #if !__STDC__ && !defined(STDC_HEADERS) 3230 #if !__STDC__ && !defined(STDC_HEADERS)
3261 npath++; 3240 npath++;
3262 strcpy (pathname, npath); 3241 strcpy (pathname, npath);
3263 xfree (spath); /* getcwd uses malloc */ 3242 xfree (spath); /* getcwd uses malloc */
3264 return pathname; 3243 return pathname;
3265 } 3244 }
3266
3267 #endif /* HAVE_GETWD */ 3245 #endif /* HAVE_GETWD */
3268 3246
3269 /* 3247 /*
3270 * Emulate rename using unlink/link. Note that this is 3248 * Emulate rename using unlink/link. Note that this is
3271 * only partially correct. Also, doesn't enforce restriction 3249 * only partially correct. Also, doesn't enforce restriction
3272 * that files be of same type (regular->regular, dir->dir, etc). 3250 * that files be of same type (regular->regular, dir->dir, etc).
3273 */ 3251 */
3274 3252
3275 #ifndef HAVE_RENAME 3253 #ifndef HAVE_RENAME
3276
3277 int 3254 int
3278 rename (CONST char *from, CONST char *to) 3255 rename (CONST char *from, CONST char *to)
3279 { 3256 {
3280 if (access (from, 0) == 0) 3257 if (access (from, 0) == 0)
3281 { 3258 {
3284 if (unlink (from) == 0) 3261 if (unlink (from) == 0)
3285 return (0); 3262 return (0);
3286 } 3263 }
3287 return (-1); 3264 return (-1);
3288 } 3265 }
3289 3266 #endif /* HAVE_RENAME */
3290 #endif
3291 3267
3292 #ifdef HPUX 3268 #ifdef HPUX
3293 #ifndef HAVE_PERROR 3269 #ifndef HAVE_PERROR
3294 3270
3295 /* HPUX curses library references perror, but as far as we know 3271 /* HPUX curses library references perror, but as far as we know