NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: PR/58786 CVS commit: src/usr.bin/ctags



The following reply was made to PR bin/58786; it has been noted by GNATS.

From: RVP <rvp%SDF.ORG@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: PR/58786 CVS commit: src/usr.bin/ctags
Date: Wed, 30 Oct 2024 07:33:30 +0000 (UTC)

 On Tue, 29 Oct 2024, Robert Elz wrote:
 
 > Log Message:
 > PR bin/58786 - fix exit status when tags file open fails
 >
 
 Fix exit status with write errors too.
 
 ```
 $ ctags -f /dev/full /usr/src/usr.bin/ctags/*.c || echo FAIL
 $ ctags -uf /dev/full /usr/src/usr.bin/ctags/*.c || echo FAIL
 ```
 
 Note that you'll have to kill the 2nd cmd. with Ctrl-C due to how sort(1) works
 for `sort -o /dev/full /dev/full' (never-ending read).
 
 --START patch--
 diff -urN ctags.orig/ctags.c ctags/ctags.c
 --- ctags.orig/ctags.c	2024-10-29 21:48:31.465414358 +0000
 +++ ctags/ctags.c	2024-10-30 06:59:55.168654673 +0000
 @@ -159,10 +159,11 @@
   			if (uflag) {
   				for (step = 0; step < argc; step++) {
   					(void)snprintf(cmd, sizeof(cmd),
 -						"mv %s OTAGS; fgrep -v '\t%s\t' OTAGS >%s; rm OTAGS",
 +						"mv %s OTAGS; fgrep -v '\t%s\t' OTAGS >%s; rm OTAGS",	/* XXX */
   							outfile, argv[step],
   							outfile);
 -					system(cmd);
 +					if (system(cmd))
 +						errx(EXIT_FAILURE, "update failed", cmd);
   				}
   				++aflag;
   			}
 @@ -173,7 +174,8 @@
   			if (uflag) {
   				(void)snprintf(cmd, sizeof(cmd),
   				    "sort -o %s %s", outfile, outfile);
 -				system(cmd);
 +				if (system(cmd))
 +					errx(EXIT_FAILURE, "update failed", cmd);
   			}
   		}
   	}
 diff -urN ctags.orig/print.c ctags/print.c
 --- ctags.orig/print.c	2009-07-13 19:05:40.000000000 +0000
 +++ ctags/print.c	2024-10-30 06:56:14.952966132 +0000
 @@ -42,6 +42,7 @@
   #endif
   #endif /* not lint */
 
 +#include <err.h>
   #include <limits.h>
   #include <stdio.h>
   #include <stdlib.h>
 @@ -116,6 +117,8 @@
   	else
   		fprintf(outf, "%s\t%s\t%c^%s%c\n",
   		    node->entry, node->file, searchar, node->pat, searchar);
 +	if (fflush(stdout) || ferror(stdout) || fflush(outf) || ferror(outf))
 +		err(EXIT_FAILURE, "write failed");
   	if (node->right)
   		put_entries(node->right);
   }
 --END patch--
 
 -RVP
 


Home | Main Index | Thread Index | Old Index