Module Name: src
Committed By: christos
Date: Sat Jan 22 14:08:19 UTC 2022
Modified Files:
src/usr.bin/find: extern.h find.h misc.c
Log Message:
Use /dev/tty for SIGINFO
Fix some size_t<->int
To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/find/extern.h
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/find/find.h
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/find/misc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/find/extern.h
diff -u src/usr.bin/find/extern.h:1.29 src/usr.bin/find/extern.h:1.30
--- src/usr.bin/find/extern.h:1.29 Sun Jun 12 20:04:40 2016
+++ src/usr.bin/find/extern.h Sat Jan 22 09:08:19 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.29 2016/06/13 00:04:40 pgoyette Exp $ */
+/* $NetBSD: extern.h,v 1.30 2022/01/22 14:08:19 christos Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-void brace_subst(char *, char **, char *, int *);
+void brace_subst(char *, char **, char *, size_t *);
PLAN *find_create(char ***);
int find_execute(PLAN *, char **);
PLAN *find_formplan(char **);
Index: src/usr.bin/find/find.h
diff -u src/usr.bin/find/find.h:1.27 src/usr.bin/find/find.h:1.28
--- src/usr.bin/find/find.h:1.27 Thu Mar 18 14:21:18 2021
+++ src/usr.bin/find/find.h Sat Jan 22 09:08:19 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: find.h,v 1.27 2021/03/18 18:21:18 cheusov Exp $ */
+/* $NetBSD: find.h,v 1.28 2022/01/22 14:08:19 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -79,7 +79,7 @@ typedef struct _plandata {
struct _ex {
char **_e_argv; /* argv array */
char **_e_orig; /* original strings */
- int *_e_len; /* allocated length */
+ size_t *_e_len; /* allocated length */
char **_ep_bxp; /* ptr to 1st addt'l arg */
char *_ep_p; /* current buffer pointer */
char *_ep_bbp; /* begin buffer pointer */
Index: src/usr.bin/find/misc.c
diff -u src/usr.bin/find/misc.c:1.14 src/usr.bin/find/misc.c:1.15
--- src/usr.bin/find/misc.c:1.14 Wed Oct 11 15:51:10 2006
+++ src/usr.bin/find/misc.c Sat Jan 22 09:08:19 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.14 2006/10/11 19:51:10 apb Exp $ */
+/* $NetBSD: misc.c,v 1.15 2022/01/22 14:08:19 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "from: @(#)misc.c 8.2 (Berkeley) 4/1/94";
#else
-__RCSID("$NetBSD: misc.c,v 1.14 2006/10/11 19:51:10 apb Exp $");
+__RCSID("$NetBSD: misc.c,v 1.15 2022/01/22 14:08:19 christos Exp $");
#endif
#endif /* not lint */
@@ -51,6 +51,8 @@ __RCSID("$NetBSD: misc.c,v 1.14 2006/10/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <paths.h>
+#include <fcntl.h>
#include "find.h"
@@ -60,9 +62,9 @@ __RCSID("$NetBSD: misc.c,v 1.14 2006/10/
* area of memory set in store.
*/
void
-brace_subst(char *orig, char **store, char *path, int *len)
+brace_subst(char *orig, char **store, char *path, size_t *len)
{
- int nlen, plen, rest;
+ size_t nlen, plen, rest;
char ch, *p, *ostore;
plen = strlen(path);
@@ -133,7 +135,9 @@ void
show_path(int sig)
{
extern FTSENT *g_entry;
- int errno_bak;
+ static int ttyfd = -2;
+ char buf[2048];
+ int oerrno, n;
if (g_entry == NULL) {
/*
@@ -143,9 +147,20 @@ show_path(int sig)
return;
}
- errno_bak = errno;
- write(STDERR_FILENO, "find path: ", 11);
- write(STDERR_FILENO, g_entry->fts_path, g_entry->fts_pathlen);
- write(STDERR_FILENO, "\n", 1);
- errno = errno_bak;
+ oerrno = errno;
+ if (ttyfd == -2)
+ ttyfd = open(_PATH_TTY, O_RDWR | O_CLOEXEC);
+
+ if (ttyfd == -1)
+ goto out;
+
+ n = snprintf_ss(buf, sizeof(buf), "%s: path %s\n", getprogname(),
+ g_entry->fts_path);
+
+ if (n <= 0)
+ goto out;
+
+ write(ttyfd, buf, (size_t)n);
+out:
+ errno = oerrno;
}