From nobody Tue Apr 02 13:54:28 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 4V88WS6tbzz5GfcD; Tue, 2 Apr 2024 13:54:28 +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 4V88WS5QzZz46RV; Tue, 2 Apr 2024 13:54:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712066068; 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=MtwtM7VCy5C0PVpvbTZcF4K9w0UOxdEp3YNQQTaKHR8=; b=tvh2inJorn4MUf7SK6AXQGTA0duJFbP6OjPdzJYH/rNdfnTF5alii+ZaF4YEfOYZA1RZkP rvKGeNMn/7NOY0f5usgjnpE41Htp2d4DObZysMkJSgAV5fFvTyr6qEfw97qAoKwAH8JKy5 NuF6dZPcho8ToRoRzo9IbIbhhbvS4mn5DSO4TqTNTykrY+4UdV4BonCchxqxedwykb/scG BTsKpAB0zerxGHPaF58//fM7QbiYc69p5/HzWs/rp8OyylkSne34k1w8DSbYNhmrAMB8k4 0GPr8kWnZNBWvY4ZH/oh6t0FhgwYb9dXZ+wcsW365FUsHguX/Frb3aS3+K5qUw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712066068; a=rsa-sha256; cv=none; b=a3ZLNvkBRnM3kgTiyTeCai4OzL7i7RWFoWgaI2PoMldMI9Z3swBVuTD3PzayFIlGnTBd19 UhNDTNiSE9CclZb6SEC0K4nIlDCX6bLmO4/XKvjic42dsOJOaNw78jjuhf+jEvjIoAX5cN yUq6qviKTHSYlsWRJOVUTZhAFZvBUpauCyxw0ekTjULlzwuHvZRM9dn9ttZkj0dkEnUiwL QtVTUb7t6e26KecH+8uEmR0m5MaeZ2VEwKIlyQoABp5LQvqd6OPrHTZ6+oR4bfgTwl5dKJ Dm5DJTheLTcUCoFRVZEE3jgX3W1vuTz+8qDKsJRZEeaXvv/WEnTqL1949t2Dew== 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=1712066068; 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=MtwtM7VCy5C0PVpvbTZcF4K9w0UOxdEp3YNQQTaKHR8=; b=j3ipSDi2YJRK/hkyqx+55OCN65RxI8d2GMmmNfPLZYfiAR2NU9OESbs7zcMt8vwy4ZS14A PxA4KJHPevQNwm1h/DuR1tZuN2dOwtNDVXB3Peu5WgT6s3vCo9+aTao/JTgo24K1ad10Yp 9LxfRM/n5EdMqH5M7GUtf/v3VY1yLJl+Mdw1rGkwpoXu4MhuQaRCSoMpseKZzmePMVdp6o duPPEYppW3EUTAtQ7uvUvm31VD9AMGS1EVhlZqElJMvqlY3LNmQXVs0eSKKjTwJLXB6KJA AHQvU/csROPNAKK++eB7sWpjNQQwPZMJUiykuqNmjfVKaWY9OPFlIdqeKN1khQ== 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 4V88WS52STzsQj; Tue, 2 Apr 2024 13:54:28 +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 432DsSjg021455; Tue, 2 Apr 2024 13:54:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 432DsSKd021452; Tue, 2 Apr 2024 13:54:28 GMT (envelope-from git) Date: Tue, 2 Apr 2024 13:54:28 GMT Message-Id: <202404021354.432DsSKd021452@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 8db49fc84c53 - stable/14 - msgs: 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 8db49fc84c53dab69265fd9c1201a5fec336f343 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=8db49fc84c53dab69265fd9c1201a5fec336f343 commit 8db49fc84c53dab69265fd9c1201a5fec336f343 Author: Collin Funk AuthorDate: 2024-02-06 12:40:05 +0000 Commit: Ed Maste CommitDate: 2024-04-02 13:53:51 +0000 msgs: Use C99 bool instead of defining our own Use stdbool.h definitions instead of defining non-standard ones. Signed-off-by: Collin Funk Pull-request: https://github.com/freebsd/freebsd-src/pull/1105 (cherry picked from commit 912b52a62c72ca9c96a396148a6b30ff9c0917e7) --- usr.bin/msgs/msgs.c | 97 ++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 50 deletions(-) diff --git a/usr.bin/msgs/msgs.c b/usr.bin/msgs/msgs.c index e4b3b09efc81..980625bb3fd4 100644 --- a/usr.bin/msgs/msgs.c +++ b/usr.bin/msgs/msgs.c @@ -87,11 +87,10 @@ static char sccsid[] = "@(#)msgs.c 8.2 (Berkeley) 4/28/95"; #include #include #include +#include #include "pathnames.h" #define CMODE 0644 /* bounds file creation mode */ -#define NO 0 -#define YES 1 #define SUPERUSER 0 /* superuser uid */ #define DAEMON 1 /* daemon uid */ #define NLINES 24 /* default number of lines/crt screen */ @@ -103,8 +102,6 @@ static char sccsid[] = "@(#)msgs.c 8.2 (Berkeley) 4/28/95"; #define MORE "More? [ynq]" #define NOMORE "(No more) [q] ?" -typedef char bool; - static FILE *msgsrc; static FILE *newmsg; static const char *sep = "-"; @@ -122,11 +119,11 @@ static bool totty; static bool seenfrom; static bool seensubj; static bool blankline; -static bool printing = NO; -static bool mailing = NO; -static bool quitit = NO; -static bool sending = NO; -static bool intrpflg = NO; +static bool printing = false; +static bool mailing = false; +static bool quitit = false; +static bool sending = false; +static bool intrpflg = false; static uid_t uid; static int msg; static int prevmsg; @@ -137,14 +134,14 @@ static time_t t; static time_t keep; /* option initialization */ -static bool hdrs = NO; -static bool qopt = NO; -static bool hush = NO; -static bool send_msg = NO; -static bool locomode = NO; -static bool use_pager = NO; -static bool clean = NO; -static bool lastcmd = NO; +static bool hdrs = false; +static bool qopt = false; +static bool hush = false; +static bool send_msg = false; +static bool locomode = false; +static bool use_pager = false; +static bool clean = false; +static bool lastcmd = false; static jmp_buf tstpbuf; static void ask(const char *); @@ -200,35 +197,35 @@ main(int argc, char *argv[]) if (uid != SUPERUSER && uid != DAEMON) errx(1, "only the super-user can use the c flag"); - clean = YES; + clean = true; break; case 'f': /* silently */ - hush = YES; + hush = true; break; case 'h': /* headers only */ - hdrs = YES; + hdrs = true; break; case 'l': /* local msgs only */ - locomode = YES; + locomode = true; break; case 'o': /* option to save last message */ - lastcmd = YES; + lastcmd = true; break; case 'p': /* pipe thru 'more' during long msgs */ - use_pager = YES; + use_pager = true; break; case 'q': /* query only */ - qopt = YES; + qopt = true; break; case 's': /* sending TO msgs */ - send_msg = YES; + send_msg = true; break; default: @@ -246,13 +243,13 @@ main(int argc, char *argv[]) /* * Test access rights to the bounds file * This can be a little tricky. if(send_msg), then - * we will create it. We assume that if(send_msg), + * we will create it. We assume that if(send_msg), * then you have write permission there. * Else, it better be there, or we bail. */ - if (send_msg != YES) { + if (!send_msg) { if (stat(fname, &buf) < 0) { - if (hush != YES) { + if (!hush) { err(errno, "%s", fname); } else { exit(1); @@ -273,7 +270,7 @@ main(int argc, char *argv[]) if (clean || bounds == NULL) { /* relocate message bounds */ struct dirent *dp; struct stat stbuf; - bool seenany = NO; + bool seenany = false; DIR *dirp; dirp = opendir(_PATH_MSGS); @@ -314,7 +311,7 @@ main(int argc, char *argv[]) lastmsg = i; if (i < firstmsg) firstmsg = i; - seenany = YES; + seenany = true; } closedir(dirp); @@ -354,7 +351,7 @@ main(int argc, char *argv[]) fprintf(bounds, "%d %d\n", firstmsg, nextmsg); fclose(bounds); - sending = YES; + sending = true; if (ruptible) signal(SIGINT, onintr); @@ -368,10 +365,10 @@ main(int argc, char *argv[]) fflush(stdout); fprintf(newmsg, "From %s %sSubject: %s\n", ptr, ctime(&t), inbuf); - blankline = seensubj = YES; + blankline = seensubj = true; } else - blankline = seensubj = NO; + blankline = seensubj = false; for (;;) { fgets(inbuf, sizeof inbuf, stdin); if (feof(stdin) || ferror(stdin)) @@ -407,20 +404,20 @@ main(int argc, char *argv[]) snprintf(fname, sizeof(fname), "%s/%s", cp, MSGSRC); msgsrc = fopen(fname, "r"); if (msgsrc) { - newrc = NO; + newrc = false; fscanf(msgsrc, "%d\n", &nextmsg); fclose(msgsrc); if (nextmsg > lastmsg+1) { printf("Warning: bounds have been reset (%d, %d)\n", firstmsg, lastmsg); truncate(fname, (off_t)0); - newrc = YES; + newrc = true; } else if (!rcfirst) rcfirst = nextmsg - rcback; } else - newrc = YES; + newrc = true; msgsrc = fopen(fname, "r+"); if (msgsrc == NULL) msgsrc = fopen(fname, "w"); @@ -457,9 +454,9 @@ main(int argc, char *argv[]) #endif Lpp -= 6; /* for headers, etc. */ - already = NO; + already = false; prevmsg = firstmsg; - printing = YES; + printing = true; if (ruptible) signal(SIGINT, onintr); @@ -493,7 +490,7 @@ main(int argc, char *argv[]) if (totty) signal(SIGTSTP, onsusp); (void) setjmp(tstpbuf); - already = YES; + already = true; nlines = 2; if (seenfrom) { printf("Message %d:\nFrom %s %s", msg, from, date); @@ -548,7 +545,7 @@ cmnd: case 'q': /* FALLTHROUGH */ case 'Q': - quitit = YES; + quitit = true; printf("--Postponed--\n"); exit(0); /* NOTREACHED */ @@ -695,7 +692,7 @@ onintr(int unused __unused) sep = "Interrupt"; if (newmsg) fseeko(newmsg, (off_t)0, SEEK_END); - intrpflg = YES; + intrpflg = true; } } @@ -746,7 +743,7 @@ ask(const char *prompt) printf("%s ", prompt); fflush(stdout); - intrpflg = NO; + intrpflg = false; (void) fgets(inbuf, sizeof inbuf, stdin); if ((n = strlen(inbuf)) > 0 && inbuf[n - 1] == '\n') inbuf[n - 1] = '\0'; @@ -792,14 +789,14 @@ ask(const char *prompt) if (fd != -1) { snprintf(cmdbuf, sizeof(cmdbuf), _PATH_MAIL, fname); - mailing = YES; + mailing = true; } } if (fd == -1 || (cpto = fdopen(fd, "a")) == NULL) { if (fd != -1) close(fd); warn("%s", fname); - mailing = NO; + mailing = false; fseeko(newmsg, oldpos, SEEK_SET); ask(prompt); fclose(cpfrom); @@ -817,7 +814,7 @@ ask(const char *prompt) else { system(cmdbuf); unlink(fname); - mailing = NO; + mailing = false; } ask(prompt); } @@ -829,8 +826,8 @@ gfrsub(FILE *infile) off_t frompos; int count; - seensubj = seenfrom = NO; - local = YES; + seensubj = seenfrom = false; + local = true; subj[0] = from[0] = date[0] = '\0'; /* @@ -841,7 +838,7 @@ gfrsub(FILE *infile) /* * expected form starts with From */ - seenfrom = YES; + seenfrom = true; frompos = ftello(infile); ptr = from; in = nxtfld(inbuf); @@ -850,7 +847,7 @@ gfrsub(FILE *infile) while (*in && *in > ' ' && count-- > 0) { if (*in == ':' || *in == '@' || *in == '!') - local = NO; + local = false; *ptr++ = *in++; } } @@ -885,7 +882,7 @@ gfrsub(FILE *infile) * extract Subject line */ if (!seensubj && strncmp(inbuf, "Subj", 4)==0) { - seensubj = YES; + seensubj = true; frompos = ftello(infile); strlcpy(subj, nxtfld(inbuf), sizeof subj); }