diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-04-10 13:26:05 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-04-10 13:26:05 +0000 |
commit | 5a709d61a37133c04bc540b7c531c49239e71145 (patch) | |
tree | c966d82948d199cb6fbe3ebf72b2838dcc15da99 /common | |
parent | 1abe484249caf1c5e462ce3110c8db09c059c6e8 (diff) | |
download | src-5a709d61a37133c04bc540b7c531c49239e71145.tar.gz src-5a709d61a37133c04bc540b7c531c49239e71145.zip |
Import nvi 2.1.3vendor/nvi/2.1.3
Approved by: peter
Notes
Notes:
svn path=/vendor/nvi/dist/; revision=281368
svn path=/vendor/nvi/2.1.3/; revision=281370; tag=vendor/nvi/2.1.3
Diffstat (limited to 'common')
-rw-r--r-- | common/common.h | 4 | ||||
-rw-r--r-- | common/conv.c | 538 | ||||
-rw-r--r-- | common/cut.c | 14 | ||||
-rw-r--r-- | common/delete.c | 2 | ||||
-rw-r--r-- | common/encoding.c | 26 | ||||
-rw-r--r-- | common/exf.c | 41 | ||||
-rw-r--r-- | common/extern.h | 262 | ||||
-rw-r--r-- | common/gs.h | 70 | ||||
-rw-r--r-- | common/key.c | 28 | ||||
-rw-r--r-- | common/line.c | 79 | ||||
-rw-r--r-- | common/log.c | 30 | ||||
-rw-r--r-- | common/main.c | 24 | ||||
-rw-r--r-- | common/mark.c | 16 | ||||
-rw-r--r-- | common/msg.c | 28 | ||||
-rw-r--r-- | common/options.c | 42 | ||||
-rw-r--r-- | common/options.h | 2 | ||||
-rw-r--r-- | common/options_f.c | 30 | ||||
-rw-r--r-- | common/put.c | 2 | ||||
-rw-r--r-- | common/recover.c | 29 | ||||
-rw-r--r-- | common/screen.c | 6 | ||||
-rw-r--r-- | common/search.c | 21 | ||||
-rw-r--r-- | common/seq.c | 30 | ||||
-rw-r--r-- | common/util.c | 30 |
23 files changed, 663 insertions, 691 deletions
diff --git a/common/common.h b/common/common.h index 71f4c7fb69cb..c64adb51d6b4 100644 --- a/common/common.h +++ b/common/common.h @@ -23,8 +23,8 @@ */ typedef struct _cb CB; typedef struct _csc CSC; -typedef struct _conv CONV; -typedef struct _conv_win CONVWIN; +typedef struct _conv CONV; +typedef struct _conv_win CONVWIN; typedef struct _event EVENT; typedef struct _excmd EXCMD; typedef struct _exf EXF; diff --git a/common/conv.c b/common/conv.c index 7803cec9922e..aaa7af37e548 100644 --- a/common/conv.c +++ b/common/conv.c @@ -12,7 +12,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: conv.c,v 2.39 2013/07/01 23:28:13 zy Exp $"; +static const char sccsid[] = "$Id: conv.c,v 2.40 2014/02/27 16:25:29 zy Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -36,35 +36,37 @@ static const char sccsid[] = "$Id: conv.c,v 2.39 2013/07/01 23:28:13 zy Exp $"; * codeset -- * Get the locale encoding. * - * PUBLIC: char * codeset __P((void)); + * PUBLIC: char * codeset(void); */ char * -codeset(void) { - static char *cs; +codeset(void) +{ + static char *cs; + + if (cs == NULL) + cs = nl_langinfo(CODESET); - if (cs == NULL) - cs = nl_langinfo(CODESET); - return cs; + return cs; } #ifdef USE_WIDECHAR static int -raw2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, - size_t *tolen, CHAR_T **dst) +raw2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, size_t *tolen, + CHAR_T **dst) { - int i; - CHAR_T **tostr = &cw->bp1.wc; - size_t *blen = &cw->blen1; + int i; + CHAR_T **tostr = &cw->bp1.wc; + size_t *blen = &cw->blen1; - BINC_RETW(NULL, *tostr, *blen, len); + BINC_RETW(NULL, *tostr, *blen, len); - *tolen = len; - for (i = 0; i < len; ++i) - (*tostr)[i] = (u_char) str[i]; + *tolen = len; + for (i = 0; i < len; ++i) + (*tostr)[i] = (u_char) str[i]; - *dst = cw->bp1.wc; + *dst = cw->bp1.wc; - return 0; + return 0; } #define CONV_BUFFER_SIZE 512 @@ -73,27 +75,27 @@ raw2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, * len contains the number of bytes put in the buffer */ #ifdef USE_ICONV -#define CONVERT(str, left, src, len) \ - do { \ - size_t outleft; \ - char *bp = buffer; \ - outleft = CONV_BUFFER_SIZE; \ - errno = 0; \ - if (iconv(id, (iconv_src_t)&str, &left, &bp, &outleft) == -1 && \ - errno != E2BIG) \ - goto err; \ - if ((len = CONV_BUFFER_SIZE - outleft) == 0) { \ - error = -left; \ - goto err; \ - } \ - src = buffer; \ - } while (0) +#define CONVERT(str, left, src, len) \ + do { \ + size_t outleft; \ + char *bp = buffer; \ + outleft = CONV_BUFFER_SIZE; \ + errno = 0; \ + if (iconv(id, (iconv_src_t)&str, &left, &bp, &outleft) \ + == -1 && errno != E2BIG) \ + goto err; \ + if ((len = CONV_BUFFER_SIZE - outleft) == 0) { \ + error = -left; \ + goto err; \ + } \ + src = buffer; \ + } while (0) #define IC_RESET() \ - do { \ - if (id != (iconv_t)-1) \ - iconv(id, NULL, NULL, NULL, NULL); \ - } while(0) + do { \ + if (id != (iconv_t)-1) \ + iconv(id, NULL, NULL, NULL, NULL); \ + } while(0) #else #define CONVERT(str, left, src, len) #define IC_RESET() @@ -101,114 +103,116 @@ raw2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, static int default_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, - size_t *tolen, CHAR_T **dst, iconv_t id) + size_t *tolen, CHAR_T **dst, iconv_t id) { - size_t i = 0, j; - CHAR_T **tostr = &cw->bp1.wc; - size_t *blen = &cw->blen1; - mbstate_t mbs; - size_t n; - ssize_t nlen = len; - char *src = (char *)str; + size_t i = 0, j; + CHAR_T **tostr = &cw->bp1.wc; + size_t *blen = &cw->blen1; + mbstate_t mbs; + size_t n; + ssize_t nlen = len; + char *src = (char *)str; #ifdef USE_ICONV - char buffer[CONV_BUFFER_SIZE]; + char buffer[CONV_BUFFER_SIZE]; #endif - size_t left = len; - int error = 1; + size_t left = len; + int error = 1; - BZERO(&mbs, 1); - BINC_RETW(NULL, *tostr, *blen, nlen); + BZERO(&mbs, 1); + BINC_RETW(NULL, *tostr, *blen, nlen); #ifdef USE_ICONV - if (id != (iconv_t)-1) - CONVERT(str, left, src, len); + if (id != (iconv_t)-1) + CONVERT(str, left, src, len); #endif - for (i = 0, j = 0; j < len; ) { - n = mbrtowc((*tostr)+i, src+j, len-j, &mbs); - /* NULL character converted */ - if (n == -2) error = -(len-j); - if (n == -1 || n == -2) goto err; - if (n == 0) n = 1; - j += n; - if (++i >= *blen) { - nlen += 256; - BINC_RETW(NULL, *tostr, *blen, nlen); - } - if (id != (iconv_t)-1 && j == len && left) { - CONVERT(str, left, src, len); - j = 0; + for (i = 0, j = 0; j < len; ) { + n = mbrtowc((*tostr)+i, src+j, len-j, &mbs); + /* NULL character converted */ + if (n == -2) + error = -(len-j); + if (n == -1 || n == -2) + goto err; + if (n == 0) + n = 1; + j += n; + if (++i >= *blen) { + nlen += 256; + BINC_RETW(NULL, *tostr, *blen, nlen); + } + if (id != (iconv_t)-1 && j == len && left) { + CONVERT(str, left, src, len); + j = 0; + } } - } - error = 0; + error = 0; err: - *tolen = i; - *dst = cw->bp1.wc; - IC_RESET(); + *tolen = i; + *dst = cw->bp1.wc; + IC_RESET(); - return error; + return error; } static int -fe_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, - size_t *tolen, CHAR_T **dst) +fe_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, size_t *tolen, + CHAR_T **dst) { - return default_char2int(sp, str, len, cw, tolen, dst, - sp->conv.id[IC_FE_CHAR2INT]); + return default_char2int(sp, str, len, cw, tolen, dst, + sp->conv.id[IC_FE_CHAR2INT]); } static int -ie_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, - size_t *tolen, CHAR_T **dst) +ie_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, size_t *tolen, + CHAR_T **dst) { - return default_char2int(sp, str, len, cw, tolen, dst, - sp->conv.id[IC_IE_CHAR2INT]); + return default_char2int(sp, str, len, cw, tolen, dst, + sp->conv.id[IC_IE_CHAR2INT]); } static int -cs_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, - size_t *tolen, CHAR_T **dst) +cs_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, size_t *tolen, + CHAR_T **dst) { - return default_char2int(sp, str, len, cw, tolen, dst, - (iconv_t)-1); + return default_char2int(sp, str, len, cw, tolen, dst, (iconv_t)-1); } static int -int2raw(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, - size_t *tolen, char **dst) +int2raw(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, size_t *tolen, + char **dst) { - int i; - char **tostr = &cw->bp1.c; - size_t *blen = &cw->blen1; + int i; + char **tostr = &cw->bp1.c; + size_t *blen = &cw->blen1; - BINC_RETC(NULL, *tostr, *blen, len); + BINC_RETC(NULL, *tostr, *blen, len); - *tolen = len; - for (i = 0; i < len; ++i) - (*tostr)[i] = str[i]; + *tolen = len; + for (i = 0; i < len; ++i) + (*tostr)[i] = str[i]; - *dst = cw->bp1.c; + *dst = cw->bp1.c; - return 0; + return 0; } static int default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, - size_t *tolen, char **pdst, iconv_t id) + size_t *tolen, char **pdst, iconv_t id) { - size_t i, j, offset = 0; - char **tostr = &cw->bp1.c; - size_t *blen = &cw->blen1; - mbstate_t mbs; - size_t n; - ssize_t nlen = len + MB_CUR_MAX; - char *dst; - size_t buflen; + size_t i, j, offset = 0; + char **tostr = &cw->bp1.c; + size_t *blen = &cw->blen1; + mbstate_t mbs; + size_t n; + ssize_t nlen = len + MB_CUR_MAX; + char *dst; + size_t buflen; #ifdef USE_ICONV - char buffer[CONV_BUFFER_SIZE]; + char buffer[CONV_BUFFER_SIZE]; #endif - int error = 1; + int error = 1; /* convert first len bytes of buffer and append it to cw->bp * len is adjusted => 0 @@ -217,87 +221,90 @@ default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, */ #ifdef USE_ICONV #define CONVERT2(_buffer, lenp, cw, offset) \ - do { \ - char *bp = _buffer; \ - int ret; \ do { \ - size_t outleft = cw->blen1 - offset; \ - char *obp = cw->bp1.c + offset; \ - if (cw->blen1 < offset + MB_CUR_MAX) { \ - nlen += 256; \ - BINC_RETC(NULL, cw->bp1.c, cw->blen1, nlen); \ - } \ - errno = 0; \ - ret = iconv(id, (iconv_src_t)&bp, lenp, &obp, &outleft); \ - if (ret == -1 && errno != E2BIG) \ - goto err; \ - offset = cw->blen1 - outleft; \ - } while (ret != 0); \ - } while (0) + char *bp = _buffer; \ + int ret; \ + do { \ + size_t outleft = cw->blen1 - offset; \ + char *obp = cw->bp1.c + offset; \ + if (cw->blen1 < offset + MB_CUR_MAX) { \ + nlen += 256; \ + BINC_RETC(NULL, cw->bp1.c, cw->blen1, \ + nlen); \ + } \ + errno = 0; \ + ret = iconv(id, (iconv_src_t)&bp, lenp, &obp, \ + &outleft); \ + if (ret == -1 && errno != E2BIG) \ + goto err; \ + offset = cw->blen1 - outleft; \ + } while (ret != 0); \ + } while (0) #else #define CONVERT2(_buffer, lenp, cw, offset) #endif - BZERO(&mbs, 1); - BINC_RETC(NULL, *tostr, *blen, nlen); - dst = *tostr; buflen = *blen; + BZERO(&mbs, 1); + BINC_RETC(NULL, *tostr, *blen, nlen); + dst = *tostr; buflen = *blen; #ifdef USE_ICONV - if (id != (iconv_t)-1) { - dst = buffer; buflen = CONV_BUFFER_SIZE; - } + if (id != (iconv_t)-1) { + dst = buffer; buflen = CONV_BUFFER_SIZE; + } #endif - for (i = 0, j = 0; i < len; ++i) { - n = wcrtomb(dst+j, str[i], &mbs); - if (n == -1) goto err; - j += n; - if (buflen < j + MB_CUR_MAX) { - if (id != (iconv_t)-1) { - CONVERT2(buffer, &j, cw, offset); - } else { - nlen += 256; - BINC_RETC(NULL, *tostr, *blen, nlen); - dst = *tostr; buflen = *blen; - } + for (i = 0, j = 0; i < len; ++i) { + n = wcrtomb(dst+j, str[i], &mbs); + if (n == -1) + goto err; + j += n; + if (buflen < j + MB_CUR_MAX) { + if (id != (iconv_t)-1) { + CONVERT2(buffer, &j, cw, offset); + } else { + nlen += 256; + BINC_RETC(NULL, *tostr, *blen, nlen); + dst = *tostr; buflen = *blen; + } + } } - } - n = wcrtomb(dst+j, L'\0', &mbs); - j += n - 1; /* don't count NUL at the end */ - *tolen = j; + n = wcrtomb(dst+j, L'\0', &mbs); + j += n - 1; /* don't count NUL at the end */ + *tolen = j; - if (id != (iconv_t)-1) { - CONVERT2(buffer, &j, cw, offset); - CONVERT2(NULL, NULL, cw, offset); /* back to the initial state */ - *tolen = offset; - } + if (id != (iconv_t)-1) { + CONVERT2(buffer, &j, cw, offset); + /* back to the initial state */ + CONVERT2(NULL, NULL, cw, offset); + *tolen = offset; + } - error = 0; + error = 0; err: - if (error) - *tolen = j; - *pdst = cw->bp1.c; - IC_RESET(); + if (error) + *tolen = j; + *pdst = cw->bp1.c; + IC_RESET(); - return error; + return error; } static int fe_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, - size_t *tolen, char **dst) + size_t *tolen, char **dst) { - return default_int2char(sp, str, len, cw, tolen, dst, - sp->conv.id[IC_FE_INT2CHAR]); + return default_int2char(sp, str, len, cw, tolen, dst, + sp->conv.id[IC_FE_INT2CHAR]); } static int cs_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, - size_t *tolen, char **dst) + size_t *tolen, char **dst) { - return default_int2char(sp, str, len, cw, tolen, dst, - (iconv_t)-1); + return default_int2char(sp, str, len, cw, tolen, dst, (iconv_t)-1); } #endif @@ -306,58 +313,58 @@ cs_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, * conv_init -- * Initialize the iconv environment. * - * PUBLIC: void conv_init __P((SCR *, SCR *)); + * PUBLIC: void conv_init(SCR *, SCR *); */ void conv_init(SCR *orig, SCR *sp) { - int i; + int i; - if (orig == NULL) - setlocale(LC_ALL, ""); - if (orig != NULL) - BCOPY(&orig->conv, &sp->conv, 1); + if (orig == NULL) + setlocale(LC_ALL, ""); + if (orig != NULL) + BCOPY(&orig->conv, &sp->conv, 1); #ifdef USE_WIDECHAR - else { - char *ctype = setlocale(LC_CTYPE, NULL); - - /* - * XXX - * This hack fixes the libncursesw issue on FreeBSD. - */ - if (!strcmp(ctype, "ko_KR.CP949")) - setlocale(LC_CTYPE, "ko_KR.eucKR"); - else if (!strcmp(ctype, "zh_CN.GB2312")) - setlocale(LC_CTYPE, "zh_CN.eucCN"); - else if (!strcmp(ctype, "zh_CN.GBK")) - setlocale(LC_CTYPE, "zh_CN.GB18030"); - - /* - * Switch to 8bit mode if locale is C; - * LC_CTYPE should be reseted to C if unmatched. - */ - if (!strcmp(ctype, "C") || !strcmp(ctype, "POSIX")) { - sp->conv.sys2int = sp->conv.file2int = raw2int; - sp->conv.int2sys = sp->conv.int2file = int2raw; - sp->conv.input2int = raw2int; - } else { - sp->conv.sys2int = cs_char2int; - sp->conv.int2sys = cs_int2char; - sp->conv.file2int = fe_char2int; - sp->conv.int2file = fe_int2char; - sp->conv.input2int = ie_char2int; - } + else { + char *ctype = setlocale(LC_CTYPE, NULL); + + /* + * XXX + * This hack fixes the libncursesw issue on FreeBSD. + */ + if (!strcmp(ctype, "ko_KR.CP949")) + setlocale(LC_CTYPE, "ko_KR.eucKR"); + else if (!strcmp(ctype, "zh_CN.GB2312")) + setlocale(LC_CTYPE, "zh_CN.eucCN"); + else if (!strcmp(ctype, "zh_CN.GBK")) + setlocale(LC_CTYPE, "zh_CN.GB18030"); + + /* + * Switch to 8bit mode if locale is C; + * LC_CTYPE should be reseted to C if unmatched. + */ + if (!strcmp(ctype, "C") || !strcmp(ctype, "POSIX")) { + sp->conv.sys2int = sp->conv.file2int = raw2int; + sp->conv.int2sys = sp->conv.int2file = int2raw; + sp->conv.input2int = raw2int; + } else { + sp->conv.sys2int = cs_char2int; + sp->conv.int2sys = cs_int2char; + sp->conv.file2int = fe_char2int; + sp->conv.int2file = fe_int2char; + sp->conv.input2int = ie_char2int; + } #ifdef USE_ICONV - o_set(sp, O_INPUTENCODING, OS_STRDUP, codeset(), 0); + o_set(sp, O_INPUTENCODING, OS_STRDUP, codeset(), 0); #endif - } + } #endif - /* iconv descriptors must be distinct to screens. */ - for (i = 0; i <= IC_IE_TO_UTF16; ++i) - sp->conv.id[i] = (iconv_t)-1; + /* iconv descriptors must be distinct to screens. */ + for (i = 0; i <= IC_IE_TO_UTF16; ++i) + sp->conv.id[i] = (iconv_t)-1; #ifdef USE_ICONV - conv_enc(sp, O_INPUTENCODING, 0); + conv_enc(sp, O_INPUTENCODING, 0); #endif } @@ -365,82 +372,99 @@ conv_init(SCR *orig, SCR *sp) * conv_enc -- * Convert file/input encoding. * - * PUBLIC: int conv_enc __P((SCR *, int, char *)); + * PUBLIC: int conv_enc(SCR *, int, char *); */ int conv_enc(SCR *sp, int option, char *enc) { #if defined(USE_WIDECHAR) && defined(USE_ICONV) - iconv_t *c2w, *w2c; + iconv_t *c2w, *w2c; + iconv_t id_c2w, id_w2c; + + switch (option) { + case O_FILEENCODING: + c2w = sp->conv.id + IC_FE_CHAR2INT; + w2c = sp->conv.id + IC_FE_INT2CHAR; + if (!enc) + enc = O_STR(sp, O_FILEENCODING); + + if (strcasecmp(codeset(), enc)) { + if ((id_c2w = iconv_open(codeset(), enc)) == + (iconv_t)-1) + goto err; + if ((id_w2c = iconv_open(enc, codeset())) == + (iconv_t)-1) + goto err; + } else { + id_c2w = (iconv_t)-1; + id_w2c = (iconv_t)-1; + } + + break; + + case O_INPUTENCODING: + c2w = sp->conv.id + IC_IE_CHAR2INT; + w2c = sp->conv.id + IC_IE_TO_UTF16; + if (!enc) + enc = O_STR(sp, O_INPUTENCODING); + + if (strcasecmp(codeset(), enc)) { + if ((id_c2w = iconv_open(codeset(), enc)) == + (iconv_t)-1) + goto err; + } else + id_c2w = (iconv_t)-1; + + /* UTF-16 can not be locale and can not be inputed. */ + if ((id_w2c = iconv_open("utf-16be", enc)) == (iconv_t)-1) + goto err; + + break; + + default: + abort(); + } - switch (option) { - case O_FILEENCODING: - c2w = sp->conv.id + IC_FE_CHAR2INT; - w2c = sp->conv.id + IC_FE_INT2CHAR; - if (!enc) enc = O_STR(sp, O_FILEENCODING); - if (*c2w != (iconv_t)-1) - iconv_close(*c2w); - if (*w2c != (iconv_t)-1) - iconv_close(*w2c); - if (strcasecmp(codeset(), enc)) { - if ((*c2w = iconv_open(codeset(), enc)) == (iconv_t)-1) - goto err; - if ((*w2c = iconv_open(enc, codeset())) == (iconv_t)-1) - goto err; - } else *c2w = *w2c = (iconv_t)-1; - break; - case O_INPUTENCODING: - c2w = sp->conv.id + IC_IE_CHAR2INT; - w2c = sp->conv.id + IC_IE_TO_UTF16; - if (!enc) enc = O_STR(sp, O_INPUTENCODING); if (*c2w != (iconv_t)-1) - iconv_close(*c2w); + iconv_close(*c2w); if (*w2c != (iconv_t)-1) - iconv_close(*w2c); - if (strcasecmp(codeset(), enc)) { - if ((*c2w = iconv_open(codeset(), enc)) == (iconv_t)-1) - goto err; - } else *c2w = (iconv_t)-1; - /* UTF-16 can not be locale and can not be inputed. */ - if ((*w2c = iconv_open("utf-16be", enc)) == (iconv_t)-1) - goto err; - break; - } - - F_CLR(sp, SC_CONV_ERROR); - F_SET(sp, SC_SCR_REFORMAT); - - return 0; + iconv_close(*w2c); + + *c2w = id_c2w; + *w2c = id_w2c; + + F_CLR(sp, SC_CONV_ERROR); + F_SET(sp, SC_SCR_REFORMAT); + + return 0; err: #endif - switch (option) { - case O_FILEENCODING: - msgq(sp, M_ERR, - "321|File encoding conversion not supported"); - break; - case O_INPUTENCODING: - msgq(sp, M_ERR, - "322|Input encoding conversion not supported"); - break; - } - return 1; + switch (option) { + case O_FILEENCODING: + msgq(sp, M_ERR, "321|File encoding conversion not supported"); + break; + case O_INPUTENCODING: + msgq(sp, M_ERR, "322|Input encoding conversion not supported"); + break; + } + return 1; } /* * conv_end -- * Close the iconv descriptors, release the buffer. * - * PUBLIC: void conv_end __P((SCR *)); + * PUBLIC: void conv_end(SCR *); */ void conv_end(SCR *sp) { #if defined(USE_WIDECHAR) && defined(USE_ICONV) - int i; - for (i = 0; i <= IC_IE_TO_UTF16; ++i) - if (sp->conv.id[i] != (iconv_t)-1) - iconv_close(sp->conv.id[i]); + int i; + for (i = 0; i <= IC_IE_TO_UTF16; ++i) + if (sp->conv.id[i] != (iconv_t)-1) + iconv_close(sp->conv.id[i]); if (sp->cw.bp1.c != NULL) - free(sp->cw.bp1.c); + free(sp->cw.bp1.c); #endif } diff --git a/common/cut.c b/common/cut.c index 11db42fb8158..810aef6ac89c 100644 --- a/common/cut.c +++ b/common/cut.c @@ -27,7 +27,7 @@ static const char sccsid[] = "$Id: cut.c,v 10.12 2012/02/11 15:52:33 zy Exp $"; #include "common.h" -static void cb_rotate __P((SCR *)); +static void cb_rotate(SCR *); /* * cut -- @@ -61,7 +61,7 @@ static void cb_rotate __P((SCR *)); * replacing the contents. Hopefully it's not worth getting right, and here * we just treat the numeric buffers like any other named buffer. * - * PUBLIC: int cut __P((SCR *, CHAR_T *, MARK *, MARK *, int)); + * PUBLIC: int cut(SCR *, CHAR_T *, MARK *, MARK *, int); */ int cut( @@ -222,7 +222,7 @@ cb_rotate(SCR *sp) * cut_line -- * Cut a portion of a single line. * - * PUBLIC: int cut_line __P((SCR *, recno_t, size_t, size_t, CB *)); + * PUBLIC: int cut_line(SCR *, recno_t, size_t, size_t, CB *); */ int cut_line( @@ -266,7 +266,7 @@ cut_line( * cut_close -- * Discard all cut buffers. * - * PUBLIC: void cut_close __P((GS *)); + * PUBLIC: void cut_close(GS *); */ void cut_close(GS *gp) @@ -291,7 +291,7 @@ cut_close(GS *gp) * text_init -- * Allocate a new TEXT structure. * - * PUBLIC: TEXT *text_init __P((SCR *, const CHAR_T *, size_t, size_t)); + * PUBLIC: TEXT *text_init(SCR *, const CHAR_T *, size_t, size_t); */ TEXT * text_init( @@ -323,7 +323,7 @@ text_init( * text_lfree -- * Free a chain of text structures. * - * PUBLIC: void text_lfree __P((TEXTH *)); + * PUBLIC: void text_lfree(TEXTH *); */ void text_lfree(TEXTH *headp) @@ -340,7 +340,7 @@ text_lfree(TEXTH *headp) * text_free -- * Free a text structure. * - * PUBLIC: void text_free __P((TEXT *)); + * PUBLIC: void text_free(TEXT *); */ void text_free(TEXT *tp) diff --git a/common/delete.c b/common/delete.c index bb476c0c8a7c..b9bd0388946f 100644 --- a/common/delete.c +++ b/common/delete.c @@ -30,7 +30,7 @@ static const char sccsid[] = "$Id: delete.c,v 10.18 2012/02/11 15:52:33 zy Exp $ * del -- * Delete a range of text. * - * PUBLIC: int del __P((SCR *, MARK *, MARK *, int)); + * PUBLIC: int del(SCR *, MARK *, MARK *, int); */ int del( diff --git a/common/encoding.c b/common/encoding.c index 6de509e5b8ec..7bdcf7069238 100644 --- a/common/encoding.c +++ b/common/encoding.c @@ -11,10 +11,10 @@ static const char sccsid[] = "$Id: encoding.c,v 1.4 2011/12/13 19:40:52 zy Exp $ #include <sys/types.h> -int looks_utf8 __P((const char *, size_t)); -int looks_utf16 __P((const char *, size_t)); -int decode_utf8 __P((const char *)); -int decode_utf16 __P((const char *, int)); +int looks_utf8(const char *, size_t); +int looks_utf16(const char *, size_t); +int decode_utf8(const char *); +int decode_utf16(const char *, int); #define F 0 /* character never appears in text */ #define T 1 /* character appears in plain ASCII text */ @@ -54,7 +54,7 @@ static char text_chars[256] = { * * Based on RFC 3629. UTF-8 with BOM is not accepted. * - * PUBLIC: int looks_utf8 __P((const char *, size_t)); + * PUBLIC: int looks_utf8(const char *, size_t); */ int looks_utf8(const char *ibuf, size_t nbytes) @@ -115,7 +115,7 @@ done: * 1: Little-endian UTF-16 * 2: Big-endian UTF-16 * - * PUBLIC: int looks_utf16 __P((const char *, size_t)); + * PUBLIC: int looks_utf16(const char *, size_t); */ int looks_utf16(const char *ibuf, size_t nbytes) @@ -175,9 +175,11 @@ looks_utf16(const char *ibuf, size_t nbytes) * * Based on RFC 3629, but without error detection. * - * PUBLIC: int decode_utf8 __P((const char *)); + * PUBLIC: int decode_utf8(const char *); */ -int decode_utf8(const char *ibuf) { +int +decode_utf8(const char *ibuf) +{ const u_char *buf = (u_char *)ibuf; int u = -1; @@ -194,6 +196,7 @@ int decode_utf8(const char *ibuf) { u = (buf[0] ^ 0xF0) << 18 ^ (buf[1] ^ 0x80) << 12 ^ (buf[2] ^ 0x80) << 6 ^ (buf[3] ^ 0x80); } + return u; } @@ -204,9 +207,11 @@ int decode_utf8(const char *ibuf) { * * No error detection on supplementary bytes. * - * PUBLIC: int decode_utf16 __P((const char *, int)); + * PUBLIC: int decode_utf16(const char *, int); */ -int decode_utf16(const char* ibuf, int bigend) { +int +decode_utf16(const char* ibuf, int bigend) +{ const u_char *buf = (u_char *)ibuf; int u = -1; unsigned int w1, w2; @@ -226,5 +231,6 @@ int decode_utf16(const char* ibuf, int bigend) { w2 = buf[2] ^ buf[3] << 8; u = ((w1 ^ 0xD800) << 10 ^ (w2 ^ 0xDC00)) + 0x10000; } + return u; } diff --git a/common/exf.c b/common/exf.c index 6579ab2118d3..1fcf7f6da498 100644 --- a/common/exf.c +++ b/common/exf.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: exf.c,v 10.62 2013/07/01 23:28:13 zy Exp $"; +static const char sccsid[] = "$Id: exf.c,v 10.64 2015/04/05 15:21:55 zy Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -37,11 +37,11 @@ static const char sccsid[] = "$Id: exf.c,v 10.62 2013/07/01 23:28:13 zy Exp $"; #include "common.h" -static int file_backup __P((SCR *, char *, char *)); -static void file_cinit __P((SCR *)); -static void file_encinit __P((SCR *)); -static void file_comment __P((SCR *)); -static int file_spath __P((SCR *, FREF *, struct stat *, int *)); +static int file_backup(SCR *, char *, char *); +static void file_cinit(SCR *); +static void file_encinit(SCR *); +static void file_comment(SCR *); +static int file_spath(SCR *, FREF *, struct stat *, int *); /* * file_add -- @@ -56,7 +56,7 @@ static int file_spath __P((SCR *, FREF *, struct stat *, int *)); * vi now remembers the last location in any file that it has ever edited, * not just the previously edited file. * - * PUBLIC: FREF *file_add __P((SCR *, char *)); + * PUBLIC: FREF *file_add(SCR *, char *); */ FREF * file_add( @@ -118,7 +118,7 @@ file_add( * let go of any previous file. Don't release the previous file until * absolutely sure we have the new one. * - * PUBLIC: int file_init __P((SCR *, FREF *, char *, int)); + * PUBLIC: int file_init(SCR *, FREF *, char *, int); */ int file_init( @@ -259,6 +259,8 @@ file_init( DB_RECNO, &oinfo)) == NULL) { msgq_str(sp, M_SYSERR, rcv_name == NULL ? oname : rcv_name, "%s"); + if (F_ISSET(frp, FR_NEWFILE)) + goto err; /* * !!! * Historically, vi permitted users to edit files that couldn't @@ -340,6 +342,8 @@ file_init( break; case LOCK_UNAVAIL: readonly = 1; + if (F_ISSET(sp, SC_READONLY)) + break; msgq_str(sp, M_INFO, oname, "239|%s already locked, session is read-only"); break; @@ -625,7 +629,7 @@ file_cinit(SCR *sp) * file_end -- * Stop editing a file. * - * PUBLIC: int file_end __P((SCR *, EXF *, int)); + * PUBLIC: int file_end(SCR *, EXF *, int); */ int file_end( @@ -737,7 +741,7 @@ file_end( * semantics for whether or not writes would happen. That's * why all the flags. * - * PUBLIC: int file_write __P((SCR *, MARK *, MARK *, char *, int)); + * PUBLIC: int file_write(SCR *, MARK *, MARK *, char *, int); */ int file_write( @@ -841,7 +845,6 @@ file_write( return (1); /* Open the file. */ - SIGBLOCK; if ((fd = open(name, oflags, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) < 0) { if (errno == EACCES && LF_ISSET(FS_FORCE)) { @@ -873,11 +876,9 @@ file_write( errno = EACCES; } msgq_str(sp, M_SYSERR, name, "%s"); - SIGUNBLOCK; return (1); } success_open: - SIGUNBLOCK; /* Try and get a lock. */ if (!noname && file_lock(sp, NULL, fd, 0) == LOCK_UNAVAIL) @@ -1246,7 +1247,7 @@ file_encinit(SCR *sp) if (looks_utf8(buf, blen) > 1) o_set(sp, O_FILEENCODING, OS_STRDUP, "utf-8", 0); else if (!O_ISSET(sp, O_FILEENCODING) || - !strncasecmp(O_STR(sp, O_FILEENCODING), "utf-8", 5)) + !strcasecmp(O_STR(sp, O_FILEENCODING), "utf-8")) o_set(sp, O_FILEENCODING, OS_STRDUP, codeset(), 0); conv_enc(sp, O_FILEENCODING, 0); @@ -1302,7 +1303,7 @@ file_comment(SCR *sp) * First modification check routine. The :next, :prev, :rewind, :tag, * :tagpush, :tagpop, ^^ modifications check. * - * PUBLIC: int file_m1 __P((SCR *, int, int)); + * PUBLIC: int file_m1(SCR *, int, int); */ int file_m1( @@ -1343,7 +1344,7 @@ file_m1( * Second modification check routine. The :edit, :quit, :recover * modifications check. * - * PUBLIC: int file_m2 __P((SCR *, int)); + * PUBLIC: int file_m2(SCR *, int); */ int file_m2( @@ -1375,7 +1376,7 @@ file_m2( * file_m3 -- * Third modification check routine. * - * PUBLIC: int file_m3 __P((SCR *, int)); + * PUBLIC: int file_m3(SCR *, int); */ int file_m3( @@ -1411,7 +1412,7 @@ file_m3( * is not set, write the file. A routine so there's a place to put the * comment. * - * PUBLIC: int file_aw __P((SCR *, int)); + * PUBLIC: int file_aw(SCR *, int); */ int file_aw( @@ -1472,7 +1473,7 @@ file_aw( * If the user edits a temporary file, there may be times when there is no * alternative file name. A name argument of NULL turns it off. * - * PUBLIC: void set_alt_name __P((SCR *, char *)); + * PUBLIC: void set_alt_name(SCR *, char *); */ void set_alt_name( @@ -1491,7 +1492,7 @@ set_alt_name( * file_lock -- * Get an exclusive lock on a file. * - * PUBLIC: lockr_t file_lock __P((SCR *, char *, int, int)); + * PUBLIC: lockr_t file_lock(SCR *, char *, int, int); */ lockr_t file_lock( diff --git a/common/extern.h b/common/extern.h index 20672e380b14..f8acf8eacd83 100644 --- a/common/extern.h +++ b/common/extern.h @@ -1,132 +1,132 @@ -char * codeset __P((void)); -void conv_init __P((SCR *, SCR *)); -int conv_enc __P((SCR *, int, char *)); -void conv_end __P((SCR *)); -int cut __P((SCR *, CHAR_T *, MARK *, MARK *, int)); -int cut_line __P((SCR *, recno_t, size_t, size_t, CB *)); -void cut_close __P((GS *)); -TEXT *text_init __P((SCR *, const CHAR_T *, size_t, size_t)); -void text_lfree __P((TEXTH *)); -void text_free __P((TEXT *)); -int del __P((SCR *, MARK *, MARK *, int)); -int looks_utf8 __P((const char *, size_t)); -int looks_utf16 __P((const char *, size_t)); -int decode_utf8 __P((const char *)); -int decode_utf16 __P((const char *, int)); -FREF *file_add __P((SCR *, char *)); -int file_init __P((SCR *, FREF *, char *, int)); -int file_end __P((SCR *, EXF *, int)); -int file_write __P((SCR *, MARK *, MARK *, char *, int)); -int file_m1 __P((SCR *, int, int)); -int file_m2 __P((SCR *, int)); -int file_m3 __P((SCR *, int)); -int file_aw __P((SCR *, int)); -void set_alt_name __P((SCR *, char *)); -lockr_t file_lock __P((SCR *, char *, int, int)); -int v_key_init __P((SCR *)); -void v_key_ilookup __P((SCR *)); -size_t v_key_len __P((SCR *, ARG_CHAR_T)); -char *v_key_name __P((SCR *, ARG_CHAR_T)); -e_key_t v_key_val __P((SCR *, ARG_CHAR_T)); -int v_event_push __P((SCR *, EVENT *, CHAR_T *, size_t, u_int)); -int v_event_get __P((SCR *, EVENT *, int, u_int32_t)); -void v_event_err __P((SCR *, EVENT *)); -int v_event_flush __P((SCR *, u_int)); -int db_eget __P((SCR *, recno_t, CHAR_T **, size_t *, int *)); -int db_get __P((SCR *, recno_t, u_int32_t, CHAR_T **, size_t *)); -int db_delete __P((SCR *, recno_t)); -int db_append __P((SCR *, int, recno_t, CHAR_T *, size_t)); -int db_insert __P((SCR *, recno_t, CHAR_T *, size_t)); -int db_set __P((SCR *, recno_t, CHAR_T *, size_t)); -int db_exist __P((SCR *, recno_t)); -int db_last __P((SCR *, recno_t *)); -int db_rget __P((SCR *, recno_t, char **, size_t *)); -int db_rset __P((SCR *, recno_t, char *, size_t)); -void db_err __P((SCR *, recno_t)); -int log_init __P((SCR *, EXF *)); -int log_end __P((SCR *, EXF *)); -int log_cursor __P((SCR *)); -int log_line __P((SCR *, recno_t, u_int)); -int log_mark __P((SCR *, LMARK *)); -int log_backward __P((SCR *, MARK *)); -int log_setline __P((SCR *)); -int log_forward __P((SCR *, MARK *)); -int editor __P((GS *, int, char *[])); -void v_end __P((GS *)); -int mark_init __P((SCR *, EXF *)); -int mark_end __P((SCR *, EXF *)); -int mark_get __P((SCR *, ARG_CHAR_T, MARK *, mtype_t)); -int mark_set __P((SCR *, ARG_CHAR_T, MARK *, int)); -int mark_insdel __P((SCR *, lnop_t, recno_t)); -void msgq __P((SCR *, mtype_t, const char *, ...)); -void msgq_wstr __P((SCR *, mtype_t, const CHAR_T *, const char *)); -void msgq_str __P((SCR *, mtype_t, const char *, const char *)); -void mod_rpt __P((SCR *)); -void msgq_status __P((SCR *, recno_t, u_int)); -int msg_open __P((SCR *, char *)); -void msg_close __P((GS *)); -const char *msg_cmsg __P((SCR *, cmsg_t, size_t *)); -const char *msg_cat __P((SCR *, const char *, size_t *)); -char *msg_print __P((SCR *, const char *, int *)); -int opts_init __P((SCR *, int *)); -int opts_set __P((SCR *, ARGS *[], char *)); -int o_set __P((SCR *, int, u_int, char *, u_long)); -int opts_empty __P((SCR *, int, int)); -void opts_dump __P((SCR *, enum optdisp)); -int opts_save __P((SCR *, FILE *)); -OPTLIST const *opts_search __P((CHAR_T *)); -void opts_nomatch __P((SCR *, CHAR_T *)); -int opts_copy __P((SCR *, SCR *)); -void opts_free __P((SCR *)); -int f_altwerase __P((SCR *, OPTION *, char *, u_long *)); -int f_columns __P((SCR *, OPTION *, char *, u_long *)); -int f_lines __P((SCR *, OPTION *, char *, u_long *)); -int f_lisp __P((SCR *, OPTION *, char *, u_long *)); -int f_msgcat __P((SCR *, OPTION *, char *, u_long *)); -int f_print __P((SCR *, OPTION *, char *, u_long *)); -int f_readonly __P((SCR *, OPTION *, char *, u_long *)); -int f_recompile __P((SCR *, OPTION *, char *, u_long *)); -int f_reformat __P((SCR *, OPTION *, char *, u_long *)); -int f_ttywerase __P((SCR *, OPTION *, char *, u_long *)); -int f_w300 __P((SCR *, OPTION *, char *, u_long *)); -int f_w1200 __P((SCR *, OPTION *, char *, u_long *)); -int f_w9600 __P((SCR *, OPTION *, char *, u_long *)); -int f_window __P((SCR *, OPTION *, char *, u_long *)); -int f_encoding __P((SCR *, OPTION *, char *, u_long *)); -int put __P((SCR *, CB *, CHAR_T *, MARK *, MARK *, int)); -int rcv_tmp __P((SCR *, EXF *, char *)); -int rcv_init __P((SCR *)); -int rcv_sync __P((SCR *, u_int)); -int rcv_list __P((SCR *)); -int rcv_read __P((SCR *, FREF *)); -int screen_init __P((GS *, SCR *, SCR **)); -int screen_end __P((SCR *)); -SCR *screen_next __P((SCR *)); -int f_search __P((SCR *, - MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int)); -int b_search __P((SCR *, - MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int)); -void search_busy __P((SCR *, busy_t)); -int seq_set __P((SCR *, CHAR_T *, - size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int)); -int seq_delete __P((SCR *, CHAR_T *, size_t, seq_t)); -int seq_free __P((SEQ *)); +char * codeset(void); +void conv_init(SCR *, SCR *); +int conv_enc(SCR *, int, char *); +void conv_end(SCR *); +int cut(SCR *, CHAR_T *, MARK *, MARK *, int); +int cut_line(SCR *, recno_t, size_t, size_t, CB *); +void cut_close(GS *); +TEXT *text_init(SCR *, const CHAR_T *, size_t, size_t); +void text_lfree(TEXTH *); +void text_free(TEXT *); +int del(SCR *, MARK *, MARK *, int); +int looks_utf8(const char *, size_t); +int looks_utf16(const char *, size_t); +int decode_utf8(const char *); +int decode_utf16(const char *, int); +FREF *file_add(SCR *, char *); +int file_init(SCR *, FREF *, char *, int); +int file_end(SCR *, EXF *, int); +int file_write(SCR *, MARK *, MARK *, char *, int); +int file_m1(SCR *, int, int); +int file_m2(SCR *, int); +int file_m3(SCR *, int); +int file_aw(SCR *, int); +void set_alt_name(SCR *, char *); +lockr_t file_lock(SCR *, char *, int, int); +int v_key_init(SCR *); +void v_key_ilookup(SCR *); +size_t v_key_len(SCR *, ARG_CHAR_T); +char *v_key_name(SCR *, ARG_CHAR_T); +e_key_t v_key_val(SCR *, ARG_CHAR_T); +int v_event_push(SCR *, EVENT *, CHAR_T *, size_t, u_int); +int v_event_get(SCR *, EVENT *, int, u_int32_t); +void v_event_err(SCR *, EVENT *); +int v_event_flush(SCR *, u_int); +int db_eget(SCR *, recno_t, CHAR_T **, size_t *, int *); +int db_get(SCR *, recno_t, u_int32_t, CHAR_T **, size_t *); +int db_delete(SCR *, recno_t); +int db_append(SCR *, int, recno_t, CHAR_T *, size_t); +int db_insert(SCR *, recno_t, CHAR_T *, size_t); +int db_set(SCR *, recno_t, CHAR_T *, size_t); +int db_exist(SCR *, recno_t); +int db_last(SCR *, recno_t *); +int db_rget(SCR *, recno_t, char **, size_t *); +int db_rset(SCR *, recno_t, char *, size_t); +void db_err(SCR *, recno_t); +int log_init(SCR *, EXF *); +int log_end(SCR *, EXF *); +int log_cursor(SCR *); +int log_line(SCR *, recno_t, u_int); +int log_mark(SCR *, LMARK *); +int log_backward(SCR *, MARK *); +int log_setline(SCR *); +int log_forward(SCR *, MARK *); +int editor(GS *, int, char *[]); +void v_end(GS *); +int mark_init(SCR *, EXF *); +int mark_end(SCR *, EXF *); +int mark_get(SCR *, ARG_CHAR_T, MARK *, mtype_t); +int mark_set(SCR *, ARG_CHAR_T, MARK *, int); +int mark_insdel(SCR *, lnop_t, recno_t); +void msgq(SCR *, mtype_t, const char *, ...); +void msgq_wstr(SCR *, mtype_t, const CHAR_T *, const char *); +void msgq_str(SCR *, mtype_t, const char *, const char *); +void mod_rpt(SCR *); +void msgq_status(SCR *, recno_t, u_int); +int msg_open(SCR *, char *); +void msg_close(GS *); +const char *msg_cmsg(SCR *, cmsg_t, size_t *); +const char *msg_cat(SCR *, const char *, size_t *); +char *msg_print(SCR *, const char *, int *); +int opts_init(SCR *, int *); +int opts_set(SCR *, ARGS *[], char *); +int o_set(SCR *, int, u_int, char *, u_long); +int opts_empty(SCR *, int, int); +void opts_dump(SCR *, enum optdisp); +int opts_save(SCR *, FILE *); +OPTLIST const *opts_search(CHAR_T *); +void opts_nomatch(SCR *, CHAR_T *); +int opts_copy(SCR *, SCR *); +void opts_free(SCR *); +int f_altwerase(SCR *, OPTION *, char *, u_long *); +int f_columns(SCR *, OPTION *, char *, u_long *); +int f_lines(SCR *, OPTION *, char *, u_long *); +int f_lisp(SCR *, OPTION *, char *, u_long *); +int f_msgcat(SCR *, OPTION *, char *, u_long *); +int f_print(SCR *, OPTION *, char *, u_long *); +int f_readonly(SCR *, OPTION *, char *, u_long *); +int f_recompile(SCR *, OPTION *, char *, u_long *); +int f_reformat(SCR *, OPTION *, char *, u_long *); +int f_ttywerase(SCR *, OPTION *, char *, u_long *); +int f_w300(SCR *, OPTION *, char *, u_long *); +int f_w1200(SCR *, OPTION *, char *, u_long *); +int f_w9600(SCR *, OPTION *, char *, u_long *); +int f_window(SCR *, OPTION *, char *, u_long *); +int f_encoding(SCR *, OPTION *, char *, u_long *); +int put(SCR *, CB *, CHAR_T *, MARK *, MARK *, int); +int rcv_tmp(SCR *, EXF *, char *); +int rcv_init(SCR *); +int rcv_sync(SCR *, u_int); +int rcv_list(SCR *); +int rcv_read(SCR *, FREF *); +int screen_init(GS *, SCR *, SCR **); +int screen_end(SCR *); +SCR *screen_next(SCR *); +int f_search(SCR *, + MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int); +int b_search(SCR *, + MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int); +void search_busy(SCR *, busy_t); +int seq_set(SCR *, CHAR_T *, + size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int); +int seq_delete(SCR *, CHAR_T *, size_t, seq_t); +int seq_free(SEQ *); SEQ *seq_find - __P((SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *)); -void seq_close __P((GS *)); -int seq_dump __P((SCR *, seq_t, int)); -int seq_save __P((SCR *, FILE *, char *, seq_t)); -int e_memcmp __P((CHAR_T *, EVENT *, size_t)); -void *binc __P((SCR *, void *, size_t *, size_t)); -int nonblank __P((SCR *, recno_t, size_t *)); -char *tail __P((char *)); -char *join __P((char *, char *)); -char *expanduser __P((char *)); -char *quote __P((char *)); -char *v_strdup __P((SCR *, const char *, size_t)); -CHAR_T *v_wstrdup __P((SCR *, const CHAR_T *, size_t)); -enum nresult nget_uslong __P((u_long *, const CHAR_T *, CHAR_T **, int)); -enum nresult nget_slong __P((long *, const CHAR_T *, CHAR_T **, int)); -void timepoint_steady __P((struct timespec *)); -void timepoint_system __P((struct timespec *)); -void TRACE __P((SCR *, const char *, ...)); + (SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *); +void seq_close(GS *); +int seq_dump(SCR *, seq_t, int); +int seq_save(SCR *, FILE *, char *, seq_t); +int e_memcmp(CHAR_T *, EVENT *, size_t); +void *binc(SCR *, void *, size_t *, size_t); +int nonblank(SCR *, recno_t, size_t *); +char *tail(char *); +char *join(char *, char *); +char *expanduser(char *); +char *quote(char *); +char *v_strdup(SCR *, const char *, size_t); +CHAR_T *v_wstrdup(SCR *, const CHAR_T *, size_t); +enum nresult nget_uslong(u_long *, const CHAR_T *, CHAR_T **, int); +enum nresult nget_slong(long *, const CHAR_T *, CHAR_T **, int); +void timepoint_steady(struct timespec *); +void timepoint_system(struct timespec *); +void TRACE(SCR *, const char *, ...); diff --git a/common/gs.h b/common/gs.h index 33a02458b0f9..4d0dc6fe5bf8 100644 --- a/common/gs.h +++ b/common/gs.h @@ -144,73 +144,55 @@ struct _gs { /* Screen interface functions. */ /* Add a string to the screen. */ - int (*scr_addstr) __P((SCR *, const char *, size_t)); + int (*scr_addstr)(SCR *, const char *, size_t); /* Add a string to the screen. */ - int (*scr_waddstr) __P((SCR *, const CHAR_T *, size_t)); + int (*scr_waddstr)(SCR *, const CHAR_T *, size_t); /* Toggle a screen attribute. */ - int (*scr_attr) __P((SCR *, scr_attr_t, int)); + int (*scr_attr)(SCR *, scr_attr_t, int); /* Terminal baud rate. */ - int (*scr_baud) __P((SCR *, u_long *)); + int (*scr_baud)(SCR *, u_long *); /* Beep/bell/flash the terminal. */ - int (*scr_bell) __P((SCR *)); + int (*scr_bell)(SCR *); /* Display a busy message. */ - void (*scr_busy) __P((SCR *, const char *, busy_t)); + void (*scr_busy)(SCR *, const char *, busy_t); /* Prepare child. */ - int (*scr_child) __P((SCR *)); + int (*scr_child)(SCR *); /* Clear to the end of the line. */ - int (*scr_clrtoeol) __P((SCR *)); + int (*scr_clrtoeol)(SCR *); /* Return the cursor location. */ - int (*scr_cursor) __P((SCR *, size_t *, size_t *)); + int (*scr_cursor)(SCR *, size_t *, size_t *); /* Delete a line. */ - int (*scr_deleteln) __P((SCR *)); + int (*scr_deleteln)(SCR *); /* Discard a screen. */ - int (*scr_discard) __P((SCR *, SCR **)); + int (*scr_discard)(SCR *, SCR **); /* Get a keyboard event. */ - int (*scr_event) __P((SCR *, EVENT *, u_int32_t, int)); + int (*scr_event)(SCR *, EVENT *, u_int32_t, int); /* Ex: screen adjustment routine. */ - int (*scr_ex_adjust) __P((SCR *, exadj_t)); + int (*scr_ex_adjust)(SCR *, exadj_t); int (*scr_fmap) /* Set a function key. */ - __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t)); + (SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t); /* Get terminal key value. */ - int (*scr_keyval) __P((SCR *, scr_keyval_t, CHAR_T *, int *)); + int (*scr_keyval)(SCR *, scr_keyval_t, CHAR_T *, int *); /* Insert a line. */ - int (*scr_insertln) __P((SCR *)); + int (*scr_insertln)(SCR *); /* Handle an option change. */ - int (*scr_optchange) __P((SCR *, int, char *, u_long *)); + int (*scr_optchange)(SCR *, int, char *, u_long *); /* Move the cursor. */ - int (*scr_move) __P((SCR *, size_t, size_t)); + int (*scr_move)(SCR *, size_t, size_t); /* Message or ex output. */ - void (*scr_msg) __P((SCR *, mtype_t, char *, size_t)); + void (*scr_msg)(SCR *, mtype_t, char *, size_t); /* Refresh the screen. */ - int (*scr_refresh) __P((SCR *, int)); + int (*scr_refresh)(SCR *, int); /* Rename the file. */ - int (*scr_rename) __P((SCR *, char *, int)); + int (*scr_rename)(SCR *, char *, int); /* Reply to an event. */ - int (*scr_reply) __P((SCR *, int, char *)); + int (*scr_reply)(SCR *, int, char *); /* Set the screen type. */ - int (*scr_screen) __P((SCR *, u_int32_t)); + int (*scr_screen)(SCR *, u_int32_t); /* Split the screen. */ - int (*scr_split) __P((SCR *, SCR *)); + int (*scr_split)(SCR *, SCR *); /* Suspend the editor. */ - int (*scr_suspend) __P((SCR *, int *)); + int (*scr_suspend)(SCR *, int *); /* Print usage message. */ - void (*scr_usage) __P((void)); + void (*scr_usage)(void); }; - -/* - * XXX - * Block signals if there are asynchronous events. Used to keep DB system calls - * from being interrupted and not restarted, as that will result in consistency - * problems. This should be handled by DB. - */ -#ifdef BLOCK_SIGNALS -#include <signal.h> -extern sigset_t __sigblockset; -#define SIGBLOCK \ - (void)sigprocmask(SIG_BLOCK, &__sigblockset, NULL) -#define SIGUNBLOCK \ - (void)sigprocmask(SIG_UNBLOCK, &__sigblockset, NULL); -#else -#define SIGBLOCK -#define SIGUNBLOCK -#endif diff --git a/common/key.c b/common/key.c index 9fc20b73d940..790c3719e9b6 100644 --- a/common/key.c +++ b/common/key.c @@ -30,11 +30,11 @@ static const char sccsid[] = "$Id: key.c,v 10.54 2013/11/13 12:15:27 zy Exp $"; #include "common.h" #include "../vi/vi.h" -static int v_event_append __P((SCR *, EVENT *)); -static int v_event_grow __P((SCR *, int)); -static int v_key_cmp __P((const void *, const void *)); -static void v_keyval __P((SCR *, int, scr_keyval_t)); -static void v_sync __P((SCR *, int)); +static int v_event_append(SCR *, EVENT *); +static int v_event_grow(SCR *, int); +static int v_key_cmp(const void *, const void *); +static void v_keyval(SCR *, int, scr_keyval_t); +static void v_sync(SCR *, int); /* * !!! @@ -97,7 +97,7 @@ static int nkeylist = * v_key_init -- * Initialize the special key lookup table. * - * PUBLIC: int v_key_init __P((SCR *)); + * PUBLIC: int v_key_init(SCR *); */ int v_key_init(SCR *sp) @@ -179,7 +179,7 @@ v_keyval( * v_key_ilookup -- * Build the fast-lookup key display array. * - * PUBLIC: void v_key_ilookup __P((SCR *)); + * PUBLIC: void v_key_ilookup(SCR *); */ void v_key_ilookup(SCR *sp) @@ -203,7 +203,7 @@ v_key_ilookup(SCR *sp) * Return the length of the string that will display the key. * This routine is the backup for the KEY_LEN() macro. * - * PUBLIC: size_t v_key_len __P((SCR *, ARG_CHAR_T)); + * PUBLIC: size_t v_key_len(SCR *, ARG_CHAR_T); */ size_t v_key_len( @@ -219,7 +219,7 @@ v_key_len( * Return the string that will display the key. This routine * is the backup for the KEY_NAME() macro. * - * PUBLIC: char *v_key_name __P((SCR *, ARG_CHAR_T)); + * PUBLIC: char *v_key_name(SCR *, ARG_CHAR_T); */ char * v_key_name( @@ -327,7 +327,7 @@ done: sp->cname[sp->clen = len] = '\0'; * Fill in the value for a key. This routine is the backup * for the KEY_VAL() macro. * - * PUBLIC: e_key_t v_key_val __P((SCR *, ARG_CHAR_T)); + * PUBLIC: e_key_t v_key_val(SCR *, ARG_CHAR_T); */ e_key_t v_key_val( @@ -351,7 +351,7 @@ v_key_val( * an associated flag value, which indicates if it has already been quoted, * and if it is the result of a mapping or an abbreviation. * - * PUBLIC: int v_event_push __P((SCR *, EVENT *, CHAR_T *, size_t, u_int)); + * PUBLIC: int v_event_push(SCR *, EVENT *, CHAR_T *, size_t, u_int); */ int v_event_push( @@ -532,7 +532,7 @@ v_event_append( * point. Given that this might make the log grow unacceptably (consider that * cursor keys are done with maps), for now we leave any changes made in place. * - * PUBLIC: int v_event_get __P((SCR *, EVENT *, int, u_int32_t)); + * PUBLIC: int v_event_get(SCR *, EVENT *, int, u_int32_t); */ int v_event_get( @@ -771,7 +771,7 @@ v_sync( * v_event_err -- * Unexpected event. * - * PUBLIC: void v_event_err __P((SCR *, EVENT *)); + * PUBLIC: void v_event_err(SCR *, EVENT *); */ void v_event_err( @@ -821,7 +821,7 @@ v_event_err( * v_event_flush -- * Flush any flagged keys, returning if any keys were flushed. * - * PUBLIC: int v_event_flush __P((SCR *, u_int)); + * PUBLIC: int v_event_flush(SCR *, u_int); */ int v_event_flush( diff --git a/common/line.c b/common/line.c index 0bceccfa5bcc..5549ad93cb66 100644 --- a/common/line.c +++ b/common/line.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: line.c,v 10.26 2011/08/12 12:36:41 zy Exp $"; +static const char sccsid[] = "$Id: line.c,v 10.27 2015/04/03 14:17:21 zy Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -26,13 +26,13 @@ static const char sccsid[] = "$Id: line.c,v 10.26 2011/08/12 12:36:41 zy Exp $"; #include "common.h" #include "../vi/vi.h" -static int scr_update __P((SCR *, recno_t, lnop_t, int)); +static int scr_update(SCR *, recno_t, lnop_t, int); /* * db_eget -- * Front-end to db_get, special case handling for empty files. * - * PUBLIC: int db_eget __P((SCR *, recno_t, CHAR_T **, size_t *, int *)); + * PUBLIC: int db_eget(SCR *, recno_t, CHAR_T **, size_t *, int *); */ int db_eget( @@ -76,7 +76,7 @@ db_eget( * Look in the text buffers for a line, followed by the cache, followed * by the database. * - * PUBLIC: int db_get __P((SCR *, recno_t, u_int32_t, CHAR_T **, size_t *)); + * PUBLIC: int db_get(SCR *, recno_t, u_int32_t, CHAR_T **, size_t *); */ int db_get( @@ -92,7 +92,6 @@ db_get( recno_t l1, l2; CHAR_T *wp; size_t wlen; - size_t nlen; /* * The underlying recno stuff handles zero by returning NULL, but @@ -152,8 +151,6 @@ db_get( ep->c_lno = OOBLNO; nocache: - nlen = 1024; -retry: /* Get the line from the underlying database. */ key.data = &lno; key.size = sizeof(lno); @@ -169,11 +166,6 @@ err3: if (lenp != NULL) if (pp != NULL) *pp = NULL; return (1); - case 0: - if (data.size > nlen) { - nlen = data.size; - goto retry; - } } if (FILE2INT(sp, data.data, data.size, wp, wlen)) { @@ -207,7 +199,7 @@ err3: if (lenp != NULL) * db_delete -- * Delete a line from the file. * - * PUBLIC: int db_delete __P((SCR *, recno_t)); + * PUBLIC: int db_delete(SCR *, recno_t); */ int db_delete( @@ -238,13 +230,11 @@ db_delete( /* Update file. */ key.data = &lno; key.size = sizeof(lno); - SIGBLOCK; if (ep->db->del(ep->db, &key, 0) == 1) { msgq(sp, M_SYSERR, "003|unable to delete line %lu", (u_long)lno); return (1); } - SIGUNBLOCK; /* Flush the cache, update line count, before screen update. */ if (lno <= ep->c_lno) @@ -265,7 +255,7 @@ db_delete( * db_append -- * Append a line into the file. * - * PUBLIC: int db_append __P((SCR *, int, recno_t, CHAR_T *, size_t)); + * PUBLIC: int db_append(SCR *, int, recno_t, CHAR_T *, size_t); */ int db_append( @@ -297,13 +287,11 @@ db_append( key.size = sizeof(lno); data.data = fp; data.size = flen; - SIGBLOCK; if (ep->db->put(ep->db, &key, &data, R_IAFTER) == -1) { msgq(sp, M_SYSERR, "004|unable to append to line %lu", (u_long)lno); return (1); } - SIGUNBLOCK; /* Flush the cache, update line count, before screen update. */ if (lno < ep->c_lno) @@ -343,7 +331,7 @@ db_append( * db_insert -- * Insert a line into the file. * - * PUBLIC: int db_insert __P((SCR *, recno_t, CHAR_T *, size_t)); + * PUBLIC: int db_insert(SCR *, recno_t, CHAR_T *, size_t); */ int db_insert( @@ -375,13 +363,11 @@ db_insert( key.size = sizeof(lno); data.data = fp; data.size = flen; - SIGBLOCK; if (ep->db->put(ep->db, &key, &data, R_IBEFORE) == -1) { msgq(sp, M_SYSERR, "005|unable to insert at line %lu", (u_long)lno); return (1); } - SIGUNBLOCK; /* Flush the cache, update line count, before screen update. */ if (lno >= ep->c_lno) @@ -412,7 +398,7 @@ db_insert( * db_set -- * Store a line in the file. * - * PUBLIC: int db_set __P((SCR *, recno_t, CHAR_T *, size_t)); + * PUBLIC: int db_set(SCR *, recno_t, CHAR_T *, size_t); */ int db_set( @@ -446,13 +432,11 @@ db_set( key.size = sizeof(lno); data.data = fp; data.size = flen; - SIGBLOCK; if (ep->db->put(ep->db, &key, &data, 0) == -1) { msgq(sp, M_SYSERR, "006|unable to store line %lu", (u_long)lno); return (1); } - SIGUNBLOCK; /* Flush the cache, before logging or screen update. */ if (lno == ep->c_lno) @@ -474,7 +458,7 @@ db_set( * db_exist -- * Return if a line exists. * - * PUBLIC: int db_exist __P((SCR *, recno_t)); + * PUBLIC: int db_exist(SCR *, recno_t); */ int db_exist( @@ -509,7 +493,7 @@ db_exist( * db_last -- * Return the number of lines in the file. * - * PUBLIC: int db_last __P((SCR *, recno_t *)); + * PUBLIC: int db_last(SCR *, recno_t *); */ int db_last( @@ -552,8 +536,6 @@ alloc_err: case 1: *lnop = 0; return (0); - case 0: - ; } memcpy(&lno, key.data, sizeof(lno)); @@ -581,9 +563,9 @@ alloc_err: /* * db_rget -- - * Retrieve a raw line from database. No cache, no conversion. + * Retrieve a raw line from the database. * - * PUBLIC: int db_rget __P((SCR *, recno_t, char **, size_t *)); + * PUBLIC: int db_rget(SCR *, recno_t, char **, size_t *); */ int db_rget( @@ -593,31 +575,26 @@ db_rget( size_t *lenp) /* Length store. */ { DBT data, key; - EXF *ep; - - /* Check for no underlying file. */ - if ((ep = sp->ep) == NULL) - return (1); + EXF *ep = sp->ep; + int rval; /* Get the line from the underlying database. */ key.data = &lno; key.size = sizeof(lno); - if (ep->db->get(ep->db, &key, &data, 0)) - /* We do not report error, and do not ensure the size! */ - return (1); - - if (lenp != NULL) + if ((rval = ep->db->get(ep->db, &key, &data, 0)) == 0) + { *lenp = data.size; - if (pp != NULL) *pp = data.data; - return (0); + } + + return (rval); } /* * db_rset -- - * Store a line in the file. No log, no conversion. + * Store a raw line into the database. * - * PUBLIC: int db_rset __P((SCR *, recno_t, char *, size_t)); + * PUBLIC: int db_rset(SCR *, recno_t, char *, size_t); */ int db_rset( @@ -627,29 +604,21 @@ db_rset( size_t len) { DBT data, key; - EXF *ep; + EXF *ep = sp->ep; - /* Check for no underlying file. */ - if ((ep = sp->ep) == NULL) - return (1); - /* Update file. */ key.data = &lno; key.size = sizeof(lno); data.data = p; data.size = len; - if (ep->db->put(ep->db, &key, &data, 0) == -1) - /* We do not report error, and do not ensure the size! */ - return (1); - - return (0); + return ep->db->put(ep->db, &key, &data, 0); } /* * db_err -- * Report a line error. * - * PUBLIC: void db_err __P((SCR *, recno_t)); + * PUBLIC: void db_err(SCR *, recno_t); */ void db_err( diff --git a/common/log.c b/common/log.c index eb8d85bc84cf..5adfeaf0fc58 100644 --- a/common/log.c +++ b/common/log.c @@ -63,13 +63,13 @@ static const char sccsid[] = "$Id: log.c,v 10.27 2011/07/13 06:25:50 zy Exp $"; * behaved that way. */ -static int log_cursor1 __P((SCR *, int)); -static void log_err __P((SCR *, char *, int)); +static int log_cursor1(SCR *, int); +static void log_err(SCR *, char *, int); #if defined(DEBUG) && 0 -static void log_trace __P((SCR *, char *, recno_t, u_char *)); +static void log_trace(SCR *, char *, recno_t, u_char *); #endif -static int apply_with __P((int (*)(SCR *, recno_t, CHAR_T *, size_t), - SCR *, recno_t, u_char *, size_t)); +static int apply_with(int (*)(SCR *, recno_t, CHAR_T *, size_t), + SCR *, recno_t, u_char *, size_t); /* Try and restart the log on failure, i.e. if we run out of memory. */ #define LOG_ERR { \ @@ -81,8 +81,8 @@ static int apply_with __P((int (*)(SCR *, recno_t, CHAR_T *, size_t), * because it is passed to db_set as a string */ typedef struct { - char data[sizeof(u_char) /* type */ + sizeof(recno_t)]; - CHAR_T str[1]; + char data[sizeof(u_char) /* type */ + sizeof(recno_t)]; + CHAR_T str[1]; } log_t; #define CHAR_T_OFFSET ((char *)(((log_t*)0)->str) - (char *)0) @@ -90,7 +90,7 @@ typedef struct { * log_init -- * Initialize the logging subsystem. * - * PUBLIC: int log_init __P((SCR *, EXF *)); + * PUBLIC: int log_init(SCR *, EXF *); */ int log_init( @@ -126,7 +126,7 @@ log_init( * log_end -- * Close the logging subsystem. * - * PUBLIC: int log_end __P((SCR *, EXF *)); + * PUBLIC: int log_end(SCR *, EXF *); */ int log_end( @@ -156,7 +156,7 @@ log_end( * log_cursor -- * Log the current cursor position, starting an event. * - * PUBLIC: int log_cursor __P((SCR *)); + * PUBLIC: int log_cursor(SCR *); */ int log_cursor(SCR *sp) @@ -221,7 +221,7 @@ log_cursor1( * log_line -- * Log a line change. * - * PUBLIC: int log_line __P((SCR *, recno_t, u_int)); + * PUBLIC: int log_line(SCR *, recno_t, u_int); */ int log_line( @@ -324,7 +324,7 @@ log_line( * would mean that undo operations would only reset marks, and not * cause any other change. * - * PUBLIC: int log_mark __P((SCR *, LMARK *)); + * PUBLIC: int log_mark(SCR *, LMARK *); */ int log_mark( @@ -370,7 +370,7 @@ log_mark( * Log_backward -- * Roll the log backward one operation. * - * PUBLIC: int log_backward __P((SCR *, MARK *)); + * PUBLIC: int log_backward(SCR *, MARK *); */ int log_backward( @@ -474,7 +474,7 @@ err: F_CLR(ep, F_NOLOG); * then move back on and do a 'U', the line will be restored to the way * it was before the original change. * - * PUBLIC: int log_setline __P((SCR *)); + * PUBLIC: int log_setline(SCR *); */ int log_setline(SCR *sp) @@ -558,7 +558,7 @@ err: F_CLR(ep, F_NOLOG); * Log_forward -- * Roll the log forward one operation. * - * PUBLIC: int log_forward __P((SCR *, MARK *)); + * PUBLIC: int log_forward(SCR *, MARK *); */ int log_forward( diff --git a/common/main.c b/common/main.c index 6ff418173007..d9ae96f9e7dd 100644 --- a/common/main.c +++ b/common/main.c @@ -10,14 +10,6 @@ #include "config.h" #ifndef lint -static const char copyright[] = -"@(#) Copyright (c) 1992, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n\ -@(#) Copyright (c) 1992, 1993, 1994, 1995, 1996\n\ - Keith Bostic. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint static const char sccsid[] = "$Id: main.c,v 11.0 2012/10/17 06:34:37 zy Exp $"; #endif /* not lint */ @@ -38,15 +30,15 @@ static const char sccsid[] = "$Id: main.c,v 11.0 2012/10/17 06:34:37 zy Exp $"; #include "../vi/vi.h" #include "pathnames.h" -static void attach __P((GS *)); -static void v_estr __P((char *, int, char *)); -static int v_obsolete __P((char *, char *[])); +static void attach(GS *); +static void v_estr(char *, int, char *); +static int v_obsolete(char *, char *[]); /* * editor -- * Main editor routine. * - * PUBLIC: int editor __P((GS *, int, char *[])); + * PUBLIC: int editor(GS *, int, char *[]); */ int editor( @@ -436,7 +428,7 @@ err: rval = 1; * v_end -- * End the program, discarding screens and most of the global area. * - * PUBLIC: void v_end __P((GS *)); + * PUBLIC: void v_end(GS *); */ void v_end(gp) @@ -455,7 +447,7 @@ v_end(gp) while ((sp = TAILQ_FIRST(gp->hq)) != NULL) (void)screen_end(sp); -#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY) +#if defined(DEBUG) || defined(PURIFY) { FREF *frp; /* Free FREF's. */ while ((frp = TAILQ_FIRST(gp->frefq)) != NULL) { @@ -499,13 +491,13 @@ v_end(gp) (void)fprintf(stderr, "%s%.*s", mp->mtype == M_ERR ? "ex/vi: " : "", (int)mp->len, mp->buf); SLIST_REMOVE_HEAD(gp->msgq, q); -#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY) +#if defined(DEBUG) || defined(PURIFY) free(mp->buf); free(mp); #endif } -#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY) +#if defined(DEBUG) || defined(PURIFY) /* Free any temporary space. */ if (gp->tmp_bp != NULL) free(gp->tmp_bp); diff --git a/common/mark.c b/common/mark.c index 7a954392278c..a3158e4560b6 100644 --- a/common/mark.c +++ b/common/mark.c @@ -26,7 +26,7 @@ static const char sccsid[] = "$Id: mark.c,v 10.14 2011/07/04 14:42:58 zy Exp $"; #include "common.h" -static LMARK *mark_find __P((SCR *, ARG_CHAR_T)); +static LMARK *mark_find(SCR *, ARG_CHAR_T); /* * Marks are maintained in a key sorted singly linked list. We can't @@ -63,7 +63,7 @@ static LMARK *mark_find __P((SCR *, ARG_CHAR_T)); * mark_init -- * Set up the marks. * - * PUBLIC: int mark_init __P((SCR *, EXF *)); + * PUBLIC: int mark_init(SCR *, EXF *); */ int mark_init( @@ -84,7 +84,7 @@ mark_init( * mark_end -- * Free up the marks. * - * PUBLIC: int mark_end __P((SCR *, EXF *)); + * PUBLIC: int mark_end(SCR *, EXF *); */ int mark_end( @@ -108,7 +108,7 @@ mark_end( * mark_get -- * Get the location referenced by a mark. * - * PUBLIC: int mark_get __P((SCR *, ARG_CHAR_T, MARK *, mtype_t)); + * PUBLIC: int mark_get(SCR *, ARG_CHAR_T, MARK *, mtype_t); */ int mark_get( @@ -125,12 +125,12 @@ mark_get( lmp = mark_find(sp, key); if (lmp == NULL || lmp->name != key) { msgq(sp, mtype, "017|Mark %s: not set", KEY_NAME(sp, key)); - return (1); + return (1); } if (F_ISSET(lmp, MARK_DELETED)) { msgq(sp, mtype, "018|Mark %s: the line was deleted", KEY_NAME(sp, key)); - return (1); + return (1); } /* @@ -153,7 +153,7 @@ mark_get( * mark_set -- * Set the location referenced by a mark. * - * PUBLIC: int mark_set __P((SCR *, ARG_CHAR_T, MARK *, int)); + * PUBLIC: int mark_set(SCR *, ARG_CHAR_T, MARK *, int); */ int mark_set( @@ -220,7 +220,7 @@ mark_find( * mark_insdel -- * Update the marks based on an insertion or deletion. * - * PUBLIC: int mark_insdel __P((SCR *, lnop_t, recno_t)); + * PUBLIC: int mark_insdel(SCR *, lnop_t, recno_t); */ int mark_insdel( diff --git a/common/msg.c b/common/msg.c index c0930b88afcd..3099b1e98b3c 100644 --- a/common/msg.c +++ b/common/msg.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: msg.c,v 11.0 2012/10/17 06:34:37 zy Exp $"; +static const char sccsid[] = "$Id: msg.c,v 11.1 2015/02/09 11:12:44 marc Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -36,7 +36,7 @@ static const char sccsid[] = "$Id: msg.c,v 11.0 2012/10/17 06:34:37 zy Exp $"; * msgq -- * Display a message. * - * PUBLIC: void msgq __P((SCR *, mtype_t, const char *, ...)); + * PUBLIC: void msgq(SCR *, mtype_t, const char *, ...); */ void msgq( @@ -60,7 +60,7 @@ msgq( size_t blen, len, mlen, nlen; const char *p; char *bp, *mp; - va_list ap; + va_list ap; #ifndef NL_ARGMAX int ch; char *rbp, *s_rbp; @@ -274,7 +274,7 @@ retry: FREE_SPACE(sp, bp, blen); #ifndef NL_ARGMAX format: /* Format the arguments into the string. */ #endif - va_start(ap, fmt); + va_start(ap, fmt); len = vsnprintf(mp, REM, fmt, ap); va_end(ap); if (len >= nlen) @@ -356,7 +356,7 @@ alloc_err: * msgq_wstr -- * Display a message with an embedded string. * - * PUBLIC: void msgq_wstr __P((SCR *, mtype_t, const CHAR_T *, const char *)); + * PUBLIC: void msgq_wstr(SCR *, mtype_t, const CHAR_T *, const char *); */ void msgq_wstr( @@ -380,7 +380,7 @@ msgq_wstr( * msgq_str -- * Display a message with an embedded string. * - * PUBLIC: void msgq_str __P((SCR *, mtype_t, const char *, const char *)); + * PUBLIC: void msgq_str(SCR *, mtype_t, const char *, const char *); */ void msgq_str( @@ -423,7 +423,7 @@ msgq_str( * the command 2d}, from the 'b' would report that two lines were deleted, * not one. * - * PUBLIC: void mod_rpt __P((SCR *)); + * PUBLIC: void mod_rpt(SCR *); */ void mod_rpt(SCR *sp) @@ -533,7 +533,7 @@ alloc_err: * msgq_status -- * Report on the file's status. * - * PUBLIC: void msgq_status __P((SCR *, recno_t, u_int)); + * PUBLIC: void msgq_status(SCR *, recno_t, u_int); */ void msgq_status( @@ -647,7 +647,7 @@ msgq_status( p += len; } else { t = msg_cat(sp, "027|line %lu of %lu [%ld%%]", &len); - (void)snprintf(p, ep - p, t, lno, last, + (void)snprintf(p, ep - p, t, (u_long)lno, (u_long)last, ((u_long)lno * 100) / last); p += strlen(p); } @@ -705,7 +705,7 @@ alloc_err: * msg_open -- * Open the message catalogs. * - * PUBLIC: int msg_open __P((SCR *, char *)); + * PUBLIC: int msg_open(SCR *, char *); */ int msg_open( @@ -772,7 +772,7 @@ ret: free(p); * msg_close -- * Close the message catalogs. * - * PUBLIC: void msg_close __P((GS *)); + * PUBLIC: void msg_close(GS *); */ void msg_close(GS *gp) @@ -785,7 +785,7 @@ msg_close(GS *gp) * msg_cont -- * Return common continuation messages. * - * PUBLIC: const char *msg_cmsg __P((SCR *, cmsg_t, size_t *)); + * PUBLIC: const char *msg_cmsg(SCR *, cmsg_t, size_t *); */ const char * msg_cmsg( @@ -823,7 +823,7 @@ msg_cmsg( * Only a single catalog message can be accessed at a time, if multiple * ones are needed, they must be copied into local memory. * - * PUBLIC: const char *msg_cat __P((SCR *, const char *, size_t *)); + * PUBLIC: const char *msg_cat(SCR *, const char *, size_t *); */ const char * msg_cat( @@ -861,7 +861,7 @@ msg_cat( * msg_print -- * Return a printable version of a string, in allocated memory. * - * PUBLIC: char *msg_print __P((SCR *, const char *, int *)); + * PUBLIC: char *msg_print(SCR *, const char *, int *); */ char * msg_print( diff --git a/common/options.c b/common/options.c index 71a5e43e58cb..e619d8f08eb7 100644 --- a/common/options.c +++ b/common/options.c @@ -30,9 +30,9 @@ static const char sccsid[] = "$Id: options.c,v 10.73 2012/10/09 06:14:07 zy Exp #include "../vi/vi.h" #include "pathnames.h" -static int opts_abbcmp __P((const void *, const void *)); -static int opts_cmp __P((const void *, const void *)); -static int opts_print __P((SCR *, OPTLIST const *)); +static int opts_abbcmp(const void *, const void *); +static int opts_cmp(const void *, const void *); +static int opts_print(SCR *, OPTLIST const *); #ifdef USE_WIDECHAR #define OPT_WC 0 @@ -243,8 +243,8 @@ OPTLIST const optlist[] = { }; typedef struct abbrev { - CHAR_T *name; - int offset; + CHAR_T *name; + int offset; } OABBREV; static OABBREV const abbrev[] = { @@ -294,7 +294,7 @@ static OABBREV const abbrev[] = { * opts_init -- * Initialize some of the options. * - * PUBLIC: int opts_init __P((SCR *, int *)); + * PUBLIC: int opts_init(SCR *, int *); */ int opts_init( @@ -460,7 +460,7 @@ err: msgq_wstr(sp, M_ERR, optlist[optindx].name, * opts_set -- * Change the values of one or more options. * - * PUBLIC: int opts_set __P((SCR *, ARGS *[], char *)); + * PUBLIC: int opts_set(SCR *, ARGS *[], char *); */ int opts_set( @@ -754,7 +754,7 @@ badnum: INT2CHAR(sp, name, STRLEN(name) + 1, * o_set -- * Set an option's value. * - * PUBLIC: int o_set __P((SCR *, int, u_int, char *, u_long)); + * PUBLIC: int o_set(SCR *, int, u_int, char *, u_long); */ int o_set( @@ -798,7 +798,7 @@ o_set( * opts_empty -- * Return 1 if the string option is invalid, 0 if it's OK. * - * PUBLIC: int opts_empty __P((SCR *, int, int)); + * PUBLIC: int opts_empty(SCR *, int, int); */ int opts_empty( @@ -821,7 +821,7 @@ opts_empty( * opts_dump -- * List the current values of selected options. * - * PUBLIC: void opts_dump __P((SCR *, enum optdisp)); + * PUBLIC: void opts_dump(SCR *, enum optdisp); */ void opts_dump( @@ -987,7 +987,7 @@ opts_print( * opts_save -- * Write the current configuration to a file. * - * PUBLIC: int opts_save __P((SCR *, FILE *)); + * PUBLIC: int opts_save(SCR *, FILE *); */ int opts_save( @@ -1045,7 +1045,7 @@ opts_save( * opts_search -- * Search for an option. * - * PUBLIC: OPTLIST const *opts_search __P((CHAR_T *)); + * PUBLIC: OPTLIST const *opts_search(CHAR_T *); */ OPTLIST const * opts_search(CHAR_T *name) @@ -1090,7 +1090,7 @@ opts_search(CHAR_T *name) * opts_nomatch -- * Standard nomatch error message for options. * - * PUBLIC: void opts_nomatch __P((SCR *, CHAR_T *)); + * PUBLIC: void opts_nomatch(SCR *, CHAR_T *); */ void opts_nomatch( @@ -1103,25 +1103,25 @@ opts_nomatch( static int opts_abbcmp( - const void *a, - const void *b) + const void *a, + const void *b) { - return(STRCMP(((OABBREV *)a)->name, ((OABBREV *)b)->name)); + return(STRCMP(((OABBREV *)a)->name, ((OABBREV *)b)->name)); } static int opts_cmp( - const void *a, - const void *b) + const void *a, + const void *b) { - return(STRCMP(((OPTLIST *)a)->name, ((OPTLIST *)b)->name)); + return(STRCMP(((OPTLIST *)a)->name, ((OPTLIST *)b)->name)); } /* * opts_copy -- * Copy a screen's OPTION array. * - * PUBLIC: int opts_copy __P((SCR *, SCR *)); + * PUBLIC: int opts_copy(SCR *, SCR *); */ int opts_copy( @@ -1169,7 +1169,7 @@ nomem: msgq(orig, M_SYSERR, NULL); * opts_free -- * Free all option strings * - * PUBLIC: void opts_free __P((SCR *)); + * PUBLIC: void opts_free(SCR *); */ void opts_free(SCR *sp) diff --git a/common/options.h b/common/options.h index fe1f80f5f16d..aaeece144d89 100644 --- a/common/options.h +++ b/common/options.h @@ -78,7 +78,7 @@ struct _option { struct _optlist { CHAR_T *name; /* Name. */ /* Change function. */ - int (*func) __P((SCR *, OPTION *, char *, u_long *)); + int (*func)(SCR *, OPTION *, char *, u_long *); /* Type of object. */ enum { OPT_0BOOL, OPT_1BOOL, OPT_NUM, OPT_STR } type; diff --git a/common/options_f.c b/common/options_f.c index 482a37e39d39..850bfc2eca5c 100644 --- a/common/options_f.c +++ b/common/options_f.c @@ -29,7 +29,7 @@ static const char sccsid[] = "$Id: options_f.c,v 10.34 04/07/11 16:06:29 zy Exp #include "common.h" /* - * PUBLIC: int f_altwerase __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_altwerase(SCR *, OPTION *, char *, u_long *); */ int f_altwerase( @@ -44,7 +44,7 @@ f_altwerase( } /* - * PUBLIC: int f_columns __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_columns(SCR *, OPTION *, char *, u_long *); */ int f_columns( @@ -78,7 +78,7 @@ f_columns( } /* - * PUBLIC: int f_lines __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_lines(SCR *, OPTION *, char *, u_long *); */ int f_lines( @@ -135,7 +135,7 @@ f_lines( } /* - * PUBLIC: int f_lisp __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_lisp(SCR *, OPTION *, char *, u_long *); */ int f_lisp( @@ -149,7 +149,7 @@ f_lisp( } /* - * PUBLIC: int f_msgcat __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_msgcat(SCR *, OPTION *, char *, u_long *); */ int f_msgcat( @@ -163,7 +163,7 @@ f_msgcat( } /* - * PUBLIC: int f_print __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_print(SCR *, OPTION *, char *, u_long *); */ int f_print( @@ -192,7 +192,7 @@ f_print( } /* - * PUBLIC: int f_readonly __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_readonly(SCR *, OPTION *, char *, u_long *); */ int f_readonly( @@ -213,7 +213,7 @@ f_readonly( } /* - * PUBLIC: int f_recompile __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_recompile(SCR *, OPTION *, char *, u_long *); */ int f_recompile( @@ -234,7 +234,7 @@ f_recompile( } /* - * PUBLIC: int f_reformat __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_reformat(SCR *, OPTION *, char *, u_long *); */ int f_reformat( @@ -248,7 +248,7 @@ f_reformat( } /* - * PUBLIC: int f_ttywerase __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_ttywerase(SCR *, OPTION *, char *, u_long *); */ int f_ttywerase( @@ -263,7 +263,7 @@ f_ttywerase( } /* - * PUBLIC: int f_w300 __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_w300(SCR *, OPTION *, char *, u_long *); */ int f_w300( @@ -284,7 +284,7 @@ f_w300( } /* - * PUBLIC: int f_w1200 __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_w1200(SCR *, OPTION *, char *, u_long *); */ int f_w1200( @@ -305,7 +305,7 @@ f_w1200( } /* - * PUBLIC: int f_w9600 __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_w9600(SCR *, OPTION *, char *, u_long *); */ int f_w9600( @@ -326,7 +326,7 @@ f_w9600( } /* - * PUBLIC: int f_window __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_window(SCR *, OPTION *, char *, u_long *); */ int f_window( @@ -342,7 +342,7 @@ f_window( } /* - * PUBLIC: int f_encoding __P((SCR *, OPTION *, char *, u_long *)); + * PUBLIC: int f_encoding(SCR *, OPTION *, char *, u_long *); */ int f_encoding( diff --git a/common/put.c b/common/put.c index 6e9dc09902de..d3adf5c08607 100644 --- a/common/put.c +++ b/common/put.c @@ -30,7 +30,7 @@ static const char sccsid[] = "$Id: put.c,v 10.19 04/07/11 17:00:24 zy Exp $"; * put -- * Put text buffer contents into the file. * - * PUBLIC: int put __P((SCR *, CB *, CHAR_T *, MARK *, MARK *, int)); + * PUBLIC: int put(SCR *, CB *, CHAR_T *, MARK *, MARK *, int); */ int put( diff --git a/common/recover.c b/common/recover.c index b20471f111b2..d0a927bd4301 100644 --- a/common/recover.c +++ b/common/recover.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: recover.c,v 11.2 2012/10/09 08:06:58 zy Exp $"; +static const char sccsid[] = "$Id: recover.c,v 11.3 2015/04/04 03:50:42 zy Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -102,18 +102,18 @@ static const char sccsid[] = "$Id: recover.c,v 11.2 2012/10/09 08:06:58 zy Exp $ #define VI_DHEADER "X-vi-data:" -static int rcv_copy __P((SCR *, int, char *)); -static void rcv_email __P((SCR *, char *)); -static int rcv_mailfile __P((SCR *, int, char *)); -static int rcv_mktemp __P((SCR *, char *, char *)); -static int rcv_dlnwrite __P((SCR *, const char *, const char *, FILE *)); -static int rcv_dlnread __P((SCR *, char **, char **, FILE *)); +static int rcv_copy(SCR *, int, char *); +static void rcv_email(SCR *, char *); +static int rcv_mailfile(SCR *, int, char *); +static int rcv_mktemp(SCR *, char *, char *); +static int rcv_dlnwrite(SCR *, const char *, const char *, FILE *); +static int rcv_dlnread(SCR *, char **, char **, FILE *); /* * rcv_tmp -- * Build a file name that will be used as the recovery file. * - * PUBLIC: int rcv_tmp __P((SCR *, EXF *, char *)); + * PUBLIC: int rcv_tmp(SCR *, EXF *, char *); */ int rcv_tmp( @@ -172,7 +172,7 @@ err: msgq(sp, M_ERR, * rcv_init -- * Force the file to be snapshotted for recovery. * - * PUBLIC: int rcv_init __P((SCR *)); + * PUBLIC: int rcv_init(SCR *); */ int rcv_init(SCR *sp) @@ -234,7 +234,7 @@ err: msgq(sp, M_ERR, * sending email to the user if the file was modified * ending the file session * - * PUBLIC: int rcv_sync __P((SCR *, u_int)); + * PUBLIC: int rcv_sync(SCR *, u_int); */ int rcv_sync( @@ -252,15 +252,12 @@ rcv_sync( /* Sync the file if it's been modified. */ if (F_ISSET(ep, F_MODIFIED)) { - SIGBLOCK; if (ep->db->sync(ep->db, R_RECNOSYNC)) { F_CLR(ep, F_RCV_ON | F_RCV_NORM); msgq_str(sp, M_SYSERR, ep->rcv_path, "060|File backup failed: %s"); - SIGUNBLOCK; return (1); } - SIGUNBLOCK; /* REQUEST: don't remove backing file on exit. */ if (LF_ISSET(RCV_PRESERVE)) @@ -505,7 +502,7 @@ err: if (!issync) * rcv_list -- * List the files that can be recovered by this user. * - * PUBLIC: int rcv_list __P((SCR *)); + * PUBLIC: int rcv_list(SCR *); */ int rcv_list(SCR *sp) @@ -612,7 +609,7 @@ next: (void)fclose(fp); * rcv_read -- * Start a recovered file as the file to edit. * - * PUBLIC: int rcv_read __P((SCR *, FREF *)); + * PUBLIC: int rcv_read(SCR *, FREF *); */ int rcv_read( @@ -635,7 +632,7 @@ rcv_read( return (1); rp = O_STR(sp, O_RECDIR); if ((dirp = opendir(rp)) == NULL) { - msgq_str(sp, M_ERR, rp, "%s"); + msgq_str(sp, M_SYSERR, rp, "%s"); return (1); } diff --git a/common/screen.c b/common/screen.c index 9ff684509d94..ae6fb207567f 100644 --- a/common/screen.c +++ b/common/screen.c @@ -32,7 +32,7 @@ static const char sccsid[] = "$Id: screen.c,v 10.25 2011/12/04 04:06:45 zy Exp $ * screen_init -- * Do the default initialization of an SCR structure. * - * PUBLIC: int screen_init __P((GS *, SCR *, SCR **)); + * PUBLIC: int screen_init(GS *, SCR *, SCR **); */ int screen_init( @@ -129,7 +129,7 @@ err: screen_end(sp); * Release a screen, no matter what had (and had not) been * initialized. * - * PUBLIC: int screen_end __P((SCR *)); + * PUBLIC: int screen_end(SCR *); */ int screen_end(SCR *sp) @@ -205,7 +205,7 @@ screen_end(SCR *sp) * screen_next -- * Return the next screen in the queue. * - * PUBLIC: SCR *screen_next __P((SCR *)); + * PUBLIC: SCR *screen_next(SCR *); */ SCR * screen_next(SCR *sp) diff --git a/common/search.c b/common/search.c index 22f020315070..4831a0874aae 100644 --- a/common/search.c +++ b/common/search.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: search.c,v 10.26 2011/07/04 20:16:26 zy Exp $"; +static const char sccsid[] = "$Id: search.c,v 10.27 2015/03/13 18:41:35 zy Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -30,8 +30,8 @@ static const char sccsid[] = "$Id: search.c,v 10.26 2011/07/04 20:16:26 zy Exp $ typedef enum { S_EMPTY, S_EOF, S_NOPREV, S_NOTFOUND, S_SOF, S_WRAP } smsg_t; -static void search_msg __P((SCR *, smsg_t)); -static int search_init __P((SCR *, dir_t, CHAR_T *, size_t, CHAR_T **, u_int)); +static void search_msg(SCR *, smsg_t); +static int search_init(SCR *, dir_t, CHAR_T *, size_t, CHAR_T **, u_int); /* * search_init -- @@ -142,8 +142,8 @@ prev: if (sp->re == NULL) { * f_search -- * Do a forward search. * - * PUBLIC: int f_search __P((SCR *, - * PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int)); + * PUBLIC: int f_search(SCR *, + * PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int); */ int f_search( @@ -159,7 +159,7 @@ f_search( recno_t lno; regmatch_t match[1]; size_t coff, len; - int cnt, eval, rval, wrapped; + int cnt, eval, rval, wrapped = 0; CHAR_T *l; if (search_init(sp, FORWARD, ptrn, plen, eptrn, flags)) @@ -198,13 +198,14 @@ f_search( return (1); } lno = 1; + wrapped = 1; } } else coff = fm->cno + 1; } btype = BUSY_ON; - for (cnt = INTERRUPT_CHECK, rval = 1, wrapped = 0;; ++lno, coff = 0) { + for (cnt = INTERRUPT_CHECK, rval = 1;; ++lno, coff = 0) { if (cnt-- == 0) { if (INTERRUPTED(sp)) break; @@ -288,8 +289,8 @@ f_search( * b_search -- * Do a backward search. * - * PUBLIC: int b_search __P((SCR *, - * PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int)); + * PUBLIC: int b_search(SCR *, + * PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int); */ int b_search( @@ -487,7 +488,7 @@ search_msg( * search_busy -- * Put up the busy searching message. * - * PUBLIC: void search_busy __P((SCR *, busy_t)); + * PUBLIC: void search_busy(SCR *, busy_t); */ void search_busy( diff --git a/common/seq.c b/common/seq.c index 45c6c1111083..61c7fcd0b285 100644 --- a/common/seq.c +++ b/common/seq.c @@ -31,8 +31,8 @@ static const char sccsid[] = "$Id: seq.c,v 10.18 2011/12/11 23:13:00 zy Exp $"; * seq_set -- * Internal version to enter a sequence. * - * PUBLIC: int seq_set __P((SCR *, CHAR_T *, - * PUBLIC: size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int)); + * PUBLIC: int seq_set(SCR *, CHAR_T *, + * PUBLIC: size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int); */ int seq_set( @@ -136,7 +136,7 @@ mem1: errno = sv_errno; * seq_delete -- * Delete a sequence. * - * PUBLIC: int seq_delete __P((SCR *, CHAR_T *, size_t, seq_t)); + * PUBLIC: int seq_delete(SCR *, CHAR_T *, size_t, seq_t); */ int seq_delete( @@ -172,7 +172,7 @@ seq_delete( * seq_free -- * Free a map entry. * - * PUBLIC: int seq_free __P((SEQ *)); + * PUBLIC: int seq_free(SEQ *); */ int seq_free(SEQ *qp) @@ -193,7 +193,7 @@ seq_free(SEQ *qp) * isn't NULL, partial matches count. * * PUBLIC: SEQ *seq_find - * PUBLIC: __P((SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *)); + * PUBLIC: (SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *); */ SEQ * seq_find( @@ -278,7 +278,7 @@ seq_find( * seq_close -- * Discard all sequences. * - * PUBLIC: void seq_close __P((GS *)); + * PUBLIC: void seq_close(GS *); */ void seq_close(GS *gp) @@ -295,7 +295,7 @@ seq_close(GS *gp) * seq_dump -- * Display the sequence entries of a specified type. * - * PUBLIC: int seq_dump __P((SCR *, seq_t, int)); + * PUBLIC: int seq_dump(SCR *, seq_t, int); */ int seq_dump( @@ -343,7 +343,7 @@ seq_dump( * seq_save -- * Save the sequence entries to a file. * - * PUBLIC: int seq_save __P((SCR *, FILE *, char *, seq_t)); + * PUBLIC: int seq_save(SCR *, FILE *, char *, seq_t); */ int seq_save( @@ -389,7 +389,7 @@ seq_save( * e_memcmp -- * Compare a string of EVENT's to a string of CHAR_T's. * - * PUBLIC: int e_memcmp __P((CHAR_T *, EVENT *, size_t)); + * PUBLIC: int e_memcmp(CHAR_T *, EVENT *, size_t); */ int e_memcmp( @@ -398,11 +398,11 @@ e_memcmp( size_t n) { if (n != 0) { - do { - if (*p1++ != ep->e_c) - return (*--p1 - ep->e_c); + do { + if (*p1++ != ep->e_c) + return (*--p1 - ep->e_c); ++ep; - } while (--n != 0); - } - return (0); + } while (--n != 0); + } + return (0); } diff --git a/common/util.c b/common/util.c index 43fa9d1e9f20..44c8e29482e6 100644 --- a/common/util.c +++ b/common/util.c @@ -39,7 +39,7 @@ static const char sccsid[] = "$Id: util.c,v 10.30 2013/03/19 10:00:27 yamt Exp $ * binc -- * Increase the size of a buffer. * - * PUBLIC: void *binc __P((SCR *, void *, size_t *, size_t)); + * PUBLIC: void *binc(SCR *, void *, size_t *, size_t); */ void * binc( @@ -76,7 +76,7 @@ binc( * including or after the starting column. On error, set * the column to 0, it's safest. * - * PUBLIC: int nonblank __P((SCR *, recno_t, size_t *)); + * PUBLIC: int nonblank(SCR *, recno_t, size_t *); */ int nonblank( @@ -112,7 +112,7 @@ nonblank( * tail -- * Return tail of a path. * - * PUBLIC: char *tail __P((char *)); + * PUBLIC: char *tail(char *); */ char * tail(char *path) @@ -128,12 +128,12 @@ tail(char *path) * join -- * Join two paths; need free. * - * PUBLIC: char *join __P((char *, char *)); + * PUBLIC: char *join(char *, char *); */ char * join( - char *path1, - char *path2) + char *path1, + char *path2) { char *p; @@ -148,7 +148,7 @@ join( * expanduser -- * Return a "~" or "~user" expanded path; need free. * - * PUBLIC: char *expanduser __P((char *)); + * PUBLIC: char *expanduser(char *); */ char * expanduser(char *str) @@ -198,7 +198,7 @@ expanduser(char *str) * quote -- * Return a escaped string for /bin/sh; need free. * - * PUBLIC: char *quote __P((char *)); + * PUBLIC: char *quote(char *); */ char * quote(char *str) @@ -245,7 +245,7 @@ quote(char *str) * v_strdup -- * Strdup for 8-bit character strings with an associated length. * - * PUBLIC: char *v_strdup __P((SCR *, const char *, size_t)); + * PUBLIC: char *v_strdup(SCR *, const char *, size_t); */ char * v_strdup( @@ -267,7 +267,7 @@ v_strdup( * v_wstrdup -- * Strdup for wide character strings with an associated length. * - * PUBLIC: CHAR_T *v_wstrdup __P((SCR *, const CHAR_T *, size_t)); + * PUBLIC: CHAR_T *v_wstrdup(SCR *, const CHAR_T *, size_t); */ CHAR_T * v_wstrdup(SCR *sp, @@ -288,7 +288,7 @@ v_wstrdup(SCR *sp, * nget_uslong -- * Get an unsigned long, checking for overflow. * - * PUBLIC: enum nresult nget_uslong __P((u_long *, const CHAR_T *, CHAR_T **, int)); + * PUBLIC: enum nresult nget_uslong(u_long *, const CHAR_T *, CHAR_T **, int); */ enum nresult nget_uslong( @@ -310,7 +310,7 @@ nget_uslong( * nget_slong -- * Convert a signed long, checking for overflow and underflow. * - * PUBLIC: enum nresult nget_slong __P((long *, const CHAR_T *, CHAR_T **, int)); + * PUBLIC: enum nresult nget_slong(long *, const CHAR_T *, CHAR_T **, int); */ enum nresult nget_slong( @@ -336,7 +336,7 @@ nget_slong( * timepoint_steady -- * Get a timestamp from a monotonic clock. * - * PUBLIC: void timepoint_steady __P((struct timespec *)); + * PUBLIC: void timepoint_steady(struct timespec *); */ void timepoint_steady( @@ -367,7 +367,7 @@ timepoint_steady( * timepoint_system -- * Get the current calendar time. * - * PUBLIC: void timepoint_system __P((struct timespec *)); + * PUBLIC: void timepoint_system(struct timespec *); */ void timepoint_system( @@ -401,7 +401,7 @@ timepoint_system( * TRACE -- * debugging trace routine. * - * PUBLIC: void TRACE __P((SCR *, const char *, ...)); + * PUBLIC: void TRACE(SCR *, const char *, ...); */ void TRACE( |