Skip to content

Commit 75475a1

Browse files
committed
feat: add runtime deprecation warnings
FORM prints deprecation warnings at startup for native Windows, 32-bit (ILP32) and ParFORM (MPI) versions, as well as for the use of the checkpoint mechanism. This encourages users who need support for these deprecated features to leave a comment on the corresponding GitHub issues. The warnings can be suppressed by using the -ignore-deprecation command-line option or by setting the environment variable FORM_IGNORE_DEPRECATION=1.
1 parent ce6be59 commit 75475a1

File tree

7 files changed

+68
-4
lines changed

7 files changed

+68
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
pull_request:
66
workflow_dispatch:
77

8+
env:
9+
FORM_IGNORE_DEPRECATION: 1
10+
811
jobs:
912
# Generate the tarball distribution, e.g., "form-v4.2.1.tar.gz" for v4.2.1.
1013
# The tarball will be tested in the following "build-bin" job.

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
pull_request:
66
workflow_dispatch:
77

8+
env:
9+
FORM_IGNORE_DEPRECATION: 1
10+
811
jobs:
912
# Simple tests on Linux; except the ParFORM case, they probably pass unless
1013
# the committer has forgotten running "make check".

sources/checkpoint.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ static void print_M()
840840
MesPrint("%d", AM.ggShortStatsMax);
841841
MesPrint("--MARK 11");
842842
MesPrint("%d", AM.FromStdin);
843+
MesPrint("%d", AM.IgnoreDeprecation);
843844
MesPrint("%%%% END M_const");
844845
/* fflush(0); */
845846
}
@@ -1503,6 +1504,7 @@ int DoRecovery(int *moduletype)
15031504
R_COPY_S(AM.Path,UBYTE *);
15041505

15051506
R_SET(AM.FromStdin, BOOL);
1507+
R_SET(AM.IgnoreDeprecation, BOOL);
15061508

15071509
#ifdef PRINTDEBUG
15081510
print_M();
@@ -2574,6 +2576,7 @@ static int DoSnapshot(int moduletype)
25742576
S_WRITE_S(AM.Path);
25752577

25762578
S_WRITE_B(&AM.FromStdin,sizeof(BOOL));
2579+
S_WRITE_B(&AM.IgnoreDeprecation,sizeof(BOOL));
25772580

25782581
/*#] AM :*/
25792582
/*#[ AC :*/

sources/compcomm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ int CoOff(UBYTE *s)
328328
AR.gzipCompress = 0;
329329
}
330330
else if ( StrICont(t,(UBYTE *)"checkpoint") == 0 ) {
331+
PrintDeprecation("the checkpoint mechanism", "issues/626");
331332
AC.CheckpointInterval = 0;
332333
if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
333334
if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }
@@ -418,6 +419,7 @@ int CoOn(UBYTE *s)
418419
}
419420
}
420421
else if ( StrICont(t,(UBYTE *)"checkpoint") == 0 ) {
422+
PrintDeprecation("the checkpoint mechanism", "issues/626");
421423
AC.CheckpointInterval = 0;
422424
if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
423425
if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }

sources/declare.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ extern WORD Processor(VOID);
642642
extern WORD Product(UWORD *,WORD *,WORD);
643643
extern VOID PrtLong(UWORD *,WORD,UBYTE *);
644644
extern VOID PrtTerms(VOID);
645+
extern void PrintDeprecation(const char *,const char *);
645646
extern VOID PrintRunningTime(VOID);
646647
extern LONG GetRunningTime(VOID);
647648
extern WORD PutBracket(PHEAD WORD *);

sources/startup.c

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ static void PrintHeader(int with_full_info)
193193
AC.LineLength = oldLineLength;
194194
}
195195
}
196+
#ifdef WINDOWS
197+
PrintDeprecation("the native Windows version", "issues/623");
198+
#endif
199+
#ifdef ILP32
200+
PrintDeprecation("the 32-bit version", "issues/624");
201+
#endif
202+
#ifdef WITHMPI
203+
PrintDeprecation("the MPI version (ParFORM)", "issues/625");
204+
#endif
205+
if ( AC.CheckpointFlag ) {
206+
PrintDeprecation("the checkpoint mechanism", "issues/626");
207+
}
196208
}
197209

