From 0519c0cb52e531f333122413977426efa70f6f8f Mon Sep 17 00:00:00 2001 From: Ole Streicher Date: Mon, 8 Apr 2024 10:18:27 +0200 Subject: [PATCH 1/6] Protoize CL and ECL This is done on an Ubuntu Trusty machine, with the command protoize -g -l -N -c "-I${iraf}unix/hlib/libc" *.c --- pkg/cl/builtin.c | 4 ++-- pkg/cl/debug.c | 2 +- pkg/cl/edcap.c | 2 +- pkg/cl/eparam.c | 6 +++--- pkg/cl/eparam.h | 4 ++-- pkg/cl/grammar.h | 2 +- pkg/cl/history.c | 6 +++--- pkg/cl/lexicon.c | 2 +- pkg/cl/main.c | 8 ++++---- pkg/cl/mem.h | 4 ++-- pkg/cl/modes.c | 6 +++--- pkg/cl/opcodes.c | 8 ++++---- pkg/cl/opcodes.h | 2 +- pkg/cl/operand.h | 7 +++---- pkg/cl/param.c | 2 +- pkg/cl/param.h | 36 ++++++++++++++++++------------------ pkg/cl/pfiles.c | 4 ++-- pkg/cl/prcache.c | 4 ++-- pkg/cl/proto.h | 2 +- pkg/cl/task.h | 10 +++++----- pkg/ecl/builtin.c | 6 +++--- pkg/ecl/debug.c | 2 +- pkg/ecl/edcap.c | 2 +- pkg/ecl/eparam.c | 6 +++--- pkg/ecl/eparam.h | 4 ++-- pkg/ecl/grammar.h | 2 +- pkg/ecl/history.c | 6 +++--- pkg/ecl/lexicon.c | 2 +- pkg/ecl/main.c | 8 ++++---- pkg/ecl/mem.h | 4 ++-- pkg/ecl/modes.c | 6 +++--- pkg/ecl/opcodes.c | 8 ++++---- pkg/ecl/opcodes.h | 2 +- pkg/ecl/operand.h | 7 +++---- pkg/ecl/param.c | 2 +- pkg/ecl/param.h | 36 ++++++++++++++++++------------------ pkg/ecl/pfiles.c | 4 ++-- pkg/ecl/prcache.c | 4 ++-- pkg/ecl/proto.h | 2 +- pkg/ecl/task.h | 10 +++++----- 40 files changed, 121 insertions(+), 123 deletions(-) diff --git a/pkg/cl/builtin.c b/pkg/cl/builtin.c index 64e7908d2..be65f31bf 100644 --- a/pkg/cl/builtin.c +++ b/pkg/cl/builtin.c @@ -2100,8 +2100,8 @@ setbuiltins (register struct package *pkp) { /* Debugging functions are in debug.c. */ - extern void d_f(), d_l(), d_d(), d_off(), d_on(), d_p(), d_t(); - extern void pr_listcache(); + extern void d_f(void), d_l(void), d_d(void), d_off(void), d_on(void), d_p(void), d_t(void); + extern void pr_listcache(FILE *fp); static struct builtin { char *b_name; diff --git a/pkg/cl/debug.c b/pkg/cl/debug.c index aacdff5b0..3377dcec2 100644 --- a/pkg/cl/debug.c +++ b/pkg/cl/debug.c @@ -32,7 +32,7 @@ extern char *nullstr; extern int cldebug; extern int cltrace; -static void dd_f(); +static void dd_f(char *msg, char *fname); /* D_STACK -- Go through the instruction stack, starting at locpc, printing diff --git a/pkg/cl/edcap.c b/pkg/cl/edcap.c index d6fc336e8..c7b903346 100644 --- a/pkg/cl/edcap.c +++ b/pkg/cl/edcap.c @@ -41,7 +41,7 @@ */ static char ed_editorcmd[SZ_LINE+1]; -static void map_escapes(); +static void map_escapes(char *input, char *output); /* EDTINIT -- Initialize the editor. diff --git a/pkg/cl/eparam.c b/pkg/cl/eparam.c index beee3bd09..49094e634 100644 --- a/pkg/cl/eparam.c +++ b/pkg/cl/eparam.c @@ -92,7 +92,7 @@ int eh_standout = YES; /* ehist default for standout */ int eh_bol = NO; /* start ehist at beginning of line */ int eh_verify = NO; /* use ehist with history meta-chars */ -char *e_tonextword(), *e_toprevword(); +char *e_tonextword(register char *ip), *e_toprevword(char *ip, char *string); int eparam (struct ep_context *cx, int *update, int *nextcmd, char *nextpset); @@ -705,7 +705,7 @@ e_check_vals ( char *string ) { - char *gquery(); /* declare gquery as returning a pointer */ + char *gquery(struct param *pp, char *string); /* declare gquery as returning a pointer */ char *errstr; /* pointer to the error string (or 0) */ char message[SZ_LINE+1];/* error message string */ int badnews; /* a flag if an array element is in error */ @@ -722,7 +722,7 @@ e_check_vals ( if (isarray) { char outstring[G_MAXSTRING]; - char *in, *e_getfield(); + char *in, *e_getfield(register char *ip, char *outstr, int maxch); int first, nelem, flen; /* Get the length of the first dimension, and the starting point. diff --git a/pkg/cl/eparam.h b/pkg/cl/eparam.h index 72ef1ab25..32ada4462 100644 --- a/pkg/cl/eparam.h +++ b/pkg/cl/eparam.h @@ -104,5 +104,5 @@ extern struct edit_commands command[MAX_COMMANDS]; extern char *cmdnames[MAX_COMMANDS]; extern int numcommands; -char *enumin(), *minmax(); -char *host_editor(); +char *enumin(register struct param *pp), *minmax(register struct param *pp); +char *host_editor(char *editor); diff --git a/pkg/cl/grammar.h b/pkg/cl/grammar.h index 21d15e088..fecb82e30 100644 --- a/pkg/cl/grammar.h +++ b/pkg/cl/grammar.h @@ -58,4 +58,4 @@ extern int parse_state; /* What are we parsing? */ extern int proc_script; /* In a procedure script? */ extern struct pfile *parse_pfile; /* Where parsed params are added. */ -char *today(); /* returns pointer to todays date */ +char *today(void); /* returns pointer to todays date */ diff --git a/pkg/cl/history.c b/pkg/cl/history.c index e4dbd88ce..f82ae8688 100644 --- a/pkg/cl/history.c +++ b/pkg/cl/history.c @@ -769,7 +769,7 @@ int get_history (int record, char *command, int maxch) { char *recptr; - char *find_history(); + char *find_history(int record); if ((recptr = find_history (record)) == NULL) { *command = EOS; @@ -884,7 +884,7 @@ show_history (FILE *fp, int max_commands) char *recptr[MAX_SHOWHIST]; char cmdblk[SZ_CMDBLK+1]; int record; - char *find_history(); + char *find_history(int record); /* Flush the "history" command so that it shows up in the history. */ yy_startblock (LOG); @@ -1082,7 +1082,7 @@ putlog ( register char *ip, *op, *otop; register int n; char msg[SZ_LOGBUF], job[5]; - char *pkg, *tname, *today(); + char *pkg, *tname, *today(void); extern int bkgno; /* job number if bkg job */ if (!keeplog()) diff --git a/pkg/cl/lexicon.c b/pkg/cl/lexicon.c index 136aaf71e..1ef58c512 100644 --- a/pkg/cl/lexicon.c +++ b/pkg/cl/lexicon.c @@ -646,7 +646,7 @@ etok_: if (!newtoken) { /* LEXINIT -- Initialize the internal state variables of the lexical analyzer, * e.g. when processing is interrupted by an interrupt. */ -int +void lexinit (void) { if (lexmodes() && !lex_cpumodeset (currentask->t_in)) { diff --git a/pkg/cl/main.c b/pkg/cl/main.c index 68f1f5eb8..b638f1eda 100644 --- a/pkg/cl/main.c +++ b/pkg/cl/main.c @@ -84,9 +84,9 @@ long cpustart, clkstart; /* starting cpu, clock times if bkg */ int logout_status = 0; /* optional status arg to logout() */ -static void execute(); -static void login(), logout(); -static void startup(), shutdown(); +static void execute(int mode); +static void login(char *cmd), logout(void); +static void startup(void), shutdown(void); static void onint (int *vex, int (**next_handler)(void)); extern int yyparse(); @@ -252,7 +252,7 @@ execute (int mode) { int parsestat; XINT old_parhead; - char *curcmd(); + char *curcmd(void); alldone = 0; gologout = 0; diff --git a/pkg/cl/mem.h b/pkg/cl/mem.h index 752b3be5e..830b9338e 100644 --- a/pkg/cl/mem.h +++ b/pkg/cl/mem.h @@ -105,5 +105,5 @@ extern XINT pc; /* program counter */ */ #define coderef(x) ((struct codeentry *)&stack[x]) -extern char *memneed(); /* insures enough core, returns start */ -extern char *comdstr(); /* compile string at topd, return start */ +extern char *memneed(int incr); /* insures enough core, returns start */ +extern char *comdstr(char *s); /* compile string at topd, return start */ diff --git a/pkg/cl/modes.c b/pkg/cl/modes.c index 651fb1da1..fd9801e17 100644 --- a/pkg/cl/modes.c +++ b/pkg/cl/modes.c @@ -268,8 +268,8 @@ query (struct param *pp) char buf[SZ_PROMPTBUF+1]; struct operand o; int bastype, batch, arrflag, offset=0, n_ele, max_ele, fd; - char *nlp, *nextstr(); - char *bkg_query(), *query_status; + char *nlp, *nextstr(char **pbuf, FILE *fp); + char *bkg_query(char *obuf, int maxch, register struct param *pp), *query_status; char *abuf; bastype = pp->p_type & OT_BASIC; @@ -537,7 +537,7 @@ text_query: fd = spf_open (buf, SZ_PROMPTBUF); char * nextstr (char **pbuf, FILE *fp) { - char *p, *nxtchr(); + char *p, *nxtchr(char *p, FILE *fp); static char tbuf[SZ_LINE]; char quote; int cnt; diff --git a/pkg/cl/opcodes.c b/pkg/cl/opcodes.c index 2ab8f8e6b..502dd3393 100644 --- a/pkg/cl/opcodes.c +++ b/pkg/cl/opcodes.c @@ -39,8 +39,8 @@ extern int cldebug; extern char *nullstr; int binpipe; /* last pipe binary or text ? */ -char *comdstr(); -extern struct param *ppfind(); /* search task psets for param */ +char *comdstr(char *s); +extern struct param *ppfind(struct pfile *pfp, char *tn, char *pn, int pos, int abbrev); /* search task psets for param */ void o_undefined (memel *argp) @@ -973,7 +973,7 @@ o_doaddpipe (memel *argp) char *ltname; struct operand o; struct ltask *ltp; - char *addpipe(); + char *addpipe(void); /* ADDPIPE is called immediately before REDIR and before EXEC so we * do not have to worry about storing the pipefile name in the dict. @@ -1005,7 +1005,7 @@ o_dogetpipe ( ) { struct operand o; - char *getpipe(), *comdstr(); + char *getpipe(void), *comdstr(char *s); /* GETPIPE is called immediately before REDIRIN and before EXEC so we * do not have to worry about storing the pipefile name in the dict. diff --git a/pkg/cl/opcodes.h b/pkg/cl/opcodes.h index bcce4b7f9..72a02896d 100644 --- a/pkg/cl/opcodes.h +++ b/pkg/cl/opcodes.h @@ -16,7 +16,7 @@ struct codeentry { memel c_args; /* addr of this is addr of first arg */ }; -extern void (*opcodetbl[])(); +extern void (*opcodetbl[])(memel *arg); /* manifest constant opcodes used in c_opcode. * value is index into opcodetbl[]. diff --git a/pkg/cl/operand.h b/pkg/cl/operand.h index ac10fc050..c774597ce 100644 --- a/pkg/cl/operand.h +++ b/pkg/cl/operand.h @@ -161,7 +161,6 @@ struct arr_desc { extern char *truestr, *falsestr; -struct operand popop(), pushop(); -struct operand makeop(); -struct operand readlist(); /* read and return operand from list */ -struct operand sexa(); /* convert n:n:n string to sexagesimal */ +struct operand popop(void), pushop(struct operand *op); +struct operand makeop(char *str, int type); +struct operand sexa(char *); /* convert n:n:n string to sexagesimal */ diff --git a/pkg/cl/param.c b/pkg/cl/param.c index f680a12a0..a1f02968b 100644 --- a/pkg/cl/param.c +++ b/pkg/cl/param.c @@ -706,7 +706,7 @@ paramsrch (char *pkname, char *ltname, char *pname) { register struct param *pp; struct pfile *pfp; - struct param *lookup_param(); + struct param *lookup_param(char *pkname, char *ltname, char *pname); /* First search for a regular parameter. If this fails then we * handle the case when currentask has no pfile. diff --git a/pkg/cl/param.h b/pkg/cl/param.h index 4e9d81182..728b8f05e 100644 --- a/pkg/cl/param.h +++ b/pkg/cl/param.h @@ -200,21 +200,21 @@ struct pfile { #define V_FILE 9 -char *nextfield(); /* cracks next pfile line field */ -char *makelower(); /* upper to lower, in place and return */ - -struct param *paramfind(); /* searches for a param on a given pfile*/ -struct param *paramsrch(); /* search, make sure param is there */ -struct param *lookup_param(); /* search standard path for a param */ -struct param *newparam(); /* allocate and link a new param */ -struct param *addparam(); /* make a new param off given pfile */ -struct param *newfakeparam(); /* add a fake param to pfile */ -struct pfile *pfilesrch(); /* read named pfile or ltask pfile */ -struct pfile *pfileload(); /* load pfile for ltask into memory */ -struct pfile *pfileread(); /* read and make params from a pfile */ -struct pfile *pfilefind(); /* look for pfile with given name */ -struct pfile *newpfile(); /* add a new pfile off parhead */ -struct pfile *pfilecopy(); /* make an in-core copy of a pfile */ - -int defpar(); /* determine whether param exists */ -int defvar(); /* determine whether envvar exists */ +char *nextfield(char **pp, FILE *fp); /* cracks next pfile line field */ +char *makelower(register char *cp); /* upper to lower, in place and return */ + +struct param *paramfind(struct pfile *pfp, char *pname, int pos, int exact); /* searches for a param on a given pfile*/ +struct param *paramsrch(char *pkname, char *ltname, char *pname); /* search, make sure param is there */ +struct param *lookup_param(char *pkname, char *ltname, char *pname); /* search standard path for a param */ +struct param *newparam(struct pfile *pfp); /* allocate and link a new param */ +struct param *addparam(struct pfile *pfp, char *buf, FILE *fp); /* make a new param off given pfile */ +struct param *newfakeparam(struct pfile *pfp, char *name, int pos, int type, int string_len); /* add a fake param to pfile */ +struct pfile *pfilesrch(char *pfilepath); /* read named pfile or ltask pfile */ +struct pfile *pfileload(register struct ltask *ltp); /* load pfile for ltask into memory */ +struct pfile *pfileread(struct ltask *ltp, char *pfilename, int checkmode); /* read and make params from a pfile */ +struct pfile *pfilefind(register struct ltask *ltp); /* look for pfile with given name */ +struct pfile *newpfile(struct ltask *ltp); /* add a new pfile off parhead */ +struct pfile *pfilecopy(register struct pfile *pfp); /* make an in-core copy of a pfile */ + +int defpar(char *param_spec); /* determine whether param exists */ +int defvar(char *envvar); /* determine whether envvar exists */ diff --git a/pkg/cl/pfiles.c b/pkg/cl/pfiles.c index 3ade4d3b2..347fec1a7 100644 --- a/pkg/cl/pfiles.c +++ b/pkg/cl/pfiles.c @@ -30,8 +30,8 @@ extern char *nullstr; extern char *indefstr, *indeflc; extern FILE *yyin; char *uparmdir = UPARM; -long filetime(); -static void mapname(); +long filetime(char *fname, char *timecode); +static void mapname(char *in, char *out, int maxlen); /* NEWPFILE -- Allocate a new pfile on the dictionary and link in at parhead. diff --git a/pkg/cl/prcache.c b/pkg/cl/prcache.c index 31687e39f..a682b6b85 100644 --- a/pkg/cl/prcache.c +++ b/pkg/cl/prcache.c @@ -88,7 +88,7 @@ int pr_pno = 1; /* incremented for each connect */ int sz_prcache = 2; /* nprocess slots in cache */ struct process pr_cache[MAXSUBPROC]; struct process *pr_head = NULL, *pr_tail = NULL; -extern char *findexe(); +extern char *findexe(struct package *pkg, char *pkg_path); static void pr_pdisconnect (struct process *pr); static void pr_tohead (struct process *pr); @@ -193,7 +193,7 @@ pr_pconnect ( ) { struct process *pr; - struct process *pr_findproc(); + struct process *pr_findproc(char *process); struct _finfo fi; int fd_in, fd_out; diff --git a/pkg/cl/proto.h b/pkg/cl/proto.h index f17cf8a75..1aef570c7 100644 --- a/pkg/cl/proto.h +++ b/pkg/cl/proto.h @@ -259,7 +259,7 @@ extern void putlog(struct task *tp, char *usermsg); /* lexicon.c */ extern int yylex(void); extern int lexicon(void); -extern int lexinit(void); +extern void lexinit(void); /* lists.c */ extern struct operand readlist(struct param *pp); extern void closelist(register struct param *pp); diff --git a/pkg/cl/task.h b/pkg/cl/task.h index 4163da47f..1e9446286 100644 --- a/pkg/cl/task.h +++ b/pkg/cl/task.h @@ -203,8 +203,8 @@ struct package { #define LTASKSIZ btoi (sizeof (struct ltask)) #define PACKAGESIZ btoi (sizeof (struct package)) -struct package *newpac(), *pacfind(); -struct ltask *addltask(), *newltask(), *ltaskfind(), *cmdsrch(); -struct ltask *ltasksrch(), *_ltasksrch(); -struct task *pushtask(), *poptask(); -int deftask(), defpac(); +struct package *newpac(char *name, char *bin), *pacfind(char *name); +struct ltask *addltask(struct package *pkp, char *ptname, char *ltname, int redef), *newltask(register struct package *pkp, char *lname, char *pname, struct ltask *oldltp), *ltaskfind(struct package *pkp, char *name, int enable_abbreviations), *cmdsrch(char *pkname, char *ltname); +struct ltask *ltasksrch(char *pkname, char *ltname), *_ltasksrch(char *pkname, char *ltname, struct package **o_pkp); +struct task *pushtask(void), *poptask(void); +int deftask(char *task_spec), defpac(char *pkname); diff --git a/pkg/ecl/builtin.c b/pkg/ecl/builtin.c index c319e5635..9dcfdd123 100644 --- a/pkg/ecl/builtin.c +++ b/pkg/ecl/builtin.c @@ -2292,9 +2292,9 @@ setbuiltins (register struct package *pkp) { /* Debugging functions are in debug.c. */ - extern void d_f(), d_l(), d_d(), d_off(), d_on(), d_p(), d_t(); - extern void d_asmark(), d_assemble(), d_prof(), d_trace(); - extern void pr_listcache(); + extern void d_f(void), d_l(void), d_d(void), d_off(void), d_on(void), d_p(void), d_t(void); + extern void d_asmark(void), d_assemble(void), d_prof(void), d_trace(int value); + extern void pr_listcache(FILE *fp); static struct builtin { char *b_name; diff --git a/pkg/ecl/debug.c b/pkg/ecl/debug.c index ba129946d..f74e2c2b0 100644 --- a/pkg/ecl/debug.c +++ b/pkg/ecl/debug.c @@ -32,7 +32,7 @@ extern char *nullstr; extern int cldebug; extern int cltrace; -static void dd_f(); +static void dd_f(char *msg, char *fname); /* D_STACK -- Go through the instruction stack, starting at locpc, printing diff --git a/pkg/ecl/edcap.c b/pkg/ecl/edcap.c index 14df4d6cf..419d9082e 100644 --- a/pkg/ecl/edcap.c +++ b/pkg/ecl/edcap.c @@ -41,7 +41,7 @@ */ static char ed_editorcmd[SZ_LINE+1]; -static void map_escapes(); +static void map_escapes(char *input, char *output); /* EDTINIT -- Initialize the editor. diff --git a/pkg/ecl/eparam.c b/pkg/ecl/eparam.c index 24f9ceeba..4047e34c7 100644 --- a/pkg/ecl/eparam.c +++ b/pkg/ecl/eparam.c @@ -98,7 +98,7 @@ int eh_readline = YES; /* use readline() for terminal input */ #endif int eh_longprompt = YES; /* print full package name as prompt */ -char *e_tonextword(), *e_toprevword(); +char *e_tonextword(register char *ip), *e_toprevword(char *ip, char *string); char epar_cmdbuf[SZ_LINE]; @@ -716,7 +716,7 @@ e_check_vals ( char *string ) { - char *gquery(); /* declare gquery as returning a pointer */ + char *gquery(struct param *pp, char *string); /* declare gquery as returning a pointer */ char *errstr; /* pointer to the error string (or 0) */ char message[SZ_LINE+1];/* error message string */ int badnews; /* a flag if an array element is in error */ @@ -733,7 +733,7 @@ e_check_vals ( if (isarray) { char outstring[G_MAXSTRING]; - char *in, *e_getfield(); + char *in, *e_getfield(register char *ip, char *outstr, int maxch); int first, nelem, flen; /* Get the length of the first dimension, and the starting point. diff --git a/pkg/ecl/eparam.h b/pkg/ecl/eparam.h index 72ef1ab25..32ada4462 100644 --- a/pkg/ecl/eparam.h +++ b/pkg/ecl/eparam.h @@ -104,5 +104,5 @@ extern struct edit_commands command[MAX_COMMANDS]; extern char *cmdnames[MAX_COMMANDS]; extern int numcommands; -char *enumin(), *minmax(); -char *host_editor(); +char *enumin(register struct param *pp), *minmax(register struct param *pp); +char *host_editor(char *editor); diff --git a/pkg/ecl/grammar.h b/pkg/ecl/grammar.h index 21d15e088..fecb82e30 100644 --- a/pkg/ecl/grammar.h +++ b/pkg/ecl/grammar.h @@ -58,4 +58,4 @@ extern int parse_state; /* What are we parsing? */ extern int proc_script; /* In a procedure script? */ extern struct pfile *parse_pfile; /* Where parsed params are added. */ -char *today(); /* returns pointer to todays date */ +char *today(void); /* returns pointer to todays date */ diff --git a/pkg/ecl/history.c b/pkg/ecl/history.c index 7c28cc331..7da1dbaa2 100644 --- a/pkg/ecl/history.c +++ b/pkg/ecl/history.c @@ -822,7 +822,7 @@ int get_history (int record, char *command, int maxch) { char *recptr; - char *find_history(); + char *find_history(int record); if ((recptr = find_history (record)) == NULL) { *command = EOS; @@ -937,7 +937,7 @@ show_history (FILE *fp, int max_commands) char *recptr[MAX_SHOWHIST]; char cmdblk[SZ_CMDBLK+1]; int record; - char *find_history(); + char *find_history(int record); /* Flush the "history" command so that it shows up in the history. */ yy_startblock (LOG); @@ -1170,7 +1170,7 @@ putlog ( register char *ip, *op, *otop; register int n; char msg[SZ_LOGBUF], job[5]; - char *pkg, *tname, *today(); + char *pkg, *tname, *today(void); extern int bkgno; /* job number if bkg job */ if (!keeplog()) diff --git a/pkg/ecl/lexicon.c b/pkg/ecl/lexicon.c index b9c05ea71..6d84f7700 100644 --- a/pkg/ecl/lexicon.c +++ b/pkg/ecl/lexicon.c @@ -650,7 +650,7 @@ etok_: if (!newtoken) { /* LEXINIT -- Initialize the internal state variables of the lexical analyzer, * e.g. when processing is interrupted by an interrupt. */ -int +void lexinit (void) { if (lexmodes() && !lex_cpumodeset (currentask->t_in)) { diff --git a/pkg/ecl/main.c b/pkg/ecl/main.c index bf01e3811..05904f748 100644 --- a/pkg/ecl/main.c +++ b/pkg/ecl/main.c @@ -86,9 +86,9 @@ long cpustart, clkstart; /* starting cpu, clock times if bkg */ int logout_status = 0; /* optional status arg to logout() */ -static void execute(); -static void login(), logout(); -static void startup(), shutdown(); +static void execute(int mode); +static void login(char *cmd), logout(void); +static void startup(void), shutdown(void); static char *file_concat (char *in1, char *in2); static void onint (int *vex, int (**next_handler)(void)); @@ -263,7 +263,7 @@ execute (int mode) { int parsestat; XINT old_parhead; - char *curcmd(); + char *curcmd(void); alldone = 0; gologout = 0; diff --git a/pkg/ecl/mem.h b/pkg/ecl/mem.h index 752b3be5e..830b9338e 100644 --- a/pkg/ecl/mem.h +++ b/pkg/ecl/mem.h @@ -105,5 +105,5 @@ extern XINT pc; /* program counter */ */ #define coderef(x) ((struct codeentry *)&stack[x]) -extern char *memneed(); /* insures enough core, returns start */ -extern char *comdstr(); /* compile string at topd, return start */ +extern char *memneed(int incr); /* insures enough core, returns start */ +extern char *comdstr(char *s); /* compile string at topd, return start */ diff --git a/pkg/ecl/modes.c b/pkg/ecl/modes.c index e4205ad3a..65ba0f4e2 100644 --- a/pkg/ecl/modes.c +++ b/pkg/ecl/modes.c @@ -268,8 +268,8 @@ query (struct param *pp) char buf[SZ_PROMPTBUF+1]; struct operand o; int bastype, batch, arrflag, offset=0, n_ele, max_ele, fd; - char *nlp, *nextstr(); - char *bkg_query(), *query_status; + char *nlp, *nextstr(char **pbuf, FILE *fp); + char *bkg_query(char *obuf, int maxch, register struct param *pp), *query_status; char *abuf; bastype = pp->p_type & OT_BASIC; @@ -537,7 +537,7 @@ text_query: fd = spf_open (buf, SZ_PROMPTBUF); char * nextstr (char **pbuf, FILE *fp) { - char *p, *nxtchr(); + char *p, *nxtchr(char *p, FILE *fp); static char tbuf[SZ_LINE]; char quote; int cnt; diff --git a/pkg/ecl/opcodes.c b/pkg/ecl/opcodes.c index 47c2a75be..df36c6e0a 100644 --- a/pkg/ecl/opcodes.c +++ b/pkg/ecl/opcodes.c @@ -39,8 +39,8 @@ extern int cldebug; extern char *nullstr; int binpipe; /* last pipe binary or text ? */ -char *comdstr(); -extern struct param *ppfind(); /* search task psets for param */ +char *comdstr(char *s); +extern struct param *ppfind(struct pfile *pfp, char *tn, char *pn, int pos, int abbrev); /* search task psets for param */ extern int currentline; void @@ -972,7 +972,7 @@ o_doaddpipe (memel *argp) char *ltname; struct operand o; struct ltask *ltp; - char *addpipe(); + char *addpipe(void); /* ADDPIPE is called immediately before REDIR and before EXEC so we * do not have to worry about storing the pipefile name in the dict. @@ -1004,7 +1004,7 @@ o_dogetpipe ( ) { struct operand o; - char *getpipe(), *comdstr(); + char *getpipe(void), *comdstr(char *s); /* GETPIPE is called immediately before REDIRIN and before EXEC so we * do not have to worry about storing the pipefile name in the dict. diff --git a/pkg/ecl/opcodes.h b/pkg/ecl/opcodes.h index ce40b762b..9dbbfe028 100644 --- a/pkg/ecl/opcodes.h +++ b/pkg/ecl/opcodes.h @@ -20,7 +20,7 @@ struct codeentry { #define SZ_CE 4 /* size of codeentry */ -extern void (*opcodetbl[])(); +extern void (*opcodetbl[])(memel *arg); /* manifest constant opcodes used in c_opcode. * value is index into opcodetbl[]. diff --git a/pkg/ecl/operand.h b/pkg/ecl/operand.h index fca448568..5f7cf4660 100644 --- a/pkg/ecl/operand.h +++ b/pkg/ecl/operand.h @@ -192,7 +192,6 @@ struct arr_desc { extern char *truestr, *falsestr; -struct operand popop(), pushop(); -struct operand makeop(); -struct operand readlist(); /* read and return operand from list */ -struct operand sexa(); /* convert n:n:n string to sexagesimal */ +struct operand popop(void), pushop(struct operand *op); +struct operand makeop(char *str, int type); +struct operand sexa(char *); /* convert n:n:n string to sexagesimal */ diff --git a/pkg/ecl/param.c b/pkg/ecl/param.c index 43570e962..db769b865 100644 --- a/pkg/ecl/param.c +++ b/pkg/ecl/param.c @@ -717,7 +717,7 @@ paramsrch (char *pkname, char *ltname, char *pname) { register struct param *pp; struct pfile *pfp; - struct param *lookup_param(); + struct param *lookup_param(char *pkname, char *ltname, char *pname); /* First search for a regular parameter. If this fails then we * handle the case when currentask has no pfile. diff --git a/pkg/ecl/param.h b/pkg/ecl/param.h index 4e9d81182..728b8f05e 100644 --- a/pkg/ecl/param.h +++ b/pkg/ecl/param.h @@ -200,21 +200,21 @@ struct pfile { #define V_FILE 9 -char *nextfield(); /* cracks next pfile line field */ -char *makelower(); /* upper to lower, in place and return */ - -struct param *paramfind(); /* searches for a param on a given pfile*/ -struct param *paramsrch(); /* search, make sure param is there */ -struct param *lookup_param(); /* search standard path for a param */ -struct param *newparam(); /* allocate and link a new param */ -struct param *addparam(); /* make a new param off given pfile */ -struct param *newfakeparam(); /* add a fake param to pfile */ -struct pfile *pfilesrch(); /* read named pfile or ltask pfile */ -struct pfile *pfileload(); /* load pfile for ltask into memory */ -struct pfile *pfileread(); /* read and make params from a pfile */ -struct pfile *pfilefind(); /* look for pfile with given name */ -struct pfile *newpfile(); /* add a new pfile off parhead */ -struct pfile *pfilecopy(); /* make an in-core copy of a pfile */ - -int defpar(); /* determine whether param exists */ -int defvar(); /* determine whether envvar exists */ +char *nextfield(char **pp, FILE *fp); /* cracks next pfile line field */ +char *makelower(register char *cp); /* upper to lower, in place and return */ + +struct param *paramfind(struct pfile *pfp, char *pname, int pos, int exact); /* searches for a param on a given pfile*/ +struct param *paramsrch(char *pkname, char *ltname, char *pname); /* search, make sure param is there */ +struct param *lookup_param(char *pkname, char *ltname, char *pname); /* search standard path for a param */ +struct param *newparam(struct pfile *pfp); /* allocate and link a new param */ +struct param *addparam(struct pfile *pfp, char *buf, FILE *fp); /* make a new param off given pfile */ +struct param *newfakeparam(struct pfile *pfp, char *name, int pos, int type, int string_len); /* add a fake param to pfile */ +struct pfile *pfilesrch(char *pfilepath); /* read named pfile or ltask pfile */ +struct pfile *pfileload(register struct ltask *ltp); /* load pfile for ltask into memory */ +struct pfile *pfileread(struct ltask *ltp, char *pfilename, int checkmode); /* read and make params from a pfile */ +struct pfile *pfilefind(register struct ltask *ltp); /* look for pfile with given name */ +struct pfile *newpfile(struct ltask *ltp); /* add a new pfile off parhead */ +struct pfile *pfilecopy(register struct pfile *pfp); /* make an in-core copy of a pfile */ + +int defpar(char *param_spec); /* determine whether param exists */ +int defvar(char *envvar); /* determine whether envvar exists */ diff --git a/pkg/ecl/pfiles.c b/pkg/ecl/pfiles.c index 3ade4d3b2..347fec1a7 100644 --- a/pkg/ecl/pfiles.c +++ b/pkg/ecl/pfiles.c @@ -30,8 +30,8 @@ extern char *nullstr; extern char *indefstr, *indeflc; extern FILE *yyin; char *uparmdir = UPARM; -long filetime(); -static void mapname(); +long filetime(char *fname, char *timecode); +static void mapname(char *in, char *out, int maxlen); /* NEWPFILE -- Allocate a new pfile on the dictionary and link in at parhead. diff --git a/pkg/ecl/prcache.c b/pkg/ecl/prcache.c index 90d19f87d..021ba83d4 100644 --- a/pkg/ecl/prcache.c +++ b/pkg/ecl/prcache.c @@ -88,7 +88,7 @@ int pr_pno = 1; /* incremented for each connect */ int sz_prcache = 2; /* nprocess slots in cache */ struct process pr_cache[MAXSUBPROC]; struct process *pr_head = NULL, *pr_tail = NULL; -extern char *findexe(); +extern char *findexe(struct package *pkg, char *pkg_path); static void pr_pdisconnect (struct process *pr); static void pr_tohead (struct process *pr); @@ -193,7 +193,7 @@ pr_pconnect ( ) { struct process *pr; - struct process *pr_findproc(); + struct process *pr_findproc(char *process); struct _finfo fi; int fd_in, fd_out; diff --git a/pkg/ecl/proto.h b/pkg/ecl/proto.h index cdb9f02fe..95b416d6f 100644 --- a/pkg/ecl/proto.h +++ b/pkg/ecl/proto.h @@ -259,7 +259,7 @@ extern void putlog(struct task *tp, char *usermsg); /* lexicon.c */ extern int yylex(void); extern int lexicon(void); -extern int lexinit(void); +extern void lexinit(void); /* lists.c */ extern struct operand readlist(struct param *pp); extern void closelist(register struct param *pp); diff --git a/pkg/ecl/task.h b/pkg/ecl/task.h index 4eb18e9a8..3e687e60a 100644 --- a/pkg/ecl/task.h +++ b/pkg/ecl/task.h @@ -218,8 +218,8 @@ struct package { #define PACKAGESIZ btoi (sizeof (struct package)) #define TCALLSIZ btoi (sizeof (struct task_call)) -struct package *newpac(), *pacfind(); -struct ltask *addltask(), *newltask(), *ltaskfind(), *cmdsrch(); -struct ltask *ltasksrch(), *_ltasksrch(); -struct task *pushtask(), *poptask(); -int deftask(), defpac(); +struct package *newpac(char *name, char *bin), *pacfind(char *name); +struct ltask *addltask(struct package *pkp, char *ptname, char *ltname, int redef), *newltask(register struct package *pkp, char *lname, char *pname, struct ltask *oldltp), *ltaskfind(struct package *pkp, char *name, int enable_abbreviations), *cmdsrch(char *pkname, char *ltname); +struct ltask *ltasksrch(char *pkname, char *ltname), *_ltasksrch(char *pkname, char *ltname, struct package **o_pkp); +struct task *pushtask(void), *poptask(void); +int deftask(char *task_spec), defpac(char *pkname); From a000f54d7dcca2d037438ae534d334a7f412e8db Mon Sep 17 00:00:00 2001 From: Ole Streicher Date: Mon, 8 Apr 2024 12:21:47 +0200 Subject: [PATCH 2/6] Remove local function declarations (already declared in header files) envget() is already declared in unix/hlib/libc/iraf_libc.h --- pkg/cl/builtin.c | 1 - pkg/cl/exec.c | 2 -- pkg/cl/gram.c | 6 ------ pkg/cl/grammar.y | 3 --- pkg/cl/main.c | 2 +- pkg/cl/modes.c | 3 +-- pkg/cl/pfiles.c | 2 +- pkg/ecl/builtin.c | 2 +- pkg/ecl/decl.c | 2 +- pkg/ecl/errs.c | 2 +- pkg/ecl/exec.c | 2 -- pkg/ecl/gram.c | 6 ------ pkg/ecl/grammar.y | 3 --- pkg/ecl/main.c | 2 +- pkg/ecl/modes.c | 3 +-- pkg/ecl/pfiles.c | 2 +- 16 files changed, 9 insertions(+), 34 deletions(-) diff --git a/pkg/cl/builtin.c b/pkg/cl/builtin.c index be65f31bf..f8daf185b 100644 --- a/pkg/cl/builtin.c +++ b/pkg/cl/builtin.c @@ -1900,7 +1900,6 @@ cledit (void) char oscmd[SZ_LINE], os_filelist[SZ_LINE]; char osfn[SZ_PATHNAME]; struct operand o; - char *envget(); int n; pfp = newtask->t_pfp; diff --git a/pkg/cl/exec.c b/pkg/cl/exec.c index e8c688a53..35e4b1d9a 100644 --- a/pkg/cl/exec.c +++ b/pkg/cl/exec.c @@ -255,7 +255,6 @@ execnewtask (void) static struct pfile *pfp; struct param *pp; - FILE *fopen(); if (newtask == NULL) /* if this ever happens, i don't want to know about it. */ @@ -684,7 +683,6 @@ findexe ( char root[SZ_FNAME+1], root_path[SZ_PATHNAME+1]; char bindir[SZ_FNAME+1], *ip = NULL, *arch = NULL; char bin_root[SZ_PATHNAME+1]; - char *envget(); memset (root, 0, SZ_FNAME); diff --git a/pkg/cl/gram.c b/pkg/cl/gram.c index ec929f530..9199d2933 100644 --- a/pkg/cl/gram.c +++ b/pkg/cl/gram.c @@ -40,7 +40,6 @@ extern int cldebug; extern int inarglist; /* set by parser when in argument list */ extern int parenlevel; /* nesting level of parens */ -extern int get_nscanval(); int pipetable[MAXPIPES]; /* for maintaining pipe temp files */ int nextpipe = 0; @@ -862,7 +861,6 @@ char * addpipe (void) { static int pipecode = 0; - char *pipefile(); if (pipecode == 0) pipecode = c_getpid(); @@ -903,8 +901,6 @@ addpipe (void) char * getpipe (void) { - char *pipefile(); - if (nextpipe == 0) cl_error (E_IERR, "Pipestack underflow"); return (pipefile (pipetable[nextpipe-1])); @@ -919,7 +915,6 @@ void delpipes (register int npipes) { register int pipe; - char *pipefile(); if (npipes == 0) { while (nextpipe > 0) @@ -942,7 +937,6 @@ pipefile (int pipecode) { static char fname[SZ_PIPEFILENAME+1]; char *dir; - char *envget(); /* Put pipefiles in 'pipes' or 'uparm' if defined, else use tmp. Do * not put pipe files in current directory or pipe commands will fail diff --git a/pkg/cl/grammar.y b/pkg/cl/grammar.y index b59b8db84..9f7304373 100644 --- a/pkg/cl/grammar.y +++ b/pkg/cl/grammar.y @@ -99,9 +99,6 @@ extern char cmdblk[SZ_CMDBLK+1]; /* Command buffer in history.c */ extern char *ip_cmdblk; /* Pointer to current char in command.*/ extern char *err_cmdblk; /* ip_cmdblk when error detected. */ -struct param *initparam(); -struct label *getlabel(), *setlabel(); - /* arbitrary large number for bracelevel in a procedure script */ #define MAX_ERR 10 diff --git a/pkg/cl/main.c b/pkg/cl/main.c index b638f1eda..36ba3ef01 100644 --- a/pkg/cl/main.c +++ b/pkg/cl/main.c @@ -89,7 +89,7 @@ static void login(char *cmd), logout(void); static void startup(void), shutdown(void); static void onint (int *vex, int (**next_handler)(void)); -extern int yyparse(); +extern int yyparse(void); /* C_MAIN -- Called by the SPP procedure in cl.x to fire up the CL. diff --git a/pkg/cl/modes.c b/pkg/cl/modes.c index fd9801e17..540e4b62e 100644 --- a/pkg/cl/modes.c +++ b/pkg/cl/modes.c @@ -751,7 +751,7 @@ bkg_query ( { char bqfile[SZ_PATHNAME], qrfile[SZ_PATHNAME]; int waitime, delay; - char *envget(), *fgets_status; + char *fgets_status; FILE *fp, *in; if (notify()) @@ -866,7 +866,6 @@ void get_bkgqfiles (int bkgno, int pid, char *bkg_query_file, char *query_response_file) { int filecode; - char *envget(); if (envget (UPARM) == NULL) cl_error (E_UERR, diff --git a/pkg/cl/pfiles.c b/pkg/cl/pfiles.c index 347fec1a7..f3db7d610 100644 --- a/pkg/cl/pfiles.c +++ b/pkg/cl/pfiles.c @@ -511,7 +511,7 @@ pfileread ( goto error_; } else if (procscript (fp)) { - extern int yyparse (); + extern int yyparse (void); /* Parse the declarations section of a procedure script. * The procscript() call leaves us positioned to the procedure diff --git a/pkg/ecl/builtin.c b/pkg/ecl/builtin.c index 9dcfdd123..3a476c3af 100644 --- a/pkg/ecl/builtin.c +++ b/pkg/ecl/builtin.c @@ -2013,7 +2013,7 @@ cledit (void) char oscmd[SZ_LINE], os_filelist[SZ_LINE]; char osfn[SZ_PATHNAME]; struct operand o; - char *envget(); + char *envget(char *name); int n; pfp = newtask->t_pfp; diff --git a/pkg/ecl/decl.c b/pkg/ecl/decl.c index a58f80ffa..1f019287a 100644 --- a/pkg/ecl/decl.c +++ b/pkg/ecl/decl.c @@ -78,7 +78,7 @@ getlimits ( int get_dim (char *pname) { - struct param *pp, *lookup_param(); + struct param *pp; char *pk, *t, *p, *f; int dim; diff --git a/pkg/ecl/errs.c b/pkg/ecl/errs.c index a8b9c6121..7409d13fe 100644 --- a/pkg/ecl/errs.c +++ b/pkg/ecl/errs.c @@ -348,7 +348,7 @@ cl_error (int errtype, char *diagstr, ...) void erract_init (void) { - char *act, *envget(); + char *act; char opt[SZ_LINE]; /* Parse the erract string to pick up new options. diff --git a/pkg/ecl/exec.c b/pkg/ecl/exec.c index 8a2c44067..8ecfc96e0 100644 --- a/pkg/ecl/exec.c +++ b/pkg/ecl/exec.c @@ -297,7 +297,6 @@ execnewtask (void) static struct pfile *pfp; struct param *pp; - FILE *fopen(); if (newtask == NULL) /* if this ever happens, i don't want to know about it. */ @@ -730,7 +729,6 @@ findexe ( char root[SZ_FNAME+1], root_path[SZ_PATHNAME+1]; char bindir[SZ_FNAME+1], *ip = NULL, *arch = NULL; char bin_root[SZ_PATHNAME+1]; - char *envget(); memset (root, 0, SZ_FNAME); diff --git a/pkg/ecl/gram.c b/pkg/ecl/gram.c index d557b60f7..1af23f264 100644 --- a/pkg/ecl/gram.c +++ b/pkg/ecl/gram.c @@ -44,7 +44,6 @@ extern int cldebug; extern int inarglist; /* set by parser when in argument list */ extern int parenlevel; /* nesting level of parens */ -extern int get_nscanval(); extern int do_error; /* runtime error handling */ int pipetable[MAXPIPES]; /* for maintaining pipe temp files */ int nextpipe = 0; @@ -1055,7 +1054,6 @@ char * addpipe (void) { static int pipecode = 0; - char *pipefile(); if (pipecode == 0) pipecode = c_getpid(); @@ -1096,8 +1094,6 @@ addpipe (void) char * getpipe (void) { - char *pipefile(); - if (nextpipe == 0) cl_error (E_IERR, "Pipestack underflow"); return (pipefile (pipetable[nextpipe-1])); @@ -1112,7 +1108,6 @@ void delpipes (register int npipes) { register int pipe; - char *pipefile(); if (npipes == 0) { while (nextpipe > 0) @@ -1135,7 +1130,6 @@ pipefile (int pipecode) { static char fname[SZ_PIPEFILENAME+1]; char *dir; - char *envget(); /* Put pipefiles in 'pipes' or 'uparm' if defined, else use tmp. Do * not put pipe files in current directory or pipe commands will fail diff --git a/pkg/ecl/grammar.y b/pkg/ecl/grammar.y index 63835d728..f27b99919 100644 --- a/pkg/ecl/grammar.y +++ b/pkg/ecl/grammar.y @@ -105,9 +105,6 @@ extern char cmdblk[SZ_CMDBLK+1]; /* Command buffer in history.c */ extern char *ip_cmdblk; /* Pointer to current char in command.*/ extern char *err_cmdblk; /* ip_cmdblk when error detected. */ -struct param *initparam(); -struct label *getlabel(), *setlabel(); - /* arbitrary large number for bracelevel in a procedure script */ #define MAX_ERR 10 diff --git a/pkg/ecl/main.c b/pkg/ecl/main.c index 05904f748..56b0681b9 100644 --- a/pkg/ecl/main.c +++ b/pkg/ecl/main.c @@ -92,7 +92,7 @@ static void startup(void), shutdown(void); static char *file_concat (char *in1, char *in2); static void onint (int *vex, int (**next_handler)(void)); -extern int yyparse(); +extern int yyparse(void); static char *tmpfile = NULL; extern char epar_cmdbuf[]; diff --git a/pkg/ecl/modes.c b/pkg/ecl/modes.c index 65ba0f4e2..e818a43d7 100644 --- a/pkg/ecl/modes.c +++ b/pkg/ecl/modes.c @@ -751,7 +751,7 @@ bkg_query ( { char bqfile[SZ_PATHNAME], qrfile[SZ_PATHNAME]; int waitime, delay; - char *envget(), *fgets_status; + char *fgets_status; FILE *fp, *in; if (notify()) @@ -866,7 +866,6 @@ void get_bkgqfiles (int bkgno, int pid, char *bkg_query_file, char *query_response_file) { int filecode; - char *envget(); if (envget (UPARM) == NULL) cl_error (E_UERR, diff --git a/pkg/ecl/pfiles.c b/pkg/ecl/pfiles.c index 347fec1a7..f3db7d610 100644 --- a/pkg/ecl/pfiles.c +++ b/pkg/ecl/pfiles.c @@ -511,7 +511,7 @@ pfileread ( goto error_; } else if (procscript (fp)) { - extern int yyparse (); + extern int yyparse (void); /* Parse the declarations section of a procedure script. * The procscript() call leaves us positioned to the procedure From a74ed391b8340e1acd1e5f992caa08c1f9fb6f18 Mon Sep 17 00:00:00 2001 From: Ole Streicher Date: Mon, 8 Apr 2024 11:13:57 +0200 Subject: [PATCH 3/6] Fix abuse of NULL as integer in CL and ECL --- pkg/cl/binop.c | 4 ++-- pkg/cl/builtin.c | 2 +- pkg/cl/eparam.c | 2 +- pkg/cl/grammar.y | 2 +- pkg/cl/prcache.c | 6 +++--- pkg/ecl/binop.c | 4 ++-- pkg/ecl/builtin.c | 2 +- pkg/ecl/eparam.c | 2 +- pkg/ecl/grammar.y | 2 +- pkg/ecl/prcache.c | 6 +++--- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/cl/binop.c b/pkg/cl/binop.c index 10dd6882d..5ddc2e128 100644 --- a/pkg/cl/binop.c +++ b/pkg/cl/binop.c @@ -326,7 +326,7 @@ binop (int opcode) first_char = o1.o_val.v_s[0]; /* Null patterns match any string. */ - if (first_char == NULL) { + if (first_char == '\0') { result.o_val.v_i = 1; result.o_type = OT_INT; goto pushresult; @@ -368,7 +368,7 @@ binop (int opcode) first_char = o1.o_val.v_s[0]; /* Null patterns match any string. */ - if (first_char == NULL) { + if (first_char == '\0') { result.o_val.v_i = 1; result.o_type = OT_INT; goto pushresult; diff --git a/pkg/cl/builtin.c b/pkg/cl/builtin.c index f8daf185b..db2e4e4f1 100644 --- a/pkg/cl/builtin.c +++ b/pkg/cl/builtin.c @@ -266,7 +266,7 @@ cl_locate (char *task_spec, int first_only) } } - if (found == NULL) + if (found == 0) oprintf ("%s: task not found.\n", task_spec); else oprintf ("\n"); diff --git a/pkg/cl/eparam.c b/pkg/cl/eparam.c index 49094e634..70f495215 100644 --- a/pkg/cl/eparam.c +++ b/pkg/cl/eparam.c @@ -452,7 +452,7 @@ e_repaint (void) * label columns (if desired). */ p = parmlist[keyid]->p_prompt; - if (p == NULL || *p == NULL) + if (p == NULL || *p == '\0') p = static_prompt; /* e_indent_prompt (p, promptbuf, startcol); */ diff --git a/pkg/cl/grammar.y b/pkg/cl/grammar.y index 9f7304373..1d1469d78 100644 --- a/pkg/cl/grammar.y +++ b/pkg/cl/grammar.y @@ -1189,7 +1189,7 @@ arg : /* nothing - compile a null posargset to bump nargs */ */ breakout (stkop($1)->o_val.v_s, &pk, &t, &p, &f); pfp = currentask->t_pfp; - if (*pk == NULL && *t == NULL && + if (*pk == '\0' && *t == '\0' && pfp && paramfind(pfp,p,0,1)) { sprintf (pname, "%s.%s", diff --git a/pkg/cl/prcache.c b/pkg/cl/prcache.c index a682b6b85..d7f063bd3 100644 --- a/pkg/cl/prcache.c +++ b/pkg/cl/prcache.c @@ -127,7 +127,7 @@ pr_connect ( register int pid; /* Connect subprocess. */ - if ((pid = pr_pconnect (process, in, out)) == NULL) + if ((pid = pr_pconnect (process, in, out)) == 0) c_erract (EA_ERROR); @@ -225,7 +225,7 @@ pr_pconnect ( /* Get process slot. */ for (pr=pr_tail; pr != NULL; pr=pr->pr_up) if (!pr_busy(pr)) { - if (pr->pr_pid != NULL) + if (pr->pr_pid != 0) pr_pdisconnect (pr); break; } @@ -239,7 +239,7 @@ pr_pconnect ( if (cltrace) eprintf ("\t----- connect to %s -----\n", process); intr_disable(); - if ((pr->pr_pid = c_propen (process, &fd_in, &fd_out)) == NULL) { + if ((pr->pr_pid = c_propen (process, &fd_in, &fd_out)) == 0) { intr_enable(); return (0); } diff --git a/pkg/ecl/binop.c b/pkg/ecl/binop.c index 06cff695e..aad9ca8d4 100644 --- a/pkg/ecl/binop.c +++ b/pkg/ecl/binop.c @@ -371,7 +371,7 @@ binop (int opcode) first_char = o1.o_val.v_s[0]; /* Null patterns match any string. */ - if (first_char == NULL) { + if (first_char == '\0') { result.o_val.v_i = 1; result.o_type = OT_INT; goto pushresult; @@ -413,7 +413,7 @@ binop (int opcode) first_char = o1.o_val.v_s[0]; /* Null patterns match any string. */ - if (first_char == NULL) { + if (first_char == '\0') { result.o_val.v_i = 1; result.o_type = OT_INT; goto pushresult; diff --git a/pkg/ecl/builtin.c b/pkg/ecl/builtin.c index 3a476c3af..212770a4f 100644 --- a/pkg/ecl/builtin.c +++ b/pkg/ecl/builtin.c @@ -270,7 +270,7 @@ cl_locate (char *task_spec, int first_only) } } - if (found == NULL) + if (found == 0) oprintf ("%s: task not found.\n", task_spec); else oprintf ("\n"); diff --git a/pkg/ecl/eparam.c b/pkg/ecl/eparam.c index 4047e34c7..b39001b58 100644 --- a/pkg/ecl/eparam.c +++ b/pkg/ecl/eparam.c @@ -463,7 +463,7 @@ e_repaint (void) * label columns (if desired). */ p = parmlist[keyid]->p_prompt; - if (p == NULL || *p == NULL) + if (p == NULL || *p == '\0') p = static_prompt; /* e_indent_prompt (p, promptbuf, startcol); */ diff --git a/pkg/ecl/grammar.y b/pkg/ecl/grammar.y index f27b99919..63a896209 100644 --- a/pkg/ecl/grammar.y +++ b/pkg/ecl/grammar.y @@ -1204,7 +1204,7 @@ arg : /* nothing - compile a null posargset to bump nargs */ */ breakout (stkop($1)->o_val.v_s, &pk, &t, &p, &f); pfp = currentask->t_pfp; - if (*pk == NULL && *t == NULL && + if (*pk == '\0' && *t == '\0' && pfp && paramfind(pfp,p,0,1)) { sprintf (pname, "%s.%s", diff --git a/pkg/ecl/prcache.c b/pkg/ecl/prcache.c index 021ba83d4..071c88fc1 100644 --- a/pkg/ecl/prcache.c +++ b/pkg/ecl/prcache.c @@ -127,7 +127,7 @@ pr_connect ( register int pid; /* Connect subprocess. */ - if ((pid = pr_pconnect (process, in, out)) == NULL) + if ((pid = pr_pconnect (process, in, out)) == 0) c_erract (EA_ERROR); @@ -225,7 +225,7 @@ pr_pconnect ( /* Get process slot. */ for (pr=pr_tail; pr != NULL; pr=pr->pr_up) if (!pr_busy(pr)) { - if (pr->pr_pid != NULL) + if (pr->pr_pid != 0) pr_pdisconnect (pr); break; } @@ -239,7 +239,7 @@ pr_pconnect ( if (cltrace) eprintf ("\t----- connect to %s -----\n", process); intr_disable(); - if ((pr->pr_pid = c_propen (process, &fd_in, &fd_out)) == NULL) { + if ((pr->pr_pid = c_propen (process, &fd_in, &fd_out)) == 0) { intr_enable(); return (0); } From b664f7056a1a18b495edef968227ef6cc79c6943 Mon Sep 17 00:00:00 2001 From: Ole Streicher Date: Mon, 8 Apr 2024 11:32:37 +0200 Subject: [PATCH 4/6] Fix potential unused variables in (e)cl --- pkg/cl/eparam.c | 2 +- pkg/cl/lexicon.c | 2 +- pkg/ecl/eparam.c | 2 +- pkg/ecl/grammar.y | 2 -- pkg/ecl/lexicon.c | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/cl/eparam.c b/pkg/cl/eparam.c index 70f495215..25d778e08 100644 --- a/pkg/cl/eparam.c +++ b/pkg/cl/eparam.c @@ -1141,7 +1141,7 @@ editstring ( int eparam /* flag to indicate eparam or ehis */ ) { - char oldchar; /* save old character after delete */ + char oldchar = '\0'; /* save old character after delete */ char oldword[G_MAXSTRING]; /* save the deleted word */ char oldline[G_MAXSTRING]; /* save the deleted line */ char tempstr[G_MAXSTRING]; diff --git a/pkg/cl/lexicon.c b/pkg/cl/lexicon.c index 1ef58c512..18093bb7c 100644 --- a/pkg/cl/lexicon.c +++ b/pkg/cl/lexicon.c @@ -148,7 +148,7 @@ lexicon (void) char *bkgerr = "ERROR: cannot submit background job inside {}\n"; register int ch, cch; register int token; - int stringtok, identifier, setlevel; + int stringtok = 1, identifier = 1, setlevel = 0; int clswitch; char *op; diff --git a/pkg/ecl/eparam.c b/pkg/ecl/eparam.c index b39001b58..52b55e480 100644 --- a/pkg/ecl/eparam.c +++ b/pkg/ecl/eparam.c @@ -1152,7 +1152,7 @@ editstring ( int eparam /* flag to indicate eparam or ehis */ ) { - char oldchar; /* save old character after delete */ + char oldchar = '\0'; /* save old character after delete */ char oldword[G_MAXSTRING]; /* save the deleted word */ char oldline[G_MAXSTRING]; /* save the deleted line */ char tempstr[G_MAXSTRING]; diff --git a/pkg/ecl/grammar.y b/pkg/ecl/grammar.y index 63a896209..55c9de0ab 100644 --- a/pkg/ecl/grammar.y +++ b/pkg/ecl/grammar.y @@ -1142,8 +1142,6 @@ command : tasknam { } BARG { inarglist = 1; } args EARG { - extern char *onerr_handler; - inarglist = 0; parenlevel = 0; scanstmt = 0; diff --git a/pkg/ecl/lexicon.c b/pkg/ecl/lexicon.c index 6d84f7700..b987831cd 100644 --- a/pkg/ecl/lexicon.c +++ b/pkg/ecl/lexicon.c @@ -148,7 +148,7 @@ lexicon (void) char *bkgerr = "ERROR: cannot submit background job inside {}\n"; register int ch, cch; register int token; - int stringtok, identifier, setlevel; + int stringtok = 1, identifier = 1, setlevel = 0; int clswitch; char *op; From 6faf887c8e09ca8dca676e6cb3f39b150806af19 Mon Sep 17 00:00:00 2001 From: Ole Streicher Date: Mon, 8 Apr 2024 11:33:45 +0200 Subject: [PATCH 5/6] Use void* for malloc/calloc/realloc/free in sys/libc --- sys/libc/calloc.c | 2 +- sys/libc/free.c | 2 +- sys/libc/malloc.c | 4 ++-- sys/libc/realloc.c | 6 +++--- unix/hlib/libc/iraf_libc.h | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/libc/calloc.c b/sys/libc/calloc.c index f9a4f044d..5e5677a2b 100644 --- a/sys/libc/calloc.c +++ b/sys/libc/calloc.c @@ -10,7 +10,7 @@ /* CALLOC -- Allocate memory for NELEM elements of size ELSIZE bytes per ** element. The space is initialized to all zeros. */ -char * +void * calloc ( unsigned int nelems, unsigned int elsize diff --git a/sys/libc/free.c b/sys/libc/free.c index 4edd18c07..668825530 100644 --- a/sys/libc/free.c +++ b/sys/libc/free.c @@ -12,7 +12,7 @@ */ void free ( - char *buf + void *buf ) { XINT x_ptr, x_dtype = TY_CHAR; diff --git a/sys/libc/malloc.c b/sys/libc/malloc.c index af5506cfa..b5124d7c8 100644 --- a/sys/libc/malloc.c +++ b/sys/libc/malloc.c @@ -9,7 +9,7 @@ /* MALLOC -- Allocate an uninitialized block of memory at least nbytes in size. */ -char * +void * malloc ( unsigned nbytes ) @@ -20,5 +20,5 @@ malloc ( iferr (MALLOC (&x_ptr, &x_nchars, &x_dtype)) return (NULL); else - return ((char *)&Memc[x_ptr]); + return ((void *)&Memc[x_ptr]); } diff --git a/sys/libc/realloc.c b/sys/libc/realloc.c index 672cc7770..35986ed7d 100644 --- a/sys/libc/realloc.c +++ b/sys/libc/realloc.c @@ -11,9 +11,9 @@ ** allocated buffer. If necessary the buffer is moved, preserving any ** data in the buffer. */ -char * +void * realloc ( - char *buf, + void *buf, unsigned newsize ) { @@ -24,5 +24,5 @@ realloc ( iferr (REALLOC (&x_ptr, &x_nchars, &x_dtype)) return (NULL); else - return ((char *)&Memc[x_ptr]); + return ((void *)&Memc[x_ptr]); } diff --git a/unix/hlib/libc/iraf_libc.h b/unix/hlib/libc/iraf_libc.h index 4e68f6b38..f760a1184 100644 --- a/unix/hlib/libc/iraf_libc.h +++ b/unix/hlib/libc/iraf_libc.h @@ -124,14 +124,14 @@ extern char *c_cnvtime (long clktime, char *outstr, int maxch); extern char *c_getuid (char *outstr, int maxch); extern char *c_salloc (unsigned nbytes); extern char *c_strpak (short *sppstr, char *cstr, int maxch); -extern char *calloc (unsigned int nelems, unsigned int elsize); +extern void *calloc (unsigned int nelems, unsigned int elsize); extern char *envget (char *var); extern char *fgets (char *buf, int maxch, struct _iobuf *fp); extern char *gets (char *buf); -extern char *malloc (unsigned nbytes); +extern void *malloc (unsigned nbytes); extern char *mktemp (char *template); extern char *freadline (char *prompt); -extern char *realloc (char *buf, unsigned newsize); +extern void *realloc (void *buf, unsigned newsize); extern char *sprintf (char *str, char *format, ...); extern double atof (char *str); @@ -285,7 +285,7 @@ extern void c_xwhen (int exception, funcptr_t new_handler, funcptr_t *old_handle extern void eprintf (char *format, ...); extern void fprintf (struct _iobuf *fp, char *format, ...); extern void fputs (char *str, struct _iobuf *fp); -extern void free (char *buf); +extern void free (void *buf); extern void perror (char *prefix); extern void printf (char *format, ...); extern void setbuf (struct _iobuf *fp, char *buf); From e08228365c10d3dca9e86c98456b16416f5ba6ed Mon Sep 17 00:00:00 2001 From: Ole Streicher Date: Mon, 8 Apr 2024 14:11:24 +0200 Subject: [PATCH 6/6] Fix string array copy procedure in ecl/pfiles.c --- pkg/cl/pfiles.c | 6 +++--- pkg/ecl/pfiles.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/cl/pfiles.c b/pkg/cl/pfiles.c index f3db7d610..7408f9549 100644 --- a/pkg/cl/pfiles.c +++ b/pkg/cl/pfiles.c @@ -908,10 +908,10 @@ pfilecopy (register struct pfile *pfp) p = parrd->a_ptr.a_s; q = qarrd->a_ptr.a_s; - for (d=0; d < size_arr; d++) { + for (d=0; d < size_arr; d++, q++, p++) { *q = memneed (btoi(len)); - strncpy (*q++, *p++, len-1); - *(q+len-1) = '\0' ; + strncpy (*q, *p, len-1); + (*q)[len-1] = '\0'; } } diff --git a/pkg/ecl/pfiles.c b/pkg/ecl/pfiles.c index f3db7d610..7408f9549 100644 --- a/pkg/ecl/pfiles.c +++ b/pkg/ecl/pfiles.c @@ -908,10 +908,10 @@ pfilecopy (register struct pfile *pfp) p = parrd->a_ptr.a_s; q = qarrd->a_ptr.a_s; - for (d=0; d < size_arr; d++) { + for (d=0; d < size_arr; d++, q++, p++) { *q = memneed (btoi(len)); - strncpy (*q++, *p++, len-1); - *(q+len-1) = '\0' ; + strncpy (*q, *p, len-1); + (*q)[len-1] = '\0'; } }