Skip to content

Commit 705b4da

Browse files
dlmilesRTimothyEdwards
authored andcommitted
TxParseString() refactor to 1-arg public form
Only the txCommands.c file needs the 3-arg form locally
1 parent 9aef87c commit 705b4da

File tree

6 files changed

+64
-17
lines changed

6 files changed

+64
-17
lines changed

graphics/grTCairo1.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ XEvent *xevent;
780780
freeMagic(vis);
781781
}
782782
/* Print Carriage Return & Put back Tcl/Tk prompt */
783-
TxParseString("", NULL, NULL);
783+
TxParseString("");
784784
}
785785
else
786786
{
@@ -816,7 +816,7 @@ XEvent *xevent;
816816
TxSetPoint(KeyPressedEvent->x,
817817
grXtransY(mw, KeyPressedEvent->y),
818818
mw->w_wid);
819-
TxParseString(macroDef, NULL, NULL);
819+
TxParseString(macroDef);
820820
}
821821
freeMagic(macroDef);
822822
}

graphics/grTOGL1.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ TOGLEventProc(clientData, xevent)
784784
freeMagic(vis);
785785
}
786786
/* Print Carriage Return & Put back Tcl/Tk prompt */
787-
TxParseString("", NULL, NULL);
787+
TxParseString("");
788788
}
789789
else
790790
{
@@ -820,7 +820,7 @@ TOGLEventProc(clientData, xevent)
820820
TxSetPoint(KeyPressedEvent->x,
821821
grXtransY(mw, KeyPressedEvent->y),
822822
mw->w_wid);
823-
TxParseString(macroDef, NULL, NULL);
823+
TxParseString(macroDef);
824824
}
825825
freeMagic(macroDef);
826826
}

graphics/grTk1.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ MagicEventProc(clientData, xevent)
10411041
freeMagic(vis);
10421042
}
10431043
/* Print Carriage Return & Put back Tcl/Tk prompt */
1044-
TxParseString("", NULL, NULL);
1044+
TxParseString("");
10451045
}
10461046
else
10471047
{
@@ -1076,7 +1076,7 @@ MagicEventProc(clientData, xevent)
10761076
TxSetPoint(KeyPressedEvent->x,
10771077
grXToMagic(KeyPressedEvent->y),
10781078
grCurrent.mw->w_wid);
1079-
TxParseString(macroDef, NULL, NULL);
1079+
TxParseString(macroDef);
10801080
}
10811081
freeMagic(macroDef);
10821082
}

tcltk/tclmagic.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -1003,10 +1003,8 @@ TxDispatch(f)
10031003
/*--------------------------------------------------------------*/
10041004

