Thu Dec 27 06:13:20 2012 UTC ()
Clean up legacy C.
Now passes gcc -Wall -Wextra -Wmissing-declarations -Wwrite-strings on gcc45.
May build with clang now too.
Changes:
- use standard headers
- don't declare own errno, fopen(), getenv(), or malloc()
- declare own functions
- declare void functions void
- avoid implicit int
- use C89
- use some const
- use some static
- fix signed/unsigned mismatches
- call execl() properly
- don't cast return value of malloc
- initialize struct sigaction correctly
- use <ctype.h> functions correctly
- don't index arrays with (signed) char
- don't put function declarations inside function bodies
- patch up two uninitialized variables
- silence some compiler warnings that are not bugs
- remove some unused objects
and:
- add patch comments for preexisting patches
- correct some minor pkglint
As a couple of these things fixed bugs (e.g. the execl calls), bump
PKGREVISION.
(dholland)
diff -r1.6 -r1.7 pkgsrc/editors/mflteco/Makefile
diff -r1.2 -r1.3 pkgsrc/editors/mflteco/distinfo
diff -r1.1.1.1 -r1.2 pkgsrc/editors/mflteco/patches/patch-aa
diff -r1.1.1.1 -r1.2 pkgsrc/editors/mflteco/patches/patch-ab
diff -r1.1.1.1 -r1.2 pkgsrc/editors/mflteco/patches/patch-ac
diff -r1.1 -r1.2 pkgsrc/editors/mflteco/patches/patch-ad
diff -r1.1 -r1.2 pkgsrc/editors/mflteco/patches/patch-ae
diff -r0 -r1.1 pkgsrc/editors/mflteco/patches/patch-te__data.c
diff -r0 -r1.1 pkgsrc/editors/mflteco/patches/patch-te__exec0.c
diff -r0 -r1.1 pkgsrc/editors/mflteco/patches/patch-te__exec1.c
diff -r0 -r1.1 pkgsrc/editors/mflteco/patches/patch-te__fxstub.c
diff -r0 -r1.1 pkgsrc/editors/mflteco/patches/patch-te__main.c
diff -r0 -r1.1 pkgsrc/editors/mflteco/patches/patch-te__srch.c
diff -r0 -r1.1 pkgsrc/editors/mflteco/patches/patch-te__subs.c
diff -r0 -r1.1 pkgsrc/editors/mflteco/patches/patch-te__utils.c
diff -r0 -r1.1 pkgsrc/editors/mflteco/patches/patch-te__window.c
--- pkgsrc/editors/mflteco/Makefile 2012/10/03 11:43:37 1.6
+++ pkgsrc/editors/mflteco/Makefile 2012/12/27 06:13:20 1.7
| @@ -1,18 +1,19 @@ | | | @@ -1,18 +1,19 @@ |
1 | # $NetBSD: Makefile,v 1.6 2012/10/03 11:43:37 asau Exp $ | | 1 | # $NetBSD: Makefile,v 1.7 2012/12/27 06:13:20 dholland Exp $ |
2 | # | | 2 | # |
3 | | | 3 | |
4 | PKGNAME= mflteco-19920331 | | | |
5 | DISTNAME= mflteco | | 4 | DISTNAME= mflteco |
| | | 5 | PKGNAME= mflteco-19920331 |
| | | 6 | PKGREVISION= 1 |
6 | CATEGORIES= editors | | 7 | CATEGORIES= editors |
7 | MASTER_SITES= http://www.catb.org/~esr/retro/ | | 8 | MASTER_SITES= http://www.catb.org/~esr/retro/ |
8 | | | 9 | |
9 | MAINTAINER= is@NetBSD.org | | 10 | MAINTAINER= is@NetBSD.org |
10 | HOMEPAGE= http://www.catb.org/~esr/retro/ | | 11 | HOMEPAGE= http://www.catb.org/~esr/retro/ |
11 | COMMENT= MFL clone of Tape Editor and COrrector | | 12 | COMMENT= MFL clone of Tape Editor and COrrector |
12 | | | 13 | |
13 | BUILD_TARGET= te | | 14 | BUILD_TARGET= te |
14 | | | 15 | |
15 | INSTALLATION_DIRS= bin share/doc/mflteco share/examples/mflteco | | 16 | INSTALLATION_DIRS= bin share/doc/mflteco share/examples/mflteco |
16 | | | 17 | |
17 | pre-patch: | | 18 | pre-patch: |
18 | cp ${WRKSRC}/Makefile.sun4 ${WRKSRC}/Makefile | | 19 | cp ${WRKSRC}/Makefile.sun4 ${WRKSRC}/Makefile |
--- pkgsrc/editors/mflteco/distinfo 2006/01/05 19:27:50 1.2
+++ pkgsrc/editors/mflteco/distinfo 2012/12/27 06:13:20 1.3
| @@ -1,10 +1,19 @@ | | | @@ -1,10 +1,19 @@ |
1 | $NetBSD: distinfo,v 1.2 2006/01/05 19:27:50 joerg Exp $ | | 1 | $NetBSD: distinfo,v 1.3 2012/12/27 06:13:20 dholland Exp $ |
2 | | | 2 | |
3 | SHA1 (mflteco.tar.gz) = d32206d961fa7068afa5a36cf9e688a018622c11 | | 3 | SHA1 (mflteco.tar.gz) = d32206d961fa7068afa5a36cf9e688a018622c11 |
4 | RMD160 (mflteco.tar.gz) = 993ea515f87c17bafc763e3d7dcd55130cf7e83e | | 4 | RMD160 (mflteco.tar.gz) = 993ea515f87c17bafc763e3d7dcd55130cf7e83e |
5 | Size (mflteco.tar.gz) = 80566 bytes | | 5 | Size (mflteco.tar.gz) = 80566 bytes |
6 | SHA1 (patch-aa) = 3ee2c99f1a14c8f155faf866d29d070face206ab | | 6 | SHA1 (patch-aa) = 5dc29c16e9359a13869eb77d5a22bad70d1758ce |
7 | SHA1 (patch-ab) = bdeaa25511e11a8e39516eb2aa4c2dbea9f1cf9e | | 7 | SHA1 (patch-ab) = 2cbe2704775cdadbffadd24d9473a8707fd004e9 |
8 | SHA1 (patch-ac) = 052cf6f4ec6d03948543248f7bb9a872b00fb9f8 | | 8 | SHA1 (patch-ac) = 756afc8dc0cd82112f5b23731158fe64ae6b328c |
9 | SHA1 (patch-ad) = cc4a7ce57a28623427163a7607952149c015d8a7 | | 9 | SHA1 (patch-ad) = 48abfc5681209efedac5a1bda9c03371a0f85760 |
10 | SHA1 (patch-ae) = 94cc73f43245b997d8504564f3efe0b74e5e9fc0 | | 10 | SHA1 (patch-ae) = b8c2d78b6c04a9c819635c7ee3bc1e0b26130e5c |
| | | 11 | SHA1 (patch-te__data.c) = 86e1a8cb4a42c4d679df8931173b5651df30b35e |
| | | 12 | SHA1 (patch-te__exec0.c) = 91598104b0088a4cd16b2296a3ac9e97ace500c2 |
| | | 13 | SHA1 (patch-te__exec1.c) = bda2147de4d814fc57d31bc24f7406542478d162 |
| | | 14 | SHA1 (patch-te__fxstub.c) = 5821a4b9d97b1385efe351e9588938b662329239 |
| | | 15 | SHA1 (patch-te__main.c) = 7539eb9840b6611b4d283d5f49d4f107bc0f1999 |
| | | 16 | SHA1 (patch-te__srch.c) = f16a8c589b53ab639466fd3cfd9909685dff9d1b |
| | | 17 | SHA1 (patch-te__subs.c) = 311416b3984b796b49abd74f44311dcbd90af075 |
| | | 18 | SHA1 (patch-te__utils.c) = 99cddefd89fa40f0f60a1b197a57477d69799cff |
| | | 19 | SHA1 (patch-te__window.c) = 01a159d93d812fa3d40c6bc09b5575b050dac918 |
--- pkgsrc/editors/mflteco/patches/Attic/patch-aa 2005/12/28 22:29:17 1.1.1.1
+++ pkgsrc/editors/mflteco/patches/Attic/patch-aa 2012/12/27 06:13:20 1.2
| @@ -1,13 +1,15 @@ | | | @@ -1,13 +1,15 @@ |
1 | $NetBSD: patch-aa,v 1.1.1.1 2005/12/28 22:29:17 is Exp $ | | 1 | $NetBSD: patch-aa,v 1.2 2012/12/27 06:13:20 dholland Exp $ |
| | | 2 | |
| | | 3 | - add defines to enable standard things |
2 | | | 4 | |
3 | --- Makefile.orig 2005-12-28 22:07:58.000000000 +0100 | | 5 | --- Makefile.orig 2005-12-28 22:07:58.000000000 +0100 |
4 | +++ Makefile | | 6 | +++ Makefile |
5 | @@ -5,7 +5,7 @@ | | 7 | @@ -5,7 +5,7 @@ |
6 | # te_sunw makes teco to run in a Sun window | | 8 | # te_sunw makes teco to run in a Sun window |
7 | # te_tool makes teco to run either in its own window (TECOtool) or in a Sun window | | 9 | # te_tool makes teco to run either in its own window (TECOtool) or in a Sun window |
8 | # tt makes TECOtool | | 10 | # tt makes TECOtool |
9 | -CDF=-O -DMCH | | 11 | -CDF=-O -DMCH |
10 | +CDF=-O -DMCH -DWAITRET_INT -DPOSIX_TECO | | 12 | +CDF=-O -DMCH -DWAITRET_INT -DPOSIX_TECO |
11 | | | 13 | |
12 | te: te_data.o te_utils.o te_subs.o te_main.o te_rdcmd.o te_exec0.o te_exec1.o te_exec2.o \ | | 14 | te: te_data.o te_utils.o te_subs.o te_main.o te_rdcmd.o te_exec0.o te_exec1.o te_exec2.o \ |
13 | te_srch.o te_chario.o te_window.o te_fxstub.o | | 15 | te_srch.o te_chario.o te_window.o te_fxstub.o |
--- pkgsrc/editors/mflteco/patches/patch-ab 2005/12/28 22:29:17 1.1.1.1
+++ pkgsrc/editors/mflteco/patches/patch-ab 2012/12/27 06:13:20 1.2
| @@ -1,31 +1,220 @@ | | | @@ -1,31 +1,220 @@ |
1 | $NetBSD: patch-ab,v 1.1.1.1 2005/12/28 22:29:17 is Exp $ | | 1 | $NetBSD: patch-ab,v 1.2 2012/12/27 06:13:20 dholland Exp $ |
2 | | | 2 | |
3 | --- te_exec2.c.orig 1993-08-06 00:29:34.000000000 +0200 | | 3 | - use standard headers |
| | | 4 | - handle EOF from getc() correctly |
| | | 5 | - move function declarations to the header file |
| | | 6 | - use some static |
| | | 7 | - declare void functions void |
| | | 8 | - use some c89 |
| | | 9 | - don't index arrays with (signed) char |
| | | 10 | - call execl() properly |
| | | 11 | |
| | | 12 | --- te_exec2.c.orig 1993-08-05 22:29:34.000000000 +0000 |
4 | +++ te_exec2.c | | 13 | +++ te_exec2.c |
5 | @@ -42,7 +42,7 @@ VOID update_header(); | | 14 | @@ -19,6 +19,7 @@ |
| | | 15 | /* add directory command, header file display 03/26/92 14.59 */ |
| | | 16 | |
| | | 17 | #include "te_defs.h" |
| | | 18 | +#include <stdlib.h> |
| | | 19 | #include <sys/wait.h> |
| | | 20 | #include <sys/types.h> |
| | | 21 | #include <sys/stat.h> |
| | | 22 | @@ -35,21 +36,26 @@ struct outfiledata po_file, so_file; /* |
| | | 23 | struct outfiledata *outfile = &po_file; /* pointer to currently active output file structure */ |
| | | 24 | FILE *eisw; /* indirect command file pointer */ |
| | | 25 | int second_buff = 0; /* variable for which buffer is selected */ |
| | | 26 | -VOID init_wd(); |
| | | 27 | -VOID update_header(); |
| | | 28 | + |
| | | 29 | +static int do_e_slash(void); /* routine to handle "change directory" command */ |
| | | 30 | +static int read_stream(FILE *file, int *ff_found, struct qp *rbuff, |
| | | 31 | + int *nchars, int endsw, int crlf_sw, int ff_sw); |
| | | 32 | +static VOID write_stream(FILE *file, struct qp *wbuff, int nchars, |
| | | 33 | + int crlf_sw); |
| | | 34 | + |
| | | 35 | + |
| | | 36 | |
| | | 37 | /* process E commands */ |
6 | | | 38 | |
7 | do_e() | | 39 | -do_e() |
| | | 40 | +VOID do_e(void) |
8 | { | | 41 | { |
9 | - char c; /* temps */ | | 42 | - char c; /* temps */ |
10 | + int c; /* temps */ | | 43 | + int c; /* temps */ |
11 | int old_var; | | 44 | int old_var; |
12 | FILE *t_eisw; | | 45 | FILE *t_eisw; |
13 | struct stat statbuff; /* buffer to fetch file stat (mode) of open file for EB */ | | 46 | struct stat statbuff; /* buffer to fetch file stat (mode) of open file for EB */ |
14 | @@ -609,7 +609,7 @@ int do_glob(gbuff, sbuff) | | 47 | int t_access; /* result from provisional "open" */ |
| | | 48 | - int do_e_slash(); /* routine to handle "change directory" command */ |
| | | 49 | |
| | | 50 | - switch (mapch_l[getcmdc(trace_sw)]) /* read next character and dispatch */ |
| | | 51 | + switch (mapch_l[(unsigned char)getcmdc(trace_sw)]) /* read next character and dispatch */ |
| | | 52 | { |
| | | 53 | |
| | | 54 | /* numeric values */ |
| | | 55 | @@ -386,7 +392,7 @@ int do_eq() |
| | | 56 | t = vfork(); /* fork a new process */ |
| | | 57 | if (t == 0) /* if this is the child */ |
| | | 58 | { |
| | | 59 | - execl(pname, pname, SHELL_OPT, &sysbuf.f->ch[0], 0); /* call the named Unix routine */ |
| | | 60 | + execl(pname, pname, SHELL_OPT, &sysbuf.f->ch[0], (void *)NULL); /* call the named Unix routine */ |
| | | 61 | printf("Error in 'execl'\n"); /* normally shouldn't get here */ |
| | | 62 | exit(1); |
| | | 63 | } |
| | | 64 | @@ -493,7 +499,7 @@ int do_eq1(shell) |
| | | 65 | if (ll == 0) /* if there are no characters to send */ |
| | | 66 | { |
| | | 67 | close(pipe_in[1]); /* close exec'd process' new "stdin" so "read" will find eof */ |
| | | 68 | - execl(shell, shell, SHELL_OPT, &sysbuf.f->ch[0], 0); /* execute specified routine */ |
| | | 69 | + execl(shell, shell, SHELL_OPT, &sysbuf.f->ch[0], (void *)NULL); /* execute specified routine */ |
| | | 70 | fputs("execl failed\n", stderr); |
| | | 71 | exit(1); |
| | | 72 | } /* end "orig m,nEQ command had zero range" */ |
| | | 73 | @@ -520,7 +526,7 @@ int do_eq1(shell) |
| | | 74 | else /* this process is the grandchild */ |
| | | 75 | { |
| | | 76 | close(pipe_in[1]); /* close "input" for writing */ |
| | | 77 | - execl(shell, shell, SHELL_OPT, &sysbuf.f->ch[0], 0); /* execute specified routine */ |
| | | 78 | + execl(shell, shell, SHELL_OPT, &sysbuf.f->ch[0], (void *)NULL); /* execute specified routine */ |
| | | 79 | fputs("execl failed\n", stderr); |
| | | 80 | exit(1); |
| | | 81 | } /* end "this is the grandchild" */ |
| | | 82 | @@ -559,7 +565,7 @@ int do_en() |
| | | 83 | } |
| | | 84 | /* routine to handle "change directory" command */ |
| | | 85 | |
| | | 86 | -int do_e_slash() |
| | | 87 | +static int do_e_slash(void) |
| | | 88 | { |
| | | 89 | int rv = -1; /* return value */ |
| | | 90 | int err_code = E_DIR; |
| | | 91 | @@ -609,7 +615,7 @@ int do_glob(gbuff, sbuff) |
15 | { | | 92 | { |
16 | char glob_cmd[CELLSIZE+5]; /* "glob filespec" command string */ | | 93 | char glob_cmd[CELLSIZE+5]; /* "glob filespec" command string */ |
17 | int t; | | 94 | int t; |
18 | - char c; | | 95 | - char c; |
19 | + int c; | | 96 | + int c; |
20 | int glob_pipe[2]; /* pipe to forked shell for expanding filenames */ | | 97 | int glob_pipe[2]; /* pipe to forked shell for expanding filenames */ |
21 | struct qp glob_ptr; /* pointer for loading result buffer */ | | 98 | struct qp glob_ptr; /* pointer for loading result buffer */ |
22 | FILE *xx_out; /* stream for reading chars from pipe */ | | 99 | FILE *xx_out; /* stream for reading chars from pipe */ |
23 | @@ -825,7 +825,7 @@ int read_stream(file, ff_found, rbuff, n | | 100 | @@ -668,7 +674,7 @@ int do_glob(gbuff, sbuff) |
| | | 101 | close(glob_pipe[0]); /* child won't read */ |
| | | 102 | dup2(glob_pipe[1], fileno(stdout)); /* substitute pipe for standard out */ |
| | | 103 | close(glob_pipe[1]); /* don't need that anymore */ |
| | | 104 | - execl("/bin/csh", "csh", "-fc", glob_cmd, 0); /* execute the "glob" */ |
| | | 105 | + execl("/bin/csh", "csh", "-fc", glob_cmd, (void *)NULL); /* execute the "glob" */ |
| | | 106 | fputs("execl failed\n", stderr); |
| | | 107 | exit(1); |
| | | 108 | } |
| | | 109 | @@ -676,7 +682,7 @@ int do_glob(gbuff, sbuff) |
| | | 110 | |
| | | 111 | /* routine to get next file spec from "EN" list into filespec buffer */ |
| | | 112 | |
| | | 113 | -do_en_next() |
| | | 114 | +VOID do_en_next(void) |
| | | 115 | { |
| | | 116 | char c; |
| | | 117 | |
| | | 118 | @@ -778,7 +784,7 @@ int read_filename(flag, func) |
| | | 119 | |
| | | 120 | /* fetch or set variable */ |
| | | 121 | |
| | | 122 | -set_var(extend, arg) |
| | | 123 | +VOID set_var(extend, arg) |
| | | 124 | int extend; /* nonzero if arg is 16 bits to be sign extended */ |
| | | 125 | int *arg; /* argument is pointer to variable */ |
| | | 126 | { |
| | | 127 | @@ -820,12 +826,12 @@ int read_file(rbuff, nchars, endsw) |
| | | 128 | /* address of a switch to set if read ended with a FF, crlf_sw is lf->crlf */ |
| | | 129 | /* conversion, ff_sw indicates whether to stop on a form feed. */ |
| | | 130 | |
| | | 131 | -int read_stream(file, ff_found, rbuff, nchars, endsw, crlf_sw, ff_sw) |
| | | 132 | +static int read_stream(file, ff_found, rbuff, nchars, endsw, crlf_sw, ff_sw) |
| | | 133 | FILE *file; |
24 | struct qp *rbuff; | | 134 | struct qp *rbuff; |
25 | int *ff_found, *nchars, endsw, crlf_sw, ff_sw; | | 135 | int *ff_found, *nchars, endsw, crlf_sw, ff_sw; |
26 | { | | 136 | { |
27 | - char chr; | | 137 | - char chr; |
28 | + int chr; | | 138 | + int chr; |
29 | int crflag; | | 139 | int crflag; |
30 | register struct buffcell *p; | | 140 | register struct buffcell *p; |
31 | register int c; | | 141 | register int c; |
| | | 142 | @@ -874,7 +880,7 @@ int read_stream(file, ff_found, rbuff, n |
| | | 143 | /* arguments are qp to start of text, number of characters, */ |
| | | 144 | /* and an "append FF" switch */ |
| | | 145 | |
| | | 146 | -write_file(wbuff, nchars, ffsw) |
| | | 147 | +VOID write_file(wbuff, nchars, ffsw) |
| | | 148 | struct qp *wbuff; |
| | | 149 | int nchars, ffsw; |
| | | 150 | { |
| | | 151 | @@ -889,7 +895,7 @@ write_file(wbuff, nchars, ffsw) |
| | | 152 | /* Unix processes. Arguments wbuff, nchars as above; file */ |
| | | 153 | /* is stream pointer, crlf_sw zero converts CRLF to LF */ |
| | | 154 | |
| | | 155 | -write_stream(file, wbuff, nchars, crlf_sw) |
| | | 156 | +static VOID write_stream(file, wbuff, nchars, crlf_sw) |
| | | 157 | FILE *file; |
| | | 158 | struct qp *wbuff; |
| | | 159 | int nchars, crlf_sw; |
| | | 160 | @@ -919,7 +925,7 @@ write_stream(file, wbuff, nchars, crlf_s |
| | | 161 | |
| | | 162 | /* routine to kill output file: argument is pointer to an output file structure */ |
| | | 163 | |
| | | 164 | -kill_output(outptr) |
| | | 165 | +VOID kill_output(outptr) |
| | | 166 | struct outfiledata *outptr; |
| | | 167 | { |
| | | 168 | if (outptr->fd) |
| | | 169 | @@ -934,7 +940,7 @@ kill_output(outptr) |
| | | 170 | |
| | | 171 | static char panic_name[16] = "TECO_SAVED.tmp"; /* name of file created to save buffer */ |
| | | 172 | |
| | | 173 | -panic() |
| | | 174 | +VOID panic(void) |
| | | 175 | { |
| | | 176 | int i; /* counter of buffers to save */ |
| | | 177 | int t_access; /* file descriptor returned by open() */ |
| | | 178 | @@ -959,13 +965,13 @@ panic() |
| | | 179 | } |
| | | 180 | /* do "F" commands */ |
| | | 181 | |
| | | 182 | -do_f() |
| | | 183 | +VOID do_f(void) |
| | | 184 | { |
| | | 185 | struct buffcell *delete_p; |
| | | 186 | int temp_dot; |
| | | 187 | VOID do_fm(); |
| | | 188 | |
| | | 189 | - switch (mapch_l[getcmdc(trace_sw)]) /* read next character and dispatch */ |
| | | 190 | + switch (mapch_l[(unsigned char)getcmdc(trace_sw)]) /* read next character and dispatch */ |
| | | 191 | { |
| | | 192 | case '<': /* back to beginning of current iteration */ |
| | | 193 | if (cptr.flag & F_ITER) /* if in iteration */ |
| | | 194 | @@ -1138,7 +1144,7 @@ do_f() |
| | | 195 | /* pop iteration: if arg nonzero, exit unconditionally */ |
| | | 196 | /* else check exit conditions and exit or reiterate */ |
| | | 197 | |
| | | 198 | -pop_iteration(arg) |
| | | 199 | +VOID pop_iteration(arg) |
| | | 200 | int arg; |
| | | 201 | { |
| | | 202 | if (!arg && (!cptr.il->dflag || (--(cptr.il->count) > 0)) ) /* if reiteration */ |
| | | 203 | @@ -1157,7 +1163,7 @@ pop_iteration(arg) |
| | | 204 | |
| | | 205 | /* find end of iteration - read over arbitrary <> and one > */ |
| | | 206 | |
| | | 207 | -find_enditer() |
| | | 208 | +VOID find_enditer(void) |
| | | 209 | { |
| | | 210 | register int icnt; |
| | | 211 | |
| | | 212 | @@ -1172,7 +1178,7 @@ find_enditer() |
| | | 213 | |
| | | 214 | |
| | | 215 | /* find end of conditional */ |
| | | 216 | -char find_endcond(arg) |
| | | 217 | +VOID find_endcond(arg) |
| | | 218 | char arg; |
| | | 219 | { |
| | | 220 | register int icnt; |
--- pkgsrc/editors/mflteco/patches/patch-ac 2005/12/28 22:29:17 1.1.1.1
+++ pkgsrc/editors/mflteco/patches/patch-ac 2012/12/27 06:13:20 1.2
| @@ -1,20 +1,85 @@ | | | @@ -1,20 +1,85 @@ |
1 | $NetBSD: patch-ac,v 1.1.1.1 2005/12/28 22:29:17 is Exp $ | | 1 | $NetBSD: patch-ac,v 1.2 2012/12/27 06:13:20 dholland Exp $ |
2 | | | 2 | |
3 | --- te_rdcmd.c.orig 1993-08-06 00:29:35.000000000 +0200 | | 3 | - use some static |
| | | 4 | - don't put function declarations inside function bodies |
| | | 5 | - remove unused goto-label |
| | | 6 | - call ctype.h functions correctly |
| | | 7 | - don't index arrays with (signed) char |
| | | 8 | - remove silly code that provokes a pointer width warning |
| | | 9 | - declare void functions void |
| | | 10 | - remove unused variable |
| | | 11 | |
| | | 12 | --- te_rdcmd.c.orig 1993-08-05 22:29:35.000000000 +0000 |
4 | +++ te_rdcmd.c | | 13 | +++ te_rdcmd.c |
5 | @@ -9,13 +9,14 @@ | | 14 | @@ -9,13 +9,15 @@ |
6 | | | 15 | |
7 | #include "te_defs.h" | | 16 | #include "te_defs.h" |
8 | | | 17 | |
9 | +static unsigned short do_func_keys(); | | 18 | +static unsigned short do_func_keys(unsigned short c); |
| | | 19 | +static int find_lasteol(void); |
10 | + | | 20 | + |
11 | int ccount; /* count of chars read in */ | | 21 | int ccount; /* count of chars read in */ |
12 | | | 22 | |
13 | int read_cmdstr() | | 23 | int read_cmdstr() |
14 | { | | 24 | { |
15 | unsigned short c; /* temporary character */ | | 25 | unsigned short c; /* temporary character */ |
16 | int i; /* temporary */ | | 26 | int i; /* temporary */ |
17 | - unsigned short do_func_keys(); | | 27 | - unsigned short do_func_keys(); |
18 | | | 28 | |
19 | goto prompt; | | 29 | goto prompt; |
20 | | | 30 | |
| | | 31 | @@ -30,7 +32,7 @@ int read_cmdstr() |
| | | 32 | ccount = 0; |
| | | 33 | lastc = ' '; |
| | | 34 | |
| | | 35 | -reline: /* continue reading */ |
| | | 36 | +/*reline:*/ /* continue reading */ |
| | | 37 | for (;;) /* loop to read command string chars */ |
| | | 38 | { |
| | | 39 | if (!eisw && !inp_noterm) /* if terminal input */ |
| | | 40 | @@ -106,7 +108,7 @@ reline: /* continue reading */ |
| | | 41 | i = (c == '~') ? NEXTQREGS/2 : 0; |
| | | 42 | type_char(c = gettty()); /* read & echo one more */ |
| | | 43 | if (isdigit(c)) i += EXTQREGS + c - '0'; |
| | | 44 | - else if (isalpha(mapch_l[c])) i += EXTQREGS + 10 + c - 'a'; |
| | | 45 | + else if (isalpha((unsigned char)mapch_l[c])) i += EXTQREGS + 10 + c - 'a'; |
| | | 46 | else ERROR(E_IQN); |
| | | 47 | } |
| | | 48 | else i = getqspec(0, c); |
| | | 49 | @@ -119,7 +121,8 @@ reline: /* continue reading */ |
| | | 50 | qreg[i].f->usecount = 1; |
| | | 51 | } |
| | | 52 | qreg[i].z = cbuf.z; |
| | | 53 | - cbuf.f = (struct buffcell *) (cbuf.z = 0); /* no old command string */ |
| | | 54 | + cbuf.z = 0; |
| | | 55 | + cbuf.f = NULL; /* no old command string */ |
| | | 56 | err = 0; /* no previous error */ |
| | | 57 | goto restart; |
| | | 58 | } |
| | | 59 | @@ -238,7 +241,7 @@ reline: /* continue reading */ |
| | | 60 | /* back up to find most recent CR or LF in entered command string */ |
| | | 61 | /* return number of chars backed up */ |
| | | 62 | |
| | | 63 | -int find_lasteol() |
| | | 64 | +static int find_lasteol(void) |
| | | 65 | { |
| | | 66 | int i; |
| | | 67 | |
| | | 68 | @@ -258,7 +261,7 @@ int find_lasteol() |
| | | 69 | |
| | | 70 | /* retype command string: entirely (arg = '*') or most recent line (arg = ' ') */ |
| | | 71 | |
| | | 72 | -retype_cmdstr(c) |
| | | 73 | +VOID retype_cmdstr(c) |
| | | 74 | char c; |
| | | 75 | { |
| | | 76 | int i; |
| | | 77 | @@ -294,7 +297,7 @@ static struct qp saved_cmd_ptr; |
| | | 78 | static unsigned short do_func_keys(c) |
| | | 79 | unsigned short c; |
| | | 80 | { |
| | | 81 | - unsigned short i, n; /* temporaries */ |
| | | 82 | + unsigned short n; /* temporaries */ |
| | | 83 | struct qh *header_p; /* pointer to register's header */ |
| | | 84 | struct qp pointer; /* q-pointer to register being copied */ |
| | | 85 | unsigned char last_c = ' ', this_c; /* char's used in copying command string */ |
--- pkgsrc/editors/mflteco/patches/patch-ad 2006/01/05 19:27:50 1.1
+++ pkgsrc/editors/mflteco/patches/patch-ad 2012/12/27 06:13:20 1.2
| @@ -1,12 +1,137 @@ | | | @@ -1,12 +1,137 @@ |
1 | $NetBSD: patch-ad,v 1.1 2006/01/05 19:27:50 joerg Exp $ | | 1 | $NetBSD: patch-ad,v 1.2 2012/12/27 06:13:20 dholland Exp $ |
2 | | | 2 | |
3 | --- te_defs.h.orig 2006-01-04 20:59:21.000000000 +0000 | | 3 | - don't declare own errno |
| | | 4 | - use some const |
| | | 5 | - don't declare own fopen() |
| | | 6 | - do declare own functions |
| | | 7 | - use C89 |
| | | 8 | |
| | | 9 | --- te_defs.h.orig 1993-08-05 22:29:33.000000000 +0000 |
4 | +++ te_defs.h | | 10 | +++ te_defs.h |
5 | @@ -387,7 +387,6 @@ extern struct outfiledata po_file, so_fi | | 11 | @@ -387,7 +387,6 @@ extern struct outfiledata po_file, so_fi |
6 | extern int char_count; /* char count for tab typer */ | | 12 | extern int char_count; /* char count for tab typer */ |
7 | extern char lastc; /* last char read */ | | 13 | extern char lastc; /* last char read */ |
8 | extern int ttyerr; /* error return from ioctl */ | | 14 | extern int ttyerr; /* error return from ioctl */ |
9 | -extern int errno; /* system error code */ | | 15 | -extern int errno; /* system error code */ |
10 | #ifdef POSIX_TECO | | 16 | #ifdef POSIX_TECO |
11 | extern struct termios ttybuf; /* local copy of tty control data */ | | 17 | extern struct termios ttybuf; /* local copy of tty control data */ |
12 | #else | | 18 | #else |
| | | 19 | @@ -429,20 +428,16 @@ extern struct buffcell *insert_p; /* po |
| | | 20 | extern int buff_mod; /* set to earliest buffer change */ |
| | | 21 | extern int search_flag; /* set nonzero by search */ |
| | | 22 | |
| | | 23 | -extern char *errors[]; /* error text */ |
| | | 24 | +extern const char *errors[]; /* error text */ |
| | | 25 | extern char mapch[], mapch_l[]; /* char mapping tables */ |
| | | 26 | extern char spec_chars[]; /* special character table */ |
| | | 27 | |
| | | 28 | -extern char skipto(), find_endcond(), getcmdc(), getcmdc0(); /* routines that return chars */ |
| | | 29 | |
| | | 30 | extern FILE *eisw; /* indirect command file pointer */ |
| | | 31 | -extern FILE *fopen(); |
| | | 32 | |
| | | 33 | extern struct buffcell *freebuff; /* buffcell free-list pointer */ |
| | | 34 | extern struct buffcell *dly_freebuff; /* delayed free-list pointer */ |
| | | 35 | extern struct is *freedcell; /* cell free-list pointer */ |
| | | 36 | -extern struct buffcell *get_bcell(); /* get buffcell routine */ |
| | | 37 | -extern struct is *get_dcell(); /* get data cell routine */ |
| | | 38 | |
| | | 39 | /* the text buffer header */ |
| | | 40 | extern struct qh buff; |
| | | 41 | @@ -466,3 +461,96 @@ extern struct exp_entry *esp; /* expres |
| | | 42 | |
| | | 43 | /* the directory string buffer */ |
| | | 44 | extern struct qh dir_name; |
| | | 45 | + |
| | | 46 | +/* te_utils.c */ |
| | | 47 | +struct buffcell *get_bcell(void); /* get buffcell routine */ |
| | | 48 | +VOID free_blist(struct buffcell *p); |
| | | 49 | +VOID dly_free_blist(struct buffcell *p); |
| | | 50 | +VOID free_dlyd_blist(struct buffcell *p); |
| | | 51 | +VOID reset_q_usecounts(void); |
| | | 52 | +extern struct is *get_dcell(void); /* get data cell routine */ |
| | | 53 | +VOID make_buffer(struct qh *p); |
| | | 54 | +int fwdc(struct qp *arg); |
| | | 55 | +int fwdcx(struct qp *arg); |
| | | 56 | +int backc(struct qp *arg); |
| | | 57 | +VOID set_pointer(int pos, struct qp *ptr); |
| | | 58 | +char getcmdc0(int trace); |
| | | 59 | +char getcmdc(int trace); |
| | | 60 | +int peekcmdc(char arg); |
| | | 61 | + |
| | | 62 | +/* te_subs.c */ |
| | | 63 | +VOID movenchars(struct qp *from, struct qp *to, register int n); |
| | | 64 | +VOID moveuntil(struct qp *form, struct qp *to, register char c, |
| | | 65 | + int *n, int max, int trace); |
| | | 66 | +int get_value(int d); |
| | | 67 | +int lines(register int arg); |
| | | 68 | +int line_args(int d, struct qp *p); |
| | | 69 | +int getqspec(int fors, char c); |
| | | 70 | +VOID insert1(void); |
| | | 71 | +VOID insert2(int count); |
| | | 72 | +VOID delete1(int nchars); |
| | | 73 | +char skipto(int arg); |
| | | 74 | +VOID do_ctlp(void); |
| | | 75 | + |
| | | 76 | +/* te_main.c */ |
| | | 77 | +VOID cleanup(void); |
| | | 78 | +VOID update_header(void); |
| | | 79 | +VOID init_wd(void); |
| | | 80 | +VOID get_term_par(void); |
| | | 81 | +VOID do_o(void); |
| | | 82 | + |
| | | 83 | +/* te_rdcmd.c */ |
| | | 84 | +int read_cmdstr(void); |
| | | 85 | +VOID retype_cmdstr(char c); |
| | | 86 | + |
| | | 87 | +/* te_exec0.c */ |
| | | 88 | +VOID exec_cmdstr(void); |
| | | 89 | + |
| | | 90 | +/* te_exec1.c */ |
| | | 91 | +VOID exec_cmds1(void); |
| | | 92 | + |
| | | 93 | +/* te_exec2.c */ |
| | | 94 | +VOID do_e(void); |
| | | 95 | +int do_eq(void); |
| | | 96 | +int do_eq1(char *shell); |
| | | 97 | +int do_en(void); |
| | | 98 | +int do_glob(struct qh *gbuff, struct qh *sbuff); |
| | | 99 | +VOID do_en_next(void); |
| | | 100 | +int read_filename(int flag, char func); |
| | | 101 | +VOID set_var(int extend, int *arg); |
| | | 102 | +int read_file(struct qp *rbuff, int *nchars, int endsw); |
| | | 103 | +VOID write_file(struct qp *wbuff, int nchars, int ffsw); |
| | | 104 | +VOID kill_output(struct outfiledata *outptr); |
| | | 105 | +VOID panic(void); |
| | | 106 | +VOID do_f(void); |
| | | 107 | +VOID pop_iteration(int arg); |
| | | 108 | +VOID find_enditer(void); |
| | | 109 | +VOID find_endcond(char arg); |
| | | 110 | + |
| | | 111 | +/* te_srch.c */ |
| | | 112 | +int build_string(struct qh *sbuff); |
| | | 113 | +int end_search(int result); |
| | | 114 | +int setup_search(void); |
| | | 115 | +int do_nsearch(char arg); |
| | | 116 | +int do_fb(void); |
| | | 117 | +int do_search(int count); |
| | | 118 | + |
| | | 119 | +/* te_chario.c */ |
| | | 120 | +VOID setup_tty(int arg); |
| | | 121 | +int gettty_nowait(void); |
| | | 122 | +int gettty(void); |
| | | 123 | +void block_inter(int func); |
| | | 124 | +VOID crlf(void); |
| | | 125 | +VOID reset_ctlo(void); |
| | | 126 | +VOID type_char(char c); |
| | | 127 | + |
| | | 128 | +/* te_window.c */ |
| | | 129 | +VOID vt(int func); |
| | | 130 | +VOID do_window(int ref_flag); |
| | | 131 | +VOID set_term_par(int lines, int cols); |
| | | 132 | +VOID window(int arg); |
| | | 133 | +VOID scroll_dly(void); |
| | | 134 | +VOID display_lines(void); |
| | | 135 | + |
| | | 136 | +/* te_fxstub.c */ |
| | | 137 | +void te_fx(void); |
--- pkgsrc/editors/mflteco/patches/patch-ae 2006/01/05 19:27:50 1.1
+++ pkgsrc/editors/mflteco/patches/patch-ae 2012/12/27 06:13:20 1.2
| @@ -1,20 +1,311 @@ | | | @@ -1,20 +1,311 @@ |
1 | $NetBSD: patch-ae,v 1.1 2006/01/05 19:27:50 joerg Exp $ | | 1 | $NetBSD: patch-ae,v 1.2 2012/12/27 06:13:20 dholland Exp $ |
2 | | | 2 | |
3 | --- te_chario.c.orig 2006-01-04 21:01:15.000000000 +0000 | | 3 | - use standard headers |
| | | 4 | - use some static |
| | | 5 | - initialize struct sigaction correctly |
| | | 6 | - declare own functions |
| | | 7 | - don't declare own errno |
| | | 8 | - restore missing close-comments |
| | | 9 | - declare void functions void |
| | | 10 | - use some c89 |
| | | 11 | - don't index arrays with (signed) char |
| | | 12 | |
| | | 13 | --- te_chario.c.orig 1993-08-05 22:29:33.000000000 +0000 |
4 | +++ te_chario.c | | 14 | +++ te_chario.c |
5 | @@ -101,7 +101,6 @@ char ldbuf[TTNAMEMAX]; | | 15 | @@ -28,6 +28,8 @@ |
| | | 16 | #endif |
| | | 17 | |
| | | 18 | #include <unistd.h> |
| | | 19 | +#include <stdlib.h> |
| | | 20 | +#include <string.h> |
| | | 21 | |
| | | 22 | #if defined(USE_SELECT) && defined(_AIX) |
| | | 23 | #include <sys/select.h> |
| | | 24 | @@ -41,10 +43,10 @@ |
| | | 25 | #include <fcntl.h> |
| | | 26 | #ifndef DEBUG |
| | | 27 | #include <signal.h> |
| | | 28 | -extern SHRET int_handler(); |
| | | 29 | -extern SHRET stp_handler(); |
| | | 30 | -extern SHRET hup_handler(); |
| | | 31 | -extern SHRET winch_handler(); |
| | | 32 | +static SHRET int_handler(); |
| | | 33 | +static SHRET stp_handler(); |
| | | 34 | +static SHRET hup_handler(); |
| | | 35 | +static SHRET winch_handler(); |
| | | 36 | #define SIGINTMASK 2 |
| | | 37 | #endif |
| | | 38 | |
| | | 39 | @@ -72,11 +74,11 @@ int bsdld; |
| | | 40 | /* this is really for linux */ |
| | | 41 | #define SA_INTERRUPT 0 |
| | | 42 | #endif |
| | | 43 | -struct sigaction intsigstruc = { int_handler, 0, SA_INTERRUPT } ; /* info structure for ^C interrupt */ |
| | | 44 | -struct sigaction stpsigstruc = { stp_handler, 0, SA_INTERRUPT } ; /* info structure for "stop" signal */ |
| | | 45 | -struct sigaction hupsigstruc = { hup_handler, 0, SA_INTERRUPT } ; /* info structure for "hangup" signal */ |
| | | 46 | -struct sigaction nosigstr = { SIG_DFL, 0, 0 }; /* default structure for signal */ |
| | | 47 | -struct sigaction sigwinchstruc = { winch_handler, 0, SA_INTERRUPT} ; |
| | | 48 | +struct sigaction intsigstruc; /* info structure for ^C interrupt */ |
| | | 49 | +struct sigaction stpsigstruc; /* info structure for "stop" signal */ |
| | | 50 | +struct sigaction hupsigstruc; /* info structure for "hangup" signal */ |
| | | 51 | +struct sigaction nosigstr; /* default structure for signal */ |
| | | 52 | +struct sigaction sigwinchstruc; |
| | | 53 | #else |
| | | 54 | struct sigvec intsigstruc = { int_handler, 0, 0 } ; /* info structure for ^C interrupt */ |
| | | 55 | struct sigvec stpsigstruc = { stp_handler, 0, 0 } ; /* info structure for "stop" signal */ |
| | | 56 | @@ -96,12 +98,13 @@ int out_noterm; /* nonzero if standar |
| | | 57 | char ldbuf[TTNAMEMAX]; |
| | | 58 | #endif |
| | | 59 | |
| | | 60 | +static void qio_char(char c); |
| | | 61 | + |
| | | 62 | #ifndef POSIX_TECO |
| | | 63 | |
6 | setup_tty(arg) | | 64 | setup_tty(arg) |
7 | int arg; | | 65 | int arg; |
8 | { | | 66 | { |
9 | - extern int errno; | | 67 | - extern int errno; |
10 | int ioerr; | | 68 | int ioerr; |
11 | struct sgttyb tmpbuf; | | 69 | struct sgttyb tmpbuf; |
12 | | | 70 | |
13 | @@ -186,7 +185,6 @@ setup_tty(arg) | | 71 | @@ -177,16 +180,15 @@ setup_tty(arg) |
14 | setup_tty(arg) | | 72 | } |
| | | 73 | } |
| | | 74 | } |
| | | 75 | -#else /* POSIX_TECO |
| | | 76 | +#else /* POSIX_TECO */ |
| | | 77 | /* |
| | | 78 | * set tty (stdin) mode. TECO mode is CBREAK, no ECHO, sep CR & LF |
| | | 79 | * operation; normal mode is none of the above. TTY_OFF and TTY_ON do this |
| | | 80 | * absolutely; TTY_SUSP and TTY_RESUME use saved signal status. |
| | | 81 | */ |
| | | 82 | -setup_tty(arg) |
| | | 83 | +VOID setup_tty(arg) |
15 | int arg; | | 84 | int arg; |
16 | { | | 85 | { |
17 | - extern int errno; | | 86 | - extern int errno; |
18 | int ioerr; | | 87 | int ioerr; |
19 | struct termios tmpbuf; | | 88 | struct termios tmpbuf; |
20 | | | 89 | |
| | | 90 | @@ -227,6 +229,22 @@ int arg; |
| | | 91 | tcdrain(fileno(stdin)); |
| | | 92 | tcdrain(fileno(stdin)); tcsetattr(fileno(stdin), TCSANOW, &tty_new); |
| | | 93 | #ifndef DEBUG |
| | | 94 | + intsigstruc.sa_sigaction = int_handler; |
| | | 95 | + sigemptyset(&intsigstruc.sa_mask); |
| | | 96 | + intsigstruc.sa_flags = SA_INTERRUPT; |
| | | 97 | + |
| | | 98 | + stpsigstruc.sa_handler = stp_handler; |
| | | 99 | + sigemptyset(&stpsigstruc.sa_mask); |
| | | 100 | + stpsigstruc.sa_flags = SA_INTERRUPT; |
| | | 101 | + |
| | | 102 | + hupsigstruc.sa_handler = hup_handler; |
| | | 103 | + sigemptyset(&hupsigstruc.sa_mask); |
| | | 104 | + hupsigstruc.sa_flags = SA_INTERRUPT; |
| | | 105 | + |
| | | 106 | + sigwinchstruc.sa_handler = winch_handler; |
| | | 107 | + sigemptyset(&sigwinchstruc.sa_mask); |
| | | 108 | + sigwinchstruc.sa_flags = SA_INTERRUPT; |
| | | 109 | + |
| | | 110 | /* Handle signals */ |
| | | 111 | if (sigaction(SIGTSTP, &stpsigstruc, NULL) < 0) { |
| | | 112 | fprintf(stderr, "could not install signal handler for SIGTSTP\n"); |
| | | 113 | @@ -249,6 +267,10 @@ int arg; |
| | | 114 | /* Restore to original state */ |
| | | 115 | tcdrain(fileno(stdin)); tcsetattr(fileno(stdin), TCSANOW, &tty_orig); |
| | | 116 | #ifndef DEBUG |
| | | 117 | + nosigstr.sa_handler = SIG_DFL; |
| | | 118 | + sigemptyset(&nosigstr.sa_mask); |
| | | 119 | + nosigstr.sa_flags = 0; |
| | | 120 | + |
| | | 121 | sigaction(SIGTSTP, &nosigstr, 0); |
| | | 122 | sigaction(SIGINT, &nosigstr, 0); |
| | | 123 | sigaction(SIGHUP, &nosigstr, 0); |
| | | 124 | @@ -263,10 +285,10 @@ int arg; |
| | | 125 | /* if lf_sw is nonzero, return the LF; else use the FNDELAY fcntl to inquire of the input */ |
| | | 126 | /* if input is not a terminal don't switch modes */ |
| | | 127 | |
| | | 128 | -unsigned short get_kbd_enh(); |
| | | 129 | +static unsigned short get_kbd_enh(void); |
| | | 130 | #ifndef POSIX_TECO |
| | | 131 | |
| | | 132 | -int gettty_nowait() |
| | | 133 | +int gettty_nowait(void) |
| | | 134 | { |
| | | 135 | int c; |
| | | 136 | |
| | | 137 | @@ -289,7 +311,7 @@ int gettty_nowait() |
| | | 138 | * set if lf_sw is nonzero, return the LF; else use the FNDELAY fcntl to |
| | | 139 | * inquire of the input |
| | | 140 | */ |
| | | 141 | -gettty_nowait() |
| | | 142 | +int gettty_nowait(void) |
| | | 143 | { |
| | | 144 | char c; |
| | | 145 | int err, cnt; |
| | | 146 | @@ -424,7 +446,7 @@ static unsigned char ca[3] = {0,0,0}; |
| | | 147 | #define c2 ca[1] |
| | | 148 | #define c3 ca[2] |
| | | 149 | |
| | | 150 | -int zread(fd,c) |
| | | 151 | +static int zread(fd,c) |
| | | 152 | int fd; |
| | | 153 | char *c; |
| | | 154 | { |
| | | 155 | @@ -435,7 +457,7 @@ char *c; |
| | | 156 | } |
| | | 157 | |
| | | 158 | #if defined(USE_SELECT) |
| | | 159 | -int timed_read(fd,c) |
| | | 160 | +static int timed_read(fd,c) |
| | | 161 | int fd; |
| | | 162 | char *c; |
| | | 163 | { |
| | | 164 | @@ -459,7 +481,7 @@ char *c; |
| | | 165 | #endif |
| | | 166 | |
| | | 167 | #if defined(USE_POLL) |
| | | 168 | -int timed_read(fd,c) |
| | | 169 | +static int timed_read(fd,c) |
| | | 170 | int fd; |
| | | 171 | char *c; |
| | | 172 | { |
| | | 173 | @@ -479,7 +501,7 @@ char *c; |
| | | 174 | #endif |
| | | 175 | |
| | | 176 | #if defined(USE_POSIX_C_CC) |
| | | 177 | -int timed_read(fd,c) |
| | | 178 | +static int timed_read(fd,c) |
| | | 179 | int fd; |
| | | 180 | char *c; |
| | | 181 | { |
| | | 182 | @@ -503,7 +525,7 @@ char *c; |
| | | 183 | } |
| | | 184 | #endif |
| | | 185 | |
| | | 186 | -unsigned short get_kbd_enh() |
| | | 187 | +static unsigned short get_kbd_enh() |
| | | 188 | { |
| | | 189 | unsigned short retval; |
| | | 190 | struct trans_entry *pt; |
| | | 191 | @@ -555,7 +577,7 @@ unsigned short get_kbd_enh() |
| | | 192 | |
| | | 193 | #ifndef DEBUG |
| | | 194 | |
| | | 195 | -SHRET winch_handler() |
| | | 196 | +static SHRET winch_handler() |
| | | 197 | { |
| | | 198 | get_term_par(); |
| | | 199 | window(WIN_INIT); |
| | | 200 | @@ -566,7 +588,7 @@ SHRET winch_handler() |
| | | 201 | } |
| | | 202 | } |
| | | 203 | |
| | | 204 | -SHRET int_handler() |
| | | 205 | +static SHRET int_handler() |
| | | 206 | { |
| | | 207 | |
| | | 208 | if (exitflag <= 0) /* if executing commands */ |
| | | 209 | @@ -594,7 +616,7 @@ SHRET int_handler() |
| | | 210 | /* routine to disable (1), enable (0) ^C interrupt, used to block interrupts during display update */ |
| | | 211 | |
| | | 212 | #ifdef POSIX_TECO |
| | | 213 | -block_inter(func) |
| | | 214 | +VOID block_inter(func) |
| | | 215 | int func; |
| | | 216 | { |
| | | 217 | sigset_t ss; |
| | | 218 | @@ -608,7 +630,7 @@ int func; |
| | | 219 | #else |
| | | 220 | int old_mask; /* storage for previous signal mask */ |
| | | 221 | #define INT_MASK 2 |
| | | 222 | -block_inter(func) |
| | | 223 | +VOID block_inter(func) |
| | | 224 | int func; |
| | | 225 | { |
| | | 226 | #ifndef DEBUG |
| | | 227 | @@ -624,7 +646,7 @@ block_inter(func) |
| | | 228 | /* routine to handle "stop" signal (^Y) */ |
| | | 229 | #ifdef POSIX_TECO |
| | | 230 | |
| | | 231 | -SHRET stp_handler() |
| | | 232 | +static SHRET stp_handler() |
| | | 233 | { |
| | | 234 | sigset_t ss; |
| | | 235 | sigemptyset(&ss); |
| | | 236 | @@ -652,7 +674,7 @@ SHRET stp_handler() |
| | | 237 | |
| | | 238 | #else /* BSD style signals */ |
| | | 239 | |
| | | 240 | -SHRET stp_handler() |
| | | 241 | +static SHRET stp_handler() |
| | | 242 | { |
| | | 243 | crlf(); |
| | | 244 | window(WIN_SUSP); /* restore screen */ |
| | | 245 | @@ -682,7 +704,7 @@ SHRET stp_handler() |
| | | 246 | |
| | | 247 | /* simulate a character's having been typed on the keyboard */ |
| | | 248 | |
| | | 249 | -qio_char(c) |
| | | 250 | +static void qio_char(c) |
| | | 251 | char c; |
| | | 252 | { |
| | | 253 | #ifdef POSIX_TECO |
| | | 254 | @@ -694,7 +716,7 @@ qio_char(c) |
| | | 255 | /* routine to handle "hangup" signal */ |
| | | 256 | #ifndef DEBUG |
| | | 257 | |
| | | 258 | -SHRET hup_handler() |
| | | 259 | +static SHRET hup_handler() |
| | | 260 | { |
| | | 261 | if (!exitflag) exitflag = -3; /* if executing, set flag to terminate */ |
| | | 262 | else |
| | | 263 | @@ -709,7 +731,7 @@ SHRET hup_handler() |
| | | 264 | |
| | | 265 | /* type a crlf */ |
| | | 266 | |
| | | 267 | -crlf() |
| | | 268 | +void crlf(void) |
| | | 269 | { |
| | | 270 | type_char(CR); |
| | | 271 | type_char(LF); |
| | | 272 | @@ -721,7 +743,7 @@ crlf() |
| | | 273 | int lflusho = LFLUSHO; |
| | | 274 | int lfo; |
| | | 275 | |
| | | 276 | -reset_ctlo() |
| | | 277 | +void reset_ctlo(void) |
| | | 278 | { |
| | | 279 | ioctl(fileno(stdin), TIOCLGET, &lfo); /* read flags */ |
| | | 280 | if (lfo & LFLUSHO) /* if ^O was set */ |
| | | 281 | @@ -731,18 +753,18 @@ reset_ctlo() |
| | | 282 | } |
| | | 283 | } |
| | | 284 | #else |
| | | 285 | -reset_ctlo() |
| | | 286 | +void reset_ctlo(void) |
| | | 287 | { |
| | | 288 | } |
| | | 289 | |
| | | 290 | #endif |
| | | 291 | /* routine to type one character */ |
| | | 292 | |
| | | 293 | -type_char(c) |
| | | 294 | +VOID type_char(c) |
| | | 295 | char c; |
| | | 296 | { |
| | | 297 | |
| | | 298 | - if ((char_count >= WN_width) && (c != CR) && !(spec_chars[c] & A_L)) /* spacing char beyond end of line */ |
| | | 299 | + if ((char_count >= WN_width) && (c != CR) && !(spec_chars[(unsigned char)c] & A_L)) /* spacing char beyond end of line */ |
| | | 300 | { |
| | | 301 | if (et_val & ET_TRUNC) return; /* truncate output to line width */ |
| | | 302 | else crlf(); /* otherwise do automatic new line (note recursive call to type_char) */ |
| | | 303 | @@ -759,7 +781,7 @@ type_char(c) |
| | | 304 | |
| | | 305 | case LF: |
| | | 306 | putchar(c); |
| | | 307 | -/* scroll_dly(); /* filler chars in case VT-100 scrolls */ |
| | | 308 | +/* scroll_dly(); */ /* filler chars in case VT-100 scrolls */ |
| | | 309 | break; |
| | | 310 | |
| | | 311 | case ESC: |
$NetBSD: patch-te__data.c,v 1.1 2012/12/27 06:13:20 dholland Exp $
- use const for string constants
- silence warning about initializer
--- te_data.c.orig 1993-08-05 22:29:33.000000000 +0000
+++ te_data.c
@@ -12,7 +12,7 @@
#include "te_defs.h"
/* error message text */
-char *errors[] =
+const char *errors[] =
{
"> not in iteration",
"Can't pop Q register",
@@ -77,8 +77,8 @@ char *errors[] =
/* the text buffer headers */
struct bh buffs[2] =
{
- { NULL, NULL, 0, 0, 0 },
- { NULL, NULL, 0, 0, 0 }
+ { NULL, NULL, 0, 0, 0, 0 },
+ { NULL, NULL, 0, 0, 0, 0 }
} ;
struct bh *pbuff = buffs;
$NetBSD: patch-te__exec0.c,v 1.1 2012/12/27 06:13:20 dholland Exp $
- declare void functions void
- remove unused variables
- use <ctype.h> functions correctly
- don't index arrays with (signed) char
--- te_exec0.c~ 1993-08-05 22:29:34.000000000 +0000
+++ te_exec0.c
@@ -13,9 +13,8 @@
#include <time.h>
#endif
-exec_cmdstr()
+VOID exec_cmdstr(void)
{
- char c;
int digit_sw;
struct tm *timeptr;
char *timestring, *asctime();
@@ -42,7 +41,7 @@ exec_cmdstr()
if (getcmdc0(trace_sw) == '^') /* interpret next char as corresp. control char */
cmdc = getcmdc(trace_sw) & 0x1f;
- if (isdigit(cmdc)) /* process number */
+ if (isdigit((unsigned char)cmdc)) /* process number */
{ /* this works lousy for hex but so does TECO-11 */
if (cmdc - '0' >= ctrl_r) ERROR(E_ILN); /* invalid digit */
if (!(digit_sw++)) esp->val1 = cmdc - '0'; /* first digit */
@@ -55,7 +54,7 @@ exec_cmdstr()
else
{
digit_sw = 0;
- switch (mapch_l[cmdc])
+ switch (mapch_l[(unsigned char)cmdc])
{
/* characters ignored */
$NetBSD: patch-te__exec1.c,v 1.1 2012/12/27 06:13:20 dholland Exp $
- declare void functions void
- don't index arrays with (signed) char
- silence warnings about assignments in conditionals
- use <ctype.h> functions correctly
--- te_exec1.c~ 1993-08-05 22:29:34.000000000 +0000
+++ te_exec1.c
@@ -12,13 +12,14 @@
#include "te_defs.h"
-exec_cmds1()
+VOID exec_cmds1(void)
{
char command; /* command character */
int cond; /* conditional in progress */
int tempz; /* temp copy of Z */
- switch (command = mapch_l[cmdc])
+ command = mapch_l[(unsigned char)cmdc];
+ switch (command)
{
/* operators */
@@ -166,7 +167,7 @@ exec_cmds1()
cptr.il->p = cptr.p; /* save start of iteration */
cptr.il->c = cptr.c;
cptr.il->dot = cptr.dot;
- if (cptr.il->dflag = esp->flag1) /* if there is an argument, set the "def iter" flag */
+ if ((cptr.il->dflag = esp->flag1) != 0) /* if there is an argument, set the "def iter" flag */
cptr.il->count = esp->val1; /* save the count */
}
esp->flag1 = 0; /* consume the argument, if any */
@@ -195,7 +196,7 @@ exec_cmds1()
if (!esp->flag1) ERROR(E_NAQ); /* must be an argument */
esp->flag1 = 0; /* consume argument */
esp->op = OP_START;
- switch (mapch_l[getcmdc(trace_sw)])
+ switch (mapch_l[(unsigned char)getcmdc(trace_sw)])
{
case 'a':
cond = isalpha(esp->val1);
@@ -500,7 +501,7 @@ exec_cmds1()
qreg[mm].z = 0;
}
- if (ll = line_args(0, &aa)) /* read args and move chars, if any */
+ if ((ll = line_args(0, &aa)) != 0) /* read args and move chars, if any */
{
make_buffer(&qreg[mm]); /* attach a text buffer to the q register */
for (bb.p = qreg[mm].f; bb.p->f != NULL; bb.p = bb.p->f); /* find end of reg */
@@ -603,14 +604,14 @@ exec_cmds1()
{
if (ctrl_r != 16) /* octal or decimal */
{ /* stop if not a valid digit */
- if ((!isdigit(aa.p->ch[aa.c])) || (aa.p->ch[aa.c] - '0' >= ctrl_r)) break;
+ if ((!isdigit((unsigned char)aa.p->ch[aa.c])) || (aa.p->ch[aa.c] - '0' >= ctrl_r)) break;
esp->val1 = esp->val1 * ctrl_r + (aa.p->ch[aa.c] - '0');
}
else
{
- if (!isxdigit(aa.p->ch[aa.c])) break;
- esp->val1 = esp->val1 * 16 + ( (isdigit(aa.p->ch[aa.c])) ?
- aa.p->ch[aa.c] - '0' : mapch_l[aa.p->ch[aa.c]] - 'a' + 10);
+ if (!isxdigit((unsigned char)aa.p->ch[aa.c])) break;
+ esp->val1 = esp->val1 * 16 + ( (isdigit((unsigned char)aa.p->ch[aa.c])) ?
+ aa.p->ch[aa.c] - '0' : mapch_l[(unsigned char)aa.p->ch[aa.c]] - 'a' + 10);
} /* end of hex */
} /* end of digit processing */
} /* end of "for each char" */
$NetBSD: patch-te__fxstub.c,v 1.1 2012/12/27 06:13:20 dholland Exp $
- declare void functions void
- use c89
--- te_fxstub.c~ 1993-08-05 22:29:34.000000000 +0000
+++ te_fxstub.c
@@ -10,7 +10,7 @@
#include "te_defs.h"
-te_fx()
+VOID te_fx(void)
{
ERROR(E_IFC);
}
$NetBSD: patch-te__main.c,v 1.1 2012/12/27 06:13:20 dholland Exp $
- use standard headers
- move external function declarations to header file
- avoid implicit int
- declare void functions void
- use C89 some
- apply static to a couple local functions
- silence warnings about assignments in conditionals
- remove unused variables
- don't declare own getenv()
--- te_main.c.orig 1993-08-05 22:29:34.000000000 +0000
+++ te_main.c
@@ -49,20 +49,18 @@
*/
#include "te_defs.h"
+#include <stdlib.h>
#include <signal.h>
-#ifdef _AIX
#include <sys/ioctl.h>
-#endif
-int cleanup();
+static VOID save_args(int argc, char *argv[], struct qh *q);
+static VOID read_startup(void);
+static VOID print_string(int arg);
-main(argc, argv)
+int main(argc, argv)
int argc; /* arg count */
char *argv[]; /* array of string pointers */
{
- int i;
- VOID init_wd();
-
init_wd(); /* set working directory */
save_args(argc, argv, &qreg[36]); /* copy command line to Qz */
read_startup(); /* read startup file */
@@ -74,7 +72,7 @@ main(argc, argv)
qsp = &qstack[-1]; /* initialize q-reg stack pointer */
/* set up error restart */
- if (err = setjmp(xxx))
+ if ((err = setjmp(xxx)) != 0)
{
if (err == E_EFI) goto quit; /* EOF from standard input - clean up and exit */
crlf();
@@ -125,7 +123,7 @@ main(argc, argv)
/* reset screen state, keyboard state; remove open output files */
-cleanup()
+VOID cleanup(void)
{
window(WIN_OFF); /* restore screen */
setup_tty(TTY_OFF); /* restore terminal */
@@ -137,7 +135,7 @@ cleanup()
/* print string for error message */
/* argument is subscript of a qreg qh, prints text from that buffer */
-print_string(arg)
+static VOID print_string(arg)
int arg;
{
int i, c;
@@ -158,7 +156,7 @@ print_string(arg)
}
/* copy invocation command line to a text buffer */
-save_args(argc, argv, q)
+static VOID save_args(argc, argv, q)
int argc;
char *argv[];
struct qh *q;
@@ -196,7 +194,7 @@ save_args(argc, argv, q)
char startup_name[] = "/.tecorc"; /* name of startup file */
-read_startup()
+static VOID read_startup(void)
{
char *hp, *getenv();
char fn[CELLSIZE]; /* filename storage */
@@ -206,7 +204,7 @@ read_startup()
if (!(eisw = fopen(&startup_name[1], "r")))
{
- if (hp = getenv("HOME")) /* if not found, look in home directory */
+ if ((hp = getenv("HOME")) != NULL) /* if not found, look in home directory */
{
for (i = 0; i < CELLSIZE; i++) if (!(fn[i] = *(hp++))) break; /* copy until trailing null */
for (hp = &startup_name[0]; i < CELLSIZE; i++) if (!(fn[i] = *(hp++))) break;
@@ -242,7 +240,6 @@ VOID update_header()
char header_text[HEADER_SIZE+3];
char *ps, *pd;
char *pdir;
- int i;
if (toolsw != 0) /* if running under SunWindows */
{
@@ -281,21 +278,20 @@ VOID update_header()
/* routine to get terminal height and width from termcap */
#ifdef NO_TERMCAP
-get_term_par()
+VOID get_term_par(void)
{
char *pname;
- char *getenv();
struct winsize ws;
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) == 0)
set_term_par(ws.ws_row, ws.ws_col);
- if (pname=getenv("TERM")) {
+ if ((pname=getenv("TERM")) != NULL) {
make_buffer(&timbuf); /* put terminal name in q# */
for (timbuf.z = 0; *pname != '\0'; )
timbuf.f->ch[timbuf.z++] = *pname++;
}
}
#else /* USE_TERMCAP */
-get_term_par()
+VOID get_term_par(void)
{
char tbuff[1024]; /* termcap buffer */
char *pname; /* pointer to name of terminal */
$NetBSD: patch-te__srch.c,v 1.1 2012/12/27 06:13:20 dholland Exp $
- use static for local functions
- don't index arrays with (signed) char
- use <ctype.h> functions correctly
- avoid implicit int
- remove unused variable
--- te_srch.c~ 1993-08-05 22:29:35.000000000 +0000
+++ te_srch.c
@@ -9,6 +9,8 @@
#include "te_defs.h"
+static int srch_cmp(void);
+
/* routine to read in a string with string-build characters */
/* used for search, tag, file name operations */
/* returns 0 if empty string entered, nonzero otherwise */
@@ -44,17 +46,17 @@ int build_string(sbuff)
case CTL('V'): /* take next char as lower case */
if (getcmdc(trace_sw) == term_char) ERROR((msp <= &mstack[0]) ? E_UTC : E_UTM);
- c = mapch_l[cmdc];
+ c = mapch_l[(unsigned char)cmdc];
break;
case CTL('W'): /* take next char as upper case */
if ((c = getcmdc(trace_sw)) == term_char) ERROR((msp <= &mstack[0]) ? E_UTC : E_UTM);
- if (islower(c)) c = toupper(c);
+ if (islower((unsigned char)c)) c = toupper((unsigned char)c);
break;
case CTL('E'): /* expanded constructs */
if (getcmdc(trace_sw) == term_char) ERROR((msp <= &mstack[0]) ? E_UTC : E_UTM);
- switch (mapch_l[cmdc])
+ switch (mapch_l[(unsigned char)cmdc])
{
case 'u': /* use char in q-reg */
if (getcmdc(trace_sw) == term_char) ERROR((msp <= &mstack[0]) ? E_UTC : E_UTM);
@@ -157,7 +159,7 @@ int setup_search()
/* routine to do N, _, E_ searches: search, if search fails, then get */
/* next page and continue */
-do_nsearch(arg)
+int do_nsearch(arg)
char arg; /* arg is 'n', '_', or 'e' to define which search */
{
int scount; /* search count */
@@ -233,7 +235,7 @@ int do_search(count)
for (sb.p = aa.p, sb.c = aa.c, sb.dot = aa.dot, sm.p = sbuf.f, sm.dot = sm.c = 0;
(sb.dot < pbuff->z) && (sm.dot < sm.z); sm.dot++, sb.dot++)
{ /* for each char in search string */
- if (spec_chars[ sm.p->ch[sm.c] ] & A_A) /* if search string char is "special" */
+ if (spec_chars[ (unsigned char)sm.p->ch[sm.c] ] & A_A) /* if search string char is "special" */
{
if (!srch_cmp()) break; /* then use expanded comparison routine */
}
@@ -290,7 +292,7 @@ int do_search(count)
for (sb.p = aa.p, sb.c = aa.c, sb.dot = aa.dot, sm.p = sbuf.f, sm.dot = sm.c = 0;
(sb.dot < last_z) && (sm.dot < sm.z); sm.dot++, sb.dot++)
{ /* loop to compare string */
- if (spec_chars[ sm.p->ch[sm.c] ] & A_A) /* if search string char is "special" */
+ if (spec_chars[ (unsigned char)sm.p->ch[sm.c] ] & A_A) /* if search string char is "special" */
{
if (!srch_cmp()) break; /* then use expanded comparison routine */
}
@@ -345,13 +347,13 @@ int do_search(count)
/* expanded search comparison */
/* returns 1 if match, 0 if not */
-int srch_cmp()
+static int srch_cmp(void)
{
int tq; /* q-reg name for ^EGq */
struct qp tqp; /* pointer to read q reg */
- int qq,oqq,i;
+ int qq,oqq;
- switch (mapch_l[sm.p->ch[sm.c]]) /* what is search character */
+ switch (mapch_l[(unsigned char)sm.p->ch[sm.c]]) /* what is search character */
{
case CTL('N'): /* match anything but following construct */
if (sm.dot >= sm.z) ERROR(E_ISS); /* don't read past end of string */
@@ -368,36 +370,36 @@ int srch_cmp()
return(*(pmap + sb.p->ch[sb.c]) == *(pmap + sm.p->ch[sm.c]));
case CTL('S'): /* match any nonalphanumeric */
- return(!isalnum(sb.p->ch[sb.c]));
+ return(!isalnum((unsigned char)sb.p->ch[sb.c]));
case CTL('E'):
if (sm.dot >= sm.z) ERROR(E_ISS); /* don't read past end of string */
fwdc(&sm); /* skip the ^E */
- switch (mapch_l[sm.p->ch[sm.c]])
+ switch (mapch_l[(unsigned char)sm.p->ch[sm.c]])
{
case 'a': /* match any alpha */
- return(isalpha(sb.p->ch[sb.c]));
+ return(isalpha((unsigned char)sb.p->ch[sb.c]));
case 'b': /* match any nonalpha */
- return(!isalnum(sb.p->ch[sb.c]));
+ return(!isalnum((unsigned char)sb.p->ch[sb.c]));
case 'c': /* rad50 symbol constituent */
- return(isalnum(sb.p->ch[sb.c]) || (sb.p->ch[sb.c] == '$') || (sb.p->ch[sb.c] == '.'));
+ return(isalnum((unsigned char)sb.p->ch[sb.c]) || (sb.p->ch[sb.c] == '$') || (sb.p->ch[sb.c] == '.'));
case 'd': /* digit */
- return(isdigit(sb.p->ch[sb.c]));
+ return(isdigit((unsigned char)sb.p->ch[sb.c]));
case 'l': /* line terminator LF, VT, FF */
return((sb.p->ch[sb.c] == LF) || (sb.p->ch[sb.c] == FF) || (sb.p->ch[sb.c] == VT));
case 'r': /* alphanumeric */
- return(isalnum(sb.p->ch[sb.c]));
+ return(isalnum((unsigned char)sb.p->ch[sb.c]));
case 'v': /* lower case */
- return(islower(sb.p->ch[sb.c]));
+ return(islower((unsigned char)sb.p->ch[sb.c]));
case 'w': /* upper case */
- return(isupper(sb.p->ch[sb.c]));
+ return(isupper((unsigned char)sb.p->ch[sb.c]));
case 's': /* any non-null string of spaces or tabs */
if (((sb.p->ch[sb.c]&0177) != ' ') && ((sb.p->ch[sb.c]&0177) != TAB)) return(0); /* failure */
/* skip remaining spaces or tabs */
@@ -431,15 +433,15 @@ int srch_cmp()
for (qq=64; qq>0 ; qq/=8) {
if (sm.dot >= sm.z) ERROR(E_ISS);
fwdc(&sm);
- if (mapch_l[sm.p->ch[sm.c]] < '0' || mapch_l[sm.p->ch[sm.c]] > '7')
+ if (mapch_l[(unsigned char)sm.p->ch[sm.c]] < '0' || mapch_l[(unsigned char)sm.p->ch[sm.c]] > '7')
ERROR(E_ISS);
- oqq+=qq*(mapch_l[sm.p->ch[sm.c]] - '0');
+ oqq+=qq*(mapch_l[(unsigned char)sm.p->ch[sm.c]] - '0');
}
if (oqq > 255)
ERROR(E_ISS);
if (sm.dot >= sm.z) ERROR(E_ISS);
fwdc(&sm);
- if (mapch_l[sm.p->ch[sm.c]] != '>')
+ if (mapch_l[(unsigned char)sm.p->ch[sm.c]] != '>')
ERROR(E_ISS);
return((int)(sb.p->ch[sb.c]) == oqq);
$NetBSD: patch-te__subs.c,v 1.1 2012/12/27 06:13:20 dholland Exp $
- declare void functions void
- don't index arrays with (signed) char
- use <ctype.h> functions correctly
--- te_subs.c.orig 1995-04-25 15:02:59.000000000 +0000
+++ te_subs.c
@@ -21,7 +21,7 @@
/* n is the returned number of chars moved */
/* max is the maximum number of chars to move */
-movenchars(from, to, n)
+VOID movenchars(from, to, n)
struct qp *from, *to; /* address of buffer pointers */
register int n; /* number of characters */
{
@@ -80,7 +80,8 @@ movenchars(from, to, n)
to->c = tc;
}
}
-moveuntil(from, to, c, n, max, trace)
+
+VOID moveuntil(from, to, c, n, max, trace)
struct qp *from, *to; /* address of buffer pointers */
register char c; /* match char that ends move */
int *n; /* pointer to returned value */
@@ -166,7 +167,7 @@ int lines(arg)
if (!(p = p->b)) break;
c = CELLSIZE - 1;
}
- if ( (ez_val & EZ_NOVTFF) ? (p->ch[c] == LF) : (spec_chars[p->ch[c]] & A_L) ) ++arg; /* if line sep found */
+ if ( (ez_val & EZ_NOVTFF) ? (p->ch[c] == LF) : (spec_chars[(unsigned char)p->ch[c]] & A_L) ) ++arg; /* if line sep found */
}
if (arg > 0) ++i; /* if terminated on a line separator, advance over the separator */
}
@@ -175,7 +176,7 @@ int lines(arg)
{
for (i = pbuff->dot; (arg > 0) && (i < pbuff->z); i++)
{
- if ( (ez_val & EZ_NOVTFF) ? (p->ch[c] == LF) : (spec_chars[p->ch[c]] & A_L) ) --arg;
+ if ( (ez_val & EZ_NOVTFF) ? (p->ch[c] == LF) : (spec_chars[(unsigned char)p->ch[c]] & A_L) ) --arg;
if (++c > CELLSIZE-1)
{
if (!(p = p->f)) break;
@@ -241,19 +242,19 @@ int getqspec(fors, c) /* fors ("file or
int fors;
char c;
{
- if (isdigit(c))
+ if (isdigit((unsigned char)c))
return(c - '0' + 1);
- else if (isalpha(c)) return(mapch_l[c] - 'a' + 11);
+ else if (isalpha((unsigned char)c)) return(mapch_l[(unsigned char)c] - 'a' + 11);
else if (c == '`')
{
- if (isdigit(c = getcmdc(trace_sw))) return (EXTQREGS + c - '0');
- else if (isalpha(c)) return (EXTQREGS + 10 + mapch_l[c] - 'a');
+ if (isdigit((unsigned char)(c = getcmdc(trace_sw)))) return (EXTQREGS + c - '0');
+ else if (isalpha((unsigned char)c)) return (EXTQREGS + 10 + mapch_l[(unsigned char)c] - 'a');
else ERROR(E_IQN);
}
else if (c == '~')
{
- if (isdigit(c = getcmdc(trace_sw))) return (EXTQREGS + NEXTQREGS/2 + c - '0');
- else if (isalpha(c)) return (EXTQREGS + NEXTQREGS/2 + 10 + mapch_l[c] - 'a');
+ if (isdigit((unsigned char)(c = getcmdc(trace_sw)))) return (EXTQREGS + NEXTQREGS/2 + c - '0');
+ else if (isalpha((unsigned char)c)) return (EXTQREGS + NEXTQREGS/2 + 10 + mapch_l[(unsigned char)c] - 'a');
else ERROR(E_IQN);
}
else if (fors)
@@ -276,7 +277,7 @@ int getqspec(fors, c) /* fors ("file or
struct buffcell *insert_p;
-insert1()
+VOID insert1(void)
{
int nchars; /* number of chars in cell */
@@ -293,7 +294,8 @@ insert1()
movenchars(&aa, &bb, nchars); /* copy cell up to dot */
}
-insert2(count) /* count is the number of chars added */
+
+VOID insert2(count) /* count is the number of chars added */
int count;
{
aa.p->b->f = insert_p; /* put the new cell where the old one was */
@@ -314,7 +316,7 @@ insert1()
/* subroutine to delete n characters starting at dot */
/* argument is number of characters */
-delete1(nchars)
+VOID delete1(nchars)
int nchars;
{
if (!nchars) return; /* 0 chars is a nop */
@@ -339,7 +341,7 @@ delete1(nchars)
struct qh obuff; /* tag string buffer */
-do_o()
+VOID do_o(void)
{
int i, j; /* i used as start of tag, j as end */
int p, level; /* p is pointer to tag string, level is iteration lvl */
@@ -400,7 +402,7 @@ do_o()
for (p = i; p < j; p++)
{
if (getcmdc(0) == '!') epfound = 1; /* mark "trailing ! found */
- if (mapch_l[cmdc] != mapch_l[obuff.f->ch[p]]) break; /* compare */
+ if (mapch_l[(unsigned char)cmdc] != mapch_l[(unsigned char)obuff.f->ch[p]]) break; /* compare */
}
if (p >= j) /* if all comparison chars matched */
{
@@ -426,7 +428,7 @@ char skipto(arg)
for (atsw = 0; ;) /* forever */
{
- while (!(ta = spec_chars[skipc = getcmdc(0)] & (A_X | A_S | A_T | A_Q))); /* read until something interesting found */
+ while (!(ta = spec_chars[(unsigned char)(skipc = getcmdc(0))] & (A_X | A_S | A_T | A_Q))); /* read until something interesting found */
again:
if (ta & A_Q) if((tb = getcmdc(0)) == '`' || tb == '~') getcmdc(0); /* if command takes a Q spec, skip the spec */
@@ -440,7 +442,7 @@ char skipto(arg)
switch (skipc)
{
case '^': /* treat next char as CTL */
- if (ta = spec_chars[skipc = getcmdc(0) & 0x1f]) goto again;
+ if ((ta = spec_chars[(unsigned char)(skipc = getcmdc(0) & 0x1f)]) != 0) goto again;
break;
case '@': /* use alternative text terminator */
@@ -464,7 +466,7 @@ char skipto(arg)
case 'e': /* first char of two-letter E or F command */
case 'f':
- if (spec_chars[getcmdc(0)] & ((skipc == 'e') ? A_E : A_F)) /* if one with a text arg */
+ if (spec_chars[(unsigned char)getcmdc(0)] & ((skipc == 'e') ? A_E : A_F)) /* if one with a text arg */
{
term = (atsw) ? getcmdc(0) : ESC;
atsw = 0;
@@ -485,7 +487,7 @@ char skipto(arg)
/* find number of characters to next matching (, [, or { (like '%' in vi) */
-do_ctlp()
+VOID do_ctlp(void)
{
int i, l;
char c, c1;
$NetBSD: patch-te__utils.c,v 1.1 2012/12/27 06:13:20 dholland Exp $
- use standard headers
- don't declare own malloc
- fix signed/unsigned mismatches
- remove useless/dangerous cast
- declare void functions void
- avoid implicit int
- don't index arrays with signed char
--- te_utils.c.orig 1993-08-05 22:29:35.000000000 +0000
+++ te_utils.c
@@ -7,6 +7,7 @@
/* improved dly_freebuf 03/30/92 11.23 */
#include "te_defs.h"
+#include <stdlib.h>
/* routines to handle storage */
/* get a buffcell */
@@ -14,13 +15,12 @@
struct buffcell *get_bcell()
{
- char *malloc();
struct buffcell *p;
- int i;
+ unsigned i;
if (freebuff == NULL)
{
- p = (struct buffcell *) malloc(BLOCKSIZE);
+ p = malloc(BLOCKSIZE);
if (!p) ERROR(E_MEM);
else
{
@@ -40,7 +40,7 @@ struct buffcell *get_bcell()
/* free a list of buffcells */
-free_blist(p)
+VOID free_blist(p)
struct buffcell *p;
{
struct buffcell *t;
@@ -53,7 +53,7 @@ free_blist(p)
}
}
/* free a list of buffcells to the "delayed free" list */
-dly_free_blist(p)
+VOID dly_free_blist(p)
struct buffcell *p;
{
struct buffcell *t;
@@ -110,7 +110,7 @@ VOID reset_q_usecounts()
struct is *get_dcell()
{
struct is *t;
- int i;
+ unsigned i;
if (freedcell == NULL)
{
@@ -129,7 +129,7 @@ struct is *get_dcell()
}
/* build a buffer: called with address of a qh */
/* if no buffer there, get a cell and link it in */
-make_buffer(p)
+VOID make_buffer(p)
struct qh *p;
{
if (!(p->f))
@@ -163,7 +163,7 @@ int fwdc(arg)
return(1);
}
-fwdcx(arg)
+int fwdcx(arg)
struct qp *arg;
{
if ((*arg).c >= CELLSIZE-1) /* test char count for max */
@@ -200,7 +200,7 @@ fwdcx(arg)
/* set up a pointer to a particular text buffer position */
-set_pointer(pos, ptr) /* first arg is position, 2nd is addr of pointer */
+VOID set_pointer(pos, ptr) /* first arg is position, 2nd is addr of pointer */
int pos;
struct qp *ptr;
{
@@ -225,7 +225,7 @@ set_pointer(pos, ptr) /* first arg is po
/* if pushcmdc() has returned any chars, read them first */
/* routines type characters as read, if argument != 0 */
-char getcmdc0(trace)
+char getcmdc0(int trace)
{
while (cptr.dot >= cptr.z) /* if at end of this level, pop macro stack */
{
@@ -252,7 +252,7 @@ char getcmdc0(trace)
}
-char getcmdc(trace)
+char getcmdc(int trace)
{
if (cptr.dot++ >= cptr.z) ERROR((msp <= &mstack[0]) ? E_UTC : E_UTM);
else
@@ -273,5 +273,5 @@ char getcmdc(trace)
int peekcmdc(arg)
char arg;
{
- return(((cptr.dot < cptr.z) && (mapch_l[cptr.p->ch[cptr.c]] == mapch_l[arg])) ? 1 : 0);
+ return(((cptr.dot < cptr.z) && (mapch_l[(unsigned char)cptr.p->ch[cptr.c]] == mapch_l[(unsigned char)arg])) ? 1 : 0);
}
$NetBSD: patch-te__window.c,v 1.1 2012/12/27 06:13:20 dholland Exp $
- remove unused variables
- fix signed/unsigned issues
- use static for local functions
- declare own functions
- declare void functions void
- use c89
- don't index arrays with (signed) char
- patch up two uninitialized variables
- silence warnings about assignments in conditionals
- #if out unused function putchar_d()
- silence unnecessary pointer width warning
--- te_window.c.orig 1995-04-25 15:02:41.000000000 +0000
+++ te_window.c
@@ -78,16 +78,37 @@ char win_dlyc[] = { 0, 2, 1, 0, 0, 0,
int rate[] = { 0, 0, 9600, 4800, 2400, 1800, 1200, 600, 300, 200, 150, 134, 110 };
#define NSPEEDS (sizeof(win_speeds) / sizeof(char))
#endif
-int real_win_speed = 0;
+static unsigned real_win_speed = 0;
#define win_speed ((ez_val & EZ_NOFILL) ? 0: real_win_speed)
-static int brate = 0;
+
+static VOID window0(int num);
+static VOID window1_both(void);
+static VOID window1(void);
+static VOID window1_abs(void);
+static VOID window1_inc(int wd);
+static VOID window1_after(void);
+static VOID w_rmcurs(void);
+static VOID window2(int arg);
+static VOID vtm(int arg);
+static VOID w_makecurs(char wc, short crflag);
+static int w_overflow(int wd);
+static VOID w_type(char c, int m);
+static VOID w_init(void);
+static VOID w_separators(void);
+static VOID w_move(short y, short x);
+static VOID w_scroll(int count);
+static VOID w_ebol(void);
+static int w_setptr(struct bh *pbuff, register int loc,
+ register struct qp *pp);
+static int w_lines(int n, register struct qp *ps, register struct qp *pd);
+
/* routine to perform simple scope operations */
/* (an attempt to concentrate VT-100 specific things in one place) */
-vt(func)
+VOID vt(func)
int func;
{
- short t;
+ unsigned t;
switch (func)
{
case VT_CLEAR: /* clear screen */
@@ -141,7 +162,7 @@ int win_min[] = { 4, 20, 4, 0, 0,
int win_max[] = { 4, W_MAX_H, W_MAX_V, 3, MAX, 12, -1, 20, 20, -1, -1 } ; /* max values */
int win_data[] = { 4, 132, 24, 0, 0, 0, 0, 0, 0, 0, 0 } ; /* window parameters */
-do_window(ref_flag)
+VOID do_window(ref_flag)
int ref_flag; /* nonzero forces "refresh" operation */
{
int i;
@@ -149,7 +170,7 @@ do_window(ref_flag)
if (colonflag && !ref_flag)
{
i = get_value(0); /* get sub-function */
- if ((i < 0) || (i > (sizeof(win_data)/sizeof(int)))) ERROR(E_IWA);
+ if ((i < 0) || (i > (int)(sizeof(win_data)/sizeof(int)))) ERROR(E_IWA);
if (!esp->flag2) /* it's a "get" */
{
esp->val1 = win_data[i];
@@ -205,7 +226,7 @@ do_window(ref_flag)
/* routine to update screen size with numbers obtained from environment */
/* (called by main program's initialization) */
-set_term_par(lines, cols)
+VOID set_term_par(lines, cols)
int lines, cols;
{
if ((lines >= win_min[2]) && (lines <= win_max[2])) win_1.size = win_data[2] = lines, win_1.end = lines - 1;
@@ -223,7 +244,7 @@ set_term_par(lines, cols)
/* WIN_LINE: does WIN_REFR unless that wouldn't do anything, in which case */
/* it does effective 1EV output */
-window(arg)
+VOID window(arg)
int arg;
{
int i;
@@ -308,8 +329,7 @@ window(arg)
/* used for ev, es, and <BS> or <LF> as immediate commands */
/* starting char position is in w_p1; argument is number of lines */
-window0(num)
-int num;
+static VOID window0(int num)
{
int wi;
char wc; /* temp char */
@@ -319,7 +339,7 @@ int num;
{
wc = w_p1.p->ch[w_p1.c]; /* get character */
- if ((char_count >= WN_width) && (wc != CR) && !(spec_chars[wc] & A_L)) /* if about to exceed width */
+ if ((char_count >= WN_width) && (wc != CR) && !(spec_chars[(unsigned char)wc] & A_L)) /* if about to exceed width */
{
if (et_val & ET_TRUNC) goto w0_noprint; /* truncate: don't print this */
else
@@ -383,7 +403,7 @@ int num;
struct bh *old_pbuff;
-window1_both()
+static VOID window1_both(void)
{
pw0 = &win_1;
pb0 = &buffs[0];
@@ -414,12 +434,14 @@ window1_both()
/* if scroll mode is enabled, the VT100 screen is split and only the upper part */
/* is used by this routine; else the whole screen is used. */
-window1()
+static VOID window1(void)
{
int i, j, m, lflag;
register struct bh *pb = pb0;
register struct w_data *pw = pw0;
+ lflag = 0; /* XXX is this right? */
+
/* return if nothing has changed */
if (!redraw_sw && (pbuff == old_pbuff) && (pb->dot == pw->last_dot) && (pb->buff_mod == MAX)) return;
@@ -514,7 +536,7 @@ window1()
}
/* routine to redraw screen absolutely */
-window1_abs()
+static VOID window1_abs(void)
{
int i, j;
struct bh *save_pbuff; /* save old pbuff during set_pointer call */
@@ -545,8 +567,8 @@ window1_abs()
/* redraw screen incrementally */
-window1_inc(wd)
- int wd; /* argument is earliest change */
+static VOID window1_inc(int wd)
+ /* argument is earliest change */
{
short temp_y;
register struct bh *pb = pb0;
@@ -572,12 +594,14 @@ window1_inc(wd)
}
/* routine to move window downwards: scroll up or redraw as appropriate */
-window1_after()
+static VOID window1_after(void)
{
int i, lflag;
register struct bh *pb = pb0;
register struct w_data *pw = pw0;
+ lflag = 0; /* XXX: is this right? */
+
w_rmcurs(); /* remove old cursor */
w_setptr(pb, wlp[pw->end]->start, &w_p1); /* set pointer to start of last line on screen */
@@ -604,7 +628,7 @@ window1_after()
/* routine to remove the existing cursor */
-w_rmcurs()
+static VOID w_rmcurs(void)
{
register struct w_data *pw = pw0;
@@ -621,8 +645,7 @@ w_rmcurs()
/* called with w_p1 at starting char, curr_y, curr_x at starting coordinate */
/* rewrites to end of screen if arg = 0, or only until line with cursor if arg = 1 */
-window2(arg)
- int arg;
+static VOID window2(int arg)
{
register struct bh *pb = pb0;
register struct w_data *pw = pw0;
@@ -635,7 +658,7 @@ window2(arg)
for (wdot = w_p1.dot; (curr_y <= pw->end) && (wdot < pb->z); wdot++) /* for each character */
{
wc = w_p1.p->ch[w_p1.c] & 0177; /* get character */
- if (dflag = (wdot == pb->dot)) if (arg) arg = -1; /* save "this is char at dot", "on line with dot" */
+ if ((dflag = (wdot == pb->dot)) != 0) if (arg) arg = -1; /* save "this is char at dot", "on line with dot" */
if (wc < ' ') switch (wc) /* dispatch control characters */
{
@@ -821,7 +844,7 @@ window2(arg)
wc = 'c'; /* get character */
else
wc = '`'; /* get character */
- if (dflag = (wdot == pb->dot)) if (arg) arg = -1; /* save "this is char at dot", "on line with dot" */
+ if ((dflag = (wdot == pb->dot)) != 0) if (arg) arg = -1; /* save "this is char at dot", "on line with dot" */
if (curr_x >= WN_width)
{
if (et_val & ET_TRUNC) goto noprint;
@@ -856,8 +879,7 @@ window2(arg)
}
/* routine to move cursor to current location and then call vt */
-vtm(arg)
- int arg;
+static VOID vtm(int arg)
{
w_move(curr_y, curr_x);
vt(arg);
@@ -869,9 +891,7 @@ vtm(arg)
/* routine to set reverse video and save cursor location */
/* first argument is char at cursor, 2nd is value for curs_crflag */
-w_makecurs(wc, crflag)
- char wc;
- short crflag;
+static VOID w_makecurs(char wc, short crflag)
{
register struct w_data *pw = pw0;
@@ -888,7 +908,7 @@ w_makecurs(wc, crflag)
/* returns nonzero if at end of screen, zero otherwise */
/* arg is current character position */
-int w_overflow(wd)
+static int w_overflow(int wd)
{
register struct w_data *pw = pw0;
@@ -912,12 +932,11 @@ int w_overflow(wd)
/* routine to type one character: arguments are char and a */
/* "mark" bit. If mark is set, the char is always retyped */
-w_type(c, m)
+static VOID w_type(c, m)
char c;
int m;
{
register char *p;
- register struct w_data *pw = pw0;
p = &wlp[curr_y]->ch[curr_x]; /* pointer to char image */
if ((c != *p) || (m) || (redraw_sw) || (curr_x >= wlp[curr_y]->n))
@@ -936,7 +955,7 @@ w_type(c, m)
/* initialize display image */
-w_init()
+static VOID w_init(void)
{
short i, j;
@@ -968,7 +987,7 @@ w_init()
/* write separator lines between windows on screen */
-w_separators()
+static VOID w_separators(void)
{
int i;
@@ -990,29 +1009,30 @@ w_separators()
/* put character followed by appropriate number of nulls for "other control function" */
/* if argument is 0, output filler chars only */
-putchar_d(c)
- char c;
+#if 0 /* not used */
+static VOID putchar_d(char c)
{
- int i;
+ unsigned i;
if (c) putchar(c); /* output character */
for (i = 0; i < win_dlyc[win_speed]; i++) putchar('\0'); /* output filler */
}
+#endif
/* put out appropriate number of filler chars for display function that scrolls (LF, etc.) */
-scroll_dly()
+VOID scroll_dly(void)
{
- int i;
+ unsigned i;
for (i = 0; i < win_dlys[win_speed]; i++) putchar('\0'); /* output filler */
}
/* move terminal cursor to stated y, x position */
/* uses incremental moves or absolute cursor position, whichever is shorter */
-w_move(y, x)
+static VOID w_move(y, x)
short y, x;
{
register short i;
@@ -1052,10 +1072,9 @@ w_move(y, x)
}
/* scroll screen: argument is count: + up, - down */
-w_scroll(count)
- int count;
+static VOID w_scroll(int count)
{
- register int i, ic;
+ register int i;
struct w_line *p[W_MAX_V]; /* temp copy of pointer array */
register struct w_data *pw = pw0;
@@ -1084,10 +1103,9 @@ w_scroll(count)
/* clear line to left of curr_x */
/* if some chars nonblank, does erase from start of line */
-w_ebol()
+static VOID w_ebol(void)
{
short i, j;
- register struct w_data *pw = pw0;
for (j = i = 0; i < curr_x; i++) if (wlp[curr_y]->ch[i] != ' ') wlp[curr_y]->ch[i] = ' ', j++;
if (j || redraw_sw) w_move(curr_y, curr_x-1), vt(VT_EBOL);
@@ -1098,7 +1116,7 @@ w_ebol()
/* routine to set a pointer to a given location (like set_pointer) */
/* returns nonzero if a text buffer exists, otherwise 0 */
-int w_setptr(pbuff, loc, pp)
+static int w_setptr(pbuff, loc, pp)
struct bh *pbuff; /* current buffer header */
register int loc; /* location */
register struct qp *pp; /* address of pointer */
@@ -1111,7 +1129,7 @@ int w_setptr(pbuff, loc, pp)
pp->c = loc % CELLSIZE;
pp->dot = loc;
}
- return( (int) pbuff->f);
+ return( pbuff->f != NULL );
}
/* routine to move N lines (back, forward, or 0) */
/* w_lines(n, &source, &dest) where n is the line count, source */
@@ -1121,7 +1139,7 @@ int w_setptr(pbuff, loc, pp)
struct qp w_lines_p; /* to compute # of display lines in -N lines */
-int w_lines(n, ps, pd)
+static int w_lines(n, ps, pd)
int n; /* number of lines */
register struct qp *ps, *pd; /* source, destination qp's */
{
@@ -1138,7 +1156,7 @@ int w_lines(n, ps, pd)
{
for (tcnt = tl = tn = 0; (tn < n) && (tdot < pb0->z); tdot++) /* forward over N line separators */
{
- if (spec_chars[ tch = tp->ch[tc] ] & A_L) ++tl, ++tn; /* count separators */
+ if (spec_chars[ (unsigned char)(tch = tp->ch[tc]) ] & A_L) ++tl, ++tn; /* count separators */
else if (!(et_val & ET_TRUNC)) /* if text lines can overflow screen lines */
{
if (!(tch & 0140)) /* if character is a control char */
@@ -1166,7 +1184,7 @@ int w_lines(n, ps, pd)
{
--tdot;
if (--tc < 0) tp = tp->b, tc = CELLSIZE -1;
- if (spec_chars[tp->ch[tc]] & A_L) --tn;
+ if (spec_chars[(unsigned char)tp->ch[tc]] & A_L) --tn;
}
if (tn < n) /* if stopped on a line sep, fwd over it */
{
@@ -1187,8 +1205,7 @@ int w_lines(n, ps, pd)
}
/* routine to move n chars on line */
/* call with # of columns, return new dot value */
-int x_to_dot(x)
- int x;
+static int x_to_dot(int x)
{
struct qp m_dot;
int m_count;
@@ -1227,7 +1244,7 @@ int last_dis_buff;
int last_dis_x;
int last_dis_wrap;
-VOID display_lines()
+VOID display_lines(void)
{
int dis_buff = (pbuff == &buffs[0]) ? 0 : 1 ; /* current buffer */
struct w_data *pw = dis_buff ? &win_2 : &win_1 ;