From nobody Tue Feb 06 13:38:19 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 4TTkpg5XyFz592BT; Tue, 6 Feb 2024 13:38:19 +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 4TTkpg51Hfz4VxG; Tue, 6 Feb 2024 13:38:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707226699; 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=GunQjHy85DHIHKpYT9yYFzF3mWyuLElr6eKgF2OrL3o=; b=lFLxsTQxDEGB9vi3SvSkiydBB2trZsOxj8X8K26zxk7zjMDYR1YfnSZsMvNnHVWvzMD4Kf fFEcC+4XBQQnU9koLyU5kD8JknQ1oMs/7G9npuCd23eYAi1p2z+6zKGuNirgHR0xshlMkt ebewtiy2xX/7paWdX7ut64vmQG9r/jg8F29wQQscJ+uQjOB7drBxLJOdHgTrHO35AjS9Db JoZcfSFCns5hlgVP/maY+maayesDLwtTbQkyQcxBMVhS4Aaw7mOhlX7O23tyII9RhagamH lSOQvc9QiCuSWebnVrJneo46jnhjds7wFsKYuw11zgnvyGJOAsG+QBMVtct79w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707226699; 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=GunQjHy85DHIHKpYT9yYFzF3mWyuLElr6eKgF2OrL3o=; b=F0s96nCbpI8kG4ZoL0NaKwr8grWvLaIHKe+Ww6SMiufmGPLkQ8qb/1GFdiZLd2R+H0BpfB rzDcGBrp2KDF408z7yY8T0iTl51kQGmC9XgBOl70XippwFpAthImUvVZVR3LNcLkybBn7r fPXklGXnwSPjTBo0LIYcbCUzT4+YOnDr0rYcXRkqxeNgU8z1JuN4X/unB1UizhHChqVBz7 sLgzBUfrBll979ehtXS3k0JBcv+/8+Yk3h5Bjaew/hp7sjxRpcatcBi5g1Egci6dOFh3Vw 8EQlutdC1SCbRxbepjcs97hS2IMF5VsVPMOGq30S2MKmDTmcnm51RBhofpl8lQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707226699; a=rsa-sha256; cv=none; b=YHe07JFH9sELqM79Qk8hA3NgCDCt88XsGCAye8qZpN8mDrNtI+tTmAxENJPVooS1UP+UTu Vw7PVUXvVWDIWIO55E/5iuxYjIhai3m8Z0+nwPIvSHdN+yM+yIqGGIvmpAWQnlBQkZbzrn TGtASPU5DUlJvJkHtcOE2tEvmNGuSW6YbAG2rFVlUnGY/dS4ycNfVpkt40hK5kqd4KY5VE s0LNmdganCAAW2VzRhDfAm4Y0s4ZqSndyT2L2s+Xxh7HgvGPqR5sIPnA37YiflaOVs0Gim 9j+oXUgkGRBD3WSa5nDJEMWdwZ5hg52S7vv8I5Ff8TzxTxjJxtO727eDDqJGyg== 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 4TTkpg43xszQYB; Tue, 6 Feb 2024 13:38:19 +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 416DcJoI081621; Tue, 6 Feb 2024 13:38:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 416DcJQC081618; Tue, 6 Feb 2024 13:38:19 GMT (envelope-from git) Date: Tue, 6 Feb 2024 13:38:19 GMT Message-Id: <202402061338.416DcJQC081618@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 912b52a62c72 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 912b52a62c72ca9c96a396148a6b30ff9c0917e7 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=912b52a62c72ca9c96a396148a6b30ff9c0917e7 commit 912b52a62c72ca9c96a396148a6b30ff9c0917e7 Author: Collin Funk AuthorDate: 2024-02-06 12:40:05 +0000 Commit: Ed Maste CommitDate: 2024-02-06 13:37:50 +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 --- 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 c9183df27610..64e21c5863d4 100644 --- a/usr.bin/msgs/msgs.c +++ b/usr.bin/msgs/msgs.c @@ -74,11 +74,10 @@ #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 */ @@ -90,8 +89,6 @@ #define MORE "More? [ynq]" #define NOMORE "(No more) [q] ?" -typedef char bool; - static FILE *msgsrc; static FILE *newmsg; static const char *sep = "-"; @@ -109,11 +106,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; @@ -124,14 +121,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 *); @@ -187,35 +184,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: @@ -233,13 +230,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); @@ -260,7 +257,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); @@ -301,7 +298,7 @@ main(int argc, char *argv[]) lastmsg = i; if (i < firstmsg) firstmsg = i; - seenany = YES; + seenany = true; } closedir(dirp); @@ -341,7 +338,7 @@ main(int argc, char *argv[]) fprintf(bounds, "%d %d\n", firstmsg, nextmsg); fclose(bounds); - sending = YES; + sending = true; if (ruptible) signal(SIGINT, onintr); @@ -355,10 +352,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)) @@ -394,20 +391,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"); @@ -444,9 +441,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); @@ -480,7 +477,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); @@ -535,7 +532,7 @@ cmnd: case 'q': /* FALLTHROUGH */ case 'Q': - quitit = YES; + quitit = true; printf("--Postponed--\n"); exit(0); /* NOTREACHED */ @@ -682,7 +679,7 @@ onintr(int unused __unused) sep = "Interrupt"; if (newmsg) fseeko(newmsg, (off_t)0, SEEK_END); - intrpflg = YES; + intrpflg = true; } } @@ -733,7 +730,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'; @@ -779,14 +776,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); @@ -804,7 +801,7 @@ ask(const char *prompt) else { system(cmdbuf); unlink(fname); - mailing = NO; + mailing = false; } ask(prompt); } @@ -816,8 +813,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'; /* @@ -828,7 +825,7 @@ gfrsub(FILE *infile) /* * expected form starts with From */ - seenfrom = YES; + seenfrom = true; frompos = ftello(infile); ptr = from; in = nxtfld(inbuf); @@ -837,7 +834,7 @@ gfrsub(FILE *infile) while (*in && *in > ' ' && count-- > 0) { if (*in == ':' || *in == '@' || *in == '!') - local = NO; + local = false; *ptr++ = *in++; } } @@ -872,7 +869,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); }