blob: 46f4bba0122ba24c1c08ac4a5c1484917f35f4ab [file] [log] [blame]
Bram Moolenaaredf3f972016-08-29 22:49:24 +02001/* vi:set ts=8 sts=4 sw=4 noet:
Bram Moolenaar071d4272004-06-13 20:20:40 +00002 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 */
8
9/*
10 * NextStep has a problem with configure, undefine a few things:
11 */
12#ifdef NeXT
13# ifdef HAVE_UTIME
14# undef HAVE_UTIME
15# endif
16# ifdef HAVE_SYS_UTSNAME_H
17# undef HAVE_SYS_UTSNAME_H
18# endif
19#endif
20
21#include <stdio.h>
22#include <ctype.h>
23
24#ifdef VAXC
25# include <types.h>
26# include <stat.h>
27#else
28# include <sys/types.h>
29# include <sys/stat.h>
30#endif
31
32#ifdef HAVE_STDLIB_H
33# include <stdlib.h>
34#endif
35
Bram Moolenaar6ef8f9e2019-03-02 07:15:28 +010036#ifdef __CYGWIN__
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010037# define WIN32UNIX // Compiling for Win32 using Unix files.
Bram Moolenaar071d4272004-06-13 20:20:40 +000038# define BINARY_FILE_IO
Bram Moolenaar24552be2005-12-10 20:17:30 +000039
40# define CASE_INSENSITIVE_FILENAME
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010041# define USE_FNAME_CASE // Fix filename case differences.
Bram Moolenaar071d4272004-06-13 20:20:40 +000042#endif
43
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010044// On AIX 4.2 there is a conflicting prototype for ioctl() in stropts.h and
45// unistd.h. This hack should fix that (suggested by Jeff George).
46// But on AIX 4.3 it's alright (suggested by Jake Hamby).
Bram Moolenaar071d4272004-06-13 20:20:40 +000047#if defined(FEAT_GUI) && defined(_AIX) && !defined(_AIX43) && !defined(_NO_PROTO)
48# define _NO_PROTO
49#endif
50
51#ifdef HAVE_UNISTD_H
Bram Moolenaar8f0b2d42009-05-16 14:41:10 +000052# include <unistd.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +000053#endif
54
55#ifdef HAVE_LIBC_H
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010056# include <libc.h> // for NeXT
Bram Moolenaar071d4272004-06-13 20:20:40 +000057#endif
58
59#ifdef HAVE_SYS_PARAM_H
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010060# include <sys/param.h> // defines BSD, if it's a BSD system
Bram Moolenaar071d4272004-06-13 20:20:40 +000061#endif
62
63/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000064 * Using getcwd() is preferred, because it checks for a buffer overflow.
65 * Don't use getcwd() on systems do use system("sh -c pwd"). There is an
66 * autoconf check for this.
67 * Use getcwd() anyway if getwd() isn't present.
68 */
69#if defined(HAVE_GETCWD) && !(defined(BAD_GETCWD) && defined(HAVE_GETWD))
70# define USE_GETCWD
71#endif
72
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010073// always use unlink() to remove files
Bram Moolenaar071d4272004-06-13 20:20:40 +000074#ifndef PROTO
75# ifdef VMS
76# define mch_remove(x) delete((char *)(x))
77# define vim_mkdir(x, y) mkdir((char *)(x), y)
Bram Moolenaar071d4272004-06-13 20:20:40 +000078# else
79# define vim_mkdir(x, y) mkdir((char *)(x), y)
80# define mch_rmdir(x) rmdir((char *)(x))
81# define mch_remove(x) unlink((char *)(x))
82# endif
83#endif
84
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010085// The number of arguments to a signal handler is configured here.
86// It used to be a long list of almost all systems. Any system that doesn't
87// have an argument???
Bram Moolenaar071d4272004-06-13 20:20:40 +000088#define SIGHASARG
89
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010090// List 3 arg systems here. I guess __sgi, please test and correct me. jw.
Bram Moolenaar071d4272004-06-13 20:20:40 +000091#if defined(__sgi) && defined(HAVE_SIGCONTEXT)
92# define SIGHAS3ARGS
93#endif
94
95#ifdef SIGHASARG
96# ifdef SIGHAS3ARGS
97# define SIGPROTOARG (int, int, struct sigcontext *)
98# define SIGDEFARG(s) (s, sig2, scont) int s, sig2; struct sigcontext *scont;
99# define SIGDUMMYARG 0, 0, (struct sigcontext *)0
100# else
101# define SIGPROTOARG (int)
Bram Moolenaar78a15312009-05-15 19:33:18 +0000102# define SIGDEFARG(s) (s) int s UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000103# define SIGDUMMYARG 0
104# endif
105#else
106# define SIGPROTOARG (void)
107# define SIGDEFARG(s) ()
108# define SIGDUMMYARG
109#endif
110
111#ifdef HAVE_DIRENT_H
112# include <dirent.h>
113# ifndef NAMLEN
114# define NAMLEN(dirent) strlen((dirent)->d_name)
115# endif
116#else
117# define dirent direct
118# define NAMLEN(dirent) (dirent)->d_namlen
119# if HAVE_SYS_NDIR_H
120# include <sys/ndir.h>
121# endif
122# if HAVE_SYS_DIR_H
123# include <sys/dir.h>
124# endif
125# if HAVE_NDIR_H
126# include <ndir.h>
127# endif
128#endif
129
Bram Moolenaar10455d42019-11-21 15:36:18 +0100130// on some systems time.h should not be included together with sys/time.h
Bram Moolenaar071d4272004-06-13 20:20:40 +0000131#if !defined(HAVE_SYS_TIME_H) || defined(TIME_WITH_SYS_TIME)
Bram Moolenaar10455d42019-11-21 15:36:18 +0100132# include <time.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133#endif
134#ifdef HAVE_SYS_TIME_H
135# include <sys/time.h>
136#endif
137
138#include <signal.h>
139
140#if defined(DIRSIZ) && !defined(MAXNAMLEN)
141# define MAXNAMLEN DIRSIZ
142#endif
143
144#if defined(UFS_MAXNAMLEN) && !defined(MAXNAMLEN)
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100145# define MAXNAMLEN UFS_MAXNAMLEN // for dynix/ptx
Bram Moolenaar071d4272004-06-13 20:20:40 +0000146#endif
147
148#if defined(NAME_MAX) && !defined(MAXNAMLEN)
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100149# define MAXNAMLEN NAME_MAX // for Linux before .99p3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000150#endif
151
152/*
153 * Note: if MAXNAMLEN has the wrong value, you will get error messages
154 * for not being able to open the swap file.
155 */
156#if !defined(MAXNAMLEN)
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100157# define MAXNAMLEN 512 // for all other Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000158#endif
159
160#define BASENAMELEN (MAXNAMLEN - 5)
161
Bram Moolenaar071d4272004-06-13 20:20:40 +0000162#ifdef HAVE_PWD_H
163# include <pwd.h>
164#endif
165
Bram Moolenaar071d4272004-06-13 20:20:40 +0000166#if (defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT)) \
167 || (defined(HAVE_SYS_SYSINFO_H) && defined(HAVE_SYSINFO)) \
168 || defined(HAVE_SYSCTL) || defined(HAVE_SYSCONF)
169# define HAVE_TOTAL_MEM
170#endif
171
Bram Moolenaar82881492012-11-20 16:53:39 +0100172
173#ifndef PROTO
174
Bram Moolenaar071d4272004-06-13 20:20:40 +0000175#ifdef VMS
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000176# include <unixio.h>
177# include <unixlib.h>
178# include <signal.h>
179# include <file.h>
180# include <ssdef.h>
181# include <descrip.h>
182# include <libclidef.h>
183# include <lnmdef.h>
184# include <psldef.h>
185# include <prvdef.h>
186# include <dvidef.h>
187# include <dcdef.h>
188# include <stsdef.h>
189# include <iodef.h>
190# include <ttdef.h>
191# include <tt2def.h>
192# include <jpidef.h>
193# include <rms.h>
194# include <trmdef.h>
195# include <string.h>
196# include <starlet.h>
197# include <socket.h>
198# include <lib$routines.h>
Bram Moolenaar4ffa0702013-12-11 17:12:37 +0100199# include <libdef.h>
200# include <libdtdef.h>
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000201
Bram Moolenaar467676d2020-12-30 13:14:45 +0100202# if defined(FEAT_GUI_MOTIF)
203# define XFree XFREE
204# define XmRepTypeInstallTearOffModelCon XMREPTYPEINSTALLTEAROFFMODELCON
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000205# endif
Bram Moolenaar467676d2020-12-30 13:14:45 +0100206#endif // VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207
Bram Moolenaarb2d0e512020-05-07 18:37:03 +0200208#ifdef HAVE_FLOCK
209# include <sys/file.h>
210#endif
211
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100212#endif // PROTO
Bram Moolenaar82881492012-11-20 16:53:39 +0100213
214#ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +0000215typedef struct dsc$descriptor DESC;
216#endif
217
218/*
219 * Unix system-dependent file names
220 */
221#ifndef SYS_VIMRC_FILE
222# define SYS_VIMRC_FILE "$VIM/vimrc"
223#endif
224#ifndef SYS_GVIMRC_FILE
225# define SYS_GVIMRC_FILE "$VIM/gvimrc"
226#endif
227#ifndef DFLT_HELPFILE
228# define DFLT_HELPFILE "$VIMRUNTIME/doc/help.txt"
229#endif
230#ifndef FILETYPE_FILE
231# define FILETYPE_FILE "filetype.vim"
232#endif
233#ifndef FTPLUGIN_FILE
234# define FTPLUGIN_FILE "ftplugin.vim"
235#endif
236#ifndef INDENT_FILE
237# define INDENT_FILE "indent.vim"
238#endif
239#ifndef FTOFF_FILE
240# define FTOFF_FILE "ftoff.vim"
241#endif
242#ifndef FTPLUGOF_FILE
243# define FTPLUGOF_FILE "ftplugof.vim"
244#endif
245#ifndef INDOFF_FILE
246# define INDOFF_FILE "indoff.vim"
247#endif
248#ifndef SYS_MENU_FILE
249# define SYS_MENU_FILE "$VIMRUNTIME/menu.vim"
250#endif
251
252#ifndef USR_EXRC_FILE
253# ifdef VMS
254# define USR_EXRC_FILE "sys$login:.exrc"
255# else
256# define USR_EXRC_FILE "$HOME/.exrc"
257# endif
258#endif
259
Bram Moolenaar071d4272004-06-13 20:20:40 +0000260#if !defined(USR_EXRC_FILE2) && defined(VMS)
261# define USR_EXRC_FILE2 "sys$login:_exrc"
262#endif
263
264#ifndef USR_VIMRC_FILE
265# ifdef VMS
266# define USR_VIMRC_FILE "sys$login:.vimrc"
267# else
268# define USR_VIMRC_FILE "$HOME/.vimrc"
269# endif
270#endif
271
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200272
Bram Moolenaarea98f8b2015-05-04 09:31:11 +0200273#if !defined(USR_VIMRC_FILE2)
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100274# ifdef VMS
275# define USR_VIMRC_FILE2 "sys$login:vimfiles/vimrc"
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200276# else
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100277# define USR_VIMRC_FILE2 "~/.vim/vimrc"
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200278# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000279#endif
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200280
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200281#if !defined(USR_VIMRC_FILE3) && defined(VMS)
282# define USR_VIMRC_FILE3 "sys$login:_vimrc"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000283#endif
284
285#ifndef USR_GVIMRC_FILE
286# ifdef VMS
287# define USR_GVIMRC_FILE "sys$login:.gvimrc"
288# else
289# define USR_GVIMRC_FILE "$HOME/.gvimrc"
290# endif
291#endif
292
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200293#ifndef USR_GVIMRC_FILE2
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100294# ifdef VMS
295# define USR_GVIMRC_FILE2 "sys$login:vimfiles/gvimrc"
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200296# else
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100297# define USR_GVIMRC_FILE2 "~/.vim/gvimrc"
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200298# endif
299#endif
300
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301#ifdef VMS
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200302# ifndef USR_GVIMRC_FILE3
303# define USR_GVIMRC_FILE3 "sys$login:_gvimrc"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000304# endif
305#endif
306
Bram Moolenaar8c08b5b2016-07-28 22:24:15 +0200307#ifndef VIM_DEFAULTS_FILE
308# define VIM_DEFAULTS_FILE "$VIMRUNTIME/defaults.vim"
309#endif
310
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311#ifndef EVIM_FILE
312# define EVIM_FILE "$VIMRUNTIME/evim.vim"
313#endif
314
315#ifdef FEAT_VIMINFO
316# ifndef VIMINFO_FILE
317# ifdef VMS
318# define VIMINFO_FILE "sys$login:.viminfo"
319# else
320# define VIMINFO_FILE "$HOME/.viminfo"
321# endif
322# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000323# if !defined(VIMINFO_FILE2) && defined(VMS)
324# define VIMINFO_FILE2 "sys$login:_viminfo"
325# endif
326#endif
327
328#ifndef EXRC_FILE
329# define EXRC_FILE ".exrc"
330#endif
331
332#ifndef VIMRC_FILE
333# define VIMRC_FILE ".vimrc"
334#endif
335
336#ifdef FEAT_GUI
337# ifndef GVIMRC_FILE
338# define GVIMRC_FILE ".gvimrc"
339# endif
340#endif
341
342#ifndef SYNTAX_FNAME
343# define SYNTAX_FNAME "$VIMRUNTIME/syntax/%s.vim"
344#endif
345
346#ifndef DFLT_BDIR
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100347# ifdef VMS
348# define DFLT_BDIR "./,sys$login:,tmp:"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349# else
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100350# define DFLT_BDIR ".,~/tmp,~/" // default for 'backupdir'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000351# endif
352#endif
353
354#ifndef DFLT_DIR
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100355# ifdef VMS
356# define DFLT_DIR "./,sys$login:,tmp:"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000357# else
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100358# define DFLT_DIR ".,~/tmp,/var/tmp,/tmp" // default for 'directory'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000359# endif
360#endif
361
362#ifndef DFLT_VDIR
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100363# ifdef VMS
364# define DFLT_VDIR "sys$login:vimfiles/view"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000365# else
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100366# define DFLT_VDIR "$HOME/.vim/view" // default for 'viewdir'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000367# endif
368#endif
369
370#define DFLT_ERRORFILE "errors.err"
371
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100372#ifndef DFLT_RUNTIMEPATH
373
374# ifdef VMS
375# define DFLT_RUNTIMEPATH "sys$login:vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,sys$login:vimfiles/after"
376# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000377# else
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100378# ifdef RUNTIME_GLOBAL
379# ifdef RUNTIME_GLOBAL_AFTER
380# define DFLT_RUNTIMEPATH "~/.vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER ",~/.vim/after"
381# define CLEAN_RUNTIMEPATH RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER
382# else
383# define DFLT_RUNTIMEPATH "~/.vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after,~/.vim/after"
384# define CLEAN_RUNTIMEPATH RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after"
385# endif
386# else
387# define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after"
388# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
389# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000390# endif
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100391
Bram Moolenaar071d4272004-06-13 20:20:40 +0000392#endif
393
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100394#ifdef VMS
395# ifndef VAX
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100396# define VMS_TEMPNAM // to fix default .LIS extension
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100398# define TEMPNAME "TMP:v?XXXXXX.txt"
399# define TEMPNAMELEN 28
400#else
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100401// Try several directories to put the temp files.
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100402# define TEMPDIRNAMES "$TMPDIR", "/tmp", ".", "$HOME"
403# define TEMPNAMELEN 256
Bram Moolenaar071d4272004-06-13 20:20:40 +0000404#endif
405
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100406// Special wildcards that need to be handled by the shell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000407#define SPECIAL_WILDCHAR "`'{"
408
Bram Moolenaar071d4272004-06-13 20:20:40 +0000409/*
410 * Unix has plenty of memory, use large buffers
411 */
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100412#define CMDBUFFSIZE 1024 // size of the command processing buffer
Bram Moolenaar38f12a92008-06-20 16:07:02 +0000413
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100414// Use the system path length if it makes sense.
Bram Moolenaar38f12a92008-06-20 16:07:02 +0000415#if defined(PATH_MAX) && (PATH_MAX > 1000)
416# define MAXPATHL PATH_MAX
417#else
418# define MAXPATHL 1024
419#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000420
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100421#define CHECK_INODE // used when checking if a swap file already
422 // exists for a file
423#ifdef VMS // Use less memory because of older systems
Bram Moolenaar071d4272004-06-13 20:20:40 +0000424# ifndef DFLT_MAXMEM
425# define DFLT_MAXMEM (2*1024)
426# endif
427# ifndef DFLT_MAXMEMTOT
428# define DFLT_MAXMEMTOT (5*1024)
429# endif
430#else
431# ifndef DFLT_MAXMEM
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100432# define DFLT_MAXMEM (5*1024) // use up to 5 Mbyte for a buffer
Bram Moolenaar071d4272004-06-13 20:20:40 +0000433# endif
434# ifndef DFLT_MAXMEMTOT
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100435# define DFLT_MAXMEMTOT (10*1024) // use up to 10 Mbyte for Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000436# endif
437#endif
438
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100439// memmove() is not present on all systems, use memmove, bcopy or memcpy.
440// Some systems have (void *) arguments, some (char *). If we use (char *) it
441// works for all
Bram Moolenaar52c0de12017-01-26 21:36:34 +0100442#if defined(USEMEMMOVE) || (!defined(USEBCOPY) && !defined(USEMEMCPY))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000443# define mch_memmove(to, from, len) memmove((char *)(to), (char *)(from), len)
444#else
445# ifdef USEBCOPY
446# define mch_memmove(to, from, len) bcopy((char *)(from), (char *)(to), len)
447# else
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100448 // ifdef USEMEMCPY
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449# define mch_memmove(to, from, len) memcpy((char *)(to), (char *)(from), len)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450# endif
451#endif
452
453#ifndef PROTO
454# ifdef HAVE_RENAME
455# define mch_rename(src, dst) rename(src, dst)
456# else
Bram Moolenaard99df422016-01-29 23:20:40 +0100457int mch_rename(const char *src, const char *dest);
Bram Moolenaar071d4272004-06-13 20:20:40 +0000458# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459# ifndef VMS
460# ifdef __MVS__
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100461 // on OS390 Unix getenv() doesn't return a pointer to persistent
462 // storage -> use __getenv()
Bram Moolenaar071d4272004-06-13 20:20:40 +0000463# define mch_getenv(x) (char_u *)__getenv((char *)(x))
464# else
465# define mch_getenv(x) (char_u *)getenv((char *)(x))
466# endif
467# define mch_setenv(name, val, x) setenv(name, val, x)
468# endif
469#endif
470
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100471// Note: Some systems need both string.h and strings.h (Savage). However,
472// some systems can't handle both, only use string.h in that case.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000473#ifdef HAVE_STRING_H
474# include <string.h>
475#endif
476#if defined(HAVE_STRINGS_H) && !defined(NO_STRINGS_WITH_STRING_H)
477# include <strings.h>
478#endif
479
480#if defined(HAVE_SETJMP_H)
481# include <setjmp.h>
482# ifdef HAVE_SIGSETJMP
483# define JMP_BUF sigjmp_buf
484# define SETJMP(x) sigsetjmp((x), 1)
485# define LONGJMP siglongjmp
486# else
487# define JMP_BUF jmp_buf
488# define SETJMP(x) setjmp(x)
489# define LONGJMP longjmp
490# endif
491#endif
492
Bram Moolenaarc41053062014-03-25 13:46:26 +0100493#ifndef HAVE_DUP
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100494# define HAVE_DUP // have dup()
Bram Moolenaarc41053062014-03-25 13:46:26 +0100495#endif
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100496#define HAVE_ST_MODE // have stat.st_mode
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100498// We have three kinds of ACL support.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000499#define HAVE_ACL (HAVE_POSIX_ACL || HAVE_SOLARIS_ACL || HAVE_AIX_ACL)