head 1.1; access; symbols pkgsrc-2026Q1:1.1.0.108 pkgsrc-2026Q1-base:1.1 pkgsrc-2025Q4:1.1.0.106 pkgsrc-2025Q4-base:1.1 pkgsrc-2025Q3:1.1.0.104 pkgsrc-2025Q3-base:1.1 pkgsrc-2025Q2:1.1.0.102 pkgsrc-2025Q2-base:1.1 pkgsrc-2025Q1:1.1.0.100 pkgsrc-2025Q1-base:1.1 pkgsrc-2024Q4:1.1.0.98 pkgsrc-2024Q4-base:1.1 pkgsrc-2024Q3:1.1.0.96 pkgsrc-2024Q3-base:1.1 pkgsrc-2024Q2:1.1.0.94 pkgsrc-2024Q2-base:1.1 pkgsrc-2024Q1:1.1.0.92 pkgsrc-2024Q1-base:1.1 pkgsrc-2023Q4:1.1.0.90 pkgsrc-2023Q4-base:1.1 pkgsrc-2023Q3:1.1.0.88 pkgsrc-2023Q3-base:1.1 pkgsrc-2023Q2:1.1.0.86 pkgsrc-2023Q2-base:1.1 pkgsrc-2023Q1:1.1.0.84 pkgsrc-2023Q1-base:1.1 pkgsrc-2022Q4:1.1.0.82 pkgsrc-2022Q4-base:1.1 pkgsrc-2022Q3:1.1.0.80 pkgsrc-2022Q3-base:1.1 pkgsrc-2022Q2:1.1.0.78 pkgsrc-2022Q2-base:1.1 pkgsrc-2022Q1:1.1.0.76 pkgsrc-2022Q1-base:1.1 pkgsrc-2021Q4:1.1.0.74 pkgsrc-2021Q4-base:1.1 pkgsrc-2021Q3:1.1.0.72 pkgsrc-2021Q3-base:1.1 pkgsrc-2021Q2:1.1.0.70 pkgsrc-2021Q2-base:1.1 pkgsrc-2021Q1:1.1.0.68 pkgsrc-2021Q1-base:1.1 pkgsrc-2020Q4:1.1.0.66 pkgsrc-2020Q4-base:1.1 pkgsrc-2020Q3:1.1.0.64 pkgsrc-2020Q3-base:1.1 pkgsrc-2020Q2:1.1.0.60 pkgsrc-2020Q2-base:1.1 pkgsrc-2020Q1:1.1.0.40 pkgsrc-2020Q1-base:1.1 pkgsrc-2019Q4:1.1.0.62 pkgsrc-2019Q4-base:1.1 pkgsrc-2019Q3:1.1.0.58 pkgsrc-2019Q3-base:1.1 pkgsrc-2019Q2:1.1.0.56 pkgsrc-2019Q2-base:1.1 pkgsrc-2019Q1:1.1.0.54 pkgsrc-2019Q1-base:1.1 pkgsrc-2018Q4:1.1.0.52 pkgsrc-2018Q4-base:1.1 pkgsrc-2018Q3:1.1.0.50 pkgsrc-2018Q3-base:1.1 pkgsrc-2018Q2:1.1.0.48 pkgsrc-2018Q2-base:1.1 pkgsrc-2018Q1:1.1.0.46 pkgsrc-2018Q1-base:1.1 pkgsrc-2017Q4:1.1.0.44 pkgsrc-2017Q4-base:1.1 pkgsrc-2017Q3:1.1.0.42 pkgsrc-2017Q3-base:1.1 pkgsrc-2017Q2:1.1.0.38 pkgsrc-2017Q2-base:1.1 pkgsrc-2017Q1:1.1.0.36 pkgsrc-2017Q1-base:1.1 pkgsrc-2016Q4:1.1.0.34 pkgsrc-2016Q4-base:1.1 pkgsrc-2016Q3:1.1.0.32 pkgsrc-2016Q3-base:1.1 pkgsrc-2016Q2:1.1.0.30 pkgsrc-2016Q2-base:1.1 pkgsrc-2016Q1:1.1.0.28 pkgsrc-2016Q1-base:1.1 pkgsrc-2015Q4:1.1.0.26 pkgsrc-2015Q4-base:1.1 pkgsrc-2015Q3:1.1.0.24 pkgsrc-2015Q3-base:1.1 pkgsrc-2015Q2:1.1.0.22 pkgsrc-2015Q2-base:1.1 pkgsrc-2015Q1:1.1.0.20 pkgsrc-2015Q1-base:1.1 pkgsrc-2014Q4:1.1.0.18 pkgsrc-2014Q4-base:1.1 pkgsrc-2014Q3:1.1.0.16 pkgsrc-2014Q3-base:1.1 pkgsrc-2014Q2:1.1.0.14 pkgsrc-2014Q2-base:1.1 pkgsrc-2014Q1:1.1.0.12 pkgsrc-2014Q1-base:1.1 pkgsrc-2013Q4:1.1.0.10 pkgsrc-2013Q4-base:1.1 pkgsrc-2013Q3:1.1.0.8 pkgsrc-2013Q3-base:1.1 pkgsrc-2013Q2:1.1.0.6 pkgsrc-2013Q2-base:1.1 pkgsrc-2013Q1:1.1.0.4 pkgsrc-2013Q1-base:1.1 pkgsrc-2012Q4:1.1.0.2 pkgsrc-2012Q4-base:1.1; locks; strict; comment @# @; 1.1 date 2012.12.28.03.03.09; author dholland; state Exp; branches; next ; desc @@ 1.1 log @Fix legacy C. Pass -Wall -W -Wmissing-declarations -Wwrite-strings on gcc45. - avoid implicit int, declare void functions void - return values from non-void functions - put most external declarations properly in header files - use some static and const - fix up a big mess with function pointer casting - use standard includes, don't provide own decls of standard functions - use types matching libc when providing own malloc, printf, and putchar - use functions correctly - silence assorted compiler warnings - fix some bugs exposed by compiler warnings - don't intentionally exercise signed overflow - remove some unused items - add patch comments to other patch (patch-aa) As this includes several fixes and removes some undefined behavior on a commonly reachable code path, bump PKGREVISION. @ text @$NetBSD$ - declare local functions static - declare void functions void - avoid implicit int - use const for string constants - silence warnings about assignments in conditionals - silence warnings about && and || precedence - silence warnings about unused arguments --- ex_vget.c~ 2012-12-27 21:58:42.000000000 +0000 +++ ex_vget.c @@@@ -89,12 +89,13 @@@@ static char sccsid[] = "@@(#)ex_vget.c 1. * large changes which appears in the echo area. */ -int addto __P((cell *, char *)); -int fastpeekkey __P((void)); +static void addto __P((cell *, char *)); +static int fastpeekkey __P((void)); /* * Return the key. */ +void ungetkey(c) int c; /* mjm: char --> int */ { @@@@ -106,6 +107,7 @@@@ ungetkey(c) /* * Return a keystroke, but never a ^@@. */ +int getkey() { register int c; /* mjm: char --> int */ @@@@ -121,6 +123,7 @@@@ getkey() /* * Tell whether next keystroke would be a ^@@. */ +int peekbr() { @@@@ -139,13 +142,14 @@@@ int doingread = 0; * from repeating commands with .), and finally new * keystrokes. */ +int getbr() { char ch; register int c; #ifdef UCVISUAL register int d; - register char *colp; + register const char *colp; #endif #ifdef BEEHIVE int cnt; @@@@ -248,7 +252,7 @@@@ again: d = toupper(c); else { colp = "({)}!|^~'~"; - while (d = *colp++) + while ((d = *colp++) != 0) if (d == c) { d = *colp++; break; @@@@ -292,6 +296,7 @@@@ again: * Get a key, but if a delete, quit or attention * is typed return 0 so we will abort a partial command. */ +int getesc() { register int c; @@@@ -320,6 +325,7 @@@@ case_ATTN: /* * Peek at the next keystroke. */ +int peekkey() { @@@@ -331,7 +337,8 @@@@ peekkey() * Read a line from the echo area, with single character prompt c. * A return value of 1 means the user blewit or blewit away. */ -readecho(c) +int +readecho(int c) { register char *sc = cursor; register int (*OP)(); @@@@ -383,6 +390,7 @@@@ blewit: * the purposes of repeat, so copy it from * the working to the previous command buffer. */ +void setLAST() { @@@@ -400,6 +408,7 @@@@ setLAST() * If the insertion buffer oveflows, then destroy * the repeatability of the insert. */ +void addtext(cp) char *cp; { @@@@ -415,6 +424,7 @@@@ addtext(cp) lastcmd[0] = 0; } +void setDEL() { @@@@ -424,6 +434,7 @@@@ setDEL() /* * Put text from cursor upto wcursor in BUF. */ +void setBUF(BUF) register cell *BUF; { @@@@ -437,6 +448,7 @@@@ setBUF(BUF) *wp = c; } +static void addto(buf, str) register cell *buf; register char *str; @@@@ -467,12 +479,13 @@@@ addto(buf, str) * to do this for open modes now; return and save for later * notification in visual. */ +int noteit(must) bool must; { register int sdl = destline, sdc = destcol; - if (notecnt < 2 || !must && state == VISUAL) + if (notecnt < 2 || (!must && state == VISUAL)) return (0); splitw++; if (WBOT == WECHO) @@@@ -483,7 +496,7 @@@@ noteit(must) putchar('s'); if (*notenam) { printf(" %s", notenam); - if (*(strend(notenam) - 1) != 'e') + if (*(strendk(notenam) - 1) != 'e') putchar('e'); putchar('d'); } @@@@ -502,7 +515,8 @@@@ noteit(must) * Rrrrringgggggg. * If possible, use flash (VB). */ -beep() +void +beep(void) { if (VB && value(FLASH)) @@@@ -517,13 +531,14 @@@@ beep() * motions. I.e. on an adm3a we might map ^K to ^P. * DM1520 for example has a lot of mappable characters. */ - +int map(c,maps) register int c; register struct maps *maps; { register int d; - register char *p, *q; + register const char *p; + register char *q; char b[10]; /* Assumption: no keypad sends string longer than 10 */ /* @@@@ -559,7 +574,7 @@@@ map(c,maps) if (trace) fprintf(trace,"\ntry '%s', ",maps[d].cap); #endif - if (p = maps[d].cap) { + if ((p = maps[d].cap) != NULL) { for (q=b; *p; p++, q++) { #ifdef MDEBUG if (trace) @@@@ -633,8 +648,9 @@@@ map(c,maps) * is false for, for example, pushing back lookahead from fastpeekkey(), * since otherwise two fast escapes can clobber our undo. */ +void macpush(st, canundo) -char *st; +const char *st; int canundo; { char tmpbuf[BUFSIZ]; @@@@ -671,8 +687,8 @@@@ int canundo; } #ifdef TRACE -visdump(s) -char *s; +static void +visdump(const char *s) { register int i; @@@@ -688,8 +704,8 @@@@ char *s; tvliny(); } -vudump(s) -char *s; +void +vudump(const char *s) { register line *p; char savelb[1024]; @@@@ -717,6 +733,7 @@@@ char *s; * Get a count from the keyed input stream. * A zero count is indistinguishable from no count. */ +int vgetcnt() { register int c, cnt; @@@@ -734,8 +751,11 @@@@ vgetcnt() return(cnt); } -woid -trapalarm(signum) { +static woid +trapalarm(int signum) +{ + (void)signum; + alarm(0); if (vcatch) LONGJMP(vreslab,1); @@@@ -747,6 +767,7 @@@@ trapalarm(signum) { * a machine generated sequence (such as a function pad from an escape * flavor terminal) but fail for a human hitting escape then waiting. */ +static int fastpeekkey() { shand Oint; @