From 705b4da105824102a31f19df6bb6b9b583555567 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Fri, 31 Jan 2025 17:39:24 +0000 Subject: [PATCH] TxParseString() refactor to 1-arg public form Only the txCommands.c file needs the 3-arg form locally --- graphics/grTCairo1.c | 4 +-- graphics/grTOGL1.c | 4 +-- graphics/grTk1.c | 4 +-- tcltk/tclmagic.c | 4 +-- textio/txCommands.c | 63 +++++++++++++++++++++++++++++++++++++++----- textio/txcommands.h | 2 +- 6 files changed, 64 insertions(+), 17 deletions(-) diff --git a/graphics/grTCairo1.c b/graphics/grTCairo1.c index 553fc5db..a3f99563 100644 --- a/graphics/grTCairo1.c +++ b/graphics/grTCairo1.c @@ -780,7 +780,7 @@ keys_and_buttons: freeMagic(vis); } /* Print Carriage Return & Put back Tcl/Tk prompt */ - TxParseString("", NULL, NULL); + TxParseString(""); } else { @@ -816,7 +816,7 @@ keys_and_buttons: TxSetPoint(KeyPressedEvent->x, grXtransY(mw, KeyPressedEvent->y), mw->w_wid); - TxParseString(macroDef, NULL, NULL); + TxParseString(macroDef); } freeMagic(macroDef); } diff --git a/graphics/grTOGL1.c b/graphics/grTOGL1.c index ec2d4c5f..7849f659 100644 --- a/graphics/grTOGL1.c +++ b/graphics/grTOGL1.c @@ -784,7 +784,7 @@ keys_and_buttons: freeMagic(vis); } /* Print Carriage Return & Put back Tcl/Tk prompt */ - TxParseString("", NULL, NULL); + TxParseString(""); } else { @@ -820,7 +820,7 @@ keys_and_buttons: TxSetPoint(KeyPressedEvent->x, grXtransY(mw, KeyPressedEvent->y), mw->w_wid); - TxParseString(macroDef, NULL, NULL); + TxParseString(macroDef); } freeMagic(macroDef); } diff --git a/graphics/grTk1.c b/graphics/grTk1.c index d783d244..01c59d8c 100644 --- a/graphics/grTk1.c +++ b/graphics/grTk1.c @@ -1041,7 +1041,7 @@ keys_and_buttons: freeMagic(vis); } /* Print Carriage Return & Put back Tcl/Tk prompt */ - TxParseString("", NULL, NULL); + TxParseString(""); } else { @@ -1076,7 +1076,7 @@ keys_and_buttons: TxSetPoint(KeyPressedEvent->x, grXToMagic(KeyPressedEvent->y), grCurrent.mw->w_wid); - TxParseString(macroDef, NULL, NULL); + TxParseString(macroDef); } freeMagic(macroDef); } diff --git a/tcltk/tclmagic.c b/tcltk/tclmagic.c index 9df119d4..a477bd4a 100644 --- a/tcltk/tclmagic.c +++ b/tcltk/tclmagic.c @@ -1003,10 +1003,8 @@ TxDispatch(f) /*--------------------------------------------------------------*/ void -TxParseString(str, q, event) +TxParseString(str) const char *str; - void *q; /* unused */ - void *event; /* always NULL (ignored) */ { const char *reply; diff --git a/textio/txCommands.c b/textio/txCommands.c index 743dc7fe..b002f04e 100644 --- a/textio/txCommands.c +++ b/textio/txCommands.c @@ -998,7 +998,7 @@ TxGetInputEvent( /* * ---------------------------------------------------------------------------- * - * TxParseString -- + * TxParseString_internal -- * * Parse a string into commands, and add them to the rear of a queue. * The commands in the queue should eventually be freed by the caller @@ -1010,11 +1010,13 @@ TxGetInputEvent( * Side Effects: * None. * + * Module internal API. See TxParseString() for public version. + * * ---------------------------------------------------------------------------- */ -void -TxParseString( +static void +TxParseString_internal( const char *str, /* The string to be parsed. */ DQueue *q, /* Add to the tail of this queue. */ TxInputEvent *event) /* An event to supply the point, window ID, @@ -1053,6 +1055,53 @@ TxParseString( } } +/* + * ---------------------------------------------------------------------------- + * + * TxParseString -- + * + * Parse a string into commands, and add them to the rear of a queue. + * The commands in the queue should eventually be freed by the caller + * via TxFreeCommand(). + * + * Results: + * None. + * + * Side Effects: + * None. + * + * Public API. See also TxParseString_internal(). + * + * ---------------------------------------------------------------------------- + */ +void +TxParseString( + const char *str) /* The string to be parsed. */ +{ + TxParseString_internal(str, NULL, NULL); +} + +#else + +/* tclmagic.c defines TxParseString() so we need a shim to other way + * + * FIXME it feels like there is some design error here, only this + * file cares about DQueue/TxInputEvent arguments but they are + * passed but not used by tclmagic.c TxParseString() + * + * It must be that !MAGIC_WRAPPER needs the DQueue/TxInputEvent for + * the other builds, such as WASM. + * + */ +static void +TxParseString_internal( + const char *str, /* The string to be parsed. */ + DQueue *q, + TxInputEvent *event) +{ + TxParseString(str); +} + #endif /* !MAGIC_WRAPPER */ /* @@ -1149,7 +1198,7 @@ txGetInteractiveCommand( (void) TxGetLinePrompt(inputLine, TX_MAX_CMDLEN, TX_CMD_PROMPT); if (inputLine[0] != '\0') MacroDefine(DBWclientID, (int)'.', inputLine, NULL, FALSE); - TxParseString(inputLine, queue, (TxInputEvent* ) NULL); + TxParseString_internal(inputLine, queue, (TxInputEvent* ) NULL); } else { @@ -1182,11 +1231,11 @@ txGetInteractiveCommand( TX_MAX_CMDLEN, TX_CMD_PROMPT, macroDef); if (inputLine[0] != '\0') MacroDefine(DBWclientID, (int)'.', inputLine, NULL, FALSE); - TxParseString(inputLine, queue, (TxInputEvent *) NULL); + TxParseString_internal(inputLine, queue, (TxInputEvent *) NULL); } else { - TxParseString(macroDef, queue, (TxInputEvent *) NULL); + TxParseString_internal(macroDef, queue, (TxInputEvent *) NULL); } freeMagic(macroDef); } @@ -1291,7 +1340,7 @@ txGetFileCommand( if ((inputLine[0] == ':') || (inputLine[1] == ';')) linep++; #endif - TxParseString(linep, queue, (TxInputEvent *) NULL); + TxParseString_internal(linep, queue, (TxInputEvent *) NULL); } /* diff --git a/textio/txcommands.h b/textio/txcommands.h index a36cedc4..cf28ef32 100644 --- a/textio/txcommands.h +++ b/textio/txcommands.h @@ -155,7 +155,7 @@ extern void TxReleaseButton(int but); extern void TxPrintCommand(TxCommand *cmd); extern TxCommand *TxNewCommand(void); extern void TxFreeCommand(TxCommand *command); -extern void TxParseString(const char *str, void *q, void *event); +extern void TxParseString(const char *str); extern void TxDispatch(FILE *f); extern void TxRebuildCommand(TxCommand *cmd); extern int TxCommandNumber; /* Serial number of current command. */