diff --git a/legacy/embryo/configure.ac b/legacy/embryo/configure.ac index c32a537bbf..b7d5d11b49 100644 --- a/legacy/embryo/configure.ac +++ b/legacy/embryo/configure.ac @@ -35,6 +35,7 @@ case "$host_os" in esac AC_SUBST(release_info) +EFL_CHECK_PATH_MAX ### Default options with respect to host diff --git a/legacy/embryo/m4/efl_path_max.m4 b/legacy/embryo/m4/efl_path_max.m4 new file mode 100644 index 0000000000..f57bfd2ab5 --- /dev/null +++ b/legacy/embryo/m4/efl_path_max.m4 @@ -0,0 +1,36 @@ +dnl Check for PATH_MAX in limits.h, and define a default value if not found +dnl This is a workaround for systems not providing PATH_MAX, like GNU/Hurd + +dnl EFL_CHECK_PATH_MAX([DEFAULT_VALUE_IF_NOT_FOUND]) +dnl +dnl If PATH_MAX is not defined in , defines it +dnl to DEFAULT_VALUE_IF_NOT_FOUND if it exists, or fallback +dnl to using 4096 + +AC_DEFUN([EFL_CHECK_PATH_MAX], +[ + +default_max=m4_default([$1], "4096") +AC_LANG_PUSH([C]) + +AC_MSG_CHECKING([for PATH_MAX in limits.h]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include + ]], + [[ +int i = PATH_MAX; + ]])], + [AC_MSG_RESULT([yes])], + [ + AC_DEFINE_UNQUOTED([PATH_MAX], + [${default_max}], + [default value since PATH_MAX is not defined]) + AC_MSG_RESULT([no: using ${default_max}]) + ]) + +AC_LANG_POP([C]) + +]) +dnl end of efl_path_max.m4 diff --git a/legacy/embryo/src/bin/Makefile.am b/legacy/embryo/src/bin/Makefile.am index 93143c6023..d918be5c4d 100644 --- a/legacy/embryo/src/bin/Makefile.am +++ b/legacy/embryo/src/bin/Makefile.am @@ -15,7 +15,6 @@ bin_PROGRAMS = embryo_cc embryo_cc_SOURCES = \ embryo_cc_amx.h \ -embryo_cc_osdefs.h \ embryo_cc_sc.h \ embryo_cc_sc1.c \ embryo_cc_sc2.c \ diff --git a/legacy/embryo/src/bin/embryo_cc_amx.h b/legacy/embryo/src/bin/embryo_cc_amx.h index dbf612fc8a..b7753919e7 100644 --- a/legacy/embryo/src/bin/embryo_cc_amx.h +++ b/legacy/embryo/src/bin/embryo_cc_amx.h @@ -21,8 +21,6 @@ * Version: $Id$ */ -#include "embryo_cc_osdefs.h" - #ifndef EMBRYO_CC_AMX_H #define EMBRYO_CC_AMX_H diff --git a/legacy/embryo/src/bin/embryo_cc_osdefs.h b/legacy/embryo/src/bin/embryo_cc_osdefs.h index 3e21814773..e69de29bb2 100644 --- a/legacy/embryo/src/bin/embryo_cc_osdefs.h +++ b/legacy/embryo/src/bin/embryo_cc_osdefs.h @@ -1,38 +0,0 @@ -/* - * Copyright 1998-2003, ITB CompuPhase, The Netherlands. - * info@compuphase.com. - */ - -#ifndef EMBRYO_CC_OSDEFS_H -# define EMBRYO_CC_OSDEFS_H - -# ifdef HAVE_STDINT_H -# include -# endif - -/* _MAX_PATH is sometimes called differently and it may be in limits.h instead - * stdio.h. - */ -# if !defined _MAX_PATH -/* not defined, perhaps stdio.h was not included */ -# include -# if !defined _MAX_PATH -/* still undefined, try a common alternative name */ -# if defined MAX_PATH -# define _MAX_PATH MAX_PATH -# else -/* no _MAX_PATH and no MAX_PATH, perhaps it is in limits.h */ -# include -# if defined PATH_MAX -# define _MAX_PATH PATH_MAX -# elif defined _POSIX_PATH_MAX -# define _MAX_PATH _POSIX_PATH_MAX -# else -/* everything failed, actually we have a problem here... */ -# define _MAX_PATH 4096 -# endif -# endif -# endif -# endif - -#endif diff --git a/legacy/embryo/src/bin/embryo_cc_sc.h b/legacy/embryo/src/bin/embryo_cc_sc.h index afa8df0f52..ea4c9a6caf 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc.h +++ b/legacy/embryo/src/bin/embryo_cc_sc.h @@ -36,7 +36,6 @@ #include #include -#include "embryo_cc_osdefs.h" #include "embryo_cc_amx.h" /* Note: the "cell" and "ucell" types are defined in AMX.H */ diff --git a/legacy/embryo/src/bin/embryo_cc_sc1.c b/legacy/embryo/src/bin/embryo_cc_sc1.c index ef6e4f0ccd..96760fb76c 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc1.c +++ b/legacy/embryo/src/bin/embryo_cc_sc1.c @@ -48,7 +48,6 @@ # include #endif /* HAVE_EVIL */ -#include "embryo_cc_osdefs.h" #include "embryo_cc_sc.h" #include "embryo_cc_prefix.h" @@ -121,31 +120,31 @@ static int rettype = 0; /* the type that a "return" expression should h static int skipinput = 0; /* number of lines to skip from the first input file */ static int wq[wqTABSZ]; /* "while queue", internal stack for nested loops */ static int *wqptr; /* pointer to next entry */ -static char binfname[_MAX_PATH]; /* binary file name */ +static char binfname[PATH_MAX]; /* binary file name */ int main(int argc, char *argv[], char *env[] __UNUSED__) { - char argv0[_MAX_PATH]; + char argv0[PATH_MAX]; int i; - snprintf(argv0, _MAX_PATH, "%s", argv[0]); + snprintf(argv0, sizeof(argv0), "%s", argv[0]); /* Linux stores the name of the program in argv[0], but not the path. * To adjust this, I store a string with the path in argv[0]. To do * so, I try to get the current path with getcwd(), and if that fails * I search for the PWD= setting in the environment. */ - if (NULL != getcwd(argv0, _MAX_PATH)) + if (NULL != getcwd(argv0, PATH_MAX)) { i = strlen(argv0); - snprintf(argv0 + i, _MAX_PATH - i, "/%s", argv[0]); + snprintf(argv0 + i, sizeof(argv0) - i, "/%s", argv[0]); } else { char *pwd = getenv("PWD"); if (pwd != NULL) - snprintf(argv0, _MAX_PATH, "%s/%s", pwd, argv[0]); + snprintf(argv0, sizeof(argv0), "%s/%s", pwd, argv[0]); } /* if */ argv[0] = argv0; /* set location to new first parameter */ @@ -291,8 +290,8 @@ sc_compile(int argc, char *argv[]) { int entry, i, jmpcode, fd_out; int retcode; - char incfname[_MAX_PATH]; - char reportname[_MAX_PATH]; + char incfname[PATH_MAX]; + char reportname[PATH_MAX]; FILE *binf; void *inpfmark; char lcl_ctrlchar; @@ -312,7 +311,7 @@ sc_compile(int argc, char *argv[]) goto cleanup; /* allocate memory for fixed tables */ - inpfname = (char *)malloc(_MAX_PATH); + inpfname = (char *)malloc(PATH_MAX); litq = (cell *) malloc(litmax * sizeof(cell)); if (litq == NULL) error(103); /* insufficient memory */ @@ -330,7 +329,7 @@ sc_compile(int argc, char *argv[]) tmpdir = (char *)evil_tmpdir_get(); #endif /* ! HAVE_EVIL */ - snprintf(outfname, _MAX_PATH, "%s/embryo_cc.asm-tmp-XXXXXX", tmpdir); + snprintf(outfname, PATH_MAX, "%s/embryo_cc.asm-tmp-XXXXXX", tmpdir); fd_out = mkstemp(outfname); if (fd_out < 0) error(101, outfname); @@ -681,7 +680,7 @@ setopt(int argc, char **argv, char *iname, char *oname, static void setconfig(char *root) { - char path[_MAX_PATH]; + char path[PATH_MAX]; char *ptr; int len; diff --git a/legacy/embryo/src/bin/embryo_cc_sc2.c b/legacy/embryo/src/bin/embryo_cc_sc2.c index be3bc5d544..de04fe0113 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc2.c +++ b/legacy/embryo/src/bin/embryo_cc_sc2.c @@ -38,7 +38,6 @@ #include #include #include -#include "embryo_cc_osdefs.h" #include "embryo_cc_sc.h" #include "Embryo.h" @@ -154,7 +153,7 @@ plungefile(char *name, int try_currentpath, int try_includepaths) { for (i = 0; !result && (ptr = get_path(i)) != NULL; i++) { - char path[_MAX_PATH]; + char path[PATH_MAX]; strncpy(path, ptr, sizeof path); path[sizeof path - 1] = '\0'; /* force '\0' termination */ @@ -190,7 +189,7 @@ check_empty(char *lptr) static void doinclude(void) { - char name[_MAX_PATH], c; + char name[PATH_MAX], c; int i, result; while (*lptr <= ' ' && *lptr != 0) /* skip leading whitespace */ @@ -933,7 +932,7 @@ command(void) case tpFILE: if (skiplevel == 0) { - char pathname[_MAX_PATH]; + char pathname[PATH_MAX]; lptr = getstring(pathname, sizeof pathname, lptr); if (pathname[0] != '\0') diff --git a/legacy/embryo/src/bin/embryo_cc_sc3.c b/legacy/embryo/src/bin/embryo_cc_sc3.c index ca1b4660ad..95027843b9 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc3.c +++ b/legacy/embryo/src/bin/embryo_cc_sc3.c @@ -31,7 +31,7 @@ #include #include -#include /* for _MAX_PATH */ +#include /* for PATH_MAX */ #include #include "embryo_cc_sc.h" diff --git a/legacy/embryo/src/bin/embryo_cc_sc4.c b/legacy/embryo/src/bin/embryo_cc_sc4.c index 600112f2f3..858f8d5d5e 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc4.c +++ b/legacy/embryo/src/bin/embryo_cc_sc4.c @@ -32,7 +32,7 @@ #include #include #include -#include /* for _MAX_PATH */ +#include /* for PATH_MAX */ #include #include "embryo_cc_sc.h" diff --git a/legacy/embryo/src/bin/embryo_cc_sc6.c b/legacy/embryo/src/bin/embryo_cc_sc6.c index 3c2fca2af0..7c16a9895f 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc6.c +++ b/legacy/embryo/src/bin/embryo_cc_sc6.c @@ -34,7 +34,6 @@ #include /* for macro max() */ #include #include -#include "embryo_cc_osdefs.h" #include "embryo_cc_sc.h" typedef cell(*OPCODE_PROC) (FILE * fbin, char *params, cell opcode); diff --git a/legacy/embryo/src/bin/embryo_cc_scvars.c b/legacy/embryo/src/bin/embryo_cc_scvars.c index 0fa802aee1..163bbc9776 100644 --- a/legacy/embryo/src/bin/embryo_cc_scvars.c +++ b/legacy/embryo/src/bin/embryo_cc_scvars.c @@ -27,7 +27,7 @@ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ -#include /* for _MAX_PATH */ +#include /* for PATH_MAX */ #include "embryo_cc_sc.h" /* global variables @@ -45,7 +45,7 @@ constvalue libname_tab = { NULL, "", 0, 0 }; /* library table (#pragma library " constvalue *curlibrary = NULL; /* current library */ symbol *curfunc; /* pointer to current function */ char *inpfname; /* pointer to name of the file currently read from */ -char outfname[_MAX_PATH]; /* output file name */ +char outfname[PATH_MAX]; /* output file name */ char sc_ctrlchar = CTRL_CHAR; /* the control character (or escape character) */ int litidx = 0; /* index to literal table */ int litmax = sDEF_LITMAX; /* current size of the literal table */ diff --git a/legacy/embryo/win32/vs9/embryo_cc.vcproj b/legacy/embryo/win32/vs9/embryo_cc.vcproj index 6aa5ea60dc..47dd2544f6 100644 --- a/legacy/embryo/win32/vs9/embryo_cc.vcproj +++ b/legacy/embryo/win32/vs9/embryo_cc.vcproj @@ -234,10 +234,6 @@ RelativePath="..\..\src\bin\embryo_cc_amx.h" > - -