Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge post-070715 commits that were trapped in the old CVS repository. #43

Merged
merged 25 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
912f69a
* w, whodo: On a 32-bit system where /proc/kcore is larger than 2 GB,
Oct 1, 2007
0960b5f
Added missing dependencies for make -j2.
Oct 28, 2007
3966f5c
* mknod: Mac OS X Leopard compilation fix.
Dec 16, 2007
221d3bb
pgrep: Mac OS X Leopard compilation fix.
Dec 16, 2007
bb78d82
ps: Mac OS X Leopard compilation fix.
Dec 16, 2007
80c941b
mac os x leopard has alloca.h
Dec 16, 2007
3db6701
* Made the getopt() substitute work with the getopt$UNIX2003() function
Dec 16, 2007
51564f6
Use the native utmpx on Mac OS X Leopard.
Dec 16, 2007
8dc0df6
Mac OS X Leopard has no updwtmpx() in its new utmpx function suite.
Dec 16, 2007
f24b80c
Clarify that -R shows memory usage in pages.
Aug 19, 2008
e0ac7a2
* ptime: Works on recent Linux kernels again.
Dec 19, 2008
7d998e7
fix for last fix
Dec 19, 2008
5a97464
* cpio: Skip over zip extra headers with fewer than four bytes (the m…
Feb 14, 2009
fdef441
* pg: Handle cases where standard output is a terminal but not open for
Jun 4, 2009
83f7bab
SUSv2 requires us to not paginate if stdout is not a tty
Jun 4, 2009
d0844c3
if isatty(1) but stdout is not readable, try 2 and then /dev/tty
Jun 5, 2009
2ac3919
* pax: Handle multiple "-s" options correctly, i.e. execute multiple
Aug 12, 2009
32db63d
the spec actually wants at most one successful substitution for pax -…
Aug 14, 2009
6e01124
new game, not yet working with Heirloom sed
Aug 14, 2009
3eff067
_POSIX_PATH_MAX
Jan 1, 2010
fa41adb
handle missing LINE_MAX
Jan 1, 2010
bfd9d2a
* col: The behavior of the -x flag has been inverted to actually match
Jun 28, 2010
5b1ea91
* cut: With "-s", print the last field of a line that was also the last
Sep 26, 2010
91e8b57
* cpio, tar: If an archive contains a file that is a hardlink to itse…
Oct 9, 2010
8c30bc1
Merge branch '20240220-fix' into ng/post-070715
takusuman Mar 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
Release ...
* cpio: Skip over zip extra headers with fewer than four bytes (the minimum
length for them to contain any information) instead of reporting a bad
header and terminating.
* pg: Handle cases where standard output is a terminal but not open for
reading (bug reported by Keith Doyle).
* cpio, tar: If an archive contains a file that is a hardlink to itself on
extraction, do nothing at all instead of discarding its data. This mainly
happens if a file with more than one link is included under the same name
in an archive twice. Since special situations on extraction such as bind
mounts on Linux may lead to this scenario even in cases where both link
names are different, this is now treated like a successful link() step
(bugreport by Thomas Graf).
* Made the getopt() substitute work with the getopt$UNIX2003() function
redirection mechanism on Mac OS X Leopard.
* mknod, pgrep, ps: Mac OS X Leopard compilation fixes.
* w, whodo: On a 32-bit system where /proc/kcore is larger than 2 GB,
avoid a harmless error message (bug reported by Pierre Gentile).
* ptime: Works on recent Linux kernels again.
* col: The behavior of the -x flag has been inverted to actually match
the documentation, i.e. to suppress conversion of spaces to tabs (patch
by Markus Schnalke).
* cut: With "-s", print the last field of a line that was also the last
field specified with "-f" (bugreport by Pierre Gentile).

Release 240220
* [NEW] seq: Stone-simple implementation; needs some improvement yet.
* [NEW] watch: Complete, simple and stable implementation.
Expand All @@ -18,7 +43,6 @@ Release 230503
* readlink: "fix: Made ``name_size`` private again, so ``pfmt()`` won't go segmentation fault."
* readlink: "feat: First step, start modularizing the code."
* libcommon: "fix: getdirentries replacement for OBSD >5.4"

* fix-me: For new releases, finish porting for OpenBSD and implement watch(1) and timeout(1).

Release 230305
Expand Down
4 changes: 2 additions & 2 deletions col/col.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#else
#define USED
#endif
static const char sccsid[] USED = "@(#)col.sl 1.9 (gritter) 5/29/05";
static const char sccsid[] USED = "@(#)col.sl 1.10 (gritter) 6/28/10";

# include <stdio.h>
# include <stdlib.h>
Expand Down Expand Up @@ -397,7 +397,7 @@ emit (long long *s, int lineno)
while (*p) {
ncp = pcp;
while ((*p++&CMASK) == ' ') {
if ((++ncp & 7) == 0 && xflag) {
if ((++ncp & 7) == 0 && !xflag) {
pcp = ncp;
putchar ('\t');
}
Expand Down
58 changes: 47 additions & 11 deletions cpio/cpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

/*
* Sccsid @(#)cpio.c 1.303 (gritter) 4/14/07
* Sccsid @(#)cpio.c 1.307 (gritter) 10/9/10
*/

#include <sys/types.h>
Expand Down Expand Up @@ -62,10 +62,12 @@

#include <sys/ioctl.h>

#if defined(__linux__) || defined(__sun) || defined(__FreeBSD__) || \
defined(__hpux) || defined(_AIX) || defined(__NetBSD__) || \
defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
#if defined (__linux__) || defined (__sun) || defined (__FreeBSD__) || \
defined (__hpux) || defined (_AIX) || defined (__NetBSD__) || \
defined (__OpenBSD__) || defined (__DragonFly__) || defined (__APPLE__)
#ifndef __G__
#include <sys/mtio.h>
#endif
#else /* SVR4.2MP */
#include <sys/scsi.h>
#include <sys/st01.h>
Expand All @@ -80,7 +82,7 @@
#endif /* __linux__ or _AIX, since sys/sysmacros.h
* adds a definition of "major". */

#ifndef major
#if !defined (major) && !defined (__G__)
#include <sys/mkdev.h>
#endif /* If "major" still not defined. */

Expand All @@ -96,6 +98,10 @@
#endif /* _IO_putc_unlocked */
#endif /* __GLIBC__ */

#ifndef _POSIX_PATH_MAX
#define _POSIX_PATH_MAX 255
#endif

/*
* The cpio code assumes that all following S_IFMT bits are the same as
* those of the mode fields in cpio headers. The only real Unix system
Expand Down Expand Up @@ -3056,13 +3062,29 @@ linkunlink(const char *path1, const char *path2)

do {
if (link(path1, path2) == 0) {
if (vflag && pax == PAX_TYPE_CPIO)
good: if (vflag && pax == PAX_TYPE_CPIO)
printf("%s linked to %s\n", path1, path2);
return 0;
}
if (errno == EEXIST && unlink(path2) < 0)
emsg(3, sysv3 ? "cannot unlink <%s>" :
if (errno == EEXIST) {
struct stat st1, st2;
if (lstat(path1, &st1) == 0 &&
lstat(path2, &st2) == 0 &&
st1.st_dev == st2.st_dev &&
st1.st_ino == st2.st_ino)
/*
* An attempt to hardlink a file to itself.
* This happens if a file with more than one
* link has been stored in the archive more
* than once under the same name. This is odd
* but the best we can do is nothing at all
* in such a case.
*/
goto good;
if (unlink(path2) < 0)
emsg(3, sysv3 ? "cannot unlink <%s>" :
"Error cannot unlink \"%s\"", path2);
}
} while (twice++ == 0);
emsg(023, sysv3 ? "Cannot link <%s> & <%s>" :
"Cannot link \"%s\" and \"%s\"", path1, path2);
Expand Down Expand Up @@ -4473,8 +4495,9 @@ skipdata(struct file *f, int (*copydata)(struct file *, const char *, int))
static int
tseek(off_t n)
{
int fault;
int fault = 0;

#ifndef __G__
if (tapeblock > 0) {
int i = (n - poffs) / tapeblock;
#if defined (__linux__) || defined (__sun) || defined (__FreeBSD__) || \
Expand All @@ -4491,6 +4514,7 @@ tseek(off_t n)
fault = ioctl(mt, t, a);
#endif /* SVR4.2MP */
} else
#endif /* __G__ */
fault = lseek(mt, n - poffs, SEEK_CUR) == (off_t)-1 ? -1 : 0;
if (fault == 0)
poffs = n;
Expand Down Expand Up @@ -4720,12 +4744,15 @@ mstat(void)
done(1);
}
#if defined (__linux__)
#ifndef __G__
if ((mtst.st_mode&S_IFMT) == S_IFCHR) {
struct mtget mg;
if (ioctl(mt, MTIOCGET, &mg) == 0)
tapeblock = (mg.mt_dsreg&MT_ST_BLKSIZE_MASK) >>
MT_ST_BLKSIZE_SHIFT;
} else if ((mtst.st_mode&S_IFMT) == S_IFBLK) {
} else
#endif /* __G__ */
if ((mtst.st_mode&S_IFMT) == S_IFBLK) {
/*
* If using a block device, write blocks of the floppy
* disk sector with direct i/o. This enables signals
Expand Down Expand Up @@ -5702,6 +5729,8 @@ ziprxtra(struct file *f, struct zip_header *z)
x = smalloc(len);
if (bread((char *)x, len) != len)
return -1;
if (len < 4)
return len;
xp = x;
while (len > 0) {
if (len < 4)
Expand Down Expand Up @@ -6050,7 +6079,7 @@ zipwtemp(int fd, const char *fn, struct stat *st, union bincpio *bp, size_t sz,
uint32_t dev, uint32_t ino, uint32_t *crc, long long *csize)
{
static int tf = -1;
static char tlate[] = "/var/tmp/cpioXXXXXX";
static char tlate[_POSIX_PATH_MAX+1];
char ibuf[32768];
#if USE_ZLIB || USE_BZLIB
char obuf[32768];
Expand All @@ -6066,6 +6095,13 @@ zipwtemp(int fd, const char *fn, struct stat *st, union bincpio *bp, size_t sz,
*crc = 0;
#if USE_ZLIB || USE_BZLIB
if (tf < 0) {
char *tmpdir;
if ((tmpdir = getenv("TMPDIR")) == NULL)
tmpdir = "/var/tmp";
if (snprintf(tlate, sizeof tlate, "%s/cpioXXXXXX", tmpdir) >=
sizeof tlate)
snprintf(tlate, sizeof tlate, "%s/cpioXXXXXX",
"/var/tmp");
if ((tf = mkstemp(tlate)) >= 0)
unlink(tlate);
} else if (lseek(tf, 0, SEEK_SET) != 0) {
Expand Down
2 changes: 2 additions & 0 deletions cpio/pax.1
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ Any character can be used as delimiter instead of
.RI ` / '.
If a file name is empty after the replacement is done,
the file is ignored.
This option can be specified multiple times
to execute multiple substitutions in the order specified.
.TP
.B \-t
Resets the access times of files
Expand Down
4 changes: 2 additions & 2 deletions cpio/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#else
#define USED
#endif
static const char sccsid[] USED = "@(#)cpio.sl 2.5 (gritter) 4/14/07";
static const char sccsid[] USED = "@(#)cpio.sl 2.11 (gritter) 10/9/10";
/* SLIST */
/*
blast.c: * Sccsid @(#)blast.c 1.2 (gritter) 2/17/04
blast.h: * Sccsid @(#)blast.h 1.2 (gritter) 2/17/04
cpio.c: * Sccsid @(#)cpio.c 1.303 (gritter) 4/14/07
cpio.c: * Sccsid @(#)cpio.c 1.307 (gritter) 10/9/10
cpio.h: Sccsid @(#)cpio.h 1.29 (gritter) 3/26/07
crc32.c: * Sccsid @(#)crc32.c 1.2 (gritter) 5/29/03
expand.c: Sccsid @(#)expand.c 1.6 (gritter) 12/15/03
Expand Down
18 changes: 10 additions & 8 deletions cut/cut.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#else
#define USED
#endif
static const char sccsid[] USED = "@(#)cut.sl 1.20 (gritter) 5/29/05";
static const char sccsid[] USED = "@(#)cut.sl 1.21 (gritter) 9/26/10";

#include <sys/types.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -241,15 +241,15 @@ cutf(struct iblok *ip)
static char *line;
static size_t linesize;
char *cp, *lp, *lq;
int c, i, n, m, gotcha;
int c, i, n, m, otherfield, gotdelim;
char b;
wint_t wc;
const int incr = 128;

if (linesize == 0)
line = smalloc(linesize = incr);
lp = line;
gotcha = 0;
gotdelim = otherfield = 0;
i = 1;
do {
if (multibyte)
Expand All @@ -265,22 +265,24 @@ cutf(struct iblok *ip)
}
n = 1;
}
if (wc == wcdelim)
gotdelim = 1;
if (cp == NULL || wc == '\n' || wc == wcdelim) {
if (have(i) && (!sflag || gotcha || wc == wcdelim) ||
if (have(i) && (!sflag || gotdelim || wc == wcdelim) ||
(!sflag && i == 1 &&
(cp == NULL || wc == '\n'))) {
if (gotcha)
if (otherfield)
for (m = 0; mbdelim[m]; m++)
putc(mbdelim[m], stdout);
for (lq = line; lq < lp; lq++)
putc(*lq, stdout);
gotcha = 1;
otherfield = 1;
}
if (wc == '\n') {
if (gotcha)
if (otherfield)
putc('\n', stdout);
i = 1;
gotcha = 0;
gotdelim = otherfield = 0;
} else
i++;
lp = line;
Expand Down
8 changes: 4 additions & 4 deletions date/date.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#define USED
#if defined (SUS)
static const char sccsid[] USED = "@(#)date_sus.sl 1.26 (gritter) 1/22/06";
static const char sccsid[] USED = "@(#)date_sus.sl 1.27 (gritter) 12/16/07";
#else
static const char sccsid[] USED = "@(#)date.sl 1.26 (gritter) 1/22/06";
static const char sccsid[] USED = "@(#)date.sl 1.27 (gritter) 12/16/07";
#endif

#include <unistd.h>
Expand Down Expand Up @@ -155,10 +155,10 @@ settime(char *op)
if (bflag == 0) {
pututxline(&before);
pututxline(&after);
#if !defined (__hpux) && !defined (_AIX)
#if !defined (__hpux) && !defined (_AIX) && !defined(__APPLE__)
updwtmpx(wtmpxfile, &before);
updwtmpx(wtmpxfile, &after);
#endif /* !__hpux, !__AIX */
#endif /* !__hpux, !__AIX, !__APPLE__ */
}
exit(0);
}
Expand Down
5 changes: 4 additions & 1 deletion libcommon/CHECK.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* SPDX-Licence-Identifier: Zlib
*/
/* Sccsid @(#)CHECK.c 1.7 (gritter) 1/22/06 */
/* Sccsid @(#)CHECK.c 1.8 (gritter) 12/16/07 */

#include <stdlib.h>

Expand All @@ -14,7 +14,10 @@
#endif

#ifdef __APPLE__
#include <available.h>
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_OS_X_VERSION_10_5
#define NEED_ALLOCA_H 1
#endif
#define NEED_MALLOC_H 1
#define NEED_UTMPX_H 1
#endif
Expand Down
18 changes: 17 additions & 1 deletion libcommon/getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Gunnar Ritter, Freiburg i. Br., Germany, March 2002.
*/

/* Sccsid @(#)getopt.c 1.5 (gritter) 4/2/07 */
/* Sccsid @(#)getopt.c 1.6 (gritter) 12/16/07 */

#include <sys/types.h>
#include <alloca.h>
Expand Down Expand Up @@ -123,3 +123,19 @@ getopt(int argc, char *const argv[], const char *optstring)
optarg = 0;
return '?';
}

