tcltk: convert K&R function definitions to ANSI C

Convert the old-style (K&R) function definitions in tcltk/ to ANSI C
prototypes, formatted in the project's convention: the return type on its
own line and each parameter on its own line, indented four spaces, with
the original parameter comments retained.

Builds cleanly under GCC 16 / C23 (with the -std=gnu17 build change).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Andreas Wendleder 2026-06-10 03:49:03 +02:00
parent 8f12f94f7f
commit 314978eec5
No known key found for this signature in database
GPG Key ID: 588785BFDFB01ABD
3 changed files with 49 additions and 43 deletions

View File

@ -18,8 +18,8 @@
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
int int
magic_AppInit(interp) magic_AppInit(
Tcl_Interp *interp; Tcl_Interp *interp)
{ {
if (Tcl_Init(interp) == TCL_ERROR) { if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR; return TCL_ERROR;
@ -42,9 +42,9 @@ magic_AppInit(interp)
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
int int
main(argc, argv) main(
int argc; int argc,
char **argv; char **argv)
{ {
Tcl_Main(argc, argv, magic_AppInit); Tcl_Main(argc, argv, magic_AppInit);
return 0; return 0;

View File

@ -44,8 +44,8 @@
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
int int
magic_AppInit(interp) magic_AppInit(
Tcl_Interp *interp; Tcl_Interp *interp)
{ {
if (Tcl_Init(interp) == TCL_ERROR) { if (Tcl_Init(interp) == TCL_ERROR) {
return TCL_ERROR; return TCL_ERROR;
@ -68,9 +68,9 @@ magic_AppInit(interp)
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
int int
main(argc, argv) main(
int argc; int argc,
char **argv; char **argv)
{ {
Tk_Main(argc, argv, magic_AppInit); Tk_Main(argc, argv, magic_AppInit);
return 0; return 0;

View File

@ -85,8 +85,8 @@ void RegisterTkCommands();
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
int int
TagVerify(keyword) TagVerify(
char *keyword; char *keyword)
{ {
char *croot, *postcmd; char *croot, *postcmd;
HashEntry *entry; HashEntry *entry;
@ -107,11 +107,11 @@ TagVerify(keyword)
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
int int
TagCallback(interp, tkpath, argc, argv) TagCallback(
Tcl_Interp *interp; Tcl_Interp *interp,
char *tkpath; char *tkpath,
int argc; /* original command's number of arguments */ int argc, /* original command's number of arguments */
char *argv[]; /* original command's argument list */ char *argv[]) /* original command's argument list */
{ {
int argidx, result = TCL_OK; int argidx, result = TCL_OK;
char *postcmd, *substcmd, *newcmd, *sptr, *sres; char *postcmd, *substcmd, *newcmd, *sptr, *sres;
@ -582,7 +582,9 @@ _tk_dispatch(ClientData clientData,
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
void void
MakeWindowCommand(char *wname, MagWindow *mw) MakeWindowCommand(
char *wname,
MagWindow *mw)
{ {
char *tclcmdstr; char *tclcmdstr;
@ -601,7 +603,8 @@ MakeWindowCommand(char *wname, MagWindow *mw)
#ifdef HAVE_SETRLIMIT #ifdef HAVE_SETRLIMIT
static int static int
process_rlimit_nofile_ensure(rlim_t nofile) process_rlimit_nofile_ensure(
rlim_t nofile)
{ {
struct rlimit rlim; struct rlimit rlim;
int err = getrlimit(RLIMIT_NOFILE, &rlim); int err = getrlimit(RLIMIT_NOFILE, &rlim);
@ -948,10 +951,10 @@ _magic_startup(ClientData clientData,
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
int int
TxDialog(prompt, responses, defresp) TxDialog(
const char *prompt; const char *prompt,
const char * const *responses; const char * const *responses,
int defresp; int defresp)
{ {
Tcl_Obj *objPtr; Tcl_Obj *objPtr;
int code, result, pos; int code, result, pos;
@ -1044,10 +1047,10 @@ TxSetPrompt(
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
char * char *
TxGetLinePfix(dest, maxChars, prefix) TxGetLinePfix(
char *dest; char *dest,
int maxChars; int maxChars,
char *prefix; char *prefix)
{ {
Tcl_Obj *objPtr; Tcl_Obj *objPtr;
int charsStored; int charsStored;
@ -1104,8 +1107,8 @@ TxGetLinePfix(dest, maxChars, prefix)
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
void void
TxDispatch(f) TxDispatch(
FILE *f; /* Under Tcl, we never call this with NULL */ FILE *f) /* Under Tcl, we never call this with NULL */
{ {
if (f == NULL) if (f == NULL)
{ {
@ -1129,8 +1132,8 @@ TxDispatch(f)
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
void void
TxParseString(str) TxParseString(
const char *str; const char *str)
{ {
const char *reply; const char *reply;
@ -1224,7 +1227,10 @@ TxFlush()
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
int int
Tcl_printf(FILE *f, const char *fmt, va_list args_in) Tcl_printf(
FILE *f,
const char *fmt,
va_list args_in)
{ {
va_list args; va_list args;
static char outstr[128] = "puts -nonewline std"; static char outstr[128] = "puts -nonewline std";
@ -1318,8 +1324,8 @@ Tcl_printf(FILE *f, const char *fmt, va_list args_in)
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
char * char *
Tcl_escape(instring) Tcl_escape(
char *instring; char *instring)
{ {
char *newstr; char *newstr;
int nchars = 0; int nchars = 0;
@ -1368,11 +1374,11 @@ Tcl_escape(instring)
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
int int
TerminalInputProc(instanceData, buf, toRead, errorCodePtr) TerminalInputProc(
ClientData instanceData; ClientData instanceData,
char *buf; char *buf,
int toRead; int toRead,
int *errorCodePtr; int *errorCodePtr)
{ {
FileState *fsPtr = (FileState *)instanceData; FileState *fsPtr = (FileState *)instanceData;
int bytesRead, i, tlen; int bytesRead, i, tlen;
@ -1417,8 +1423,8 @@ TerminalInputProc(instanceData, buf, toRead, errorCodePtr)
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
int int
Tclmagic_Init(interp) Tclmagic_Init(
Tcl_Interp *interp; Tcl_Interp *interp)
{ {
const char *cadroot; const char *cadroot;
@ -1475,8 +1481,8 @@ Tclmagic_Init(interp)
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
int int
Tclmagic_SafeInit(interp) Tclmagic_SafeInit(
Tcl_Interp *interp; Tcl_Interp *interp)
{ {
return Tclmagic_Init(interp); return Tclmagic_Init(interp);
} }