From nobody Fri Apr 19 18:48:55 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VLkFN52Mxz5HXrN; Fri, 19 Apr 2024 18:48:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VLkFN0v4Wz4npt; Fri, 19 Apr 2024 18:48:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713552536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T0d8eywxsLfjCGnwRckGXbNf2Emk1DXhvo2qsxIvhk4=; b=NQ+GP+3ph/bhzGP8k1LmQ8/+HF3eMNrqC0zPsP6msdEoTJ4EqQ07gUSg8J3/6cH0XSUOvK ZUjRHzdKjD1dFMerSgARwSE7K4B5dYGzFUxq/rG76qo0ocpiWLRqOXoVNtih2UmcjGZoas x/RIj9ZfAcH32wcuv45R4dxCzpWcmOrsG62qGQLVACQ9XHAo2QznfpIVazbxdtyFiGWOJl hTOycHCmDiJ9oMVVmfpzqlVIQKr7zCGpAM0N5NpGA3vUFvFRMkdriEnLAhj4fysOOmdzrl N4pXol8QjUUjYHHBwsFjP3QutrrAluH6hmDJ7qyIdBW4KE6aJTVrRNUg7JfTOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713552536; a=rsa-sha256; cv=none; b=iTjtcr3GQ1tSBYtK1bLYLiy9ynkiCYW1QGLrB88vHZ8yRxrlDnA6qTWYQhoQJrmLMyQeGe YWSUqxaE23Eo+3VP4teHVC8rRtQWmmBLf20wu+skiCp52Nj9JVUAO6pSZkN4mhH40KQPg3 RGcJYex6Y5luKBPptBczizNzSe9aG8s0+FOdNQwb0CRJHWYRy0LJvbodrPQeO4zVHvNY1i 8Vi1k+SdxOVlW9L/Md2xUuht9RaNy2FOBZ8SOHKMy9H/YsheMuD5q3GlIorgK6+aOCg1nO uMKPmFxiwEm8B6OCG3YEvg8y3sHcl2LEeTViAMJWY2nVyY3UIKQowYbvtxL8mg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713552536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T0d8eywxsLfjCGnwRckGXbNf2Emk1DXhvo2qsxIvhk4=; b=auVjAJ+FLQf+KA3tY/dT2WayCZZSOF4Mo8YLj2aWaBWoTXEe0oh9Xoi/kVm5++IugM9NsX BQFOiQRDow2texAl5HMNu3bo82RlxsXFle5uwci0OLw73xpHVSTxksrnj8CehFl1us2SW1 k3iIQ48aq6RyyyudHKKCS4OVFEPwhIPOadZIvtBav7njalo7wzP6GzKLsXHWshd1SZmZ3B Y0voTBasXsfBo8kJW8z/1ZjS9fuqwjwgg9gOGcTNcmqjWQqStUug5hkx8iZYPB64hJ5qHO v6zn83LWOdS3HHHV7WONx3WXDpz6fg26aVV9LNAbZUjzF9Xw6CYq6S39IthDFg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VLkFN0TvNz14PT; Fri, 19 Apr 2024 18:48:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43JImtWS003502; Fri, 19 Apr 2024 18:48:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43JImtqF003499; Fri, 19 Apr 2024 18:48:55 GMT (envelope-from git) Date: Fri, 19 Apr 2024 18:48:55 GMT Message-Id: <202404191848.43JImtqF003499@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 87b0195ace1a - main - ctags: Use C99 bool instead of defining our own List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 87b0195ace1a71a1a07244890be3aaef72e1ffcd Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=87b0195ace1a71a1a07244890be3aaef72e1ffcd commit 87b0195ace1a71a1a07244890be3aaef72e1ffcd Author: Collin Funk AuthorDate: 2024-02-07 00:34:50 +0000 Commit: Mark Johnston CommitDate: 2024-04-19 18:48:37 +0000 ctags: Use C99 bool instead of defining our own Use stdbool.h definitions instead of defining non-standard ones. Signed-off-by: Collin Funk Reviewed by: markj MFC after: 2 weeks Pull Request: https://github.com/freebsd/freebsd-src/pull/1107 --- usr.bin/ctags/C.c | 76 ++++++++++++++++++++++++------------------------- usr.bin/ctags/ctags.c | 22 +++++++------- usr.bin/ctags/ctags.h | 11 ++++--- usr.bin/ctags/fortran.c | 12 ++++---- usr.bin/ctags/lisp.c | 8 +++--- usr.bin/ctags/tree.c | 2 +- usr.bin/ctags/yacc.c | 10 +++---- 7 files changed, 70 insertions(+), 71 deletions(-) diff --git a/usr.bin/ctags/C.c b/usr.bin/ctags/C.c index 283a08ec555d..20a2cf072aa9 100644 --- a/usr.bin/ctags/C.c +++ b/usr.bin/ctags/C.c @@ -37,10 +37,10 @@ #include "ctags.h" -static int func_entry(void); +static bool func_entry(void); static void hash_entry(void); static void skip_string(int); -static int str_entry(int); +static bool str_entry(int); /* * c_entries -- @@ -52,13 +52,13 @@ c_entries(void) int c; /* current character */ int level; /* brace level */ int token; /* if reading a token */ - int t_def; /* if reading a typedef */ + bool t_def; /* if reading a typedef */ int t_level; /* typedef's brace level */ char *sp; /* buffer pointer */ char tok[MAXTOKEN]; /* token buffer */ lineftell = ftell(inf); - sp = tok; token = t_def = NO; t_level = -1; level = 0; lineno = 1; + sp = tok; token = t_def = false; t_level = -1; level = 0; lineno = 1; while (GETC(!=, EOF)) { switch (c) { /* @@ -92,11 +92,11 @@ c_entries(void) */ endtok: if (sp > tok) { *sp = EOS; - token = YES; + token = true; sp = tok; } else - token = NO; + token = false; continue; /* @@ -174,7 +174,7 @@ c_entries(void) */ case ';': if (t_def && level == t_level) { - t_def = NO; + t_def = false; get_line(); if (sp != tok) *sp = EOS; @@ -207,7 +207,7 @@ c_entries(void) /* no typedefs inside typedefs */ if (!t_def && !memcmp(tok, "typedef",8)) { - t_def = YES; + t_def = true; t_level = level; break; } @@ -233,15 +233,15 @@ c_entries(void) if (sp == tok + sizeof tok - 1) /* Too long -- truncate it */ *sp = EOS; - else + else *sp++ = c; - token = YES; + token = true; } continue; } sp = tok; - token = NO; + token = false; } } @@ -249,7 +249,7 @@ c_entries(void) * func_entry -- * handle a function reference */ -static int +static bool func_entry(void) { int c; /* current character */ @@ -287,7 +287,7 @@ func_entry(void) SETLINE; } } - return (NO); + return (false); fnd: /* * we assume that the character after a function's right paren @@ -299,7 +299,7 @@ fnd: if (c == '\n') SETLINE; if (c == EOF) - return NO; + return false; /* * Recognize the gnu __attribute__ extension, which would * otherwise make the heuristic test DTWT @@ -311,7 +311,7 @@ fnd: } } else { if (intoken(c)) { - if (anext - maybe_attribute + if (anext - maybe_attribute < (ptrdiff_t)(sizeof attribute - 1)) *anext++ = c; else break; @@ -320,7 +320,7 @@ fnd: *anext++ = '\0'; if (strcmp(maybe_attribute, attribute) == 0) { (void)ungetc(c, inf); - return NO; + return false; } break; } @@ -331,12 +331,12 @@ fnd: skip_comment(c); else { /* don't ever "read" '/' */ (void)ungetc(c, inf); - return (NO); + return (false); } } if (c != '{') (void)skip_key('{'); - return (YES); + return (true); } /* @@ -365,7 +365,7 @@ hash_entry(void) if (sp == tok + sizeof tok - 1) /* Too long -- truncate it */ *sp = EOS; - else + else *sp++ = c; } *sp = EOS; @@ -381,7 +381,7 @@ hash_entry(void) if (sp == tok + sizeof tok - 1) /* Too long -- truncate it */ *sp = EOS; - else + else *sp++ = c; if (GETC(==, EOF)) return; @@ -409,7 +409,7 @@ skip: if (c == '\n') { /* get rid of rest of define */ * str_entry -- * handle a struct, union or enum entry */ -static int +static bool str_entry(int c) /* c is current character */ { int curline; /* line started on */ @@ -419,17 +419,17 @@ str_entry(int c) /* c is current character */ curline = lineno; while (iswhite(c)) if (GETC(==, EOF)) - return (NO); + return (false); if (c == '{') /* it was "struct {" */ - return (YES); + return (true); for (sp = tok;;) { /* get next token */ if (sp == tok + sizeof tok - 1) /* Too long -- truncate it */ *sp = EOS; - else + else *sp++ = c; if (GETC(==, EOF)) - return (NO); + return (false); if (!intoken(c)) break; } @@ -446,12 +446,12 @@ str_entry(int c) /* c is current character */ break; if (c != '{') { (void)ungetc(c, inf); - return (NO); + return (false); } } *sp = EOS; pfnote(tok, curline); - return (YES); + return (true); } /* @@ -468,7 +468,7 @@ skip_comment(int t) /* t is comment character */ switch(c) { /* comments don't nest, nor can they be escaped. */ case '*': - star = YES; + star = true; break; case '/': if (star && t == '*') @@ -480,7 +480,7 @@ skip_comment(int t) /* t is comment character */ return; /*FALLTHROUGH*/ default: - star = NO; + star = false; break; } } @@ -495,7 +495,7 @@ skip_string(int key) int c, skip; - for (skip = NO; GETC(!=, EOF); ) + for (skip = false; GETC(!=, EOF); ) switch (c) { case '\\': /* a backslash escapes anything */ skip = !skip; /* we toggle in case it's "\\" */ @@ -506,7 +506,7 @@ skip_string(int key) default: if (c == key && !skip) return; - skip = NO; + skip = false; } } @@ -514,21 +514,21 @@ skip_string(int key) * skip_key -- * skip to next char "key" */ -int +bool skip_key(int key) { - int c, - skip, - retval; + int c; + bool skip; + bool retval; - for (skip = retval = NO; GETC(!=, EOF);) + for (skip = retval = false; GETC(!=, EOF);) switch(c) { case '\\': /* a backslash escapes anything */ skip = !skip; /* we toggle in case it's "\\" */ break; case ';': /* special case for yacc; if one */ case '|': /* of these chars occurs, we may */ - retval = YES; /* have moved out of the rule */ + retval = true; /* have moved out of the rule */ break; /* not used by C */ case '\'': case '"': @@ -551,7 +551,7 @@ skip_key(int key) norm: if (c == key && !skip) return (retval); - skip = NO; + skip = false; } return (retval); } diff --git a/usr.bin/ctags/ctags.c b/usr.bin/ctags/ctags.c index 1f8966a409db..b8d642520466 100644 --- a/usr.bin/ctags/ctags.c +++ b/usr.bin/ctags/ctags.c @@ -86,8 +86,8 @@ main(int argc, char **argv) setlocale(LC_ALL, ""); - aflag = uflag = NO; - tflag = YES; + aflag = uflag = false; + tflag = true; while ((ch = getopt(argc, argv, "BFTadf:tuwvx")) != -1) switch(ch) { case 'B': @@ -97,7 +97,7 @@ main(int argc, char **argv) searchar = '/'; break; case 'T': - tflag = NO; + tflag = false; break; case 'a': aflag++; @@ -109,7 +109,7 @@ main(int argc, char **argv) outfile = optarg; break; case 't': - tflag = YES; + tflag = true; break; case 'u': uflag++; @@ -251,24 +251,24 @@ init(void) const unsigned char *sp; for (i = 0; i < 256; i++) { - _wht[i] = _etk[i] = _itk[i] = _btk[i] = NO; - _gd[i] = YES; + _wht[i] = _etk[i] = _itk[i] = _btk[i] = false; + _gd[i] = true; } #define CWHITE " \f\t\n" for (sp = CWHITE; *sp; sp++) /* white space chars */ - _wht[*sp] = YES; + _wht[*sp] = true; #define CTOKEN " \t\n\"'#()[]{}=-+%*/&|^~!<>;,.:?" for (sp = CTOKEN; *sp; sp++) /* token ending chars */ - _etk[*sp] = YES; + _etk[*sp] = true; #define CINTOK "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789" for (sp = CINTOK; *sp; sp++) /* valid in-token chars */ - _itk[*sp] = YES; + _itk[*sp] = true; #define CBEGIN "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" for (sp = CBEGIN; *sp; sp++) /* token starting chars */ - _btk[*sp] = YES; + _btk[*sp] = true; #define CNOTGD ",;" for (sp = CNOTGD; *sp; sp++) /* invalid after-function chars */ - _gd[*sp] = NO; + _gd[*sp] = false; } /* diff --git a/usr.bin/ctags/ctags.h b/usr.bin/ctags/ctags.h index c9a7539b277a..b74bf7ea7602 100644 --- a/usr.bin/ctags/ctags.h +++ b/usr.bin/ctags/ctags.h @@ -30,10 +30,9 @@ * */ -#define bool char +/* This header requires bool for some externed symbols. */ +#include -#define YES 1 -#define NO 0 #define EOS '\0' #define ENDLINE 50 /* max length of pattern */ @@ -81,14 +80,14 @@ extern char lbuf[LINE_MAX]; extern char *lbp; extern char searchar; /* ex search character */ -extern int cicmp(const char *); +extern bool cicmp(const char *); extern void get_line(void); extern void pfnote(const char *, int); -extern int skip_key(int); +extern bool skip_key(int); extern void put_entries(NODE *); extern void toss_yysec(void); extern void l_entries(void); extern void y_entries(void); -extern int PF_funcs(void); +extern bool PF_funcs(void); extern void c_entries(void); extern void skip_comment(int); diff --git a/usr.bin/ctags/fortran.c b/usr.bin/ctags/fortran.c index 55d8d824f568..4375076f5914 100644 --- a/usr.bin/ctags/fortran.c +++ b/usr.bin/ctags/fortran.c @@ -41,14 +41,14 @@ static void takeprec(void); char *lbp; /* line buffer pointer */ -int +bool PF_funcs(void) { bool pfcnt; /* pascal/fortran functions found */ char *cp; char tok[MAXTOKEN]; - for (pfcnt = NO;;) { + for (pfcnt = false;;) { lineftell = ftell(inf); if (!fgets(lbuf, sizeof(lbuf), inf)) return (pfcnt); @@ -120,7 +120,7 @@ PF_funcs(void) (void)strlcpy(tok, lbp, sizeof(tok)); /* possible trunc */ get_line(); /* process line for ex(1) */ pfnote(tok, lineno); - pfcnt = YES; + pfcnt = true; } /*NOTREACHED*/ } @@ -129,7 +129,7 @@ PF_funcs(void) * cicmp -- * do case-independent strcmp */ -int +bool cicmp(const char *cp) { int len; @@ -140,9 +140,9 @@ cicmp(const char *cp) continue; if (!*cp) { lbp += len; - return (YES); + return (true); } - return (NO); + return (false); } static void diff --git a/usr.bin/ctags/lisp.c b/usr.bin/ctags/lisp.c index e219fcee4634..e721bf8f757d 100644 --- a/usr.bin/ctags/lisp.c +++ b/usr.bin/ctags/lisp.c @@ -44,7 +44,7 @@ void l_entries(void) { - int special; + bool special; char *cp; char savedc; char tok[MAXTOKEN]; @@ -57,15 +57,15 @@ l_entries(void) lbp = lbuf; if (!cicmp("(def")) continue; - special = NO; + special = false; switch(*lbp | ' ') { case 'm': if (cicmp("method")) - special = YES; + special = true; break; case 'w': if (cicmp("wrapper") || cicmp("whopper")) - special = YES; + special = true; } for (; !isspace(*lbp); ++lbp) continue; diff --git a/usr.bin/ctags/tree.c b/usr.bin/ctags/tree.c index e8250bcbcf67..7643d1895b93 100644 --- a/usr.bin/ctags/tree.c +++ b/usr.bin/ctags/tree.c @@ -100,7 +100,7 @@ add_node(NODE *node, NODE *cur_node) if (!cur_node->been_warned) if (!wflag) fprintf(stderr, "Duplicate entry in files %s and %s: %s (Warning only)\n", node->file, cur_node->file, node->entry); - cur_node->been_warned = YES; + cur_node->been_warned = true; } else if (dif < 0) if (cur_node->left) diff --git a/usr.bin/ctags/yacc.c b/usr.bin/ctags/yacc.c index 502fbc98b714..71dddaa36f67 100644 --- a/usr.bin/ctags/yacc.c +++ b/usr.bin/ctags/yacc.c @@ -48,7 +48,7 @@ y_entries(void) bool in_rule; char tok[MAXTOKEN]; - in_rule = NO; + in_rule = false; while (GETC(!=, EOF)) switch (c) { @@ -62,12 +62,12 @@ y_entries(void) break; case '{': if (skip_key('}')) - in_rule = NO; + in_rule = false; break; case '\'': case '"': if (skip_key(c)) - in_rule = NO; + in_rule = false; break; case '%': if (GETC(==, '%')) @@ -82,7 +82,7 @@ y_entries(void) break; case '|': case ';': - in_rule = NO; + in_rule = false; break; default: if (in_rule || (!isalpha(c) && c != '.' && c != '_')) @@ -101,7 +101,7 @@ y_entries(void) } if (c == ':') { pfnote(tok, lineno); - in_rule = YES; + in_rule = true; } else (void)ungetc(c, inf);