#ifdef __APPLE__
/*
* Starting with Mac OS 10.5 Leopard, <unistd.h> turns getopt()
* into getopt$UNIX2003() by default. Consequently, this function
* is called instead of the one defined above. However, optind is
* still taken from this file, so in effect, options are not
* properly handled. Defining an own getopt$UNIX2003() function
* works around this issue.
*/
int
getopt$UNIX2003(int argc, char *const argv[], const char *optstring)
{
return getopt(argc, argv, optstring);
}
#endif /* __APPLE__ */
10 changes: 6 additions & 4 deletions libcommon/utmpx.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
*
* SPDX-Licence-Identifier: Zlib
*/
/* Sccsid @(#)utmpx.c 1.12 (gritter) 1/22/06 */
/* Sccsid @(#)utmpx.c 1.13 (gritter) 12/16/07 */

#include <stdio.h>

#if defined(__FreeBSD__) || defined(__dietlibc__) || defined(__NetBSD__) || \
defined(__UCLIBC__) || defined(__OpenBSD__) || \
defined(__DragonFly__) || defined(__APPLE__) || !defined(__GLIBC__)
#if defined (__FreeBSD__) || defined (__dietlibc__) || defined (__NetBSD__) || \
defined (__UCLIBC__) || defined (__OpenBSD__) || \
defined (__DragonFly__) || \
defined (__APPLE__) && \
(__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_OS_X_VERSION_10_5)
#include <sys/types.h>
#include <sys/time.h>
#include <utmp.h>
Expand Down
2 changes: 2 additions & 0 deletions libwchar/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fake:
ar r libwchar.a $(OBJ); \
fi

.NO_PARALLEL: fake

install:

clean:
Expand Down
Loading