From 1d6e2ef1877cb9abb76bf42925e180a743bacb67 Mon Sep 17 00:00:00 2001 From: runkharr Date: Thu, 12 Apr 2018 21:34:02 +0200 Subject: [PATCH] - src/compiler/OPT.Mod: Introduced two new constants in the pseudo-module SYSTEM: MAXPATHLEN and 'MAXFILENAMELEN. Both represent the maximum lengths of pathnames and (single) filenames of the underlying operating system for which the compiler will actually be generated. This is done by importing the system dependent constants from the automatically created module 'Configuration.Mod' which is hereby *imported* into 'OPT.Mod' ... - src/tools/make/configure.c: Added '#include ' (introducing PATH_MAX and NAME_MAX into this program. Extended the code for the module 'Configuration.Mod' by two constant definitions: 'MaxPathLen' (holding the value if PATH_MAX) and 'MaxFnLen' (=> NAME_MAX). This allows for an automatical configuration of MAXPATHLEN and MAXFILENAMELEN in 'src/compiler/OPT.Mod' ... --- src/compiler/OPT.Mod | 12 +++++++++++- src/tools/make/configure.c | 7 +++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/compiler/OPT.Mod b/src/compiler/OPT.Mod index 2641703e..737e5040 100644 --- a/src/compiler/OPT.Mod +++ b/src/compiler/OPT.Mod @@ -4,7 +4,7 @@ MODULE OPT; (* NW, RC 6.3.89 / 23.1.92 *) (* object model 24.2.94 *) 2002-08-20 jt: NewStr: txtpos remains 0 for structs read from symbol file *) -IMPORT OPS, OPM, SYSTEM; +IMPORT OPS, OPM, SYSTEM, Configuration; (* Constants - value of literals *) @@ -1310,6 +1310,13 @@ END Import; obj^.mode := Con; obj^.typ := booltyp; obj^.conval^.intval := value END EnterBoolConst; + PROCEDURE EnterIntConst(name: OPS.Name; value: LONGINT); + VAR obj: Object; + BEGIN + Insert(name, obj); obj^.conval := NewConst(); + obj^.mode := Con; obj^.typ := int32typ; obj^.conval^.intval := value; + END EntarIntConst; + PROCEDURE EnterTyp(name: OPS.Name; form: SHORTINT; size: INTEGER; VAR res: Struct); VAR obj: Object; typ: Struct; BEGIN @@ -1367,6 +1374,9 @@ BEGIN topScope := NIL; OpenScope(0, NIL); OPM.errpos := 0; EnterProc("NEW", sysnewfn); EnterProc("MOVE", movefn); + (* POSIX systems normally support PATH_MAX *) + EnterIntConst("MAXPATHLEN", Configuration.MaxPathLen); + EnterIntConst("MAXFILENAMELENGTH", Configuration.MaxFnLen); syslink := topScope^.right; universe := topScope; topScope^.right := NIL; diff --git a/src/tools/make/configure.c b/src/tools/make/configure.c index f82a5d37..df6c6204 100644 --- a/src/tools/make/configure.c +++ b/src/tools/make/configure.c @@ -30,6 +30,7 @@ #include #include #include +#include // for enabling PATH_MAX ... void fail(char *msg) {fprintf(stderr, "Error: %s\n", msg); exit(1);} @@ -42,8 +43,8 @@ char builddate[256]; char installdir[256]; char versionstring[256]; char osrelease[1024]; -char cwd[1024]; -char libspec[1024]; +char cwd[PATH_MAX]; +char libspec[PATH_MAX*8]; #define macrotostringhelper(s) #s #define macrotostring(s) macrotostringhelper(s) @@ -401,6 +402,8 @@ void writeConfigurationMod() { fprintf(fd, " compile* = '%s';\n", cc); fprintf(fd, " installdir* = '%s';\n", installdir); fprintf(fd, " staticLink* = '%s';\n", staticlink); + fprintf(fd, " MaxPathLen* = %d;\n", PATH_MAX); + fprintf(fd " MaxFnLen* = %d;\n", NAME_MAX); fprintf(fd, "VAR\n"); fprintf(fd, " versionLong-: ARRAY %d OF CHAR;\n", (int)strnlen(versionstring, 100)+1); fprintf(fd, "BEGIN\n");