From da6d49d1b3f80950ec80234657de56ab6b023488 Mon Sep 17 00:00:00 2001 From: Andreas Wendleder Date: Wed, 10 Jun 2026 03:48:52 +0200 Subject: [PATCH] utils: convert K&R function definitions to ANSI C Convert the old-style (K&R) function definitions in utils/ 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. Updates the utils headers (netlist.h, stack.h, undo.h, macros.h) to prototype the affected declarations. TechAddClient keeps a generic (unprototyped) declaration because its per-section callbacks have intentionally varying signatures; its "opt" parameter is typed int (not bool) so the empty-parameter-list declaration stays compatible with the prototyped definition under C23. Builds cleanly under GCC 16 / C23 (with the -std=gnu17 build change). Co-Authored-By: Claude Opus 4.8 --- utils/LIBdbio.c | 10 ++-- utils/LIBmain.c | 4 +- utils/LIBtextio.c | 14 ++++-- utils/dqueue.c | 42 ++++++++--------- utils/flsbuf.c | 14 +++--- utils/fraction.c | 10 ++-- utils/hash.c | 74 ++++++++++++++--------------- utils/lookupany.c | 6 +-- utils/lookupfull.c | 14 +++--- utils/macros.c | 80 +++++++++++++++---------------- utils/macros.h | 2 +- utils/main.c | 36 +++++++------- utils/malloc.c | 12 ++--- utils/netlist.c | 40 ++++++++-------- utils/netlist.h | 2 +- utils/path.c | 115 +++++++++++++++++++++++---------------------- utils/pathvisit.c | 34 +++++++------- utils/printstuff.c | 8 ++-- utils/show.c | 14 +++--- utils/signals.c | 49 +++++++++++-------- utils/stack.c | 45 +++++++++--------- utils/stack.h | 2 +- utils/strdup.c | 20 ++++---- utils/tech.c | 58 ++++++++++++----------- utils/tech.h | 5 ++ utils/touchtypes.c | 22 ++++----- utils/undo.c | 63 +++++++++++++------------ utils/undo.h | 2 +- 28 files changed, 412 insertions(+), 385 deletions(-) diff --git a/utils/LIBdbio.c b/utils/LIBdbio.c index 0a1e03e9..924b2ddf 100644 --- a/utils/LIBdbio.c +++ b/utils/LIBdbio.c @@ -45,11 +45,11 @@ static char rcsid[] = "$Header: /usr/cvsroot/magic-8.0/utils/LIBdbio.c,v 1.1.1.1 */ FILE * -flock_open(filename, mode, is_locked, fdb) - char *filename; - char *mode; - bool *is_locked; - int *fdb; +flock_open( + char *filename, + char *mode, + bool *is_locked, + int *fdb) { FILE *f; diff --git a/utils/LIBmain.c b/utils/LIBmain.c index 20cff26d..307e1650 100644 --- a/utils/LIBmain.c +++ b/utils/LIBmain.c @@ -42,8 +42,8 @@ static char rcsid[] = "$Header: /usr/cvsroot/magic-8.0/utils/LIBmain.c,v 1.1.1.1 */ void -MainExit(code) - int code; +MainExit( + int code) { exit (code); } diff --git a/utils/LIBtextio.c b/utils/LIBtextio.c index ef42e225..283be47b 100644 --- a/utils/LIBtextio.c +++ b/utils/LIBtextio.c @@ -41,9 +41,9 @@ static char rcsid[] = "$Header: /usr/cvsroot/magic-8.0/utils/LIBtextio.c,v 1.1.1 */ char * -TxGetLine(buf, size) - char *buf; - int size; +TxGetLine( + char *buf, + int size) { return (fgets(buf, size, stdin)); } @@ -96,7 +96,9 @@ TxFlush() */ void -TxError(const char *fmt, ...) +TxError( + const char *fmt, + ...) { va_list ap; @@ -126,7 +128,9 @@ TxError(const char *fmt, ...) */ void -TxPrintf(const char *fmt, ...) +TxPrintf( + const char *fmt, + ...) { va_list ap; diff --git a/utils/dqueue.c b/utils/dqueue.c index b3ab7e87..0f0a00fd 100644 --- a/utils/dqueue.c +++ b/utils/dqueue.c @@ -43,9 +43,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ */ void -DQInit(q, capacity) - DQueue *q; - int capacity; +DQInit( + DQueue *q, + int capacity) { if (capacity < 1) capacity = 1; q->dq_data = (ClientData *) mallocMagic((unsigned)((capacity+1) * sizeof (ClientData))); @@ -73,8 +73,8 @@ DQInit(q, capacity) */ void -DQFree(q) - DQueue *q; +DQFree( + DQueue *q) { freeMagic((char *) q->dq_data); } @@ -96,9 +96,9 @@ DQFree(q) */ void -DQPushFront(q, elem) - DQueue *q; - ClientData elem; +DQPushFront( + DQueue *q, + ClientData elem) { if (q->dq_size == q->dq_maxSize) DQChangeSize(q, 2 * q->dq_maxSize); q->dq_data[q->dq_front] = elem; @@ -108,9 +108,9 @@ DQPushFront(q, elem) } void -DQPushRear(q, elem) - DQueue *q; - ClientData elem; +DQPushRear( + DQueue *q, + ClientData elem) { if (q->dq_size == q->dq_maxSize) DQChangeSize(q, 2 * q->dq_maxSize); q->dq_data[q->dq_rear] = elem; @@ -136,8 +136,8 @@ DQPushRear(q, elem) */ ClientData -DQPopFront(q) - DQueue *q; +DQPopFront( + DQueue *q) { if (q->dq_size == 0) return (ClientData) NULL; q->dq_size--; @@ -147,8 +147,8 @@ DQPopFront(q) } ClientData -DQPopRear(q) - DQueue *q; +DQPopRear( + DQueue *q) { if (q->dq_size == 0) return (ClientData) NULL; q->dq_size--; @@ -175,9 +175,9 @@ DQPopRear(q) */ void -DQChangeSize(q, newSize) - DQueue *q; - int newSize; +DQChangeSize( + DQueue *q, + int newSize) { DQueue newq; @@ -209,9 +209,9 @@ DQChangeSize(q, newSize) */ void -DQCopy(dst, src) - DQueue *dst; /* The destination queue */ - DQueue *src; /* The source queue */ +DQCopy( + DQueue *dst, /* The destination queue */ + DQueue *src) /* The source queue */ { int i; dst->dq_size = 0; diff --git a/utils/flsbuf.c b/utils/flsbuf.c index c7143408..4625b18c 100644 --- a/utils/flsbuf.c +++ b/utils/flsbuf.c @@ -48,9 +48,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ char *malloc(); int -_flsbuf(c, iop) - unsigned c; - FILE *iop; +_flsbuf( + unsigned c, + FILE *iop) { char *base; n, rn; @@ -125,8 +125,8 @@ tryagain: } int -fflush(iop) - struct _iobuf *iop; +fflush( + struct _iobuf *iop) { char *base; n, rn; @@ -149,8 +149,8 @@ fflush(iop) } int -fclose(iop) - struct _iobuf *iop; +fclose( + struct _iobuf *iop) { int r; diff --git a/utils/fraction.c b/utils/fraction.c index d5ace09b..4fc70801 100644 --- a/utils/fraction.c +++ b/utils/fraction.c @@ -51,8 +51,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ */ int -FindGCF(a, b) - int a, b; +FindGCF( + int a, + int b) { int a_mod_b, bp; @@ -80,8 +81,9 @@ FindGCF(a, b) */ void -ReduceFraction(n, d) - int *n, *d; +ReduceFraction( + int *n, + int *d) { int c; diff --git a/utils/hash.c b/utils/hash.c index 342f2f57..fe7e4128 100644 --- a/utils/hash.c +++ b/utils/hash.c @@ -143,10 +143,10 @@ static int rebuildLimit = 3; */ void -HashInit(table, nBuckets, ptrKeys) - HashTable *table; /* Table to be initialized */ - int nBuckets; /* How many buckets to create for starters */ - int ptrKeys; /* See comments above */ +HashInit( + HashTable *table, /* Table to be initialized */ + int nBuckets, /* How many buckets to create for starters */ + int ptrKeys) /* See comments above */ { ASSERT(ptrKeys != HT_CLIENTKEYS, "HashInit: should use HashInitClient"); HashInitClient(table, nBuckets, ptrKeys, @@ -155,14 +155,14 @@ HashInit(table, nBuckets, ptrKeys) } void -HashInitClient(table, nBuckets, ptrKeys, compareFn, copyFn, hashFn, killFn) - HashTable *table; /* Table to be initialized */ - int nBuckets; /* How many buckets to create for starters */ - int ptrKeys; /* See comments above */ - int (*compareFn)(); /* Function to compare two keys */ - char *(*copyFn)(); /* Function to copy a key */ - int (*hashFn)(); /* For hashing */ - int (*killFn)(); /* For hashing */ +HashInitClient( + HashTable *table, /* Table to be initialized */ + int nBuckets, /* How many buckets to create for starters */ + int ptrKeys, /* See comments above */ + int (*compareFn)(), /* Function to compare two keys */ + char *(*copyFn)(), /* Function to copy a key */ + int (*hashFn)(), /* For hashing */ + int (*killFn)()) /* For hashing */ { HashEntry ** ptr; int i; @@ -215,9 +215,9 @@ HashInitClient(table, nBuckets, ptrKeys, compareFn, copyFn, hashFn, killFn) */ int -hash(table, key) - HashTable *table; - char *key; +hash( + HashTable *table, + char *key) { unsigned *up; unsigned long i; @@ -280,9 +280,9 @@ hash(table, key) */ HashEntry * -HashLookOnly(table, key) - HashTable *table; /* Hash table to search. */ - const char *key; /* Interpreted according to table->ht_ptrKeys +HashLookOnly( + HashTable *table, /* Hash table to search. */ + const char *key) /* Interpreted according to table->ht_ptrKeys * as described in HashInit()'s comments. */ { @@ -350,9 +350,9 @@ next: */ HashEntry * -HashFind(table, key) - HashTable *table; /* Hash table to search. */ - const char *key; /* Interpreted according to table->ht_ptrKeys +HashFind( + HashTable *table, /* Hash table to search. */ + const char *key) /* Interpreted according to table->ht_ptrKeys * as described in HashInit()'s comments. */ { @@ -475,8 +475,8 @@ next: */ void -rebuild(table) - HashTable *table; /* Table to be enlarged. */ +rebuild( + HashTable *table) /* Table to be enlarged. */ { HashEntry **oldTable, **old2, *h, *next; int oldSize, bucket; @@ -537,8 +537,8 @@ rebuild(table) #define MAXCOUNT 15 void -HashStats(table) - HashTable *table; +HashStats( + HashTable *table) { int count[MAXCOUNT], overflow, i, j; HashEntry *h; @@ -575,9 +575,9 @@ HashStats(table) */ void -HashRemove(table, key) - HashTable *table; /* Hash table to search. */ - const char *key; /* Interpreted according to table->ht_ptrKeys +HashRemove( + HashTable *table, /* Hash table to search. */ + const char *key) /* Interpreted according to table->ht_ptrKeys * as described in HashInit()'s comments. */ { @@ -624,8 +624,8 @@ HashRemove(table, key) */ void -HashStartSearch(hs) - HashSearch *hs; /* Area in which to keep state about search.*/ +HashStartSearch( + HashSearch *hs) /* Area in which to keep state about search.*/ { hs->hs_nextIndex = 0; hs->hs_h = NIL; @@ -651,9 +651,9 @@ HashStartSearch(hs) */ HashEntry * -HashNext(table, hs) - HashTable *table; /* Table to be searched. */ - HashSearch *hs; /* Area used to keep state about search. */ +HashNext( + HashTable *table, /* Table to be searched. */ + HashSearch *hs) /* Area used to keep state about search. */ { HashEntry *h; @@ -684,8 +684,8 @@ HashNext(table, hs) */ void -HashKill(table) - HashTable *table; /* Hash table whose space is to be freed */ +HashKill( + HashTable *table) /* Hash table whose space is to be freed */ { HashEntry *h, **hp, **hend; int (*killFn)() = (int (*)()) NULL; @@ -731,8 +731,8 @@ HashKill(table) *--------------------------------------------------------- */ void -HashFreeKill(table) -HashTable *table; +HashFreeKill( +HashTable *table) { HashSearch hs; HashEntry *he; diff --git a/utils/lookupany.c b/utils/lookupany.c index d489d9c2..e9bff179 100644 --- a/utils/lookupany.c +++ b/utils/lookupany.c @@ -45,9 +45,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ */ int -LookupAny(c, table) - char c; - const char * const *table; +LookupAny( + char c, + const char * const *table) { const char * const *tp; diff --git a/utils/lookupfull.c b/utils/lookupfull.c index b72c02fc..be1278bc 100644 --- a/utils/lookupfull.c +++ b/utils/lookupfull.c @@ -49,9 +49,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ */ int -LookupFull(name, table) - const char *name; - const char * const *table; +LookupFull( + const char *name, + const char * const *table) { const char * const *tp; @@ -106,15 +106,15 @@ LookupFull(name, table) */ int -LookupStructFull(str, table, size) - const char *str; /* Pointer to a string to be looked up */ - const char * const *table; +LookupStructFull( + const char *str, /* Pointer to a string to be looked up */ + const char * const *table, /* Pointer to an array of structs containing string * pointers to valid commands. * The last table entry should have a NULL * string pointer. */ - int size; /* The size, in bytes, of each table entry */ + int size) /* The size, in bytes, of each table entry */ { const char * const *entry; int pos; diff --git a/utils/macros.c b/utils/macros.c index 25ab1adc..84b8af0d 100644 --- a/utils/macros.c +++ b/utils/macros.c @@ -93,12 +93,12 @@ MacroInit() */ void -MacroDefineByName(clientName, xc, str, help, imacro) - char *clientName; /* window client name */ - int xc; /* full (X11) keycode of macro with modifiers */ - char *str; /* ...and the string to be attached to it */ - char *help; /* ...and/or the help text for the macro */ - bool imacro; /* is this an interactive macro? */ +MacroDefineByName( + char *clientName, /* window client name */ + int xc, /* full (X11) keycode of macro with modifiers */ + char *str, /* ...and the string to be attached to it */ + char *help, /* ...and/or the help text for the macro */ + bool imacro) /* is this an interactive macro? */ { HashEntry *h; HashTable *clienttable, newTable; @@ -159,12 +159,12 @@ MacroDefineByName(clientName, xc, str, help, imacro) */ void -MacroDefine(client, xc, str, help, imacro) - WindClient client; /* window client type */ - int xc; /* full (X11) keycode of macro with modifiers */ - char *str; /* ...and the string to be attached to it */ - char *help; /* ...and/or the help text for the macro */ - bool imacro; /* is this an interactive macro? */ +MacroDefine( + WindClient client, /* window client type */ + int xc, /* full (X11) keycode of macro with modifiers */ + char *str, /* ...and the string to be attached to it */ + char *help, /* ...and/or the help text for the macro */ + bool imacro) /* is this an interactive macro? */ { char *clientName = NULL; @@ -193,10 +193,10 @@ MacroDefine(client, xc, str, help, imacro) */ void -MacroDefineHelp(client, xc, help) - WindClient client; /* window client type */ - int xc; /* full (X11) keycode of macro with modifiers */ - char *help; /* ...and/or the help text for the macro */ +MacroDefineHelp( + WindClient client, /* window client type */ + int xc, /* full (X11) keycode of macro with modifiers */ + char *help) /* ...and/or the help text for the macro */ { HashEntry *h; HashTable *clienttable; @@ -241,10 +241,10 @@ MacroDefineHelp(client, xc, help) */ char * -MacroRetrieve(client, xc, iReturn) - WindClient client; /* window client type */ - int xc; /* the extended name of the macro */ - bool *iReturn; /* TRUE if macro is interactive */ +MacroRetrieve( + WindClient client, /* window client type */ + int xc, /* the extended name of the macro */ + bool *iReturn) /* TRUE if macro is interactive */ { HashEntry *h; HashTable *clienttable; @@ -297,9 +297,9 @@ MacroRetrieve(client, xc, iReturn) */ char * -MacroRetrieveHelp(client, xc) - WindClient client; /* window client type */ - int xc; /* the extended name of the macro */ +MacroRetrieveHelp( + WindClient client, /* window client type */ + int xc) /* the extended name of the macro */ { HashEntry *h; HashTable *clienttable; @@ -347,10 +347,10 @@ MacroRetrieveHelp(client, xc) */ char * -MacroSubstitute(macrostr, searchstr, replacestr) - char *macrostr; - char *searchstr; - char *replacestr; +MacroSubstitute( + char *macrostr, + char *searchstr, + char *replacestr) { char *found, *last, *new; int expand, length, oldlength, srchsize; @@ -402,9 +402,9 @@ MacroSubstitute(macrostr, searchstr, replacestr) */ void -MacroDelete(client, xc) - WindClient client; /* window client type */ - int xc; /* the extended name of the macro */ +MacroDelete( + WindClient client, /* window client type */ + int xc) /* the extended name of the macro */ { HashEntry *h; HashTable *clienttable; @@ -459,9 +459,9 @@ MacroDelete(client, xc) */ void -MacroCopy(client, clientkey) - WindClient client; /* Current window client */ - char *clientkey; /* Name of client to copy macros to */ +MacroCopy( + WindClient client, /* Current window client */ + char *clientkey) /* Name of client to copy macros to */ { HashTable *clienttable; HashTable *copytable; @@ -511,8 +511,8 @@ MacroCopy(client, clientkey) */ char * -MacroName(xc) - int xc; +MacroName( + int xc) { char *vis; static char hex[17] = "0123456789ABCDEF"; @@ -598,9 +598,9 @@ MacroName(xc) */ int -MacroKey(str, verbose) - char *str; - int *verbose; +MacroKey( + char *str, + int *verbose) { static int warn = 1; @@ -759,8 +759,8 @@ MacroKey(str, verbose) */ int -TranslateChar(key) - int key; +TranslateChar( + int key) { int rval = key; diff --git a/utils/macros.h b/utils/macros.h index b55cf626..ab4e7c65 100644 --- a/utils/macros.h +++ b/utils/macros.h @@ -40,7 +40,7 @@ extern HashTable MacroClients; /* procedures */ extern void MacroInit(); -extern void MacroDefine(); +extern void MacroDefine(WindClient client, int xc, char *str, char *help, bool imacro); extern void MacroDefineHelp(); extern void MacroDefineInt(); extern char *MacroRetrieve(); /* returns a malloc'ed string */ diff --git a/utils/main.c b/utils/main.c index f02e3bd1..7d76c757 100644 --- a/utils/main.c +++ b/utils/main.c @@ -187,8 +187,8 @@ char *mainArg(); */ void -MainExit(errNum) - int errNum; +MainExit( + int errNum) { #ifdef MOCHA MochaExit(errNum); @@ -250,9 +250,9 @@ MainExit(errNum) */ int -mainDoArgs(argc, argv) - int argc; - char **argv; +mainDoArgs( + int argc, + char **argv) { bool haveDashI = FALSE; char *cp; @@ -471,10 +471,10 @@ mainDoArgs(argc, argv) */ char * -mainArg(pargc, pargv, mesg) - int *pargc; - char ***pargv; - char *mesg; +mainArg( + int *pargc, + char ***pargv, + char *mesg) { char option, *cp; @@ -508,9 +508,9 @@ mainArg(pargc, pargv, mesg) */ int -mainInitBeforeArgs(argc, argv) - int argc; - char *argv[]; +mainInitBeforeArgs( + int argc, + char *argv[]) { TechOverridesDefault = FALSE; if (Path == NULL) @@ -1283,9 +1283,9 @@ mainFinished() */ void -magicMain(argc, argv) - int argc; - char *argv[]; +magicMain( + int argc, + char *argv[]) { int rstatus; @@ -1295,9 +1295,9 @@ magicMain(argc, argv) } int -magicMainInit(argc, argv) - int argc; - char *argv[]; +magicMainInit( + int argc, + char *argv[]) { int rstatus; diff --git a/utils/malloc.c b/utils/malloc.c index 02444d56..2b01fa91 100644 --- a/utils/malloc.c +++ b/utils/malloc.c @@ -104,8 +104,8 @@ static char *freeDelayedItem = NULL; */ void * -mallocMagicLegacy(nbytes) - size_t nbytes; +mallocMagicLegacy( + size_t nbytes) { void *p; @@ -139,8 +139,8 @@ mallocMagicLegacy(nbytes) */ void -freeMagicLegacy(cp) - void *cp; +freeMagicLegacy( + void *cp) { if (cp == NULL) TxError("freeMagic called with NULL argument.\n"); @@ -162,8 +162,8 @@ freeMagicLegacy(cp) */ void * -callocMagicLegacy(nbytes) - size_t nbytes; +callocMagicLegacy( + size_t nbytes) { void *cp; diff --git a/utils/netlist.c b/utils/netlist.c index 5195c928..bab9f8db 100644 --- a/utils/netlist.c +++ b/utils/netlist.c @@ -45,7 +45,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ #define NETSIZE(r) ((int)((r)->r_xtop - (r)->r_xbot + (r)->r_ytop - (r)->r_ybot)) /* Forward declarations */ -int nlTermFunc(), nlLabelFunc(); +int nlTermFunc(char *name, bool firstInNet, NLNetList *netList), nlLabelFunc(); /* * ---------------------------------------------------------------------------- @@ -71,9 +71,9 @@ int nlTermFunc(), nlLabelFunc(); */ int -NLBuild(rootUse, netList) - CellUse *rootUse; /* Cell searched for terminals */ - NLNetList *netList; /* Netlist to build */ +NLBuild( + CellUse *rootUse, /* Cell searched for terminals */ + NLNetList *netList) /* Netlist to build */ { NLTerm *term; NLNet *net; @@ -154,10 +154,10 @@ done: */ int -nlTermFunc(name, firstInNet, netList) - char *name; - bool firstInNet; - NLNetList *netList; +nlTermFunc( + char *name, + bool firstInNet, + NLNetList *netList) { NLNet *net; NLTerm *term; @@ -212,11 +212,11 @@ nlTermFunc(name, firstInNet, netList) */ int -nlLabelFunc(area, name, label, term) - Rect *area; /* Root coords of label */ - char *name; /* Same as term->nterm_name (UNUSED) */ - Label *label; /* Label within scx->scx_use->cu_def */ - NLTerm *term; /* Prepend new NLTermLoc to this terminal */ +nlLabelFunc( + Rect *area, /* Root coords of label */ + char *name, /* Same as term->nterm_name (UNUSED) */ + Label *label, /* Label within scx->scx_use->cu_def */ + NLTerm *term) /* Prepend new NLTermLoc to this terminal */ { NLTermLoc *loc; @@ -261,8 +261,8 @@ nlLabelFunc(area, name, label, term) */ void -NLFree(netList) - NLNetList *netList; +NLFree( + NLNetList *netList) { NLTermLoc *loc; NLTerm *term; @@ -303,9 +303,9 @@ NLFree(netList) */ void -NLSort(netList, netHeap) - NLNetList *netList; - Heap *netHeap; +NLSort( + NLNetList *netList, + Heap *netHeap) { NLTermLoc *loc; NLTerm *term; @@ -366,8 +366,8 @@ NLSort(netList, netHeap) */ char * -NLNetName(net) - NLNet *net; +NLNetName( + NLNet *net) { static char tempId[100]; #if defined(EMSCRIPTEN) diff --git a/utils/netlist.h b/utils/netlist.h index 09ddb48e..b7abf837 100644 --- a/utils/netlist.h +++ b/utils/netlist.h @@ -110,7 +110,7 @@ typedef struct nlNet * A NLNetList contains a list of nets, along with the * table that maps from signal names to terminals. */ -typedef struct +typedef struct nlNetList { struct nlNet *nnl_nets; /* List of nets */ int nnl_numNets; /* # of nets in list (redundant, since diff --git a/utils/path.c b/utils/path.c index a4ead248..4ccd981f 100644 --- a/utils/path.c +++ b/utils/path.c @@ -71,7 +71,11 @@ bool FileLocking = TRUE; * Made non-static as flock() can use it but still considered module internal API. */ gzFile -path_gzdopen_internal(const char *path, int oflags, const char *modestr, int *fdp) +path_gzdopen_internal( + const char *path, + int oflags, + const char *modestr, + int *fdp) { ASSERT(fdp, "fdp"); @@ -113,8 +117,8 @@ close: */ char * -PaCheckCompressed(filename) - const char *filename; +PaCheckCompressed( + const char *filename) { char *gzname; @@ -137,7 +141,9 @@ PaCheckCompressed(filename) * newstring is the new string to append to the path. */ void -PaAppend(char **pathptr, const char *newstring) +PaAppend( + char **pathptr, + const char *newstring) { int oldlength, addlength; char *new; @@ -190,11 +196,10 @@ PaAppend(char **pathptr, const char *newstring) */ int -PaExpand(psource, pdest, size) - const char **psource; /* Pointer to a pointer to the source string */ - char **pdest; /* Pointer to a ptr to dest string area. */ - int size; /* Number of bytes available at pdest */ - +PaExpand( + const char **psource, /* Pointer to a pointer to the source string */ + char **pdest, /* Pointer to a ptr to dest string area. */ + int size) /* Number of bytes available at pdest */ { const char *ps; char *pd; @@ -386,14 +391,13 @@ noexpand: */ char * -nextName(ppath, file, dest, size) - const char **ppath; /* Pointer to a pointer to the next +nextName( + const char **ppath, /* Pointer to a pointer to the next * entry in the path. */ - const char *file; /* Pointer to a file name. */ - char *dest; /* Place to build result name. */ - int size; /* Size of result area. */ - + const char *file, /* Pointer to a file name. */ + char *dest, /* Place to build result name. */ + int size) /* Size of result area. */ { char *p; @@ -444,32 +448,32 @@ nextName(ppath, file, dest, size) */ gzFile -PaLockZOpen(file, mode, ext, path, library, pRealName, is_locked, fdp) - const char *file; /* Name of the file to be opened. */ - const char *mode; /* The file mode, as given to fopen. */ - const char *ext; /* The extension to be added to the file name, +PaLockZOpen( + const char *file, /* Name of the file to be opened. */ + const char *mode, /* The file mode, as given to fopen. */ + const char *ext, /* The extension to be added to the file name, * or NULL. Note: this string must include * the dot (or whatever separator you use). */ - const char *path; /* A search path: a list of directory names + const char *path, /* A search path: a list of directory names * separated by colons or blanks. To use * only the working directory, use "." for * the path. */ - const char *library; /* A 2nd path containing library names. Can be + const char *library, /* A 2nd path containing library names. Can be * NULL to indicate no library. */ - char **pRealName; /* Pointer to a location that will be filled + char **pRealName, /* Pointer to a location that will be filled * in with the address of the real name of * the file that was successfully opened. * If NULL, then nothing is stored. */ - bool *is_locked; /* Pointer to a location to store the result + bool *is_locked, /* Pointer to a location to store the result * of the attempt to grab an advisory lock * on the file. If NULL, then nothing is * stored. */ - int *fdp; /* If non-NULL, put the file descriptor here */ + int *fdp) /* If non-NULL, put the file descriptor here */ { char extendedName[MAXSIZE], *p1; const char *p2; @@ -644,32 +648,32 @@ PaLockZOpen(file, mode, ext, path, library, pRealName, is_locked, fdp) */ FILE * -PaLockOpen(file, mode, ext, path, library, pRealName, is_locked, fdp) - const char *file; /* Name of the file to be opened. */ - const char *mode; /* The file mode, as given to fopen. */ - const char *ext; /* The extension to be added to the file name, +PaLockOpen( + const char *file, /* Name of the file to be opened. */ + const char *mode, /* The file mode, as given to fopen. */ + const char *ext, /* The extension to be added to the file name, * or NULL. Note: this string must include * the dot (or whatever separator you use). */ - const char *path; /* A search path: a list of directory names + const char *path, /* A search path: a list of directory names * separated by colons or blanks. To use * only the working directory, use "." for * the path. */ - const char *library; /* A 2nd path containing library names. Can be + const char *library, /* A 2nd path containing library names. Can be * NULL to indicate no library. */ - char **pRealName; /* Pointer to a location that will be filled + char **pRealName, /* Pointer to a location that will be filled * in with the address of the real name of * the file that was successfully opened. * If NULL, then nothing is stored. */ - bool *is_locked; /* Pointer to a location to store the result + bool *is_locked, /* Pointer to a location to store the result * of the attempt to grab an advisory lock * on the file. If NULL, then nothing is * stored. */ - int *fdp; /* If non-NULL, put the file descriptor here. */ + int *fdp) /* If non-NULL, put the file descriptor here. */ { char extendedName[MAXSIZE], *p1; const char *p2; @@ -829,22 +833,22 @@ PaLockOpen(file, mode, ext, path, library, pRealName, is_locked, fdp) */ gzFile -PaZOpen(file, mode, ext, path, library, pRealName) - const char *file; /* Name of the file to be opened. */ - const char *mode; /* The file mode, as given to gzopen. */ - const char *ext; /* The extension to be added to the file name, +PaZOpen( + const char *file, /* Name of the file to be opened. */ + const char *mode, /* The file mode, as given to gzopen. */ + const char *ext, /* The extension to be added to the file name, * or NULL. Note: this string must include * the dot (or whatever separator you use). */ - const char *path; /* A search path: a list of directory names + const char *path, /* A search path: a list of directory names * separated by colons or blanks. To use * only the working directory, use "." for * the path. */ - const char *library; /* A 2nd path containing library names. Can be + const char *library, /* A 2nd path containing library names. Can be * NULL to indicate no library. */ - char **pRealName; /* Pointer to a location that will be filled + char **pRealName) /* Pointer to a location that will be filled * in with the address of the real name of * the file that was successfully opened. * If NULL, then nothing is stored. @@ -964,22 +968,22 @@ PaZOpen(file, mode, ext, path, library, pRealName) */ FILE * -PaOpen(file, mode, ext, path, library, pRealName) - const char *file; /* Name of the file to be opened. */ - const char *mode; /* The file mode, as given to fopen. */ - const char *ext; /* The extension to be added to the file name, +PaOpen( + const char *file, /* Name of the file to be opened. */ + const char *mode, /* The file mode, as given to fopen. */ + const char *ext, /* The extension to be added to the file name, * or NULL. Note: this string must include * the dot (or whatever separator you use). */ - const char *path; /* A search path: a list of directory names + const char *path, /* A search path: a list of directory names * separated by colons or blanks. To use * only the working directory, use "." for * the path. */ - const char *library; /* A 2nd path containing library names. Can be + const char *library, /* A 2nd path containing library names. Can be * NULL to indicate no library. */ - char **pRealName; /* Pointer to a location that will be filled + char **pRealName) /* Pointer to a location that will be filled * in with the address of the real name of * the file that was successfully opened. * If NULL, then nothing is stored. @@ -1008,12 +1012,11 @@ PaOpen(file, mode, ext, path, library, pRealName) */ char * -PaSubsWD(path, newWD) -const char *path; /* Path in which to substitute. */ -const char *newWD; /* New working directory to be used. Must +PaSubsWD( +const char *path, /* Path in which to substitute. */ +const char *newWD) /* New working directory to be used. Must * end in a slash. */ - { #define NEWPATHSIZE 1000 static char newPath[NEWPATHSIZE]; @@ -1107,13 +1110,13 @@ const char *newWD; /* New working directory to be used. Must */ int -PaEnum(path, file, proc, cdata) - const char *path; /* Search path */ - const char *file; /* Each element of the search path is prepended to +PaEnum( + const char *path, /* Search path */ + const char *file, /* Each element of the search path is prepended to * this file name and passed to the client. */ - int (*proc)(); /* Client procedure */ - ClientData cdata; /* Passed to (*proc)() */ + int (*proc)(), /* Client procedure */ + ClientData cdata) /* Passed to (*proc)() */ { char component[MAXSIZE], *next; diff --git a/utils/pathvisit.c b/utils/pathvisit.c index bcf3c5d0..0028d12b 100644 --- a/utils/pathvisit.c +++ b/utils/pathvisit.c @@ -78,8 +78,8 @@ PaVisitInit() */ void -PaVisitFree(pv) - PaVisit *pv; +PaVisitFree( + PaVisit *pv) { PaVisitClient *pvc; @@ -126,11 +126,11 @@ PaVisitFree(pv) */ void -PaVisitAddClient(pv, keyword, proc, cdata) - PaVisit *pv; - char *keyword; - int (*proc)(); - ClientData cdata; +PaVisitAddClient( + PaVisit *pv, + char *keyword, + int (*proc)(), + ClientData cdata) { PaVisitClient *pvc; @@ -175,17 +175,17 @@ PaVisitAddClient(pv, keyword, proc, cdata) */ int -PaVisitFiles(path, file, pv) - char *path; /* Colon or space separated list of directories to +PaVisitFiles( + char *path, /* Colon or space separated list of directories to * search for the file 'file'. If 'file' does not * exist in a given directory, that directory is * skipped. */ - char *file; /* If 'file' exists in a directory of 'path' we + char *file, /* If 'file' exists in a directory of 'path' we * open it and match each line against the list * of clients pointed to by 'pv'. */ - PaVisit *pv; + PaVisit *pv) { int paVisitFilesProc(); @@ -219,9 +219,9 @@ PaVisitFiles(path, file, pv) */ int -paVisitFilesProc(name, pv) - char *name; /* Full filename */ - PaVisit *pv; /* Points to list of clients */ +paVisitFilesProc( + char *name, /* Full filename */ + PaVisit *pv) /* Points to list of clients */ { char *lp; char line[BUFSIZ+2]; @@ -280,9 +280,9 @@ next: ; */ int -paVisitProcess(line, pv) - char *line; - PaVisit *pv; +paVisitProcess( + char *line, + PaVisit *pv) { PaVisitClient *pvc; char *cp; diff --git a/utils/printstuff.c b/utils/printstuff.c index 81477c15..58bc25bb 100644 --- a/utils/printstuff.c +++ b/utils/printstuff.c @@ -8,8 +8,8 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ #include "utils/geometry.h" void -PrintTrans(t) - Transform *t; +PrintTrans( + Transform *t) { printf("Translate: (%d, %d)\n", t->t_c, t->t_f); printf("%d\t%d\n", t->t_a, t->t_d); @@ -17,8 +17,8 @@ PrintTrans(t) } void -PrintRect(r) - Rect *r; +PrintRect( + Rect *r) { printf("(%d,%d) :: (%d,%d)\n", r->r_xbot, r->r_ybot, r->r_xtop, r->r_ytop); } diff --git a/utils/show.c b/utils/show.c index 7d41223f..a142b23a 100644 --- a/utils/show.c +++ b/utils/show.c @@ -58,10 +58,10 @@ int ShowRectStyle; CellDef *ShowRectDef; void -ShowRect(def, r, style) - CellDef *def; /* The area is in this def */ - Rect *r; /* Display this area (in coords of def above) */ - int style; /* in this style */ +ShowRect( + CellDef *def, /* The area is in this def */ + Rect *r, /* Display this area (in coords of def above) */ + int style) /* in this style */ { int ShowRectFunc(); @@ -72,9 +72,9 @@ ShowRect(def, r, style) } int -ShowRectFunc(w, r) - MagWindow *w; - Rect *r; +ShowRectFunc( + MagWindow *w, + Rect *r) { Rect screenRect; diff --git a/utils/signals.c b/utils/signals.c index 772c7078..338825f2 100644 --- a/utils/signals.c +++ b/utils/signals.c @@ -121,7 +121,8 @@ static int sigNumDisables = 0; */ void -SigSetTimer(int secs) +SigSetTimer( + int secs) { #ifdef __EMSCRIPTEN__ (void)secs; @@ -170,7 +171,8 @@ SigRemoveTimer() } sigRetVal -sigOnAlarm(int signo) +sigOnAlarm( + int signo) { if (GrDisplayStatus == DISPLAY_IN_PROGRESS) GrDisplayStatus = DISPLAY_BREAK_PENDING; @@ -211,7 +213,8 @@ SigTimerInterrupts() */ sigRetVal -sigOnStop(int signo) +sigOnStop( + int signo) { /* fix things up */ TxResetTerminal(TRUE); @@ -262,8 +265,8 @@ sigOnStop(int signo) */ bool -SigCheckProcess(pid) - int pid; +SigCheckProcess( + int pid) { #ifdef __EMSCRIPTEN__ (void)pid; @@ -341,9 +344,9 @@ SigDisableInterrupts() */ void -SigWatchFile(filenum, filename) - int filenum; /* A file descriptor number */ - char *filename; /* Used to recognize special files that +SigWatchFile( + int filenum, /* A file descriptor number */ + char *filename) /* Used to recognize special files that * don't support a full range of fcntl * calls (such as windows: /dev/winXX). */ @@ -422,9 +425,9 @@ SigWatchFile(filenum, filename) /*ARGSUSED*/ void -SigUnWatchFile(filenum, filename) - int filenum; /* A file descriptor number */ - char *filename; /* Used to recognize special files that +SigUnWatchFile( + int filenum, /* A file descriptor number */ + char *filename) /* Used to recognize special files that * don't support a full range of fcntl * calls (such as windows: /dev/winXX). */ @@ -471,7 +474,8 @@ SigUnWatchFile(filenum, filename) */ sigRetVal -sigOnInterrupt(int signo) +sigOnInterrupt( + int signo) { if (sigNumDisables != 0) sigInterruptReceived = TRUE; @@ -499,7 +503,8 @@ sigOnInterrupt(int signo) */ sigRetVal -sigOnTerm(int signo) +sigOnTerm( + int signo) { DBWriteBackup(NULL, FALSE, FALSE); exit (1); @@ -522,7 +527,8 @@ sigOnTerm(int signo) */ sigRetVal -sigOnWinch(int signo) +sigOnWinch( + int signo) { SigGotSigWinch = TRUE; sigReturn; @@ -543,7 +549,8 @@ sigOnWinch(int signo) */ sigRetVal -sigIO(int signo) +sigIO( + int signo) { SigIOReady = TRUE; if (SigInterruptOnSigIO == 1) sigOnInterrupt(0); @@ -567,8 +574,8 @@ sigIO(int signo) */ sigRetVal -sigCrash(signum) - int signum; +sigCrash( + int signum) { static int magicNumber = 1239987; char *msg; @@ -637,8 +644,8 @@ sigCrash(signum) */ void -SigInit(batchmode) - int batchmode; +SigInit( + int batchmode) { #ifdef __EMSCRIPTEN__ SigInterruptOnSigIO = (batchmode) ? -1 : 0; @@ -706,7 +713,9 @@ SigInit(batchmode) } void -sigSetAction(int signo, sigRetVal (*handler)(int)) +sigSetAction( + int signo, + sigRetVal (*handler)(int)) { #if defined(SYSV) || defined(CYGWIN) || defined(__NetBSD__) || defined(EMSCRIPTEN) struct sigaction sa; diff --git a/utils/stack.c b/utils/stack.c index ab54054a..3a381cdc 100644 --- a/utils/stack.c +++ b/utils/stack.c @@ -46,8 +46,8 @@ bool stackCopyStr; */ Stack * -StackNew(sincr) - int sincr; /* Number of entries by which to grow storage area */ +StackNew( + int sincr) /* Number of entries by which to grow storage area */ { Stack *stack; @@ -76,8 +76,8 @@ StackNew(sincr) */ void -StackFree(stack) - Stack *stack; +StackFree( + Stack *stack) { struct stackBody *stackp, *stacknext; @@ -106,9 +106,9 @@ StackFree(stack) * ---------------------------------------------------------------------------- */ void -StackPush(arg, stack) - ClientData arg; - Stack *stack; +StackPush( + ClientData arg, + Stack *stack) { struct stackBody *bodyNew; @@ -142,8 +142,8 @@ StackPush(arg, stack) */ ClientData -StackPop(stack) - Stack *stack; +StackPop( + Stack *stack) { struct stackBody *bodyOld; @@ -177,8 +177,8 @@ StackPop(stack) */ ClientData -StackLook(stack) - Stack *stack; +StackLook( + Stack *stack) { struct stackBody *bodyNext; @@ -218,10 +218,10 @@ StackLook(stack) * ---------------------------------------------------------------------------- */ void -StackEnum(stack, func, cd) - Stack * stack; - int (* func)(); - ClientData cd; +StackEnum( + Stack * stack, + int (* func)(), + ClientData cd) { int i, j; struct stackBody * sb; @@ -256,9 +256,10 @@ StackEnum(stack, func, cd) * ---------------------------------------------------------------------------- */ void -StackCopy(src, dest, copystr) - Stack * src, ** dest; - bool copystr; +StackCopy( + Stack *src, + Stack **dest, + bool copystr) { int stackCopyFn(); @@ -276,10 +277,10 @@ StackCopy(src, dest, copystr) /*ARGSUSED*/ int -stackCopyFn(stackItem, i, cd) - ClientData stackItem; - int i; - ClientData cd; +stackCopyFn( + ClientData stackItem, + int i, + ClientData cd) { if(stackCopyStr) StackPush((ClientData) StrDup((char **) NULL, (char *)stackItem), (Stack *) cd); diff --git a/utils/stack.h b/utils/stack.h index 1a9ee563..733b6740 100644 --- a/utils/stack.h +++ b/utils/stack.h @@ -54,7 +54,7 @@ ClientData StackLook(); void StackPush(); void StackFree(); void StackEnum(); -void StackCopy(); +void StackCopy(Stack *src, Stack **dest, bool copystr); #define stackBodyEmpty(st) ((st)->st_ptr <= (st)->st_body->sb_data) diff --git a/utils/strdup.c b/utils/strdup.c index b8736c61..0b074d9f 100644 --- a/utils/strdup.c +++ b/utils/strdup.c @@ -51,9 +51,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ */ char * -StrDup(oldstr, str) - char **oldstr; - const char *str; +StrDup( + char **oldstr, + const char *str) { char *newstr; @@ -89,9 +89,9 @@ StrDup(oldstr, str) */ bool -StrIsWhite(line, commentok) - const char *line; - bool commentok; /* TRUE means # comments are considered all-white */ +StrIsWhite( + const char *line, + bool commentok) /* TRUE means # comments are considered all-white */ { if ( (*line == '#') && commentok) return TRUE; @@ -122,8 +122,8 @@ StrIsWhite(line, commentok) */ bool -StrIsInt(s) - const char *s; +StrIsInt( + const char *s) { if (*s == '-' || *s == '+') s++; while (*s) @@ -151,8 +151,8 @@ StrIsInt(s) */ bool -StrIsNumeric(s) - const char *s; +StrIsNumeric( + const char *s) { double result; char *endptr; diff --git a/utils/tech.c b/utils/tech.c index ce0dd39c..222e4b42 100644 --- a/utils/tech.c +++ b/utils/tech.c @@ -156,9 +156,9 @@ techSection *techFindSection(); */ SectionID -TechSectionGetMask(sectionName, depend) - char *sectionName; - SectionID *depend; +TechSectionGetMask( + char *sectionName, + SectionID *depend) { techSection *tsp, *thissect; SectionID invid = 0; @@ -234,9 +234,9 @@ TechInit() */ void -TechAddAlias(primaryName, alias) - char *primaryName; - char *alias; +TechAddAlias( + char *primaryName, + char *alias) { techSection *tsp; @@ -278,9 +278,9 @@ TechAddAlias(primaryName, alias) */ int -changePlanesFunc(cellDef, arg) - CellDef *cellDef; - int *arg; +changePlanesFunc( + CellDef *cellDef, + int *arg) { int oldnumplanes = *arg; int pNum; @@ -355,14 +355,14 @@ changePlanesFunc(cellDef, arg) */ void -TechAddClient(sectionName, init, proc, final, prevSections, pSectionID, opt) - char *sectionName; - void (*init)(); - bool (*proc)(); - void (*final)(); - SectionID prevSections; - SectionID *pSectionID; - bool opt; /* optional section */ +TechAddClient( + char *sectionName, + void (*init)(), + bool (*proc)(), + void (*final)(), + SectionID prevSections, + SectionID *pSectionID, + int opt) /* optional section */ { techSection *tsp; techClient *tcp, *tcl; @@ -422,9 +422,9 @@ TechAddClient(sectionName, init, proc, final, prevSections, pSectionID, opt) */ bool -TechLoad(filename, initmask) - char *filename; - SectionID initmask; +TechLoad( + char *filename, + SectionID initmask) { FILE *tf; techSection *tsp; @@ -901,7 +901,9 @@ TechPrintLine() } void -TechError(const char *fmt, ...) +TechError( + const char *fmt, + ...) { va_list args; @@ -932,8 +934,8 @@ TechError(const char *fmt, ...) */ techSection * -techFindSection(sectionName) - char *sectionName; +techFindSection( + char *sectionName) { techSection *tsp; @@ -974,11 +976,11 @@ techFindSection(sectionName) */ int -techGetTokens(line, size, fstack, argv) - char *line; /* Character array into which line is read */ - int size; /* Size of character array */ - filestack **fstack; /* Open technology file on top of stack */ - char *argv[]; /* Vector of tokens built by techGetTokens() */ +techGetTokens( + char *line, /* Character array into which line is read */ + int size, /* Size of character array */ + filestack **fstack, /* Open technology file on top of stack */ + char *argv[]) /* Vector of tokens built by techGetTokens() */ { char *get, *put, *getp; bool inquote; diff --git a/utils/tech.h b/utils/tech.h index 7f56eb7a..46fc7380 100644 --- a/utils/tech.h +++ b/utils/tech.h @@ -52,6 +52,11 @@ extern bool TechOverridesDefault; /* Set TRUE if technology was specified on /* ----------------- Exported procedures ---------------- */ extern void TechError(const char *, ...) ATTR_FORMAT_PRINTF_1; +/* TechAddClient takes per-section callbacks with intentionally varying + * signatures, so its declaration stays generic (unprototyped) and "opt" is + * declared int (not bool) in the definition so this empty-parameter-list + * declaration remains compatible with it under C23/GCC 16. + */ extern void TechAddClient(); extern void TechAddAlias(); diff --git a/utils/touchtypes.c b/utils/touchtypes.c index b6a4923b..95952eab 100644 --- a/utils/touchtypes.c +++ b/utils/touchtypes.c @@ -58,10 +58,10 @@ typedef struct touchingfuncparms * ---------------------------------------------------------------------------- */ TileTypeBitMask -TouchingTypes(cellUse, expansionMask, point) - CellUse *cellUse; - int expansionMask; - Point *point; +TouchingTypes( + CellUse *cellUse, + int expansionMask, + Point *point) { int touchingTypesFunc(); int touchingSubcellsFunc(); @@ -138,10 +138,10 @@ TouchingTypes(cellUse, expansionMask, point) */ int -touchingTypesFunc(tile, dinfo, cxp) - Tile *tile; - TileType dinfo; /* (unused, but should be handled) */ - TreeContext *cxp; +touchingTypesFunc( + Tile *tile, + TileType dinfo, /* (unused, but should be handled) */ + TreeContext *cxp) { SearchContext *scx = cxp->tc_scx; Rect r, rDest; @@ -179,9 +179,9 @@ touchingTypesFunc(tile, dinfo, cxp) */ int -touchingSubcellsFunc(scx, cdarg) - SearchContext *scx; - ClientData cdarg; +touchingSubcellsFunc( + SearchContext *scx, + ClientData cdarg) { Rect r, rDest; TouchingFuncParms *parms = (TouchingFuncParms *) cdarg; diff --git a/utils/undo.c b/utils/undo.c index b4124c5e..3e01ec1b 100644 --- a/utils/undo.c +++ b/utils/undo.c @@ -228,11 +228,11 @@ extern void undoMemTruncate(); */ bool -UndoInit(logFileName, mode) - char *logFileName; /* Name of log file. This may contain tilde +UndoInit( + char *logFileName, /* Name of log file. This may contain tilde * abbreviations. */ - char *mode; /* Mode for opening. Must be "r", "rw", or "w" */ + char *mode) /* Mode for opening. Must be "r", "rw", or "w" */ { UndoDisableCount = 0; undoLogTail = NULL; @@ -330,13 +330,14 @@ UndoInit(logFileName, mode) */ UndoType -UndoAddClient(init, done, readEvent, writeEvent, forwEvent, backEvent, name) - void (*init)(); - void (*done)(); - UndoEvent *(*readEvent)(); - int (*writeEvent)(); - void (*forwEvent)(), (*backEvent)(); - char *name; +UndoAddClient( + void (*init)(), + void (*done)(), + UndoEvent * (*readEvent)(), + int (*writeEvent)(), + void (*forwEvent)(), + void (*backEvent)(), + char *name) { if (undoNumClients >= MAXUNDOCLIENTS) return ((UndoType) -1); @@ -464,9 +465,9 @@ UndoEnable() */ UndoEvent * -UndoNewEvent(clientType, size) - UndoType clientType; /* Type of event to allocate */ - unsigned int size; /* Number of bytes of client data to allocate */ +UndoNewEvent( + UndoType clientType, /* Type of event to allocate */ + unsigned int size) /* Number of bytes of client data to allocate */ { internalUndoEvent *iup; int usize; @@ -567,8 +568,8 @@ UndoNext() */ int -UndoBackward(n) - int n; /* Number of events to unplay */ +UndoBackward( + int n) /* Number of events to unplay */ { internalUndoEvent *iup; int client, count; @@ -649,8 +650,8 @@ UndoBackward(n) */ int -UndoForward(n) - int n; /* Number of events to replay */ +UndoForward( + int n) /* Number of events to replay */ { internalUndoEvent *iup; int count, client; @@ -729,8 +730,8 @@ done: */ internalUndoEvent * -undoGetForw(iup) - internalUndoEvent *iup; +undoGetForw( + internalUndoEvent *iup) { if (iup != (internalUndoEvent *) NULL) { @@ -775,8 +776,8 @@ undoGetForw(iup) */ internalUndoEvent * -undoGetBack(iup) - internalUndoEvent *iup; +undoGetBack( + internalUndoEvent *iup) { if (iup == (internalUndoEvent *) NULL) return (iup); if (iup->iue_back != (internalUndoEvent *) NULL) return (iup->iue_back); @@ -913,8 +914,8 @@ undoMemTruncate() */ void -undoPrintEvent(iup) - internalUndoEvent *iup; +undoPrintEvent( + internalUndoEvent *iup) { char *client_name; if (iup->iue_type < 0) @@ -930,9 +931,9 @@ undoPrintEvent(iup) /* the end of the stack. Otherwise, print the next n events. */ void -undoPrintForw(iup, n) - internalUndoEvent *iup; - int n; +undoPrintForw( + internalUndoEvent *iup, + int n) { int i = 0; @@ -953,9 +954,9 @@ undoPrintForw(iup, n) /* the beginning of the stack. Otherwise, print the previous n events. */ void -undoPrintBack(iup, n) - internalUndoEvent *iup; - int n; +undoPrintBack( + internalUndoEvent *iup, + int n) { int i = 0; @@ -977,8 +978,8 @@ undoPrintBack(iup, n) /* and n = 0 (backward). */ void -UndoStackTrace(n) - int n; +UndoStackTrace( + int n) { if (n < 0) undoPrintBack(undoLogCur, -(n + 1)); diff --git a/utils/undo.h b/utils/undo.h index a593bfb1..79c7db0d 100644 --- a/utils/undo.h +++ b/utils/undo.h @@ -62,7 +62,7 @@ typedef char UndoEvent; /* Externally visible undo event */ */ extern bool UndoInit(char *, char *); -extern UndoType UndoAddClient(); +extern UndoType UndoAddClient(void (*init)(), void (*done)(), UndoEvent *(*readEvent)(), int (*writeEvent)(), void (*forwEvent)(), void (*backEvent)(), char *name); extern UndoEvent *UndoNewEvent(UndoType, unsigned int); /* extern UndoEvent *UndoCopyEvent(); */ extern void UndoNext(void);