Page MenuHomeFreeBSD

D13939.id64374.diff
No OneTemporary

D13939.id64374.diff

Index: bin/cat/Makefile
===================================================================
--- bin/cat/Makefile
+++ bin/cat/Makefile
@@ -6,6 +6,12 @@
PACKAGE=runtime
PROG= cat
+.ifdef BOOTSTRAPPING
+# For the bootstrap cat we disable all wide char support to allow building
+# on Linux/macOS
+CFLAGS+=-DBOOTSTRAP_CAT
+.endif
+
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
Index: bin/cat/cat.c
===================================================================
--- bin/cat/cat.c
+++ bin/cat/cat.c
@@ -96,6 +96,17 @@
*/
#define BUFSIZE_SMALL (MAXPHYS)
+
+/*
+ * For the bootstrapped cat binary (needed for locked appending to METALOG), we
+ * disable all flags except -l and -u to avoid non-portable function calls.
+ */
+#ifdef BOOTSTRAP_CAT
+#define SUPPORTED_FLAGS "lu"
+#else
+#define SUPPORTED_FLAGS "belnstuv"
+#endif
+
int
main(int argc, char *argv[])
{
@@ -104,7 +115,7 @@
setlocale(LC_CTYPE, "");
- while ((ch = getopt(argc, argv, "belnstuv")) != -1)
+ while ((ch = getopt(argc, argv, SUPPORTED_FLAGS)) != -1)
switch (ch) {
case 'b':
bflag = nflag = 1; /* -b implies -n */
@@ -158,7 +169,7 @@
usage(void)
{
- fprintf(stderr, "usage: cat [-belnstuv] [file ...]\n");
+ fprintf(stderr, "usage: cat [-" SUPPORTED_FLAGS "] [file ...]\n");
exit(1);
/* NOTREACHED */
}
@@ -187,6 +198,7 @@
if (fd < 0) {
warn("%s", path);
rval = 1;
+#ifndef BOOTSTRAP_CAT
} else if (cooked) {
if (fd == STDIN_FILENO)
cook_cat(stdin);
@@ -195,6 +207,7 @@
cook_cat(fp);
fclose(fp);
}
+#endif
} else {
raw_cat(fd);
if (fd != STDIN_FILENO)
@@ -206,6 +219,7 @@
}
}
+#ifndef BOOTSTRAP_CAT
static void
cook_cat(FILE *fp)
{
@@ -295,6 +309,7 @@
if (ferror(stdout))
err(1, "stdout");
}
+#endif /* BOOTSTRAP_CAT */
static void
raw_cat(int rfd)

File Metadata

Mime Type
text/plain
Expires
Thu, May 1, 3:52 AM (19 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17872137
Default Alt Text
D13939.id64374.diff (1 KB)

Event Timeline