Guard the UnixTime globals, so JsonWebToken and Security can be used together - #14
Open
mckuipers wants to merge 2 commits into
Conversation
JWT/UnixTime.pkg guards its other five definitions - gVoid, tFileTime,
tSystemTime, and the two External_Functions - but `Function CurrentUnixTime
Global` had no #IFNDEF around it.
DataFlex-dev/Security ships a byte-identical copy of this file as
include/UnixTime.pkg, also unguarded. DataFlex resolves a Use by path, so to
the compiler these are two unrelated files and the global is defined twice:
Error 4390: Illegal method name definition
Global method GET CURRENTUNIXTIME already defined
That combination is not exotic: it is what the OAuth Server Lib needs. OAuth
Server Lib requires this package, and any OIDC provider offering TOTP as a
second factor also wants cSecureOneTimePassword from Security. The first
build putting both in one program fails, pointing at a
package-manager-installed file that cannot be edited - so it reads like a
broken dependency rather than a name collision.
Get_CurrentUnixTime is the symbol a `Function ... Global` defines; the
precedent is DataFlex's own cWorkspace.pkg, which guards `Function
LastDelimeter Global` with `#IFDEF Get_LastDelimeter`. Verified by compiling
this file into a program that already defines CurrentUnixTime: 4390 before,
clean after.
Guarding either copy fixes the collision. Both are being offered one, so
neither library depends on Use order.
Not needed for the Security collision in the previous commit - Security's
copy of this file does not define UnixTimeToDateTime, so that name does not
clash between the two libraries today. This is for consistency with the six
guards now around it, and it makes the file idempotent: including it a second
time by a different path becomes a no-op rather than Error 4390.
Demonstrated by compiling this file into a program that already has the whole
package. With only CurrentUnixTime guarded:
Error 4390: Illegal method name definition
Global method GET UNIXTIMETODATETIME already defined
With both guarded, it compiles clean.
DateTimetoUnixTime below needs no guard and does not get one: it is declared
without the Global keyword, and the same double-inclusion test shows it does
not collide.
Separable from the previous commit - drop this one if you would rather keep
the change to the single name that actually clashes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JWT/UnixTime.pkgguards five of its definitions —gVoid,tFileTime,tSystemTime, andboth
External_Functions — but not its two global functions. This adds the missing guards.Two commits, separable: the first fixes a real collision, the second is consistency.
Commit 1 —
CurrentUnixTime, which actually clashesDataFlex-dev/Securityships a byte-identical copy of this file asinclude/UnixTime.pkg,also unguarded. DataFlex resolves a
Useby path, so to the compiler these are two unrelatedfiles, and any program containing both gets the global twice:
That combination is not exotic — it is what the OAuth Server Lib needs. OAuth Server Lib
requires this package, and any OIDC provider offering TOTP as a second factor also wants
cSecureOneTimePasswordfrom Security. The first build that puts both in one program fails,and the error points into a package-manager-installed folder that cannot be edited, so it reads
like a broken dependency rather than a name collision.
Reproduce by building any program that uses
cSecureOneTimePasswordandJWT.pkgtogether.The matching PR is open on
DataFlex-dev/Security. Guarding either copy fixes the collision;both are being offered one so neither library depends on
Useorder.Commit 2 —
UnixTimeToDateTime, for consistencyNot needed for the collision above: Security's copy does not define
UnixTimeToDateTime, sothat name does not clash between the two libraries today. It makes the file idempotent —
including it a second time by a different path becomes a no-op rather than an error — which is
what the six guards around it already achieve for everything else.
Drop this commit if you would rather change only the name that actually clashes.
DateTimetoUnixTimedeliberately gets no guardIt is declared without the
Globalkeyword, and the test below shows it does not collide.Why
Get_<Name>is the right symbolA
Function <Name> GlobaldefinesGet_<Name>. The precedent is DataFlex's owncWorkspace.pkg, which guardsFunction LastDelimeter Globalwith#IFDEF Get_LastDelimeter.I used this file's existing
#IFNDEF … #ENDIFstyle rather thancWorkspace.pkg's#IFDEF … #ELSE … #ENDIF, to match the guards already here.Verification
Compiled this file into a program that already contains the whole package, so every global in
it is defined twice by two different paths:
4390at(40,1)GET CURRENTUNIXTIME4390at(59,1)GET UNIXTIMETODATETIMEDateTimetoUnixTimewas double-included in all three runs and never raised4390, which isthe basis for leaving it alone. The compiler reports all 4390s in a run rather than stopping at
the first, so its absence is evidence and not an artefact of ordering.
The same build asserts the symbol name is right rather than assuming it:
placed after a known definition. Neither
#ERRORfires — the second exists so the first cannotpass vacuously.