10051005
void
1006-
TxParseString(str, q, event)
1006+
TxParseString(str)
10071007
const char *str;
1008-
void *q; /* unused */
1009-
void *event; /* always NULL (ignored) */
10101008
{
10111009
const char *reply;
10121010

textio/txCommands.c

+56-7
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ TxGetInputEvent(
998998
/*
999999
* ----------------------------------------------------------------------------
10001000
*
1001-
* TxParseString --
1001+
* TxParseString_internal --
10021002
*
10031003
* Parse a string into commands, and add them to the rear of a queue.
10041004
* The commands in the queue should eventually be freed by the caller
@@ -1010,11 +1010,13 @@ TxGetInputEvent(
10101010
* Side Effects:
10111011
* None.
10121012
*
1013+
* Module internal API. See TxParseString() for public version.
1014+
*
10131015
* ----------------------------------------------------------------------------
10141016
*/
10151017

1016-
void
1017-
TxParseString(
1018+
static void
1019+
TxParseString_internal(
10181020
const char *str, /* The string to be parsed. */
10191021
DQueue *q, /* Add to the tail of this queue. */
10201022
TxInputEvent *event) /* An event to supply the point, window ID,
@@ -1053,6 +1055,53 @@ TxParseString(
10531055
}
10541056
}
10551057

1058+
/*
1059+
* ----------------------------------------------------------------------------
1060+
*
1061+
* TxParseString --
1062+
*
1063+
* Parse a string into commands, and add them to the rear of a queue.
1064+
* The commands in the queue should eventually be freed by the caller
1065+
* via TxFreeCommand().
1066+
*
1067+
* Results:
1068+
* None.
1069+
*
1070+
* Side Effects:
1071+
* None.
1072+
*
1073+
* Public API. See also TxParseString_internal().
1074+
*
1075+
* ----------------------------------------------------------------------------
1076+
*/
1077+
void
1078+
TxParseString(
1079+
const char *str) /* The string to be parsed. */
1080+
{
1081+
TxParseString_internal(str, NULL, NULL);
1082+
}
1083+
1084+
#else
1085+
1086+
/* tclmagic.c defines TxParseString() so we need a shim to other way
1087+
*
1088+
* FIXME it feels like there is some design error here, only this
1089+
* file cares about DQueue/TxInputEvent arguments but they are
1090+
* passed but not used by tclmagic.c TxParseString()
1091+
*
1092+
* It must be that !MAGIC_WRAPPER needs the DQueue/TxInputEvent for
1093+
* the other builds, such as WASM.
1094+
*
1095+
*/
1096+
static void
1097+
TxParseString_internal(
1098+
const char *str, /* The string to be parsed. */
1099+
DQueue *q,
1100+
TxInputEvent *event)
1101+
{
1102+
TxParseString(str);
1103+
}
1104+
10561105
#endif /* !MAGIC_WRAPPER */
10571106

10581107
/*
@@ -1149,7 +1198,7 @@ txGetInteractiveCommand(
11491198
(void) TxGetLinePrompt(inputLine, TX_MAX_CMDLEN, TX_CMD_PROMPT);
11501199
if (inputLine[0] != '\0') MacroDefine(DBWclientID, (int)'.',
11511200
inputLine, NULL, FALSE);
1152-
TxParseString(inputLine, queue, (TxInputEvent* ) NULL);
1201+
TxParseString_internal(inputLine, queue, (TxInputEvent* ) NULL);
11531202
}
11541203
else
11551204
{
@@ -1182,11 +1231,11 @@ txGetInteractiveCommand(
11821231
TX_MAX_CMDLEN, TX_CMD_PROMPT, macroDef);
11831232
if (inputLine[0] != '\0') MacroDefine(DBWclientID, (int)'.',
11841233
inputLine, NULL, FALSE);
1185-
TxParseString(inputLine, queue, (TxInputEvent *) NULL);
1234+
TxParseString_internal(inputLine, queue, (TxInputEvent *) NULL);
11861235
}
11871236
else
11881237
{
1189-
TxParseString(macroDef, queue, (TxInputEvent *) NULL);
1238+
TxParseString_internal(macroDef, queue, (TxInputEvent *) NULL);
11901239
}
11911240
freeMagic(macroDef);
11921241
}
@@ -1291,7 +1340,7 @@ txGetFileCommand(
12911340
if ((inputLine[0] == ':') || (inputLine[1] == ';')) linep++;
12921341
#endif
12931342

1294-
TxParseString(linep, queue, (TxInputEvent *) NULL);
1343+
TxParseString_internal(linep, queue, (TxInputEvent *) NULL);
12951344
}
12961345

12971346
/*

textio/txcommands.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ extern void TxReleaseButton(int but);
155155
extern void TxPrintCommand(TxCommand *cmd);
156156
extern TxCommand *TxNewCommand(void);
157157
extern void TxFreeCommand(TxCommand *command);
158-
extern void TxParseString(const char *str, void *q, void *event);
158+
extern void TxParseString(const char *str);
159159
extern void TxDispatch(FILE *f);
160160
extern void TxRebuildCommand(TxCommand *cmd);
161161
extern int TxCommandNumber; /* Serial number of current command. */

0 commit comments

Comments
 (0)