File pdksh-5.2.14.dif of Package pdksh
--- .pkgextract
+++ .pkgextract 2004-08-02 11:30:32.000000000 +0200
@@ -0,0 +1,3 @@
+patch -p 2 -s --suffix=.patches.1 < ../pdksh-5.2.14-patches.1
+patch -p 0 -s --suffix=.patches.2 < ../pdksh-5.2.14-patches.2
+patch -p 0 -s --suffix=.10711 < ../pdksh-5.2.14-10711.patch
+patch -p 0 -s --suffix=.73718 < ../pdksh-5.2.14-73718.patch
--- Makefile.in
+++ Makefile.in 2004-08-02 11:30:32.000000000 +0200
@@ -27,7 +27,7 @@
transform=@program_transform_name@
bindir = $(exec_prefix)/bin
-mandir = $(prefix)/man/man$(manext)
+mandir = @mandir@/man$(manext)
manext = 1
# Suffix for executables: nothing for unix, .exe for os/2.
--- alloc.c
+++ alloc.c 2004-08-02 11:30:32.000000000 +0200
@@ -110,6 +110,9 @@
Block *block;
struct {int _;} junk; /* alignment */
double djunk; /* alignment */
+#ifdef __ia64__ /* Force 128 bit alignment. */
+ double ddjunk[2] __attribute__ ((aligned (16)));
+#endif
};
struct Block {
--- c_ksh.c
+++ c_ksh.c 2004-08-02 11:30:32.000000000 +0200
@@ -1110,13 +1110,14 @@
return 1;
}
wp += builtin_opt.optind;
- if (!*wp)
+ if (!*wp) {
if (j_jobs((char *) 0, flag, nflag))
rv = 1;
- else
+ } else {
for (; *wp; wp++)
if (j_jobs(*wp, flag, nflag))
rv = 1;
+ }
return rv;
}
--- exec.c
+++ exec.c 2004-08-02 11:30:32.000000000 +0200
@@ -1310,10 +1310,10 @@
iotmp.name = (iotype == IOHERE) ? (char *) 0 : cp;
iotmp.flag |= IONAMEXP;
- if (Flag(FXTRACE))
- shellf("%s%s\n",
- PS4_SUBSTITUTE(str_val(global("PS4"))),
- snptreef((char *) 0, 32, "%R", &iotmp));
+ if (Flag(FXTRACE)) {
+ shellf("%s", PS4_SUBSTITUTE(str_val(global("PS4"))));
+ shellf("%s\n", snptreef((char *) 0, 32, "%R", &iotmp));
+ }
switch (iotype) {
case IOREAD:
--- history.c
+++ history.c 2004-08-02 11:30:32.000000000 +0200
@@ -689,7 +689,7 @@
hname = str_save(f, APERM);
if ((fh = fopen(hname, "r"))) {
- int pos = 0, nread = 0;
+ size_t pos = 0, nread = 0;
int contin = 0; /* continuation of previous command */
char *end;
char hline[LINE + 1];
--- io.c
+++ io.c 2004-08-02 11:30:32.000000000 +0200
@@ -297,11 +297,12 @@
if (fd < FDBASE) {
nfd = ksh_dupbase(fd, FDBASE);
- if (nfd < 0)
+ if (nfd < 0) {
if (errno == EBADF)
return -1;
else
errorf("too many files open in shell");
+ }
if (!noclose)
close(fd);
} else
--- jobs.c
+++ jobs.c 2004-08-02 11:30:32.000000000 +0200
@@ -811,7 +811,6 @@
int sig;
{
Job *j;
- Proc *p;
int rv = 0;
int ecode;
#ifdef JOB_SIGS
@@ -1564,11 +1563,12 @@
break;
}
- if (how != JP_SHORT)
+ if (how != JP_SHORT) {
if (p == j->proc_list)
shf_fprintf(shf, "[%d] %c ", j->job, jobchar);
else
shf_fprintf(shf, "%s", filler);
+ }
if (how == JP_LONG)
shf_fprintf(shf, "%5d ", p->pid);
--- lex.c
+++ lex.c 2004-08-02 11:30:32.000000000 +0200
@@ -645,11 +645,12 @@
if (c == c2 || (c == '<' && c2 == '>')) {
iop->flag = c == c2 ?
(c == '>' ? IOCAT : IOHERE) : IORDWR;
- if (iop->flag == IOHERE)
+ if (iop->flag == IOHERE) {
if ((c2 = getsc()) == '-')
iop->flag |= IOSKIP;
else
ungetsc(c2);
+ }
} else if (c2 == '&')
iop->flag = IODUP | (c == '<' ? IORDUP : 0);
else {
--- main.c
+++ main.c 2004-08-02 11:30:32.000000000 +0200
@@ -400,6 +400,11 @@
else if (Flag(FTALKING))
include(substitute("$HOME/kshrc.ksh", 0), 0,
(char **) 0, 1);
+#else
+ else if (Flag(FTALKING)) {
+ include(substitute("/etc/ksh.kshrc", 0), 0, (char **) 0, 1);
+ include(substitute("$HOME/.kshrc", 0), 0, (char **) 0, 1);
+ }
#endif /* OS2 */
}
@@ -576,11 +581,12 @@
if (trap)
runtraps(0);
- if (s->next == NULL)
+ if (s->next == NULL) {
if (Flag(FVERBOSE))
s->flags |= SF_ECHO;
else
s->flags &= ~SF_ECHO;
+ }
if (interactive) {
j_notify();
--- misc.c
+++ misc.c 2004-08-02 11:30:32.000000000 +0200
@@ -1191,13 +1191,13 @@
/* Like read(2), but if read fails due to non-blocking flag, resets flag
* and restarts read.
*/
-int
+ssize_t
blocking_read(fd, buf, nbytes)
int fd;
char *buf;
- int nbytes;
+ size_t nbytes;
{
- int ret;
+ ssize_t ret;
int tried_reset = 0;
while ((ret = read(fd, buf, nbytes)) < 0) {
--- proto.h
+++ proto.h 2004-08-02 11:30:32.000000000 +0200
@@ -201,7 +201,7 @@
void *arg, int max_width));
int strip_nuls ARGS((char *buf, int nbytes));
char *str_zcpy ARGS((char *dst, const char *src, int dsize));
-int blocking_read ARGS((int fd, char *buf, int nbytes));
+ssize_t blocking_read ARGS((int fd, char *buf, size_t nbytes));
int reset_nonblock ARGS((int fd));
char *ksh_get_wd ARGS((char *buf, int bsize));
/* path.c */
--- shf.c
+++ shf.c 2004-08-02 11:30:32.000000000 +0200
@@ -17,7 +17,7 @@
* file descriptors.
*/
-static int shf_fillbuf ARGS((struct shf *shf));
+static ssize_t shf_fillbuf ARGS((struct shf *shf));
static int shf_emptybuf ARGS((struct shf *shf, int flags));
/* Open a file. First three args are for open(), last arg is flags for
@@ -32,7 +32,7 @@
int sflags;
{
struct shf *shf;
- int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
+ size_t bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
int fd;
/* Done before open so if alloca fails, fd won't be lost. */
@@ -74,7 +74,7 @@
int sflags;
struct shf *shf;
{
- int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
+ size_t bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
/* use fcntl() to figure out correct read/write flags */
if (sflags & SHF_GETFL) {
@@ -127,7 +127,7 @@
int sflags;
struct shf *shf;
{
- int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
+ size_t bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
/* use fcntl() to figure out correct read/write flags */
if (sflags & SHF_GETFL) {
@@ -174,7 +174,7 @@
struct shf *
shf_sopen(buf, bsize, sflags, shf)
char *buf;
- int bsize;
+ size_t bsize;
int sflags;
struct shf *shf;
{
@@ -189,7 +189,7 @@
}
shf->areap = ATEMP;
if (!buf && (sflags & SHF_WR) && (sflags & SHF_DYNAMIC)) {
- if (bsize <= 0)
+ if (bsize == 0)
bsize = 64;
sflags |= SHF_ALLOCB;
buf = alloc(bsize, shf->areap);
@@ -401,7 +401,7 @@
}
/* Fill up a read buffer. Returns EOF for a read error, 0 otherwise. */
-static int
+static ssize_t
shf_fillbuf(shf)
struct shf *shf;
{
@@ -496,20 +496,20 @@
* if no bytes were read, returns 0 if end of file was seen, EOF if
* a read error occurred.
*/
-int
+ssize_t
shf_read(buf, bsize, shf)
char *buf;
- int bsize;
+ size_t bsize;
struct shf *shf;
{
- int orig_bsize = bsize;
- int ncopy;
+ size_t orig_bsize = bsize;
+ off_t ncopy;
if (!(shf->flags & SHF_RD))
internal_errorf(1, "shf_read: flags %x", shf->flags);
- if (bsize <= 0)
- internal_errorf(1, "shf_read: bsize %d", bsize);
+ if (bsize == 0)
+ internal_errorf(1, "shf_read: bsize %zu", bsize);
while (bsize > 0) {
if (shf->rnleft == 0
@@ -525,8 +525,8 @@
shf->rnleft -= ncopy;
}
/* Note: fread(3S) returns 0 for errors - this doesn't */
- return orig_bsize == bsize ? (shf_error(shf) ? EOF : 0)
- : orig_bsize - bsize;
+ return orig_bsize == bsize ? (ssize_t)(shf_error(shf) ? EOF : 0)
+ : (ssize_t)(orig_bsize - bsize);
}
/* Read up to a newline or EOF. The newline is put in buf; buf is always
@@ -536,11 +536,11 @@
char *
shf_getse(buf, bsize, shf)
char *buf;
- int bsize;
+ size_t bsize;
struct shf *shf;
{
unsigned char *end;
- int ncopy;
+ off_t ncopy;
char *orig_buf = buf;
if (!(shf->flags & SHF_RD))
@@ -692,21 +692,21 @@
}
/* Write a buffer. Returns nbytes if successful, EOF if there is an error. */
-int
+ssize_t
shf_write(buf, nbytes, shf)
const char *buf;
- int nbytes;
+ size_t nbytes;
struct shf *shf;
{
- int orig_nbytes = nbytes;
- int n;
- int ncopy;
+ size_t orig_nbytes = nbytes;
+ ssize_t n;
+ off_t ncopy;
if (!(shf->flags & SHF_WR))
internal_errorf(1, "shf_write: flags %x", shf->flags);
if (nbytes < 0)
- internal_errorf(1, "shf_write: nbytes %d", nbytes);
+ internal_errorf(1, "shf_write: nbytes %zu", nbytes);
/* Don't buffer if buffer is empty and we're writting a large amount. */
if ((ncopy = shf->wnleft)
@@ -753,7 +753,7 @@
}
}
- return orig_nbytes;
+ return (ssize_t)orig_nbytes;
}
int
@@ -778,11 +778,11 @@
int
#ifdef HAVE_PROTOTYPES
-shf_snprintf(char *buf, int bsize, const char *fmt, ...)
+shf_snprintf(char *buf, size_t bsize, const char *fmt, ...)
#else
shf_snprintf(buf, bsize, fmt, va_alist)
char *buf;
- int bsize;
+ size_t bsize;
const char *fmt;
va_dcl
#endif
@@ -791,8 +791,8 @@
va_list args;
int n;
- if (!buf || bsize <= 0)
- internal_errorf(1, "shf_snprintf: buf %lx, bsize %d",
+ if (!buf || bsize == 0)
+ internal_errorf(1, "shf_snprintf: buf %lx, bsize %zu",
(long) buf, bsize);
shf_sopen(buf, bsize, SHF_WR, &shf);
--- shf.h
+++ shf.h 2004-08-02 11:30:32.000000000 +0200
@@ -44,15 +44,15 @@
struct shf {
int flags; /* see SHF_* */
unsigned char *rp; /* read: current position in buffer */
- int rbsize; /* size of buffer (1 if SHF_UNBUF) */
- int rnleft; /* read: how much data left in buffer */
+ size_t rbsize; /* size of buffer (1 if SHF_UNBUF) */
+ ssize_t rnleft; /* read: how much data left in buffer */
unsigned char *wp; /* write: current position in buffer */
- int wbsize; /* size of buffer (0 if SHF_UNBUF) */
- int wnleft; /* write: how much space left in buffer */
+ size_t wbsize; /* size of buffer (0 if SHF_UNBUF) */
+ ssize_t wnleft; /* write: how much space left in buffer */
unsigned char *buf; /* buffer */
int fd; /* file descriptor */
int errno_; /* saved value of errno after error */
- int bsize; /* actual size of buf */
+ size_t bsize; /* actual size of buf */
Area *areap; /* area shf/buf were allocated in */
};
@@ -62,7 +62,7 @@
int sflags));
struct shf *shf_fdopen ARGS((int fd, int sflags, struct shf *shf));
struct shf *shf_reopen ARGS((int fd, int sflags, struct shf *shf));
-struct shf *shf_sopen ARGS((char *buf, int bsize, int sflags,
+struct shf *shf_sopen ARGS((char *buf, size_t bsize, int sflags,
struct shf *shf));
int shf_close ARGS((struct shf *shf));
int shf_fdclose ARGS((struct shf *shf));
@@ -70,15 +70,15 @@
int shf_finish ARGS((struct shf *shf));
int shf_flush ARGS((struct shf *shf));
int shf_seek ARGS((struct shf *shf, off_t where, int from));
-int shf_read ARGS((char *buf, int bsize, struct shf *shf));
-char *shf_getse ARGS((char *buf, int bsize, struct shf *shf));
+ssize_t shf_read ARGS((char *buf, size_t bsize, struct shf *shf));
+char *shf_getse ARGS((char *buf, size_t bsize, struct shf *shf));
int shf_getchar ARGS((struct shf *shf));
int shf_ungetc ARGS((int c, struct shf *shf));
int shf_putchar ARGS((int c, struct shf *shf));
int shf_puts ARGS((const char *s, struct shf *shf));
-int shf_write ARGS((const char *buf, int nbytes, struct shf *shf));
+ssize_t shf_write ARGS((const char *buf, size_t nbytes, struct shf *shf));
int shf_fprintf ARGS((struct shf *shf, const char *fmt, ...));
-int shf_snprintf ARGS((char *buf, int bsize, const char *fmt, ...));
+int shf_snprintf ARGS((char *buf, size_t bsize, const char *fmt, ...));
char *shf_smprintf ARGS((const char *fmt, ...));
int shf_vfprintf ARGS((struct shf *, const char *fmt, va_list args));
--- siglist.sh
+++ siglist.sh 2004-08-02 11:31:02.000000000 +0200
@@ -11,7 +11,7 @@
out=tmpo$$.c
ecode=1
trapsigs='0 1 2 13 15'
-trap 'rm -f $in $out; trap 0; exit $ecode' $trapsigs
+trap 'rm -f $in $out; trap - 0; exit $ecode' $trapsigs
CPP="${1-cc -E}"
@@ -23,7 +23,7 @@
{ QwErTy SIG\1 , "\1", "\2" },\
#endif/') > $in
$CPP $in > $out
-sed -n 's/{ QwErTy/{/p' < $out | awk '{print NR, $0}' | sort +2n +0n |
+sed -n 's/{ QwErTy/{/p' < $out | awk '{print NR, $0}' | sort -k 3n -k 1n |
sed 's/^[0-9]* //' |
awk 'BEGIN { last=0; nsigs=0; }
{
--- table.c
+++ table.c 2004-08-02 11:30:32.000000000 +0200
@@ -53,7 +53,7 @@
if (otblp == NULL)
return;
for (i = 0; i < osize; i++)
- if ((tblp = otblp[i]) != NULL)
+ if ((tblp = otblp[i]) != NULL) {
if ((tblp->flag&DEFINED)) {
for (p = &ntblp[hash(tblp->name)
& (tp->size-1)];
@@ -65,6 +65,7 @@
} else if (!(tblp->flag & FINUSE)) {
afree((void*)tblp, tp->areap);
}
+ }
afree((void*)otblp, tp->areap);
}
--- var.c
+++ var.c 2004-08-02 11:30:32.000000000 +0200
@@ -63,11 +63,12 @@
e->loc = l->next; /* pop block */
for (i = l->vars.size; --i >= 0; )
- if ((vp = *vpp++) != NULL && (vp->flag&SPECIAL))
+ if ((vp = *vpp++) != NULL && (vp->flag&SPECIAL)) {
if ((vq = global(vp->name))->flag & ISSET)
setspec(vq);
else
unsetspec(vq);
+ }
if (l->flags & BF_DOGETOPTS)
user_opt = l->getopts_state;
afreeall(&l->area);
@@ -217,11 +218,12 @@
}
for (l = e->loc; ; l = l->next) {
vp = tsearch(&l->vars, n, h);
- if (vp != NULL)
+ if (vp != NULL) {
if (array)
return arraysearch(vp, val);
else
return vp;
+ }
if (l->next == NULL)
break;
}