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 - fix up function pointer casting mess - declare void functions void - use const for string constants - silence warnings about && and || precedence - use functions correctly - avoid implicit int --- ex_voper.c~ 2012-12-27 21:58:41.000000000 +0000 +++ ex_voper.c @@@@ -89,7 +89,35 @@@@ static char sccsid[] = "@@(#)ex_voper.c 1 cell vscandir[2] = { '/', 0 }; -int edge __P((void)); +static int edge __P((void)); + +static void +dovfilter(int ignore) +{ + (void)ignore; + vfilter(); +} + +static void +dovshftop(int ignore) +{ + (void)ignore; + vshftop(); +} + +static void +dovyankit(int ignore) +{ + (void)ignore; + vyankit(); +} + +static void +dobeep(int ignore) +{ + (void)ignore; + beep(); +} /* * Decode an operator/operand type command. @@@@ -101,14 +129,17 @@@@ int edge __P((void)); * and if wcursor is zero, then the first non-blank location of the * other line is implied. */ +void operate(c, cnt) register int c, cnt; { register int i = 0; - int (*moveop)(), (*deleteop)(); - int (*opf)(); + void (*volatile moveop)(int); + void (*deleteop)(int); + void (*opf)(int); bool subop = 0; - char *oglobp, *ocurs; + const char *oglobp; + char *ocurs; register line *addr; line *odot; static char lastFKND, lastFCHR; @@@@ -120,7 +151,8 @@@@ operate(c, cnt) qmarkcell[0] = '?'; slashcell[0] = '/'; nullcell[0] = qmarkcell[1] = slashcell[1] = 0; - moveop = vmove, deleteop = vdelete; + moveop = vmove_i; + deleteop = vdelete; wcursor = cursor; wdot = NOLINE; notecnt = 0; @@@@ -132,7 +164,7 @@@@ operate(c, cnt) */ case 'd': moveop = vdelete; - deleteop = beep; + deleteop = dobeep; break; /* @@@@ -147,18 +179,18 @@@@ operate(c, cnt) * c Change operator. */ case 'c': - if (c == 'c' && workcmd[0] == 'C' || workcmd[0] == 'S') + if ((c == 'c' && workcmd[0] == 'C') || workcmd[0] == 'S') subop++; moveop = vchange; - deleteop = beep; + deleteop = dobeep; break; /* * ! Filter through a UNIX command. */ case '!': - moveop = vfilter; - deleteop = beep; + moveop = dovfilter; + deleteop = dobeep; break; /* @@@@ -166,8 +198,8 @@@@ operate(c, cnt) * can be put back with p/P. Also yanks to named buffers. */ case 'y': - moveop = vyankit; - deleteop = beep; + moveop = dovyankit; + deleteop = dobeep; break; /* @@@@ -185,8 +217,8 @@@@ operate(c, cnt) */ case '<': case '>': - moveop = vshftop; - deleteop = beep; + moveop = dovshftop; + deleteop = dobeep; break; /* @@@@ -309,7 +341,7 @@@@ ein: #endif getDOT(); forbid(!i); - if (opf != vmove) + if (opf != vmove_i) if (dir > 0) wcursor++; else @@@@ -353,8 +385,8 @@@@ ein: */ case ',': forbid (lastFKND == 0); - c = isupper(cuc(lastFKND)) - ? tolower(lastFKND) : toupper(lastFKND); + c = isupper(cuc((unsigned char)lastFKND)) + ? tolower((unsigned char)lastFKND) : toupper((unsigned char)lastFKND); i = lastFCHR; if (vglobp == 0) vglobp = nullcell; @@@@ -415,7 +447,7 @@@@ ein: wcursor--; case 'f': fixup: - if (moveop != vmove) + if (moveop != vmove_i) wcursor++; break; } @@@@ -444,13 +476,13 @@@@ fixup: * $ To end of line. */ case '$': - if (opf == vmove) { + if (opf == vmove_i) { vmoving = 1; vmovcol = 20000; } else vmoving = 0; if (cnt > 1) { - if (opf == vmove) { + if (opf == vmove_i) { wcursor = 0; cnt--; } else @@@@ -480,10 +512,10 @@@@ fixup: */ case 'l': case ' ': - forbid (margin() || opf == vmove && edge()); + forbid (margin() || (opf == vmove_i && edge())); while (cnt > 0 && !margin()) wcursor += dir, cnt--; - if (margin() && opf == vmove || wcursor < linebuf) + if ((margin() && opf == vmove_i) || wcursor < linebuf) wcursor -= dir; vmoving = 0; break; @@@@ -520,7 +552,7 @@@@ deleteit: * Stuttered operators are equivalent to the operator on * a line, thus turn dd into d_. */ - if (opf == vmove || c != workcmd[0]) { + if (opf == vmove_i || c != workcmd[0]) { errlab: beep(); vmacp = 0; @@@@ -545,7 +577,7 @@@@ errlab: */ case 'H': wdot = (dot - vcline) + cnt - 1; - if (opf == vmove) + if (opf == vmove_i) markit(wdot); vmoving = 0; wcursor = 0; @@@@ -578,7 +610,7 @@@@ errlab: */ case 'L': wdot = dot + vcnt - vcline - cnt; - if (opf == vmove) + if (opf == vmove_i) markit(wdot); vmoving = 0; wcursor = 0; @@@@ -589,7 +621,7 @@@@ errlab: */ case 'M': wdot = dot + ((vcnt + 1) / 2) - vcline - 1; - if (opf == vmove) + if (opf == vmove_i) markit(wdot); vmoving = 0; wcursor = 0; @@@@ -656,7 +688,7 @@@@ errlab: forbid (Xhadcnt); vmoving = 0; wcursor = d == '`' ? ncols[c - 'a'] : 0; - if (opf == vmove && (wdot != dot || (d == '`' && wcursor != cursor))) + if (opf == vmove_i && (wdot != dot || (d == '`' && wcursor != cursor))) markDOT(); if (wcursor) { vsave(); @@@@ -678,7 +710,7 @@@@ errlab: cnt = lineDOL(); wdot = zero + cnt; forbid (wdot < one || wdot > dol); - if (opf == vmove) + if (opf == vmove_i) markit(wdot); vmoving = 0; wcursor = 0; @@@@ -765,7 +797,7 @@@@ slerr: wcursor = loc1; if (i != 0) vsetsiz(i); - if (opf == vmove) { + if (opf == vmove_i) { if (state == ONEOPEN || state == HARDOPEN) outline = destline = WBOT; if (addr != dot || loc1 != cursor) @@@@ -804,7 +836,8 @@@@ slerr: /* * Find single character c, in direction dir from cursor. */ -find(c) +int +find(int c) { for(;;) { @@@@ -820,8 +853,9 @@@@ find(c) * Do a word motion with operator op, and cnt more words * to go after this. */ +int word(op, cnt) - register int (*op)(); + register void (*op)(int); int cnt; { register int which = 0; @@@@ -832,7 +866,7 @@@@ word(op, cnt) iwc = wcursor; which = wordch(wcursor); while (wordof(which, wcursor)) { - if (cnt == 1 && op != vmove && wcursor[1] == 0) { + if (cnt == 1 && op != vmove_i && wcursor[1] == 0) { wcursor++; break; } @@@@ -848,7 +882,7 @@@@ word(op, cnt) else if (wcursor == iwc && iwdot == wdot && *iwc) wcursor++; - if (op == vmove && margin()) + if (op == vmove_i && margin()) wcursor--; } else { if (!lnext()) @@@@ -871,8 +905,9 @@@@ word(op, cnt) * To end of word, with operator op and cnt more motions * remaining after this. */ +void eend(op) - register int (*op)(); + register void (*op)(int); { register int which; @@@@ -898,8 +933,8 @@@@ eend(op) * Wordof tells whether the character at *wc is in a word of * kind which (blank/nonblank words are 0, conservative words 1). */ -wordof(which, wc) - register char *wc; +int +wordof(int which, register char *wc) { if (isspace(cuc(*wc))) @@@@ -911,12 +946,13 @@@@ wordof(which, wc) * Wordch tells whether character at *wc is a word character * i.e. an alfa, digit, or underscore. */ +int wordch(wc) char *wc; { register int c; - c = wc[0]; + c = (unsigned char)wc[0]; return (isalpha(c) || isdigit(c) || c == '_' #ifdef BIT8 #ifdef ISO8859_1 @@@@ -935,7 +971,8 @@@@ wordch(wc) /* * Edge tells when we hit the last character in the current line. */ -edge() +static int +edge(void) { if (linebuf[0] == 0) @@@@ -949,7 +986,8 @@@@ edge() /* * Margin tells us when we have fallen off the end of the line. */ -margin() +int +margin(void) { return (wcursor < linebuf || wcursor[0] == 0); @