198210
/*
@@ -260,9 +272,17 @@ int DoTail(int argc, UBYTE **argv)
260272
AM.FileOnlyFlag = 1; AM.LogType = 1; break;
261273
case 'h': /* For old systems: wait for key before exit */
262274
AM.HoldFlag = 1; break;
275+
case 'i':
276+
if ( StrCmp(s, (UBYTE *)"ignore-deprecation") == 0 ) {
277+
AM.IgnoreDeprecation = 1;
278+
break;
279+
}
263280
#ifdef WITHINTERACTION
264-
case 'i': /* Interactive session (not used yet) */
265-
AM.Interact = 1; break;
281+
/* Interactive session (not used yet) */
282+
AM.Interact = 1;
283+
break;
284+
#else
285+
goto IllegalOption;
266286
#endif
267287
case 'I': /* Next arg is dir for inc/prc/sub files */
268288
TAKEPATH(AM.IncDir) break;
@@ -425,6 +445,7 @@ printversion:;
425445
}
426446
}
427447
else {
448+
IllegalOption:
428449
#ifdef WITHMPI
429450
if ( PF.me == MASTER )
430451
#endif
@@ -1849,6 +1870,36 @@ VOID Terminate(int errorcode)
18491870

18501871
/*
18511872
#] Terminate :
1873+
#[ PrintDeprecation :
1874+
*/
1875+
1876+
/**
1877+
* Prints a deprecation warning for a given feature.
1878+
*
1879+
* @param feature The name of the deprecated feature.
1880+
* @param issue The associated issue, e.g., "issues/700".
1881+
*/
1882+
void PrintDeprecation(const char *feature, const char *issue) {
1883+
#ifdef WITHMPI
1884+
if ( PF.me != MASTER ) return;
1885+
#endif
1886+
if ( AM.IgnoreDeprecation ) return;
1887+
1888+
UBYTE *e = (UBYTE *)getenv("FORM_IGNORE_DEPRECATION");
1889+
if ( e && e[0] && StrCmp(e, (UBYTE *)"0") && StrICmp(e, (UBYTE *)"false") && StrICmp(e, (UBYTE *)"no") ) return;
1890+
1891+
MesPrint("DeprecationWarning: We are considering deprecating %s.", feature);
1892+
MesPrint("If you want this support to continue, leave a comment at:");
1893+
MesPrint("");
1894+
MesPrint(" https://github.com/vermaseren/form/%s", issue);
1895+
MesPrint("");
1896+
MesPrint("Otherwise, it will be discontinued in the future.");
1897+
MesPrint("To suppress this warning, use the -ignore-deprecation command line option or");
1898+
MesPrint("set the environment variable FORM_IGNORE_DEPRECATION=1.");
1899+
}
1900+
1901+
/*
1902+
#] PrintDeprecation :
18521903
#[ PrintRunningTime :
18531904
*/
18541905

sources/structs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,10 +1528,11 @@ struct M_const {
15281528
WORD ClearStore;
15291529
WORD BracketFactors[8];
15301530
BOOL FromStdin; /* read the input from STDIN */
1531+
BOOL IgnoreDeprecation; /* ignore deprecation warning */
15311532
#ifdef WITHPTHREADS
1532-
PADPOSITION(17,26,62,83,(sizeof(pthread_rwlock_t)+sizeof(pthread_mutex_t)*2+1));
1533+
PADPOSITION(17,26,62,83,(sizeof(pthread_rwlock_t)+sizeof(pthread_mutex_t)*2)+2);
15331534
#else
1534-
PADPOSITION(17,24,62,83,1);
1535+
PADPOSITION(17,24,62,83,2);
15351536
#endif
15361537
};
15371538
/*

0 commit comments

Comments
 (0)