Re: [Oorexx-devel] MAXIMUM_FILENAME_LENGTH and more
You are the expert on that! I just cloned the logic already implemented for maxpathlength Enrico PS. For my education I will try to implement both of them as methods of the .File class In my sandbox > On 7 Mar 2019, at 23:27, Rick McGuire wrote: > > Would really work better as a class method of the .File class rather than on > RexxInfo. That's where we tend to put file system related stuff. > > Rick ___ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel
Re: [Oorexx-devel] MAXIMUM_FILENAME_LENGTH and more
Would really work better as a class method of the .File class rather than on RexxInfo. That's where we tend to put file system related stuff. Rick On Thu, Mar 7, 2019 at 5:22 PM Enrico Sorichetti via Oorexx-devel < oorexx-devel@lists.sourceforge.net> wrote: > Here is the patch to > fix the MAXIMUM_FILENAME_LENGTH glitch > Implement .RexxInfo~getMaxFileNameLength > > [enrico@enrico-imac tests]$rexx -e "say .rexxinfo~maxfilenamelength" > 255 > [enrico@enrico-imac tests]$rexx -e "say .rexxinfo~maxpathlength" > 1024 > [enrico@enrico-imac tests]$ > > > Index: interpreter/classes/RexxInfoClass.cpp > === > --- interpreter/classes/RexxInfoClass.cpp (revision 11825) > +++ interpreter/classes/RexxInfoClass.cpp (working copy) > @@ -457,7 +457,18 @@ > return new_integer(Numerics::MIN_EXPONENT); > } > > +/** > + * Return the maximum FileName length allowed by the file system > + * > + * @return (Windows) MAX_PATH - 1 or (Unix) NAME_MAX, as an Integer > object. > + */ > +RexxObject *RexxInfo::getMaxFileNameLength() > +{ > +// usable length is one less, as one char is reserved for the > terminating NUL > +return new_integer(SysFileSystem::MaximumFileNameLength - 1); > +} > > + > /** > * Return the maximum path length allowed by the file system > * > Index: interpreter/classes/RexxInfoClass.hpp > === > --- interpreter/classes/RexxInfoClass.hpp (revision 11825) > +++ interpreter/classes/RexxInfoClass.hpp (working copy) > @@ -91,6 +91,7 @@ > RexxObject *getInternalMinNumber(); > RexxObject *getMaxExponent(); > RexxObject *getMinExponent(); > +RexxObject *getMaxFileNameLength(); > RexxObject *getMaxPathLength(); > RexxObject *getMaxArraySize(); > > Index: interpreter/execution/CPPCode.cpp > === > --- interpreter/execution/CPPCode.cpp (revision 11825) > +++ interpreter/execution/CPPCode.cpp (working copy) > @@ -1213,6 +1213,7 @@ > CPPM(RexxInfo::getInternalMinNumber), > CPPM(RexxInfo::getMaxExponent), > CPPM(RexxInfo::getMinExponent), > +CPPM(RexxInfo::getMaxFileNameLength), > CPPM(RexxInfo::getMaxPathLength), > CPPM(RexxInfo::getMaxArraySize), > > Index: interpreter/memory/Setup.cpp > === > --- interpreter/memory/Setup.cpp(revision 11825) > +++ interpreter/memory/Setup.cpp(working copy) > @@ -1240,6 +1240,7 @@ > AddMethod("internalMinNumber", RexxInfo::getInternalMinNumber, 0); > AddMethod("maxExponent", RexxInfo::getMaxExponent, 0); > AddMethod("minExponent", RexxInfo::getMinExponent, 0); > +AddMethod("maxFileNameLength", RexxInfo::getMaxFileNameLength, 0); > AddMethod("maxPathLength", RexxInfo::getMaxPathLength, 0); > AddMethod("maxArraySize", RexxInfo::getMaxArraySize, 0); > > Index: interpreter/platform/unix/SysFileSystem.hpp > === > --- interpreter/platform/unix/SysFileSystem.hpp (revision 11825) > +++ interpreter/platform/unix/SysFileSystem.hpp (working copy) > @@ -56,13 +56,11 @@ > #elif defined(_POSIX_PATH_MAX) > #define MAXIMUM_PATH_LENGTH _POSIX_PATH_MAX + 1 > #else > -#define MAXIMUM_PATH_LENGTH > +#define MAXIMUM_PATH_LENGTH 1025 > #endif > > -#if defined(FILENAME_MAX) > -#define MAXIMUM_FILENAME_LENGTH FILENAME_MAX + 1 > -#elif defined(_MAX_FNAME) > -#define MAXIMUM_FILENAME_LENGTH _MAX_FNAME + 1 > +#if defined(NAME_MAX) > +#define MAXIMUM_FILENAME_LENGTH NAME_MAX + 1 > #elif defined(_POSIX_NAME_MAX) > #define MAXIMUM_FILENAME_LENGTH _POSIX_NAME_MAX + 1 > #else > > ___ > Oorexx-devel mailing list > Oorexx-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/oorexx-devel > ___ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel
Re: [Oorexx-devel] MAXIMUM_FILENAME_LENGTH and more
Here is the patch to fix the MAXIMUM_FILENAME_LENGTH glitch Implement .RexxInfo~getMaxFileNameLength [enrico@enrico-imac tests]$rexx -e "say .rexxinfo~maxfilenamelength" 255 [enrico@enrico-imac tests]$rexx -e "say .rexxinfo~maxpathlength" 1024 [enrico@enrico-imac tests]$ Index: interpreter/classes/RexxInfoClass.cpp === --- interpreter/classes/RexxInfoClass.cpp (revision 11825) +++ interpreter/classes/RexxInfoClass.cpp (working copy) @@ -457,7 +457,18 @@ return new_integer(Numerics::MIN_EXPONENT); } +/** + * Return the maximum FileName length allowed by the file system + * + * @return (Windows) MAX_PATH - 1 or (Unix) NAME_MAX, as an Integer object. + */ +RexxObject *RexxInfo::getMaxFileNameLength() +{ +// usable length is one less, as one char is reserved for the terminating NUL +return new_integer(SysFileSystem::MaximumFileNameLength - 1); +} + /** * Return the maximum path length allowed by the file system * Index: interpreter/classes/RexxInfoClass.hpp === --- interpreter/classes/RexxInfoClass.hpp (revision 11825) +++ interpreter/classes/RexxInfoClass.hpp (working copy) @@ -91,6 +91,7 @@ RexxObject *getInternalMinNumber(); RexxObject *getMaxExponent(); RexxObject *getMinExponent(); +RexxObject *getMaxFileNameLength(); RexxObject *getMaxPathLength(); RexxObject *getMaxArraySize(); Index: interpreter/execution/CPPCode.cpp === --- interpreter/execution/CPPCode.cpp (revision 11825) +++ interpreter/execution/CPPCode.cpp (working copy) @@ -1213,6 +1213,7 @@ CPPM(RexxInfo::getInternalMinNumber), CPPM(RexxInfo::getMaxExponent), CPPM(RexxInfo::getMinExponent), +CPPM(RexxInfo::getMaxFileNameLength), CPPM(RexxInfo::getMaxPathLength), CPPM(RexxInfo::getMaxArraySize), Index: interpreter/memory/Setup.cpp === --- interpreter/memory/Setup.cpp(revision 11825) +++ interpreter/memory/Setup.cpp(working copy) @@ -1240,6 +1240,7 @@ AddMethod("internalMinNumber", RexxInfo::getInternalMinNumber, 0); AddMethod("maxExponent", RexxInfo::getMaxExponent, 0); AddMethod("minExponent", RexxInfo::getMinExponent, 0); +AddMethod("maxFileNameLength", RexxInfo::getMaxFileNameLength, 0); AddMethod("maxPathLength", RexxInfo::getMaxPathLength, 0); AddMethod("maxArraySize", RexxInfo::getMaxArraySize, 0); Index: interpreter/platform/unix/SysFileSystem.hpp === --- interpreter/platform/unix/SysFileSystem.hpp (revision 11825) +++ interpreter/platform/unix/SysFileSystem.hpp (working copy) @@ -56,13 +56,11 @@ #elif defined(_POSIX_PATH_MAX) #define MAXIMUM_PATH_LENGTH _POSIX_PATH_MAX + 1 #else -#define MAXIMUM_PATH_LENGTH +#define MAXIMUM_PATH_LENGTH 1025 #endif -#if defined(FILENAME_MAX) -#define MAXIMUM_FILENAME_LENGTH FILENAME_MAX + 1 -#elif defined(_MAX_FNAME) -#define MAXIMUM_FILENAME_LENGTH _MAX_FNAME + 1 +#if defined(NAME_MAX) +#define MAXIMUM_FILENAME_LENGTH NAME_MAX + 1 #elif defined(_POSIX_NAME_MAX) #define MAXIMUM_FILENAME_LENGTH _POSIX_NAME_MAX + 1 #else ___ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel
[Oorexx-devel] MAXIMUM_FILENAME_LENGTH and more
POINT ONE The logic to determine the MAXIMUM_FILENAME_LENGTH is broken the relevant code form the rexx sources #include #include #if defined(PATH_MAX) # define MAXIMUM_PATH_LENGTH PATH_MAX + 1 #elif defined(_POSIX_PATH_MAX) # define MAXIMUM_PATH_LENGTH _POSIX_PATH_MAX + 1 #else # define MAXIMUM_PATH_LENGTH #endif #if defined(FILENAME_MAX) # define MAXIMUM_FILENAME_LENGTH FILENAME_MAX + 1 #elif defined(_MAX_FNAME) # define MAXIMUM_FILENAME_LENGTH _MAX_FNAME + 1 #elif defined(_POSIX_NAME_MAX) # define MAXIMUM_FILENAME_LENGTH _POSIX_NAME_MAX + 1 #else # define MAXIMUM_FILENAME_LENGTH 256 #endif int main() { printf("MAXIMUM_PATH_LENGTH %d\n", MAXIMUM_PATH_LENGTH); printf("MAXIMUM_FILENAME_LENGTH %d\n", MAXIMUM_FILENAME_LENGTH); return (0); } Gives APPLE / FreeBSD / OpenBSD MAXIMUM_PATH_LENGTH 1025 MAXIMUM_FILENAME_LENGTH 1025 Fedora29/Debian9 MAXIMUM_PATH_LENGTH 4097 MAXIMUM_FILENAME_LENGTH 4097 The right coding #include #include #if defined(PATH_MAX) # define MAXIMUM_PATH_LENGTH PATH_MAX + 1 #elif defined(_POSIX_PATH_MAX) # define MAXIMUM_PATH_LENGTH _POSIX_PATH_MAX + 1 #else # define MAXIMUM_PATH_LENGTH 1025 #endif #if defined(NAME_MAX) # define MAXIMUM_FILENAME_LENGTH NAME_MAX + 1 #elif defined(_POSIX_NAME_MAX) # define MAXIMUM_FILENAME_LENGTH _POSIX_NAME_MAX + 1 #else # define MAXIMUM_FILENAME_LENGTH 256 #endif int main() { printf("MAXIMUM_PATH_LENGTH %d\n", MAXIMUM_PATH_LENGTH); printf("MAXIMUM_FILENAME_LENGTH %d\n", MAXIMUM_FILENAME_LENGTH); return (0); } Returns Darwin/FreeBSD/OpenBSD MAXIMUM_PATH_LENGTH 1025 MAXIMUM_FILENAME_LENGTH 256 Debian9/Fedora29 MAXIMUM_PATH_LENGTH 4097 MAXIMUM_FILENAME_LENGTH 256 Also the maximum path length should be defined to something Or the build should be aborted # define MAXIMUM_PATH_LENGTH 1025 Should be a reasonable value The current # define MAXIMUM_PATH_LENGTH Results in /Users/enrico/ooRexx.svn.src/interpreter/platform/unix/SysFileSystem.hpp:85:49: error: expected expression MaximumPathLength = MAXIMUM_PATH_LENGTH, POINT TWO The utilisation of MaximumPathLength MaximumFileNameLength MAXIMUM_PATH_LENGTH MAXIMUM_FILENAME_LENGTH .rexxinfo~maxpathlength Is consistently inconsistent , Sometime they are used as the length of the items Sometime they are used as the length of the buffer to be allocated POINT THREE It might be useful To have also a .rexxinfo~maxfilenamelength POINT FOUR. Test: TEST_REXXINFO_DATE Given the current coding is likely to fail randomly The dates are filled using the compiler builtin __DATE__ The two terms to be compared are build by different sources In an incremental build ( as per make/ninja logic ) the two sources might not be built at the same time resulting in the mismatch Just happened a few minutes ago POINT FIVE please run - on a unix like system d = copies("D",5000) call sysmkdir(d) f = copies("F",5000) call lineout f , "a truckload of equine nitrogen waste” o=.stream~new(f) o~open("replace" ) o~lineout( "a truckload of equine nitrogen waste" ) o~close This just very small oversight has been there at least since ooRexx-4.1.2 ( could not test one previous versions ) To give You a hint … Nothing is told, nothing happens The script runs happily without any error Regina rexx nicely complains DOES NOT DEPEND ON POINTS ONE/TWO E ___ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel