Accepting request 239905 from shells

- Update to 2014-06-26 of ksh93v- version
  * A bug on some systems in which cd to a directory without execute
    permission would not fail has been fixed.
  * The BASH_SOURCE variable was added when ksh is run in bash mode.
  * The -D and -E options have been added to the complete builtin.
  * References to dgk@research.att.com were deleted.
  * The -l flag to trap and the -p flag to umask were added as in bash.
  * In bash mode ${!parameter} is treated like ${$parameter}.
  * Fixed a bug in which eval inside a dot script invoked by a profile file
    terminated the dot script prematurely after running the eval command.
  * Added parameter expansion operator ${$parameter} for variables and
    positional parameters.
  * Added -a option to read which is equivalent to -A.
  * Fixed a bug in builtin -p.
  * Added -n option to builtin to disable builtins.
  * Fixed a couple of file completion bugs.
  * When compiled with the SHOPT_BASH and run with the name bash,
    the shell now uses dynamic scoping for name() and function name. 
    In addition the builtins declare and local are supported.
    The SHOPT_BASH option is on by default in the Makefile.
    More work remains with the bash compatibility option.
  * Fixed a bug in vi command completion in which tab did not work
    after a space.
  * Replaced the -p option for read with -p prompt.  For backword
    compatibility, if a coprocess is running and prompt begins with -
    or is a valid variable name, -p causes the read from a pipe.
  * Modified the -u option for read and print so that it accepts the
    option argument p to indicate the coprocess file descriptor.
- Remove patch ksh93-cd_pwd.dif and ksh93-jobs.dif as now upstream

OBS-URL: https://build.opensuse.org/request/show/239905
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/ksh?expand=0&rev=103
This commit is contained in:
Stephan Kulow 2014-07-16 14:16:21 +00:00 committed by Git OBS Bridge
commit fe1da8d2d4
42 changed files with 741 additions and 4925 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0b854435757829f9fbc9d24242192e2056069862d9c463bf8dcfb76b1f094c8b
size 295820

3
INIT.2014-06-25.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:aae227f4af1192d81ac3415cd59deaf7a69c4f40d4750ccf89bd72b4b12db10f
size 305854

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:81f4007679dad9a93b2a4ed241cbe2e86d1422ee3b74c4f905aaae1345070af2
size 8035476

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6d3da64fb55c68e66e50b125bfd26c456c5a326d5621e3ac42a35242f720c6ad
size 8453430

View File

@ -1,887 +0,0 @@
--- src/cmd/ksh93/Makefile
+++ src/cmd/ksh93/Makefile 2012-08-06 21:25:47.000000000 +0000
@@ -161,6 +161,7 @@ DATAFILES = limits.c msg.c strdata.c tes
shell$(RELEASE) $(VERSION) id=shell :LIBRARY: shell.3 nval.3 alarm.c cd_pwd.c cflow.c deparse.c \
enum.c getopts.c hist.c misc.c print.c read.c sleep.c trap.c test.c \
+ poll.c \
typeset.c ulimit.c umask.c whence.c main.c nvdisc.c nvtype.c \
arith.c args.c array.c completion.c defs.c edit.c expand.c regress.c \
fault.c fcin.c history.c init.c io.c jobs.c lex.c macro.c name.c \
--- src/cmd/ksh93/Mamfile
+++ src/cmd/ksh93/Mamfile 2012-08-06 21:25:47.000000000 +0000
@@ -548,6 +548,22 @@ meta test.o %.c>%.o bltins/test.c test
prev bltins/test.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -D_API_ast=20100309 -D_PACKAGE_ast -D_BLD_shell -DSHOPT_DYNAMIC -DSHOPT_MULTIBYTE -DSHOPT_PFSH -DSHOPT_STATS -DSHOPT_NAMESPACE -DSHOPT_COSHELL -DSHOPT_HISTEXPAND -DERROR_CONTEXT_T=Error_context_t -DSHOPT_FIXEDARRAY -DSHOPT_ESH -DKSHELL -c bltins/test.c
done test.o generated
+
+make poll.o
+make bltins/poll.c
+prev ${PACKAGE_ast_INCLUDE}/tmx.h implicit
+prev FEATURE/poll implicit
+prev FEATURE/externs implicit
+prev include/builtins.h implicit
+prev include/io.h implicit
+prev ${PACKAGE_ast_INCLUDE}/error.h implicit
+prev include/defs.h implicit
+done bltins/poll.c
+meta poll.o %.c>%.o bltins/poll.c test
+prev bltins/poll.c
+exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -D_API_ast=20100309 -D_PACKAGE_ast -D_BLD_shell -DSHOPT_DYNAMIC -DSHOPT_MULTIBYTE -DSHOPT_PFSH -DSHOPT_STATS -DSHOPT_NAMESPACE -DSHOPT_COSHELL -DSHOPT_DYNAMIC -DSHOPT_HISTEXPAND -DERROR_CONTEXT_T=Error_context_t -DSHOPT_FIXEDARRAY -DSHOPT_ESH -DKSHELL -c bltins/poll.c
+done poll.o generated
+
make typeset.o
make bltins/typeset.c
prev FEATURE/dynamic implicit
@@ -1328,7 +1344,7 @@ meta hexpand.o %.c>%.o edit/hexpand.c he
prev edit/hexpand.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DSHOPT_HISTEXPAND -DSHOPT_EDPREDICT -DSHOPT_MULTIBYTE -DKSHELL -DSHOPT_ESH -DSHOPT_VSH -D_PACKAGE_ast -DSHOPT_PFSH -DSHOPT_STATS -DSHOPT_NAMESPACE -DSHOPT_COSHELL -D_BLD_shell -D_API_ast=20100309 -DERROR_CONTEXT_T=Error_context_t -DSHOPT_FIXEDARRAY -c edit/hexpand.c
done hexpand.o generated
-exec - ${AR} rc libshell.a alarm.o cd_pwd.o cflow.o deparse.o enum.o getopts.o hist.o misc.o print.o read.o sleep.o trap.o test.o typeset.o ulimit.o umask.o whence.o main.o nvdisc.o nvtype.o arith.o args.o array.o completion.o defs.o edit.o expand.o regress.o fault.o fcin.o
+exec - ${AR} rc libshell.a alarm.o cd_pwd.o cflow.o deparse.o enum.o getopts.o hist.o misc.o poll.o print.o read.o sleep.o trap.o test.o typeset.o ulimit.o umask.o whence.o main.o nvdisc.o nvtype.o arith.o args.o array.o completion.o defs.o edit.o expand.o regress.o fault.o fcin.o
exec - ${AR} rc libshell.a history.o init.o io.o jobs.o lex.o macro.o name.o nvtree.o parse.o path.o string.o streval.o subshell.o tdump.o timers.o trestore.o waitevent.o xec.o env.o limits.o msg.o strdata.o testops.o keywords.o options.o signals.o aliases.o builtins.o variables.o lexstates.o emacs.o vi.o hexpand.o
exec - (ranlib libshell.a) >/dev/null 2>&1 || true
done libshell.a generated
--- src/cmd/ksh93/bltins/poll.c
+++ src/cmd/ksh93/bltins/poll.c 2012-08-07 03:13:40.000000000 +0000
@@ -0,0 +1,717 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 2007-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Roland Mainz <roland.mainz@nrubsig.org> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#include "defs.h"
+#include "variables.h"
+#include "lexstates.h"
+#include "io.h"
+#include "name.h"
+#include "builtins.h"
+#include "history.h"
+#include "terminal.h"
+#include <stdio.h>
+#include <stdbool.h>
+#include <poll.h>
+#include <tmx.h>
+#include <stk.h>
+
+#ifndef SH_DICT
+# define SH_DICT "libshell"
+#endif
+
+#define sh_contexttoshell(context) ((context)?((context)->shp):(NULL))
+
+static
+const char sh_optpoll[] =
+"[-?\n@(#)$Id: poll (AT&T Labs Research) 2012-08-01 $\n]"
+"[-author?Roland Mainz <roland.mainz@nrubsig.org>]"
+"[-license?http://www.eclipse.org/org/documents/epl-v10.html]"
+"[+NAME? poll - input/output multiplexing]"
+"[+DESCRIPTION?The poll command provides applications with a "
+ "mechanism for multiplexing input/output over a set of "
+ "file descriptors. "
+ "For each member of the (optionally sparse) indexed or "
+ "associative compound or type (see \btypeset -T\b) array "
+ "variable \bvar\b, poll examines the given file descriptor "
+ "in the subscript \b.fd\b for the event(s) specified in "
+ "the subscript \b.events\b. "
+ "The poll command identifies those file descriptors on "
+ "which an application can read or write data, or on which "
+ "certain events have occurred.]"
+"[+?The \bvar\b argument specifies an array of file descriptors to "
+ "be examined and the events of interest for each file "
+ "descriptor. "
+ "It is a array of compound variables (or user-defined type) "
+ "with one member for each open file descriptor of interest. "
+ "The array's compound or type variable members contain the "
+ "following subscripts:]{"
+ "[+?\b.fd\b # file descriptor]"
+ "[+?\b.events\b # compound variable of requested event(s)]"
+ "[+?\b.revents\b # compound variable of returned event(s)]"
+ "}"
+"[+?The \bfd\b variable specifies an open file descriptor and the "
+ "\bevents\b and \brevents\b members are compound variables "
+ "constructed from the following boolean member variables:]"
+ "{ "
+ "[+.pollin?('true'|'false') Data other than high priority "
+ "data may be read without blocking. For STREAMS, this "
+ "flag is set in \brevents\b even if the message "
+ "is of zero length.]"
+ "[+.pollrdnorm?('true'|'false') Normal data (priority band "
+ "equals 0) may be read without blocking. For STREAMS, "
+ "this flag is set in \brevents\b even if the message "
+ "is of zero length.]"
+ "[+.pollrdband?('true'|'false') Data from a non-zero "
+ "priority band may be read without blocking. For "
+ "STREAMS, this flag is set in \brevents\b even if the "
+ "message is of zero length.]"
+ "[+.pollpri?('true'|'false') High priority data may be "
+ "received without blocking. For STREAMS, this flag is "
+ "set in \brevents\b even if the message is of zero "
+ "length.]"
+ "[+.pollout?('true'|'false') Normal data (priority band "
+ "equals 0) may be written without blocking.]"
+ "[+.pollwrnorm?('true'|'false') The same as \bpollout\b.]"
+ "[+.pollwrband?('true'|'false') Priority data (priority band "
+ "> 0) may be written. This event only examines bands "
+ "that have been written to at least once.]"
+ "[+.pollerr?('true'|'false') An error has occurred on the "
+ "device or stream. This flag is only valid in the "
+ "\brevents\b compound variable; it is not used in the "
+ "\bevents\b compound variable.]"
+ "[+.pollhup?('true'|'false') A hangup has occurred on the "
+ "stream. This event and \bpollout\b are mutually "
+ "exclusive; a stream can never be writable if a "
+ "hangup has occurred. "
+ "However, this event and \bpollin\b, "
+ "\bpollrdband\b, or \bpollpri\b are not "
+ "mutually exclusive. This flag is only valid "
+ "in the \brevents\b compound variable; it is not "
+ "used in the \bevents\b compound variable.]"
+ "[+.pollnval?('true'|'false') The specified fd value does "
+ "not belong to an open file. "
+ "This flag is only valid in the \brevents\b compound "
+ "variable; it is not used in the \bevents\b "
+ "compound variable.]"
+ "}"
+"]"
+
+"[+?If the value fd is less than 0, events is ignored and "
+ "revents is set to 0 in that entry on return from poll.]"
+
+"[+?The results of the poll query are stored in the \brevents\b "
+ "compound variable members in the \bvar\b structure. "
+ "\bpoll*\b-variables are set in the \brevents\b compound "
+ "variable to indicate which of the requested events are true. "
+ "If none are true, the matching member in the \brevents\b "
+ "compound variable will have the value of 'false' when the "
+ "poll command returns. "
+ "The \brevents\b compound variable members \bpollhup\b, "
+ "\bpollerr\b, and \bpollnval\b are always set to 'true' in "
+ "\brevents\b if the conditions they indicate are true; this "
+ "occurs even though these flags were not present and/or set "
+ "to 'true' in the \bevents\b compound variable.]"
+
+"[+?If none of the defined events have occurred on any selected "
+ "file descriptor, poll waits at least timeout milliseconds "
+ "for an event to occur on any of the selected file "
+ "descriptors. "
+ "On a computer where millisecond timing accuracy is not "
+ "available, timeout is rounded up to the nearest legal value "
+ "available on that system. If the value timeout is 0, poll "
+ "returns immediately. If the value of timeout is -1, poll "
+ "blocks until a requested event occurs or until the call is "
+ "interrupted.]"
+
+"[+?The poll utility supports regular files, terminal and "
+ "pseudo-terminal devices, STREAMS-based files, FIFOs, and "
+ "pipes. The behavior of poll on elements of fds that refer "
+ "to other types of file is unspecified.]"
+
+"[+?The poll utility supports sockets.]"
+#ifdef __SunOS
+"[+?The poll utility may be used on Solaris on directory fds of "
+ "/proc/$pid/ to get a \bpollhup='true'\b when the process quits.]"
+#endif
+"[+?A file descriptor for a socket that is listening for connections "
+ "will indicate that it is ready for reading, once connections "
+ "are available. A file descriptor for a socket that "
+ "is connecting asynchronously will indicate that it is ready "
+ "for writing, once a connection has been established.]"
+
+"[+?Regular files always poll TRUE for reading and writing.]"
+
+"[e:eventarray]:[fdcount?Upon successful completion, an indexed array "
+ "of strings is returned which contains a list of array "
+ "subscripts in the poll array which received events.]"
+"[S!:pollsfio?Look into sfio streams for buffered information and set "
+ "pollin/pollout to reflect sfio stream state.]"
+"[R:pollttyraw?Put tty connections into raw mode when polling. The "
+ "fd is returned to tty cooked mode before poll(1) exits.]"
+"[t:timeout]:[seconds?Timeout in seconds. If the value timeout is 0, "
+ "poll returns immediately. If the value of timeout is -1, "
+ "poll blocks until a requested event occurs or until the "
+ "call is interrupted.]"
+"\n"
+"\nvar\n"
+"\n"
+"[+EXIT STATUS?]{"
+ "[+0?Success.]"
+ "[+>0?An error occurred.]"
+"}"
+"[+NOTES?]{"
+ "[+?poll*-variables defined in \bevents\b will always appear "
+ "in \brevents\b. This gives the script author control over "
+ "which poll*-variables he can expect in \brevents\b.]"
+
+ "[+?The \bpollinhup\b, \bpollnval\b and \bpollerr\b variables "
+ "may appear in the \brevents\b compound variable even if "
+ "they were not requested in \bevents\b.]"
+
+ "[+?Using the value of variables in \brevents\b which are "
+ "not set in \bevents\b can be done by putting a '-' suffix "
+ "after the variable name, e.g. use "
+ "\b${ar[x]].revents.pollhup-}\b to get the value of "
+ "\bar[x]].revents.pollhup\b or an empty string if the variable "
+ "was not set.]"
+
+ "[+?Like \bpoll\b(2) it is legal to poll on the same fd in "
+ "multiple entries, for exanple to listen for different events "
+ "or to allow multiple callers to pool their poll lists "
+ "together into one \bpoll\b(1) call.]"
+"}"
+
+/* quoting: ']' must be quoted as "]]" and '?' must be quoted as "//" */
+"[+EXAMPLES?]{"
+ "[+?The following example will wait for 10 seconds for input "
+ "on fd 0, variable \bp[fd0]].revents.pollin\b will be 'true' "
+ "or 'false' depening on whether the stream 0 is ready for "
+ "reading:]{"
+ "[+?compound -A p=( [fd0]]=( fd=0 events=( pollin='true' ) ) ) ; poll -t10 p ; print -v p]"
+ "}"
+
+ "[+?The following example will wait for 2 seconds for input "
+ "on fd 0, and variables \bp[0]].revents.pollin\b and "
+ "\bp[0]].revents.pollhup\b will be 'true' after polling ends "
+ "because there is both input data available and the end of "
+ "the stream was reached:]{"
+ "[+?printf '\\n' | ksh -c 'compound -a p=( ( fd=0 events=( pollin=\"true\" pollhup=\"true\" ) ) ) ; poll -t2 p ; print -v p']"
+ "}"
+"}"
+
+"[+SEE ALSO?\bopen\b(1),\btmpfile\b(1),\bdup\b(1),\bclose\b(1),\bpoll\b(2)]"
+;
+
+
+/* Like |nv_open()| but constructs variable name on the fly using |sprintf()| format */
+static
+Namval_t *nv_open_fmt(Dt_t *dict, int flags, const char *namefmt, ...)
+{
+ char varnamebuff[PATH_MAX];
+ va_list ap;
+
+ va_start(ap, namefmt);
+ vsnprintf(varnamebuff, sizeof(varnamebuff), namefmt, ap);
+ va_end(ap);
+
+ return nv_open(varnamebuff, dict, flags);
+}
+
+/* Name/value mapping table for POLL*-flags */
+struct pollflagnamemap
+{
+ const int flag;
+ const char *name;
+};
+
+const
+struct pollflagnamemap pfnm[]=
+{
+ { POLLIN, "pollin" },
+#ifdef POLLPRI
+ { POLLPRI, "pollpri" },
+#endif
+ { POLLOUT, "pollout" },
+#ifdef POLLRDNORM
+ { POLLRDNORM, "pollrdnorm" },
+#endif
+#ifdef POLLWRNORM
+ { POLLWRNORM, "pollwrnorm" },
+#endif
+#ifdef POLLRDBAND
+ { POLLRDBAND, "pollrdband" },
+#endif
+#ifdef POLLWRBAND
+ { POLLWRBAND, "pollwrband" },
+#endif
+#ifdef POLLMSG
+ { POLLMSG, "pollmsg" },
+#endif
+#ifdef POLLREMOVE
+ { POLLREMOVE, "pollremove" },
+#endif
+#ifdef POLLRDHUP
+ { POLLRDHUP, "pollrdhup" },
+#endif
+ { POLLERR, "pollerr" },
+ { POLLHUP, "pollhup" },
+ { POLLNVAL, "pollnval" },
+ { 0, NULL },
+};
+
+/* structure to keep track of per array entry data */
+struct pollstat
+{
+ /* name of array subscript */
+ const char *array_subscript;
+
+ /* |sfio| keeps track of sfio information */
+ struct
+ {
+ Sfio_t *sfd;
+ ssize_t flags;
+ } sfio;
+
+ /*
+ * Bits in |eventvar_found| are POLL*-bits, set if matching
+ * ar[i].events.poll* var was found. We use this later to
+ * set the same ar[i].revents.poll* variable, regardless
+ * whether it was polled or not. This was done so the script
+ * author can control which poll* variables in the "revents"
+ * compound appear and which not.
+ */
+ int eventvar_found;
+};
+
+/* poll on given |fds| data and retry after EINTR/EAGAIN while adjusting timeout */
+static
+int poll_loop(Shbltin_t* context, struct pollfd *fds, nfds_t nfds, int timeout)
+{
+/* nanoseconds to milliseconds */
+#define TIME_NS2MS(t) ((t)/(1000UL*1000UL))
+/* milliseconds to nanoseconds */
+#define TIME_MS2NS(t) (((Time_t)(t))*(1000UL*1000UL))
+
+ int n;
+
+ /* We need two codepaths here:
+ * 1. timeout > 0: we have to wait for |timeout| or events.
+ * 2. timeout <= 0: we have to wait forever (-1), return
+ * immediately (0) or an event occurs.
+ */
+ if (timeout > 0)
+ {
+ const Time_t starttime = tmxgettime();
+ Time_t timeout_ns = TIME_MS2NS(timeout);
+
+ do
+ {
+ while(((n = poll(fds, nfds, timeout)) < 0) &&
+ ((errno == EINTR) || (errno == EAGAIN)) &&
+ (!context->sigset))
+ errno=0;
+
+ timeout_ns=timeout_ns-(tmxgettime()-starttime);
+ timeout=TIME_NS2MS(timeout_ns);
+ } while((timeout > 0) && (!context->sigset));
+ }
+ else
+ {
+ while(((n = poll(fds, nfds, timeout)) < 0) &&
+ ((errno == EINTR) || (errno == EAGAIN)) &&
+ (!context->sigset))
+ errno=0;
+ }
+ return n;
+}
+
+/* set ".poll*"-variables in "ar[i].revents" per data in |currpollfd| and |currps| */
+static
+void set_compound_revents(Shell_t *shp, const char *parrayname, struct pollstat *currps, struct pollfd *currpollfd)
+{
+ const char *subname=currps->array_subscript;
+ Namval_t *np;
+ int pi;
+
+ np = nv_open_fmt(shp->var_tree, NV_VARNAME|NV_NOFAIL|NV_COMVAR, "%s[%s].revents", parrayname, subname);
+ if (!np)
+ {
+ errormsg(SH_DICT, ERROR_ERROR, "could not create pollfd %s[%s].revents", parrayname, subname);
+ return;
+ }
+ nv_setvtree(np); /* make "revents" really a compound variable */
+ nv_close(np);
+
+ for (pi=0 ; pfnm[pi].name != NULL ; pi++)
+ {
+ /*
+ * POLLHUP|POLLNVAL|POLLERR can always appear in |currpollfd->revents|
+ * even if we did not request them in |currpollfd->events|
+ */
+ if ((currps->eventvar_found & pfnm[pi].flag) ||
+ ((currpollfd->revents & (POLLHUP|POLLNVAL|POLLERR)) & pfnm[pi].flag))
+ {
+ np = nv_open_fmt(shp->var_tree, NV_VARNAME|NV_NOFAIL, "%s[%s].revents.%s", parrayname, subname, pfnm[pi].name);
+ if (!np)
+ continue;
+
+ nv_putval(np, ((currpollfd->revents & pfnm[pi].flag)?"true":"false"), 0);
+ nv_close(np);
+ }
+ }
+}
+
+/* |main()| for poll(1) builtin */
+extern
+int b_poll(int argc, char *argv[], Shbltin_t* context)
+{
+ Shell_t *shp = sh_contexttoshell(context);
+ Namval_t *np,
+ *array_np,
+ *array_np_sub;
+ Sfio_t *strstk = NULL; /* stk object for memory allocations */
+ const char *parrayname, /* name of array with poll data */
+ *eventarrayname = NULL, /* name of array with indexes to results */
+ *subname, /* current subscript */
+ *s;
+ int n;
+ int fd;
+ nfds_t numpollfd = 0; /* number of entries to poll */
+ int i,
+ j;
+ double timeout = -1.;
+ char buff[PATH_MAX*2+1]; /* fixme: theoretically enough to hold two variable names */
+ bool ttyraw = false;
+ bool pollsfio = true;
+ int pi; /* index for |pfnm| */
+ struct pollfd *pollfd = NULL, /* data for poll(2) */
+ *currpollfd; /* current |pollfd| we are working on */
+ struct pollstat *pollstat = NULL, /* context data from shell array */
+ *currps; /* current |pollstat| we are working on */
+ int retval = 0; /* return value of builtin */
+
+ while (n = optget(argv, sh_optpoll)) switch (n)
+ {
+ case 't':
+ errno = 0;
+ timeout = strtod(opt_info.arg, (char **)NULL);
+ if (errno != 0)
+ errormsg(SH_DICT, ERROR_system(1), "%s: invalid timeout", opt_info.arg);
+
+ /* -t uses seconds */
+ if (timeout >=0)
+ timeout *= 1000.;
+ break;
+ case 'e':
+ eventarrayname = opt_info.arg;
+ break;
+ case 'S':
+ pollsfio=opt_info.num?true:false;
+ break;
+ case 'R':
+ ttyraw=opt_info.num?true:false;
+ break;
+ case ':':
+ errormsg(SH_DICT, ERROR_ERROR, "%s", opt_info.arg);
+ break;
+ case '?':
+ errormsg(SH_DICT, ERROR_usage(2), "%s", opt_info.arg);
+ break;
+ }
+ argc -= opt_info.index;
+ argv += opt_info.index;
+ if(argc!=1)
+ errormsg(SH_DICT, ERROR_usage(2), optusage((char*)0));
+
+ parrayname = argv[0];
+
+ strstk = stkopen(0);
+ if (!strstk)
+ errormsg(SH_DICT, ERROR_system(1), e_nospace);
+
+ array_np = nv_open(parrayname, shp->var_tree, NV_VARNAME|NV_NOFAIL|NV_NOADD);
+ if (!array_np)
+ {
+ stkclose(strstk);
+ errormsg(SH_DICT, ERROR_system(1), "cannot find array variable %s", parrayname);
+ }
+ if (!nv_isattr(array_np, NV_ARRAY))
+ {
+ nv_close(array_np);
+ stkclose(strstk);
+ errormsg(SH_DICT, ERROR_system(1), "variable %s is not an array", parrayname);
+ }
+
+ /*
+ * Count number of array elememts. We need to do it "manually"
+ * to handle sparse indexed and associative arrays
+ */
+ nv_putsub(array_np, NULL, ARRAY_SCAN);
+ array_np_sub = array_np;
+ do
+ {
+ if (!(subname=nv_getsub(array_np_sub)))
+ break;
+ numpollfd++;
+ } while(array_np_sub && nv_nextsub(array_np_sub));
+
+ /*
+ * Done with counting, now we need to allocate a work area big enough
+ */
+ pollfd = (struct pollfd *)stkalloc(strstk, (sizeof(struct pollfd) * numpollfd));
+ pollstat = (struct pollstat *)stkalloc(strstk, (sizeof(struct pollstat) * numpollfd));
+ if (!pollfd || !pollstat)
+ {
+ errormsg(SH_DICT, ERROR_ERROR, e_nospace);
+ goto done_error;
+ }
+
+ /*
+ * Walk the array again and fetch the data we need...
+ */
+ nv_putsub(array_np, NULL, ARRAY_SCAN);
+ array_np_sub = array_np;
+ i = 0;
+ do
+ {
+ currps=&pollstat[i];
+ currpollfd=&pollfd[i];
+
+ if (!(subname=nv_getsub(array_np_sub)))
+ break;
+
+ currps->array_subscript=subname=stkcopy(strstk, subname);
+ if (!subname)
+ {
+ errormsg(SH_DICT, ERROR_ERROR, e_nospace);
+ goto done_error;
+ }
+
+ np = nv_open_fmt(shp->var_tree, NV_VARNAME|NV_NOFAIL|NV_NOADD, "%s[%s].fd", parrayname, subname);
+ if (!np)
+ {
+ errormsg(SH_DICT, ERROR_ERROR, "missing pollfd %s[%s].fd", parrayname, subname);
+ goto done_error;
+ }
+ fd = (int)nv_getnum(np);
+ nv_close(np);
+ if ((fd < -1) || (fd > OPEN_MAX))
+ {
+ errormsg(SH_DICT, ERROR_ERROR, "invalid pollfd %s[%s].fd %d", parrayname, subname, fd);
+ goto done_error;
+ }
+ currpollfd->fd = fd;
+
+ np = nv_open_fmt(shp->var_tree, NV_VARNAME|NV_NOFAIL|NV_COMVAR|NV_NOADD, "%s[%s].events", parrayname, subname);
+ if (!np)
+ {
+ errormsg(SH_DICT, ERROR_ERROR, "missing pollfd %s[%s].events", parrayname, subname);
+ goto done_error;
+ }
+ nv_close(np);
+
+ currpollfd->events=0;
+ currpollfd->revents=0;
+ currps->eventvar_found=0;
+ for (pi=0 ; pfnm[pi].name != NULL ; pi++)
+ {
+ const char *s;
+
+ np = nv_open_fmt(shp->var_tree, NV_VARNAME|NV_NOFAIL|NV_NOADD, "%s[%s].events.%s", parrayname, subname, pfnm[pi].name);
+ if (!np)
+ continue;
+
+ currps->eventvar_found |= pfnm[pi].flag;
+ s=nv_getval(np);
+ if ((s != NULL) && (!strcmp(s, "true")))
+ currpollfd->events |= pfnm[pi].flag;
+ nv_close(np);
+ }
+
+ i++;
+ } while(array_np_sub && nv_nextsub(array_np_sub));
+
+ nv_close(array_np);
+ array_np=NULL;
+
+ /*
+ * If sfio handles fds we need to check whether there are
+ * any data in the sfio buffers and remember this information
+ * so we can set { POLLIN, POLLOUT } on demand to reflect
+ * this information.
+ */
+ if (pollsfio)
+ {
+ Sfio_t **sfd;
+ int num_sfd=0,
+ active_sfd=0;
+
+ sfd = (Sfio_t **)stkalloc(strstk, (sizeof(Sfio_t *) * (numpollfd+1)));
+ if (!sfd)
+ {
+ errormsg(SH_DICT, ERROR_ERROR, e_nospace);
+ goto done_error;
+ }
+
+ for (i=0 ; i < numpollfd ; i++)
+ {
+ currps=&pollstat[i];
+ fd=pollfd[i].fd;
+
+ currps->sfio.sfd=(fd>=0)?sh_fd2sfio(fd):NULL;
+ currps->sfio.flags=0;
+ if (currps->sfio.sfd!=NULL)
+ {
+ /* Only add |currps->sfio.sfd| to the
+ * |sfd| array (list of |Sfio_t*|
+ * passed to |sfpoll()|) if it is not
+ * in that list yet. This prevents
+ * that we call |sfpoll()| on the same
+ * sfio stream multiple times (which
+ * can happen if pollfd contains the
+ * same fd multiple times (which is
+ * valid usage, for example if multiple
+ * consumers pool their pool lists in
+ * one poll call or listen to different
+ * sets of poll event flags)).
+ */
+ for (j=0 ; j < num_sfd ; j++)
+ {
+ if (sfd[j]==currps->sfio.sfd)
+ break;
+ }
+ if (j == num_sfd)
+ sfd[num_sfd++]=currps->sfio.sfd;
+ }
+ }
+
+ active_sfd = sfpoll(&sfd[0], num_sfd, 0);
+ if (active_sfd > 0)
+ {
+ ssize_t sfpoll_flags;
+
+ for (i=0 ; i < active_sfd ; i++)
+ {
+ sfpoll_flags=sfvalue(sfd[i]);
+
+ /*
+ * We have to loop over all entries
+ * because single fd may be polled
+ * multiple times in different pollfd
+ * entries
+ */
+ for (j=0 ; j < numpollfd ; j++)
+ {
+ if (pollstat[j].sfio.sfd == sfd[i])
+ pollstat[j].sfio.flags=sfpoll_flags;
+ }
+ }
+ }
+ }
+
+ /*
+ * Create --eventarray array on demand
+ */
+ if (eventarrayname)
+ {
+ np = nv_open_fmt(shp->var_tree, NV_VARNAME|NV_ARRAY|NV_NOFAIL, "%s", eventarrayname);
+ if (!np)
+ {
+ errormsg(SH_DICT, ERROR_ERROR, "could not create eventarray variable %s", eventarrayname);
+ goto done_error;
+ }
+
+ nv_close(np);
+ }
+
+ /*
+ * Make sure we poll on "raw" tty to catch _every_ keystroke...
+ */
+ if (ttyraw)
+ {
+ for (i=0 ; i < numpollfd ; i++)
+ {
+ fd=pollfd[i].fd;
+ if ((fd >=0) && (shp->fdstatus[fd]&IOTTY))
+ tty_raw(fd, 1);
+ }
+ }
+
+ /*
+ * ... then poll for events...
+ */
+ n = poll_loop(context, pollfd, numpollfd, timeout);
+
+ /*
+ * ... and restore the tty's to "cooked" mode
+ */
+ if (ttyraw)
+ {
+ for (i=0 ; i < numpollfd ; i++)
+ {
+ fd=pollfd[i].fd;
+ if ((fd >=0) && (shp->fdstatus[fd]&IOTTY))
+ tty_cooked(fd);
+ }
+ }
+
+ if (n < 0)
+ {
+ /* |ERROR_system(0)| won't quit the builtin */
+ errormsg(SH_DICT, ERROR_system(0), "poll(2) failure");
+ retval=1;
+ }
+
+ /*
+ * Write results back into the array
+ */
+ for (i=0 ; i < numpollfd ; i++)
+ {
+ /* Adjust data in |pollfd[i]| to reflect sfio stream status (if requested) */
+ if (pollsfio)
+ {
+ if ((pollfd[i].events & POLLIN) && (pollstat[i].sfio.flags & SF_READ))
+ pollfd[i].revents |= POLLIN;
+ if ((pollfd[i].events & POLLOUT) && (pollstat[i].sfio.flags & SF_WRITE))
+ pollfd[i].revents |= POLLOUT;
+ }
+
+ set_compound_revents(shp, parrayname, &pollstat[i], &pollfd[i]);
+
+ if (eventarrayname && pollfd[i].revents)
+ {
+ sprintf(buff, "%s+=( '%s' )", eventarrayname, pollstat[i].array_subscript);
+ sh_trap(buff, 0);
+ }
+ }
+
+ goto done;
+
+done_error:
+ retval=1;
+done:
+ if (array_np)
+ nv_close(array_np);
+ if (strstk)
+ stkclose(strstk);
+
+ return(retval);
+}
--- src/cmd/ksh93/data/builtins.c
+++ src/cmd/ksh93/data/builtins.c 2012-08-06 21:25:47.000000000 +0000
@@ -109,6 +109,7 @@ const struct shtable3 shtab_builtins[] =
#endif /* JOBS */
"false", NV_BLTIN|BLT_ENV, bltin(false),
"getopts", NV_BLTIN|BLT_ENV, bltin(getopts),
+ "poll", NV_BLTIN, bltin(poll),
"print", NV_BLTIN|BLT_ENV, bltin(print),
"printf", NV_BLTIN|BLT_ENV, bltin(printf),
"pwd", NV_BLTIN, bltin(pwd),
--- src/cmd/ksh93/include/builtins.h
+++ src/cmd/ksh93/include/builtins.h 2012-08-06 21:25:47.000000000 +0000
@@ -100,6 +100,7 @@ extern int b_wait(int, char*[],Shbltin_t
extern int b_whence(int, char*[],Shbltin_t*);
extern int b_alarm(int, char*[],Shbltin_t*);
+extern int b_poll(int, char*[],Shbltin_t*);
extern int b_print(int, char*[],Shbltin_t*);
extern int b_printf(int, char*[],Shbltin_t*);
extern int b_pwd(int, char*[],Shbltin_t*);
--- src/cmd/ksh93/tests/builtin_poll.sh
+++ src/cmd/ksh93/tests/builtin_poll.sh 2012-08-07 01:22:35.000000000 +0000
@@ -0,0 +1,100 @@
+########################################################################
+# #
+# This software is part of the ast package #
+# Copyright (c) 2009-2012 Roland Mainz #
+# and is licensed under the #
+# Eclipse Public License, Version 1.0 #
+# by AT&T Intellectual Property #
+# #
+# A copy of the License is available at #
+# http://www.eclipse.org/org/documents/epl-v10.html #
+# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
+# #
+# #
+# Roland Mainz <roland.mainz@nrubsig.org> #
+# #
+########################################################################
+
+#
+# Copyright (c) 2009, 2012, Roland Mainz. All rights reserved.
+#
+
+#
+# Test module to check the ksh93 "poll" builtin
+#
+
+# test setup
+function err_exit
+{
+ print -u2 -n '\t'
+ print -u2 -r ${Command}[$1]: "${@:2}"
+ (( Errors++ ))
+}
+alias err_exit='err_exit $LINENO'
+
+set -o nounset
+Command=${0##*/}
+integer Errors=0
+
+typeset ocwd
+typeset tmpdir
+
+# create temporary test directory
+ocwd="${PWD}"
+tmpdir="${ mktemp -t -d 'test_builtin_poll.XXXXXXXX' ; }" || err_exit 'Cannot create temporary directory.'
+
+cd "${tmpdir}" || { err_exit "cd ${tmpdir} failed." ; exit $((Errors<125?Errors:125)) ; }
+
+
+# basic tests
+function test1
+{
+ compound d1=(
+ compound -A u=(
+ [y]=( integer fd=5 ; compound events=( pollin='true' ) revents=() )
+ [x]=( integer fd=5 ; compound events=( pollin='true' ) revents=() )
+ )
+ )
+
+ # test 1:
+ print -C d1 >'testdata.cpv'
+ cat '/dev/zero' | $SHELL -o errexit -c 'builtin poll ; read -C <"testdata.cpv" d1 ; redirect 5<&0 ; poll -e d1.res -t 5. d1.u ; print -C d1 >"testdata.cpv"' >'log.txt' 2>&1 || err_exit "poll returned non-zero exit code $?"
+ unset d1 ; read -C d1 <'testdata.cpv' || err_exit 'Cannot read test data.'
+ [[ "$(< 'log.txt')" == '' ]] || err_exit "Excepted empty stdout/stderr, got $(printf '%q\n' "$(< 'log.txt')")"
+ [[ "${d1.u[x].revents.pollin-}" == 'true' ]] || err_exit "d1.u[x].revents contains '${d1.u[x].revents-}', not 'POLLIN'"
+ [[ "${d1.u[y].revents.pollin-}" == 'true' ]] || err_exit "d1.u[y].revents contains '${d1.u[y].revents-}', not 'POLLIN'"
+ [[ "${d1.res[*]-}" == 'x y' ]] || err_exit "d1.res contains '${d1.res[*]-}', not 'x y'"
+
+ rm 'testdata.cpv' 'log.txt'
+
+ # test 2:
+ unset d1.res
+ d1.u[z]=( integer fd=5 ; compound events=( pollout='true' ) revents=() )
+
+ print -C d1 >'testdata.cpv'
+ $SHELL -o errexit -c 'builtin poll ; read -C <"testdata.cpv" d1 ; { poll -e d1.res -t 5. d1.u ; } 5<"/dev/null" 5>"/dev/null" ; print -C d1 >"testdata.cpv"' >'log.txt' 2>&1 || err_exit "poll returned non-zero exit code $?"
+ unset d1 ; read -C d1 <'testdata.cpv' || err_exit 'Cannot read test data.'
+
+ [[ "$(< 'log.txt')" == '' ]] || err_exit "Excepted empty stdout/stderr, got $(printf '%q\n' "$(< 'log.txt')")"
+ [[ "${d1.u[x].revents.pollin-}" == 'true' ]] || err_exit "d1.u[x].revents contains '${d1.u[x].revents-}', not 'POLLIN'"
+ [[ "${d1.u[y].revents.pollin-}" == 'true' ]] || err_exit "d1.u[y].revents contains '${d1.u[y].revents-}', not 'POLLIN'"
+ [[ "${d1.u[z].revents.pollout-}" == 'true' ]] || err_exit "d1.u[z].revents contains '${d1.u[z].revents-}', not 'POLLOUT,'"
+ [[ "${d1.res[*]-}" == 'x y z' ]] || err_exit "d1.res contains '${d1.res[*]-}', not 'x y z'"
+
+ rm 'testdata.cpv' 'log.txt'
+
+ return 0
+}
+
+# run tests
+builtin 'poll' || err_exit 'poll builtin not found.'
+
+test1
+
+# cleanup
+cd "${ocwd}"
+rmdir "${tmpdir}" || err_exit "Cannot remove temporary directory ${tmpdir}."
+
+
+# tests done
+exit $((Errors<125?Errors:125))

View File

@ -1,8 +1,8 @@
--- lib/package/ast-ksh.pkg
+++ lib/package/ast-ksh.pkg 2011-07-05 16:29:57.891926052 +0000
@@ -1,4 +1,4 @@
-ast-ksh :PACKAGE: ksh93 libast libcmd libcoshell libsum libdll
+ast-ksh :PACKAGE: msgcc ksh93 libpp libast libcmd libcoshell libsum libdll
-ast-ksh :PACKAGE: ksh93 msggen libast libcmd libcoshell libsum libdll
+ast-ksh :PACKAGE: ksh93 msggen msgcc libpp libast libcmd libcoshell libsum libdll
:COVERS: ksh

View File

@ -1,6 +1,6 @@
--- src/lib/libast/features/lib
+++ src/lib/libast/features/lib
@@ -92,27 +92,6 @@
--- ./src/lib/libast/features/lib
+++ ./src/lib/libast/features/lib 2014-02-17 15:26:32.488708646 +0000
@@ -134,27 +134,6 @@ tst lib_poll_fd_1 note{ fd is first arg
}
}end
@ -28,9 +28,11 @@
exp _lib_poll _lib_poll_fd_1||_lib_poll_fd_2
tst lib_poll_notimer note{ poll with no fds ignores timeout }end execute{
@@ -241,120 +220,6 @@
}
}end
--- ./src/lib/libast/features/spawn
+++ ./src/lib/libast/features/spawn 2014-02-17 15:29:54.946324412 +0000
@@ -6,123 +6,6 @@ lib posix_spawnattr_setfchdir,posix_spaw
mem inheritance.pgroup spawn.h
-tst lib_posix_spawn unistd.h stdlib.h spawn.h -Dfork=______fork note{ posix_spawn exists and it works and its worth using }end status{
- #include <sys/types.h>
@ -55,9 +57,9 @@
- posix_spawnattr_t attr;
- int n;
- int status;
- char* cmd[3];
- char* cmd[4];
- char tmp[1024];
- if (argv[1])
- if (argv[2])
- _exit(signal(SIGHUP, SIG_DFL) != SIG_IGN);
- signal(SIGHUP, SIG_IGN);
- if (posix_spawnattr_init(&attr))
@ -77,8 +79,9 @@
- }
- /* first try an a.out and verify that SIGHUP is ignored */
- cmd[0] = argv[0];
- cmd[1] = "test";
- cmd[2] = 0;
- cmd[1] = argv[1];
- cmd[2] = "test";
- cmd[3] = 0;
- if (posix_spawn(&pid, cmd[0], 0, &attr, cmd, 0))
- {
- NOTE("posix_spawn() FAILED");
@ -141,6 +144,8 @@
- NOTE("ENOEXEC invokes sh");
- else if (status == 0)
- NOTE("ENOEXEC reports no error");
- else
- NOTE("ENOEXEC produces non-zero exit status");
- }
- _exit(n);
- }

View File

@ -1,8 +1,177 @@
-------------------------------------------------------------------
Tue Jul 8 12:54:51 UTC 2014 - werner@suse.de
- Update to 2014-06-26 of ksh93v- version
* A bug on some systems in which cd to a directory without execute
permission would not fail has been fixed.
* The BASH_SOURCE variable was added when ksh is run in bash mode.
* The -D and -E options have been added to the complete builtin.
* References to dgk@research.att.com were deleted.
* The -l flag to trap and the -p flag to umask were added as in bash.
* In bash mode ${!parameter} is treated like ${$parameter}.
* Fixed a bug in which eval inside a dot script invoked by a profile file
terminated the dot script prematurely after running the eval command.
* Added parameter expansion operator ${$parameter} for variables and
positional parameters.
* Added -a option to read which is equivalent to -A.
* Fixed a bug in builtin -p.
* Added -n option to builtin to disable builtins.
* Fixed a couple of file completion bugs.
* When compiled with the SHOPT_BASH and run with the name bash,
the shell now uses dynamic scoping for name() and function name.
In addition the builtins declare and local are supported.
The SHOPT_BASH option is on by default in the Makefile.
More work remains with the bash compatibility option.
* Fixed a bug in vi command completion in which tab did not work
after a space.
* Replaced the -p option for read with -p prompt. For backword
compatibility, if a coprocess is running and prompt begins with -
or is a valid variable name, -p causes the read from a pipe.
* Modified the -u option for read and print so that it accepts the
option argument p to indicate the coprocess file descriptor.
- Remove patch ksh93-cd_pwd.dif and ksh93-jobs.dif as now upstream
-------------------------------------------------------------------
Fri Jun 27 10:29:17 UTC 2014 - werner@suse.de
- Add patches
ksh93-cd_pwd.dif to see error if a directory does not have execution bit
ksh93-jobs.dif to avoid a crash due broken optimization in job locking
-------------------------------------------------------------------
Thu May 15 07:02:32 UTC 2014 - werner@suse.de
- Add SIGALRM to sigexec
- Enforce reentrant usage of glibc
-------------------------------------------------------------------
Wed May 14 11:07:39 UTC 2014 - werner@suse.de
- Update to 2014-05-09 of ksh93v- version
* A bug in the option parser which could cause 'X -a v=((...)...) to
core dump has been fixed.
* A change to improve the performance of appending an element to an
array has been fixed.
* A complilation option to add programmable completion with the two
new builtins, complete and compgen has been added. It should behave
the same as it does with bash. Please try this out and report any
problems you find. Use compgen --man and complete --man to get the
man pages. Use the bash documentation for now for information about
programmable completion. The compilation is on by default for now.
14-05-12 libast:
* features/lib: mmap() error return may be ((caaddr_t)0) or ((caaddr_t)-1)
* misc/optget.c: save opt_info state in case infof callout munges it
* misc/spawnvex.c: fix nil pointer deref
- Modified patch ksh93-crashes.dif to remove fixed issues
-------------------------------------------------------------------
Tue Apr 29 11:47:11 UTC 2014 - werner@suse.de
- Update to 2014-04-15 of ksh93v- version
* A bug in which type name starting with the letter a, did not
allow instances to be created has been fixed.
* A bug which caused a syntax error when a here-doc was embedded
in `` command substitution has been fixed.
* A bug in `` command substition of a pipeline which could cause
memory problems has been fixed.
* A bug in which the assignment A=() when A is an index array of types
did not eliminate the zero-th element has been fixed.
* A bug in which the braceexpand option was ignored when noglob was
on has been fixed.
* A bug in which a timer alarm during a built-in could cause a core
dump has been fixed.
* A bug in which creating an empty array of a type variable with
required fields has been fixed
* A bug which occurs in an interactive shell when a file is opened as
file descriptor 3 for reading which causes a subsequent read
command to fail to read a line from the file has been fixed.
14-04-15 libast:
* sfio/sfcvt.c: fix flot bug that printed |x|<1 as 0
- Modified patch ksh93-crashes.dif to fix two new issues
-------------------------------------------------------------------
Wed Apr 23 10:10:17 UTC 2014 - dmueller@suse.com
- avoid hanging build on probe run
-------------------------------------------------------------------
Fri Apr 11 15:07:59 UTC 2014 - werner@suse.de
- Update to 2014-03-01 of ksh93v- version
* The description of .sh.match in the sh.1 man page was fixed.
* A typeset -p bug for an associative array of types has been fixed.
* A process substitution bug which caused a process to hang has been
fixed.
* Another bug in which extended regular expressions give with the =~
operator in [[...]] gave syntax errors with multiple (...){...} has
been fixed.
* The value of errno is now saved and restored during shell interrupt
handlers.
* A bug in which a read from a script invoked with set -m could stop
when trying to read, and cause the parent to try to restart which
causes a loop has been fixed.
* A bug in the right shift operator in arithmetic expressions when the
shift count is greated then the number of bits in a long integer has
been fixed.
* Another memory leak which occured for functions defined in subshells
has been fixed.
- Add patch ksh93-crashes.dif to fix various crashes as shown in
bnc #844071
* Avoid double free() as well as sfclose()
-------------------------------------------------------------------
Thu Feb 20 12:29:05 UTC 2014 - werner@suse.de
- Update to 2014-01-14 of ksh93v- version
13-12-05 cmd/builtin:
* Round about 10 bugs had been fixed
14-01-14 --- Release ksh93v- ---
* More than 120 bugs had been fixed
14-01-14 libast:
* Round about 80 changes
13-12-05 libcmd:
* Round about 35 changes
13-07-24 libcoshell:
* Two fixes had been done
- Deleted the following patches
* astksh_builtin_poll20120806_001.diff
* ksh93-dttree-crash.dif
* ksh93-fdstatus.dif
* ksh93-heredoclex.dif
* ksh93-jobs.dif
* ksh93-pwd.dif
* ksh93-sfio.dif
* ksh93-uninitialized.dif
as now upstream
- Modify or extend the following patches
* ksh-locale.patch
* ksh-qemu.patch
* ksh93-alias-k.dif
* ksh93-aso.dif
* ksh93-builtin.dif
* ksh93-compat.dif
* ksh93-env.dif
* ksh93-foreground-prgrp.dif
* ksh93-gcc.dif
* ksh93-heredoc.dif
* ksh93-ia64.dif
* ksh93-limit-name-len.dif
* ksh93-pathtemp.dif
* ksh93-profile.dif
* ksh93-reg.dif
* ksh93-s390.dif
* ksh93-shift_ijs.dif
* ksh93-signals.dif
* ksh93-suid_exec.dif
* ksh93-test.dif
* ksh93-typedef.dif
* ksh93-unset-f.dif
* ksh93-vi.dif
* ksh93-vm.dif
* ksh93.dif
* workaround-stupid-build-system.diff
to work with new ksh93v release
-------------------------------------------------------------------
Sat Feb 8 13:13:22 UTC 2014 - gber@opensuse.org

162
ksh.spec
View File

@ -17,7 +17,7 @@
Name: ksh
%global date 2012-08-01
%global date 2014-06-25
%global use_suid_exe 0
%if %suse_version > 1210
%global use_opt_bins 1
@ -25,11 +25,12 @@ Name: ksh
%global use_opt_bins 0
%endif
%if !0%{?qemu_user_space_build:1}
%global do_tests 1
%bcond_without do_tests
%else
%global do_tests 0
%bcond_with do_tests
%endif
%global use_locale 0
%bcond_with use_locale
%bcond_with vm_debug
BuildRequires: bind-utils
BuildRequires: bison
BuildRequires: flex
@ -48,6 +49,15 @@ BuildRequires: libbz2-devel
%if %suse_version > 1120
BuildRequires: update-alternatives
%endif
%if %{with vm_debug}
BuildRequires: ccache
BuildRequires: gdb
BuildRequires: less
BuildRequires: procps
BuildRequires: strace
BuildRequires: valgrind
BuildRequires: vim
%endif
# /bin/ex and /bin/ed required for build
BuildRequires: awk
BuildRequires: ed
@ -63,7 +73,7 @@ Requires(preun): update-alternatives
%if %use_suid_exe
PreReq: permissions
%endif
Version: 93u
Version: 93v
Release: 0
Summary: Korn Shell
License: CPL-1.0 and EPL-1.0
@ -101,42 +111,26 @@ Patch14: ksh93-ia64.dif
Patch15: ksh93-s390.dif
Patch16: ksh93-gcc.dif
Patch17: ksh93-heredoc.dif
Patch18: ksh93-jobs.dif
Patch19: ksh93-reg.dif
Patch20: ksh93-aso.dif
Patch21: ksh93-vm.dif
Patch22: ksh93-limit-name-len.dif
Patch23: ksh93-foreground-prgrp.dif
Patch24: ksh93-builtin.dif
# PATCH-FIX-UPSTREAM ksh93-read-dont-ignore-esc.dif [bnc#765171]
# is part of ksh93u+ 2012-06-28
# PATCH-EXTEND-UPSTREAM astksh_builtin_poll20120806_001.diff [bnc#779888]
Patch27: astksh_builtin_poll20120806_001.diff
# PATCH-FIX-UPSTREAM ksh93-env.dif [bnc#785266, bnc#803613]
Patch28: ksh93-env.dif
# PATCH-FIX-UPSTREAM ksh93-typedef.dif
# PATCH-FIX-SUSE ksh93-typedef.dif
Patch29: ksh93-typedef.dif
# PATCH-EXTEND-UPSTREAM ksh93-pathtemp.dif [bnc#786134]
# the fix is part of ksh93u+ 2012-06-28
# nevertheless the /dev/shm extension is useful
Patch30: ksh93-pathtemp.dif
# PATCH-FIX-UPSTREAM ksh93-dttree-crash.dif [bnc#795324]
Patch31: ksh93-dttree-crash.dif
# PATCH-FIX-UPSTREAM ksh93-heredoclex.dif [bnc#804998]
Patch32: ksh93-heredoclex.dif
# PATCH-FIX-UPSTREAM ksh93-fdstatus.dif [bnc#808449, bnc#814135]
# this is a backport from the alpha version ksh93v-2013-04-22
Patch33: ksh93-fdstatus.dif
# PATCH-FIX-UPSTREAM ksh93-alias-k.dif [bnc#824187]
Patch34: ksh93-alias-k.dif
# PATCH-FIX-SUSE Reduce warnings about uninitialized varaibles (most of them are handled correct)
Patch35: ksh93-uninitialized.dif
# PATCH-FIX-SUSE Do not use mount(2) system call instead of fs3d_mount(3ast)
Patch36: ksh93-fs3d.dif
# PATCH-FIX-UPSTREAM Ouch ... use memmove instead of memcopy on overlapping areas
Patch37: ksh93-sfio.dif
# PATCH-FIX-SUSE Do not crash wenn cwd is gone [bnc#852160]
Patch38: ksh93-pwd.dif
# PATCH-FIX-SUSE Various crashes fixed for bnc#844071
Patch37: ksh93-crashes.dif
Patch42: ksh-locale.patch
%description
@ -178,7 +172,7 @@ chmod +x %{S:31}
tar --use-compress-program=bzcat -xf %{S:1} \
lib/package/ \
src/cmd/ksh93/ src/lib/libast/ src/lib/libcmd/ src/lib/libcoshell/ src/lib/libdll/ src/lib/libsum/ \
src/cmd/builtin/ src/cmd/msgcc/ src/lib/libpp/ src/lib/libuu/
src/cmd/builtin/ src/cmd/msggen/ src/cmd/msgcc/ src/lib/libpp/ src/lib/libuu/
if test -d share ; then
find share/ \( -name chef -o -name fudd -o -name piglatin -o -name valley \) -a -type d |\
xargs -r rm -vrf
@ -188,7 +182,6 @@ if test -d share ; then
find share/ -type d -a -empty | xargs -r rm -vrf
fi
%patch
%patch42
%patch1
%ifarch %arm
%patch2
@ -210,56 +203,38 @@ fi
%patch15
%patch16
%patch17
%patch18
%patch19
%patch20
%patch21
%patch22
%patch23
%patch24
%patch27
%patch28
%patch29
%patch30
%patch31
%patch32
%patch33
%patch34
%patch35
%patch36
%patch37
%patch38
%patch42
%build
#
# Check for a clean signal environment for runtime tests
#
typeset -i IGNORED=0x$(ps --no-headers -o ignored $$)
typeset -i SIGMASK=0x0
typeset -i usesigexec=0
PATH=$(getconf PATH)
export PATH
unset MALLOC_CHECK_
let "SIGMASK|=(1<<($(kill -l PIPE)-1))"
let "SIGMASK|=(1<<($(kill -l URG) -1))"
let "SIGMASK|=(1<<($(kill -l XFSZ)-1))"
((IGNORED & SIGMASK)) && let ++usesigexec || true
test -t 0 || let ++usesigexec
%if 0%{?qemu_user_space_build:1}
# agraf: In a qemu user space build, ps can not find the actual sigmask
# of processes, so we run into an endless loop. Disable sigexec.
usesigexec=0
%endif
if ((usesigexec > 0)) ; then
${CC:-gcc} ${RPM_OPT_FLAGS} -o sigexec %{S:42} -lutil
if test "$USESIGEXEC" != 0 ; then
#
# The environment variable USESIGEXEC is set by the sigexec
# helper program which provides a real pty/tty pair as well
# as a clean signal environment.
#
${CC:-gcc} ${RPM_OPT_FLAGS} -D_GNU_SOURCE -o sigexec %{S:42} -lutil
for fd in /proc/$$/fd/*; do
test -s $fd -a ! -c $fd && break || true
done
set -- $(readlink $fd)
exec ./sigexec $SHELL ${1+"$@"}
fi
IGNORED=0x$(ps --no-headers -o ignored $$)
AR="ar"
CC=gcc
@ -346,10 +321,14 @@ fi
#define SHOPT_REMOTE 1
#define SHOPT_CMDLIB_BLTIN 1
#define SHOPT_CMDLIB_HDR <cmdlist.h>
#define SHOPT_CMDLIB_DIR "/%{_lib}/ast/bin"
#define SH_CMDLIB_DIR "/%{_lib}/ast/bin"
#define SHOPT_CMDLIB_DIR "/opt/ast/bin"
#define SH_CMDLIB_DIR "/opt/ast/bin"
#define THISPROG "/%{_lib}/ast/bin/suid_exec"
%if %{with vm_debug}
#define _AST_std_malloc 1
%else
#define _AST_std_malloc 0
%endif
#define _map_malloc 1
EOF
set +C
@ -429,6 +408,9 @@ fi
cflags -fsigned-bitfields RPM_OPT_FLAGS
cflags -fsigned-chars RPM_OPT_FLAGS
cflags -fsigned-zeros RPM_OPT_FLAGS
%if %{with vm_debug}
cflags -fno-omit-frame-pointer RPM_OPT_FLAGS
%endif
case "$(gcc --version | head -n 1)" in
*4.[012345].*)
cflags -fno-tree-sink RPM_OPT_FLAGS ;;
@ -436,6 +418,8 @@ fi
esac
cflags -g2 RPM_OPT_FLAGS
cflags -pipe RPM_OPT_FLAGS
cflags -D_GNU_SOURCE RPM_OPT_FLAGS
cflags -D_REENTRANT RPM_OPT_FLAGS
cflags -Wl,-O2 LDFLAGS
cflags -Wl,--hash-size=16699 LDFLAGS
cflags -Wl,-O2 LDSOFLG
@ -444,7 +428,7 @@ fi
cflags -Wl,--hash-size=8599 LDSOFLG
cflags -Wl,-Bsymbolic-functions LDSOFLG
cflags -Wl,-rpath,/%{_lib}/ast LDSOFLG
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE $LARGEFILE"
RPM_OPT_FLAGS="$RPM_OPT_FLAGS $LARGEFILE"
RPM_OPT_FLAGS="$RPM_OPT_FLAGS $IGNORE $FEATURE"
mam_cc_L=use
mam_cc_OPTIMIZE=-pipe
@ -498,7 +482,7 @@ fi
*) cflags @$nobuiltin RPM_OPT_FLAGS
esac
export | grep -vE 'PROFILEREAD|PWD|MAIL|HOME|HOST|HIST|LESS|TMP' > .env
export | grep -vE 'PROFILEREAD|PWD|MAIL|HOME|HOST|HIST|LESS' > .env
bin/package make CCFLAGS="$RPM_OPT_FLAGS -I${root}/include" HOSTTYPE="$HOSTTYPE" AR="$AR" CC="$CC"
root=$(echo ${PWD}/arch/linux*)
test -d $root || exit 1
@ -538,19 +522,26 @@ fi
popd
done
base=src/cmd/ksh93
%if %{with do_tests}
pushd ${root}/bin
mkdir ${TMPDIR}/bin
for bin in * ; do
test -e "$bin" || continue
test "$bin" = ".paths" && continue
test "${bin#*.}" = "old" && continue
install -m 0755 $bin ${TMPDIR}/bin/
done
popd
test=${PWD}/${base}/tests
OPATH=$PATH
OSHELL=$SHELL
PATH=$PATH:${root}/bin
SHELL=${root}/bin/ksh
SHCOMP=${root}/bin/shcomp
PATH=${TMPDIR}/bin:$PATH
SHELL=${TMPDIR}/bin/ksh
SHCOMP=${TMPDIR}/bin/shcomp
export PATH SHCOMP SHELL
%if %do_tests
pushd ${test}
typeset -i failed=0
ln -sf ${root}/lib ${test}/../
sed -ri '/^L[[:blank:]]/a \t 8000' pty.sh
sed -ri 's/(SECONDS[[:blank:]]*>[[:blank:]]*)([[:digit:]]+)/\18/' signal.sh
unset ${!LESS*}
printf '\033[1m'
grep -E '^(model name|flags)[[:blank:]]*:' /proc/cpuinfo | sort -ur | fold -s
@ -563,6 +554,18 @@ fi
result=$(${SHELL} -c 'echo | echo "x$(/bin/echo y)"')
test "$result" = xy || exit 1
${SHELL} -c 'trap "exit 0" EXIT; typeset -T X=(typeset x; function x.get { :; }); X -a xs=((x=yo) (x=jo))'
cat > eso_boot.mod.sh <<-'EOF'
. ./environ.mod
EOF
cat > environ.mod <<-'EOF'
f() {
:
}
unset -f f
msg=`echo OK`
echo $msg
EOF
${SHELL} ./eso_boot.mod.sh
exec 3> ${TMPDIR:-/tmp}/log
LANG=POSIX
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:10} 400
@ -618,7 +621,7 @@ fi
s@^\+ g?cc@$SHELL msgcc -M-set=ast $includes@
s@[[:blank:]]-c[[:blank:]]([^[:blank:]\.]+/([^[:blank:]\.\/]+))\.c@ -c \1\.c -o msgs/\2\.mso@p
}" ${root}/lib/package/gen/make.out > src/cmd/ksh93/doit
%if %use_locale
%if %{with use_locale}
pushd src/cmd/ksh93
mkdir msgs
${root}/lib/probe/C/pp/probe $(type -p gcc) > pp_default.h
@ -652,7 +655,7 @@ fi
mkdir -p %{buildroot}%{_mandir}
mkdir %{buildroot}%{_mandir}/man1
mkdir %{buildroot}%{_mandir}/man3
%if %use_locale
%if %{with use_locale}
mkdir -p %{buildroot}%{_datadir}/locale
%endif
mkdir -p %{buildroot}%{_datadir}/ksh/fun
@ -680,8 +683,8 @@ fi
ln -sf %{_sysconfdir}/alternatives/rksh.1.gz %{buildroot}/%{_mandir}/man1/rksh.1.gz
%else
# create ghost files
ln -sf /bin/true %{buildroot}/bin/ksh
ln -sf /bin/true %{buildroot}%{_bindir}/ksh
ln -sf /bin/true %{buildroot}/bin/ksh
ln -sf /bin/true %{buildroot}%{_bindir}/ksh
%endif
ln -sf /bin/ksh93 %{buildroot}%{_bindir}/rksh
ln -sf /bin/ksh93 %{buildroot}/%{_lib}/ast/ksh
@ -726,12 +729,24 @@ fi
ast=${man}ast
install -m 0644 man/man3/${man} %{buildroot}%{_mandir}/man3/${ast}
done
install -m 0644 include/ast/* %{buildroot}%{_includedir}/ast/
if test -d include/ast/sys/ ; then
for head in include/ast/* ; do
test -e "$head" || continue
if test -d $head ; then
install -d %{buildroot}%{_includedir}/ast/${head##*/}
install -m 0644 ${head}/* %{buildroot}%{_includedir}/ast/${head##*/}/
else
install -m 0644 $head %{buildroot}%{_includedir}/ast/
fi
done
else
install -m 0644 include/ast/* %{buildroot}%{_includedir}/ast/
fi
if cmp -s %{buildroot}%{_includedir}/ast/namval.h %{buildroot}%{_includedir}/ast/ast_namval.h ; then
ln -sf ast_namval.h %{buildroot}%{_includedir}/ast/namval.h
fi
popd
%if %use_locale
%if %{with use_locale}
for msg in share/locale/* ; do
test -d $msg || continue
mkdir -p %{buildroot}%{_datadir}/locale/${msg##*/}/LC_MESSAGES
@ -825,15 +840,14 @@ fi
%endif
%if %suse_version > 1120
%preun
if test $1 -eq 0 ; then
%{_sbindir}/update-alternatives --quiet --remove ksh /bin/ksh93
fi
%endif
%postun
%if %suse_version < 1320
%postun
if test $1 -eq 0 -a ! -x bin/ksh ; then
if test ! -x bin/pdksh ; then
rm -f etc/ksh.kshrc
@ -844,8 +858,8 @@ if test $1 -eq 0 -a ! -x bin/ksh ; then
fi
%endif
%posttrans
%if %suse_version < 1320
%posttrans
if test -x bin/ksh -o -x bin/pdksh ; then
test -e etc/bash.bashrc && ln -sf bash.bashrc etc/ksh.kshrc || true
fi

View File

@ -1,6 +1,6 @@
--- src/cmd/ksh93/data/builtins.c
+++ src/cmd/ksh93/data/builtins.c 2013-06-11 16:24:46.269439322 +0000
@@ -78,8 +78,8 @@ const struct shtable3 shtab_builtins[] =
+++ src/cmd/ksh93/data/builtins.c 2014-02-19 11:05:51.494209208 +0000
@@ -85,8 +85,8 @@ const struct shtable3 shtab_builtins[] =
#if _bin_newgrp || _usr_bin_newgrp
"newgrp", NV_BLTIN|BLT_ENV|BLT_SPC, Bltin(login),
#endif /* _bin_newgrp || _usr_bin_newgrp */
@ -8,6 +8,6 @@
- "hash", NV_BLTIN|BLT_SPC, bltin(alias),
+ "alias", NV_BLTIN|BLT_SPC|BLT_DCL, bltin(alias),
+ "hash", NV_BLTIN|BLT_SPC|BLT_DCL, bltin(alias),
"enum", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(enum),
"eval", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_EXIT,bltin(eval),
"exit", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(return),
"fc", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),

View File

@ -1,6 +1,6 @@
--- src/lib/libast/features/aso
+++ src/lib/libast/features/aso 2012-02-20 12:09:41.065934089 +0100
@@ -5,7 +5,10 @@ if aso note{ gcc 4.1+ 64 bit memory atom
+++ src/lib/libast/features/aso 2014-02-18 13:50:32.820793960 +0000
@@ -10,7 +10,10 @@ if aso note{ gcc 4.1+ 64 bit memory atom
int main()
{
uint64_t i = 0;
@ -11,8 +11,8 @@
+ return __sync_fetch_and_add(&i,7)+__sync_fetch_and_add(&j,7)+__sync_fetch_and_add(&l,7)+__sync_fetch_and_add(&m,7);
}
}end && {
#define _aso_cas8(p,o,n) __sync_val_compare_and_swap(p,o,n)
@@ -31,7 +34,9 @@ elif aso note{ gcc 4.1+ 32 bit memory at
#define _ASO_INTRINSIC 1
@@ -46,7 +49,9 @@ elif aso note{ gcc 4.1+ 32 bit memory at
int main()
{
uint32_t i = 0;
@ -22,4 +22,4 @@
+ return __sync_fetch_and_add(&i,7)+__sync_fetch_and_add(&j,7)+__sync_fetch_and_add(&l,7);
}
}end && {
#define _aso_cas8(p,o,n) __sync_val_compare_and_swap(p,o,n)
#define _ASO_INTRINSIC 1

View File

@ -1,6 +1,20 @@
--- src/cmd/builtin/pty.c
+++ src/cmd/builtin/pty.c 2013-02-01 15:59:52.697952156 +0000
@@ -216,27 +216,64 @@ mkpty(int* master, int* slave)
+++ src/cmd/builtin/pty.c 2014-02-18 14:37:47.047276323 +0000
@@ -113,6 +113,13 @@ USAGE_LICENSE
#include <sys/stat.h>
#include "FEATURE/pty"
+#ifdef __linux__
+# if !_lib_openpty
+# undef _lib_openpty
+# define _lib_openpty 1
+# endif
+#endif
+
#define MODE_666 (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
#define MAXNAME 64
@@ -216,27 +223,59 @@ mkpty(int* master, int* slave)
#if !_lib_openpty
char* sname;
#endif
@ -16,7 +30,7 @@
*/
- alarm(4);
- if (tcgetattr(STDERR_FILENO, &tty) >= 0)
- if (tcgetattr(sffileno(sfstderr), &tty) >= 0)
- ttyp = &tty;
- else
+ alarm(6);
@ -46,9 +60,10 @@
+ cfsetispeed(&tty, B38400);
+ cfsetospeed(&tty, B38400);
+#endif
+ ttyp = &tty;
+ ttyp = &tty;
+
#ifdef TIOCGWINSZ
- if (ioctl(STDERR_FILENO, TIOCGWINSZ, &win) >= 0)
- if (ioctl(sffileno(sfstderr), TIOCGWINSZ, &win) >= 0)
- winp = &win;
- else
+ if (ioctl(sffileno(sfstderr), TIOCGWINSZ, &win) < 0)
@ -65,16 +80,10 @@
+ if (win.ws_col < 80)
+ win.ws_col = 80;
+ winp = &win;
+#endif
+#ifdef __linux__
+# if !_lib_openpty
+# undef _lib_openpty
+# define _lib_openpty 1
+# endif
#endif
#if _lib_openpty
if (openpty(master, slave, NULL, ttyp, winp) < 0)
@@ -279,6 +316,9 @@ mkpty(int* master, int* slave)
@@ -279,6 +318,9 @@ mkpty(int* master, int* slave)
#if !O_cloexec
fcntl(*slave, F_SETFD, FD_CLOEXEC);
#endif
@ -84,89 +93,8 @@
alarm(0);
return 0;
}
@@ -317,9 +357,13 @@ process(Sfio_t* mp, Sfio_t* lp, int dela
char* s;
Sfio_t* ip;
Sfio_t* sps[2];
+ struct stat dst;
+ struct stat fst;
ip = sfstdin;
- for (;;)
+ if (!fstat(sffileno(ip), &dst) && !stat("/dev/null", &fst) && dst.st_dev == fst.st_dev && dst.st_ino == fst.st_ino)
+ ip = 0;
+ do
{
i = 0;
t = timeout;
@@ -336,39 +380,39 @@ process(Sfio_t* mp, Sfio_t* lp, int dela
{
if (n < 0)
error(ERROR_SYSTEM|2, "poll failed");
- if (t < 0)
- break;
+ break;
}
- else
- for (i = 0; i < n; i++)
+ for (i = t = 0; i < n; i++)
+ {
+ if (!(sfvalue(sps[i]) & SF_READ))
+ /*skip*/;
+ else if (sps[i] == mp)
{
- if (!(sfvalue(sps[i]) & SF_READ))
- /*skip*/;
- else if (sps[i] == mp)
+ t++;
+ if (!(s = (char*)sfreserve(mp, SF_UNBOUND, -1)))
{
- if (!(s = (char*)sfreserve(mp, SF_UNBOUND, -1)))
- {
- sfclose(mp);
- mp = 0;
- }
- else if ((r = sfvalue(mp)) > 0 && (sfwrite(sfstdout, s, r) != r || sfsync(sfstdout)))
- {
- error(ERROR_SYSTEM|2, "output write failed");
- goto done;
- }
+ sfclose(mp);
+ mp = 0;
}
- else
+ else if ((r = sfvalue(mp)) > 0 && (sfwrite(sfstdout, s, r) != r || sfsync(sfstdout)))
{
- if (!(s = sfgetr(ip, '\n', 1)))
- ip = 0;
- else if (sfputr(mp, s, '\r') < 0 || sfsync(mp))
- {
- error(ERROR_SYSTEM|2, "write failed");
- goto done;
- }
+ error(ERROR_SYSTEM|2, "output write failed");
+ goto done;
}
}
- }
+ else
+ {
+ t++;
+ if (!(s = sfgetr(ip, '\n', 1)))
+ ip = 0;
+ else if (sfputr(mp, s, '\r') < 0 || sfsync(mp))
+ {
+ error(ERROR_SYSTEM|2, "write failed");
+ goto done;
+ }
+ }
+ }
+ } while (t);
done:
if (mp)
sfclose(mp);
--- src/cmd/builtin/what.c
+++ src/cmd/builtin/what.c 2012-02-13 11:02:18.645933606 +0000
+++ src/cmd/builtin/what.c 2014-02-18 14:29:07.979144811 +0000
@@ -68,7 +68,7 @@ static struct
int match;
int single;

View File

@ -1,6 +1,6 @@
--- src/lib/libast/astsa/ast.h
+++ src/lib/libast/astsa/ast.h 2012-02-21 12:03:33.000000000 +0000
@@ -93,6 +93,12 @@ typedef struct
+++ src/lib/libast/astsa/ast.h 2014-02-17 16:21:31.627048693 +0000
@@ -100,6 +100,12 @@ typedef struct
#define pointerof(x) ((void*)((char*)0+(x)))
#define roundof(x,y) (((x)+(y)-1)&~((y)-1))
@ -14,18 +14,20 @@
#define offsetof(type,member) ((unsigned long)&(((type*)0)->member))
#endif
--- src/lib/libast/features/libpath.sh
+++ src/lib/libast/features/libpath.sh 2007-03-30 16:45:55.000000000 +0000
@@ -21,7 +21,7 @@
+++ src/lib/libast/features/libpath.sh 2014-02-18 11:00:22.655840483 +0000
@@ -21,8 +21,8 @@
########################################################################
ok=0
for i in \
- -x /lib/ld.so /lib/ld-*.so /usr/lib/ld.so /lib/rld \
- -f /usr/shlib/libc.so /shlib/libc.so /usr/lib/libc.so \
+ -x /lib64/ld.so /lib/ld.so /lib64/ld-*.so /lib/ld-*.so /usr/lib/ld.so /lib/rld \
-f /usr/shlib/libc.so /shlib/libc.so /usr/lib/libc.so \
-r /usr/shlib/libc.so /shlib/libc.so
+ -f /usr/shlib/libc.so /shlib/libc.so /usr/lib/libc.so /usr/lib64/libc.so \
-r /usr/shlib/libc.so /shlib/libc.so \
-x /lib*/*ld*.so*
do case $i in
--- src/lib/libast/features/map.c
+++ src/lib/libast/features/map.c 2009-12-09 11:13:24.000000000 +0000
+++ src/lib/libast/features/map.c 2014-02-17 16:21:31.627048693 +0000
@@ -67,10 +67,14 @@ main()
#define _map_malloc 1
printf("\n");
@ -42,8 +44,8 @@
printf("#undef eaccess\n");
printf("#define eaccess _ast_eaccess\n");
--- src/lib/libast/features/sys
+++ src/lib/libast/features/sys 2012-02-21 12:04:43.000000000 +0000
@@ -134,7 +134,7 @@ tst typ_signed_size_t output{
+++ src/lib/libast/features/sys 2014-02-17 16:21:31.627048693 +0000
@@ -139,7 +139,7 @@ tst typ_signed_size_t output{
}
}end
@ -53,7 +55,7 @@
define EXIT_SUCCESS 0
define MB_CUR_MAX 1
--- src/lib/libdll/features/dll
+++ src/lib/libdll/features/dll 2007-03-30 16:40:59.000000000 +0000
+++ src/lib/libdll/features/dll 2014-02-17 16:21:31.627048693 +0000
@@ -15,7 +15,7 @@ tst dll_DYNAMIC link{
}end
tst run{

28
ksh93-crashes.dif Normal file
View File

@ -0,0 +1,28 @@
--- src/cmd/ksh93/sh/name.c
+++ src/cmd/ksh93/sh/name.c 2014-05-14 11:00:22.538735546 +0000
@@ -2645,6 +2645,7 @@ void _nv_unset(register Namval_t *np,int
while(stkclose(slp->slptr)==1);
else
sfclose(slp->slptr);
+ slp->slptr = 0;
free((void*)np->nvalue.ip);
np->nvalue.ip = 0;
}
--- src/cmd/ksh93/sh/parse.c
+++ src/cmd/ksh93/sh/parse.c 2014-04-14 12:24:29.098237738 +0000
@@ -486,11 +486,14 @@
void sh_funstaks(register struct slnod *slp,int flag)
{
register struct slnod *slpold;
- while(slpold=slp)
+ while(slp)
{
if(slp->slchild)
sh_funstaks(slp->slchild,flag);
+ slpold = slp;
slp = slp->slnext;
+ if (!slpold->slptr)
+ continue;
if(flag<=0)
stakdelete(slpold->slptr);
else

View File

@ -1,960 +0,0 @@
--- src/cmd/ksh93/bltins/typeset.c
+++ src/cmd/ksh93/bltins/typeset.c 2013-10-25 13:20:42.799733785 +0000
@@ -579,7 +579,7 @@ static int setall(char **argv,regist
np = sh_fsearch(shp,name,NV_ADD|HASH_NOSCOPE);
else
#endif /* SHOPT_NAMESPACE */
- np = nv_open(name,sh_subfuntree(1),NV_NOARRAY|NV_IDENT|NV_NOSCOPE);
+ np = nv_open(name,sh_subfuntree(shp,1),NV_NOARRAY|NV_IDENT|NV_NOSCOPE);
}
else
{
@@ -1168,14 +1168,14 @@ static int unall(int argc, char **argv,
{
name = sh_optunalias;
if(shp->subshell)
- troot = sh_subaliastree(0);
+ troot = sh_subaliastree(shp,0);
}
else
name = sh_optunset;
while(r = optget(argv,name)) switch(r)
{
case 'f':
- troot = sh_subfuntree(1);
+ troot = sh_subfuntree(shp,1);
break;
case 'a':
all=1;
--- src/cmd/ksh93/include/defs.h
+++ src/cmd/ksh93/include/defs.h 2013-10-25 13:20:42.799733785 +0000
@@ -423,10 +423,10 @@ extern void sh_printopts(Shopt_t,int,Sh
extern int sh_readline(Shell_t*,char**,volatile int,int,ssize_t,long);
extern Sfio_t *sh_sfeval(char*[]);
extern void sh_setmatch(Shell_t*,const char*,int,int,int[],int);
-extern Dt_t *sh_subaliastree(int);
+extern Dt_t *sh_subaliastree(Shell_t*,int);
extern void sh_scope(Shell_t*, struct argnod*, int);
extern Namval_t *sh_scoped(Shell_t*, Namval_t*);
-extern Dt_t *sh_subfuntree(int);
+extern Dt_t *sh_subfuntree(Shell_t*,int);
extern void sh_subjobcheck(pid_t);
extern int sh_subsavefd(int);
extern void sh_subtmpfile(Shell_t*);
--- src/cmd/ksh93/sh/arith.c
+++ src/cmd/ksh93/sh/arith.c 2013-10-25 13:20:42.799733785 +0000
@@ -180,7 +180,10 @@ static Namval_t *scope(register Namval_t
{
ap = nv_arrayptr(np);
if(ap && !ap->table)
+ {
ap->table = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(ap->table,shp,1);
+ }
if(ap && ap->table && (nq=nv_search(nv_getsub(np),ap->table,NV_ADD)))
nq->nvenv = (char*)np;
if(nq && nv_isnull(nq))
--- src/cmd/ksh93/sh/array.c
+++ src/cmd/ksh93/sh/array.c 2013-10-25 13:20:42.800733693 +0000
@@ -79,6 +79,7 @@ struct assoc_array
static Namarr_t *array_scope(Namval_t *np, Namarr_t *ap, int flags)
{
+ Shell_t *shp = sh_getinterp();
Namarr_t *aq;
#if SHOPT_FIXEDARRAY
struct fixed_array *fp;
@@ -95,6 +96,7 @@ static Namarr_t *array_scope(Namval_t *n
if(is_associative(aq))
{
aq->scope = (void*)dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(aq->scope,shp,1);
dtview((Dt_t*)aq->scope,aq->table);
aq->table = (Dt_t*)aq->scope;
return(aq);
@@ -271,6 +273,7 @@ int nv_arrayisset(Namval_t *np, Namarr_t
*/
static Namval_t *array_find(Namval_t *np,Namarr_t *arp, int flag)
{
+ Shell_t *shp=sh_getinterp();
register struct index_array *ap = (struct index_array*)arp;
register union Value *up;
Namval_t *mp;
@@ -373,7 +376,10 @@ static Namval_t *array_find(Namval_t *np
{
char *cp;
if(!ap->header.table)
+ {
ap->header.table = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(ap->header.table,shp,1);
+ }
sfprintf(sh.strbuf,"%d",ap->cur);
cp = sfstruse(sh.strbuf);
mp = nv_search(cp, ap->header.table, NV_ADD);
@@ -402,6 +408,7 @@ static Namval_t *array_find(Namval_t *np
#if SHOPT_TYPEDEF
int nv_arraysettype(Namval_t *np, Namval_t *tp, const char *sub, int flags)
{
+ Shell_t *shp = sh_getinterp();
Namval_t *nq;
char *av[2];
int rdonly = nv_isattr(np,NV_RDONLY);
@@ -410,7 +417,10 @@ int nv_arraysettype(Namval_t *np, Namval
av[1] = 0;
sh.last_table = 0;
if(!ap->table)
+ {
ap->table = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(ap->table,shp,1);
+ }
if(nq = nv_search(sub, ap->table, NV_ADD))
{
if(!nq->nvfun && nq->nvalue.cp && *nq->nvalue.cp==0)
@@ -485,6 +495,7 @@ static Namfun_t *array_clone(Namval_t *n
if(ap->table)
{
ap->table = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(ap->table,shp,1);
if(ap->scope && !(flags&NV_COMVAR))
{
ap->scope = ap->table;
@@ -854,7 +865,9 @@ static struct index_array *array_grow(Na
np->nvalue.cp=0;
if(nv_hasdisc(np,&array_disc) || (nv_type(np) && nv_isvtree(np)))
{
+ Shell_t *shp = sh_getinterp();
ap->header.table = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(ap->header.table,shp,1);
mp = nv_search("0", ap->header.table,NV_ADD);
if(mp && nv_isnull(mp))
{
@@ -1169,6 +1182,7 @@ int nv_nextsub(Namval_t *np)
*/
Namval_t *nv_putsub(Namval_t *np,register char *sp,register long mode)
{
+ Shell_t *shp = sh_getinterp();
register struct index_array *ap = (struct index_array*)nv_arrayptr(np);
register int size = (mode&ARRAY_MASK);
#if SHOPT_FIXEDARRAY
@@ -1180,7 +1194,6 @@ Namval_t *nv_putsub(Namval_t *np,registe
{
if(sp)
{
- Shell_t *shp = sh_getinterp();
if(ap && ap->xp && !strmatch(sp,"+([0-9])"))
{
Namval_t *mp = nv_namptr(ap->xp,0);
@@ -1258,7 +1271,10 @@ Namval_t *nv_putsub(Namval_t *np,registe
char *cp;
Namval_t *mp;
if(!ap->header.table)
+ {
ap->header.table = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(ap->header.table,shp,1);
+ }
sfprintf(sh.strbuf,"%d",ap->cur);
cp = sfstruse(sh.strbuf);
mp = nv_search(cp, ap->header.table, NV_ADD);
@@ -1666,6 +1682,7 @@ int nv_aimax(register Namval_t* np)
*/
void *nv_associative(register Namval_t *np,const char *sp,int mode)
{
+ Shell_t *shp = sh_getinterp();
register struct assoc_array *ap = (struct assoc_array*)nv_arrayptr(np);
register int type;
switch(mode)
@@ -1674,6 +1691,7 @@ void *nv_associative(register Namval_t *
if(ap = (struct assoc_array*)calloc(1,sizeof(struct assoc_array)))
{
ap->header.table = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(ap->header.table,shp,1);
ap->cur = 0;
ap->pos = 0;
ap->header.hdr.disc = &array_disc;
@@ -1742,7 +1760,6 @@ void *nv_associative(register Namval_t *
case NV_ANAME:
if(ap->cur)
{
- Shell_t *shp = sh_getinterp();
if(!shp->instance && nv_isnull(ap->cur))
return(NIL(void*));
return((void*)ap->cur->nvname);
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c 2013-10-25 13:20:42.800733693 +0000
@@ -1909,9 +1909,13 @@ static Init_t *nv_init(Shell_t *shp)
(OPTINDNOD)->nvalue.lp = (&shp->st.optindex);
/* set up the seconds clock */
shp->alias_tree = inittree(shp,shtab_aliases);
+ dtuserdata(shp->alias_tree,shp,1);
shp->track_tree = dtopen(&_Nvdisc,Dtset);
+ dtuserdata(shp->track_tree,shp,1);
shp->bltin_tree = inittree(shp,(const struct shtable2*)shtab_builtins);
+ dtuserdata(shp->bltin_tree,shp,1);
shp->fun_tree = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(shp->fun_tree,shp,1);
dtview(shp->fun_tree,shp->bltin_tree);
nv_mount(DOTSHNOD, "type", shp->typedict=dtopen(&_Nvdisc,Dtoset));
nv_adddisc(DOTSHNOD, shdiscnames, (Namval_t**)0);
@@ -1954,6 +1958,7 @@ static Dt_t *inittree(Shell_t *shp,const
nbltins = n;
}
base_treep = treep = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(treep,shp,1);
treep->user = (void*)shp;
for(tp=name_vals;*tp->sh_name;tp++,np++)
{
--- src/cmd/ksh93/sh/macro.c
+++ src/cmd/ksh93/sh/macro.c 2013-10-25 13:20:42.801733601 +0000
@@ -2742,7 +2742,10 @@ static char *sh_tilde(Shell_t *shp,regis
skip:
#endif /* _WINIX */
if(!logins_tree)
+ {
logins_tree = dtopen(&_Nvdisc,Dtbag);
+ dtuserdata(logins_tree,shp,1);
+ }
if(np=nv_search(string,logins_tree,NV_ADD))
{
c = shp->subshell;
--- src/cmd/ksh93/sh/name.c
+++ src/cmd/ksh93/sh/name.c 2013-10-25 13:20:42.802733508 +0000
@@ -821,6 +821,7 @@ Namval_t *nv_create(const char *name, D
{
Dt_t *dp = dtview(shp->var_tree,(Dt_t*)0);
rp->sdict = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(rp->sdict,shp,1);
dtview(rp->sdict,dp);
dtview(shp->var_tree,rp->sdict);
}
@@ -1170,7 +1171,10 @@ Namval_t *nv_create(const char *name, D
ap = nv_arrayptr(np);
}
if(n && ap && !ap->table)
+ {
ap->table = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(ap->table,shp,1);
+ }
if(ap && ap->table && (nq=nv_search(sub,ap->table,n)))
nq->nvenv = (char*)np;
if(nq && nv_isnull(nq))
@@ -1391,7 +1395,7 @@ Namval_t *nv_open(const char *name, Dt_t
while((c= *(unsigned char*)cp++) && (c!='=') && (c!='/') &&
(c>=0x200 || !(c=sh_lexstates[ST_NORM][c]) || c==S_EPAT || c==S_COLON));
if(shp->subshell && c=='=')
- root = sh_subaliastree(1);
+ root = sh_subaliastree(shp,1);
if(c= *--cp)
*cp = 0;
np = nv_search(name, root, (flags&NV_NOADD)?0:NV_ADD);
@@ -2350,6 +2354,7 @@ void sh_scope(Shell_t *shp, struct argno
newroot = nv_dict(shp->namespace);
#endif /* SHOPT_NAMESPACE */
newscope = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(newscope,shp,1);
if(envlist)
{
dtview(newscope,(Dt_t*)shp->var_tree);
@@ -3334,7 +3339,10 @@ int nv_rename(register Namval_t *np, int
if(ap=nv_arrayptr(np))
{
if(!ap->table)
+ {
ap->table = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(ap->table,shp,1);
+ }
if(ap->table)
mp = nv_search(nv_getsub(np),ap->table,NV_ADD);
nv_arraychild(np,mp,0);
--- src/cmd/ksh93/sh/nvdisc.c
+++ src/cmd/ksh93/sh/nvdisc.c 2013-10-25 13:20:42.802733508 +0000
@@ -246,6 +246,7 @@ static void chktfree(register Namval_t *
*/
static void assign(Namval_t *np,const char* val,int flags,Namfun_t *handle)
{
+ Shell_t *shp = sh_getinterp();
int type = (flags&NV_APPEND)?APPEND:ASSIGN;
register struct vardisc *vp = (struct vardisc*)handle;
register Namval_t *nq = vp->disc[type];
@@ -330,7 +331,7 @@ static void assign(Namval_t *np,const ch
}
else if(!nq || !isblocked(bp,type))
{
- Dt_t *root = sh_subfuntree(1);
+ Dt_t *root = sh_subfuntree(shp,1);
int n;
Namarr_t *ap;
block(bp,type);
@@ -1296,6 +1297,7 @@ static Namfun_t *clone_table(Namval_t* n
Dt_t *oroot=tp->dict,*nroot=dtopen(&_Nvdisc,Dtoset);
if(!nroot)
return(0);
+ dtuserdata(nroot,dtuserdata(oroot,0,0),1);
memcpy((void*)ntp,(void*)fp,sizeof(struct table));
ntp->dict = nroot;
ntp->parent = nv_lastdict();
@@ -1493,6 +1495,6 @@ Namval_t *sh_fsearch(Shell_t *shp, const
sfputr(stkp,nv_name(shp->namespace),'.');
sfputr(stkp,fname,0);
fname = stkptr(stkp,offset);
- return(nv_search(fname,sh_subfuntree(add&NV_ADD),add));
+ return(nv_search(fname,sh_subfuntree(shp,add&NV_ADD),add));
}
#endif /* SHOPT_NAMESPACE */
--- src/cmd/ksh93/sh/path.c
+++ src/cmd/ksh93/sh/path.c 2013-10-25 13:20:42.803733416 +0000
@@ -592,7 +592,7 @@ static void funload(Shell_t *shp,int fno
pname = path_fullname(shp,stakptr(PATH_OFFSET));
if(shp->fpathdict && (rp = dtmatch(shp->fpathdict,(void*)pname)))
{
- Dt_t *funtree = sh_subfuntree(1);
+ Dt_t *funtree = sh_subfuntree(shp,1);
while(1)
{
rpfirst = dtprev(shp->fpathdict,rp);
@@ -868,13 +868,13 @@ Pathcomp_t *path_absolute(Shell_t *shp,r
if(isfun && f>=0 && (cp = strrchr(name,'.')))
{
*cp = 0;
- if(nv_open(name,sh_subfuntree(1),NV_NOARRAY|NV_IDENT|NV_NOSCOPE))
+ if(nv_open(name,sh_subfuntree(shp,1),NV_NOARRAY|NV_IDENT|NV_NOSCOPE))
f = -1;
*cp = '.';
}
if(isfun && f>=0)
{
- nv_onattr(nv_open(name,sh_subfuntree(1),NV_NOARRAY|NV_IDENT|NV_NOSCOPE),NV_LTOU|NV_FUNCTION);
+ nv_onattr(nv_open(name,sh_subfuntree(shp,1),NV_NOARRAY|NV_IDENT|NV_NOSCOPE),NV_LTOU|NV_FUNCTION);
funload(shp,f,name);
close(f);
f = -1;
--- src/cmd/ksh93/sh/subshell.c
+++ src/cmd/ksh93/sh/subshell.c 2013-10-25 13:20:42.803733416 +0000
@@ -379,7 +379,7 @@ static void nv_restore(struct subshell *
* return pointer to alias tree
* create new one if in a subshell and one doesn't exist and create is non-zero
*/
-Dt_t *sh_subaliastree(int create)
+Dt_t *sh_subaliastree(Shell_t *shp,int create)
{
register struct subshell *sp = subshell_data;
if(!sp || sp->shp->curenv==0)
@@ -387,6 +387,7 @@ Dt_t *sh_subaliastree(int create)
if(!sp->salias && create)
{
sp->salias = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(sp->salias,shp,1);
dtview(sp->salias,sp->shp->alias_tree);
sp->shp->alias_tree = sp->salias;
}
@@ -397,7 +398,7 @@ Dt_t *sh_subaliastree(int create)
* return pointer to function tree
* create new one if in a subshell and one doesn't exist and create is non-zero
*/
-Dt_t *sh_subfuntree(int create)
+Dt_t *sh_subfuntree(Shell_t *shp,int create)
{
register struct subshell *sp = subshell_data;
if(!sp || sp->shp->curenv==0)
@@ -405,6 +406,7 @@ Dt_t *sh_subfuntree(int create)
if(!sp->sfun && create)
{
sp->sfun = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(sp->sfun,shp,1);
dtview(sp->sfun,sp->shp->fun_tree);
sp->shp->fun_tree = sp->sfun;
}
--- src/cmd/ksh93/sh/xec.c
+++ src/cmd/ksh93/sh/xec.c 2013-10-25 13:20:42.804733324 +0000
@@ -2688,6 +2688,7 @@ int sh_exec(register const Shnode_t *t,
else
{
root = dtopen(&_Nvdisc,Dtoset);
+ dtuserdata(root,shp,1);
nv_mount(np, (char*)0, root);
np->nvalue.cp = Empty;
dtview(root,shp->var_base);
@@ -2729,7 +2730,7 @@ int sh_exec(register const Shnode_t *t,
np = sh_fsearch(shp,fname,NV_ADD|HASH_NOSCOPE);
if(!np)
#endif /* SHOPT_NAMESPACE */
- np = nv_open(fname,sh_subfuntree(1),NV_NOASSIGN|NV_NOARRAY|NV_VARNAME|NV_NOSCOPE);
+ np = nv_open(fname,sh_subfuntree(shp,1),NV_NOASSIGN|NV_NOARRAY|NV_VARNAME|NV_NOSCOPE);
if(npv)
{
if(!shp->mktype)
@@ -2743,11 +2744,6 @@ int sh_exec(register const Shnode_t *t,
slp = (struct slnod*)np->nvenv;
sh_funstaks(slp->slchild,-1);
stakdelete(slp->slptr);
- if(shp->funload)
- {
- free((void*)np->nvalue.rp);
- np->nvalue.rp = 0;
- }
if(rp->sdict)
{
Namval_t *mp, *nq;
@@ -2761,6 +2757,12 @@ int sh_exec(register const Shnode_t *t,
dtclose(rp->sdict);
rp->sdict = 0;
}
+ if(shp->funload)
+ {
+ if(!shp->fpathdict)
+ free((void*)np->nvalue.rp);
+ np->nvalue.rp = 0;
+ }
}
if(!np->nvalue.rp)
{
@@ -2799,7 +2801,10 @@ int sh_exec(register const Shnode_t *t,
if(!shp->fpathdict)
shp->fpathdict = dtopen(&_Rpdisc,Dtobag);
if(shp->fpathdict)
+ {
+ dtuserdata(shp->fpathdict,shp,1);
dtinsert(shp->fpathdict,rp);
+ }
}
}
else
--- src/lib/libast/Mamfile
+++ src/lib/libast/Mamfile 2013-10-25 13:20:42.806733139 +0000
@@ -3969,6 +3969,14 @@ meta dtopen.o %.c>%.o cdt/dtopen.c dtope
prev cdt/dtopen.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Icdt -Icomp -Iinclude -Istd -I${INSTALLROOT}/include/ast -D_PACKAGE_ast -c cdt/dtopen.c
done dtopen.o generated
+make dtstat.o
+make cdt/dtstat.c
+prev cdt/dthdr.h implicit
+done cdt/dtstat.c
+meta dtstat.o %.c>%.o cdt/dtstat.c dtstat
+prev cdt/dtstat.c
+exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Icdt -Icomp -Iinclude -Istd -I${INSTALLROOT}/include/ast -D_PACKAGE_ast -c cdt/dtstat.c
+done dtstat.o generated
make dtstrhash.o
make cdt/dtstrhash.c
prev cdt/dthdr.h implicit
@@ -3985,6 +3993,14 @@ meta dttree.o %.c>%.o cdt/dttree.c dttre
prev cdt/dttree.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Icdt -Icomp -Iinclude -Istd -I${INSTALLROOT}/include/ast -D_PACKAGE_ast -c cdt/dttree.c
done dttree.o generated
+make dtuser.o
+make cdt/dtuser.c
+prev cdt/dthdr.h implicit
+done cdt/dtuser.c
+meta dtuser.o %.c>%.o cdt/dtuser.c dtuser
+prev cdt/dtuser.c
+exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Icdt -Icomp -Iinclude -Istd -I${INSTALLROOT}/include/ast -D_PACKAGE_ast -c cdt/dtuser.c
+done dtuser.o generated
make dtview.o
make cdt/dtview.c
prev cdt/dthdr.h implicit
@@ -6101,7 +6117,7 @@ exec - ${AR} rc libast.a state.o transit
exec - ${AR} rc libast.a streval.o strexpr.o strmatch.o strcopy.o modei.o modex.o strmode.o strlcat.o strlcpy.o strlook.o strncopy.o strsearch.o strpsearch.o stresc.o stropt.o strtape.o strpcmp.o strnpcmp.o strvcmp.o strnvcmp.o tok.o tokline.o tokscan.o pathaccess.o pathcat.o pathcanon.o pathcheck.o pathpath.o pathexists.o pathfind.o pathkey.o pathprobe.o pathrepl.o pathnative.o pathposix.o pathtemp.o pathtmp.o pathstat.o pathgetlink.o pathsetlink.o pathbin.o pathshell.o pathcd.o pathprog.o fs3d.o ftwalk.o ftwflags.o fts.o astintercept.o conformance.o getenv.o setenviron.o optget.o optjoin.o optesc.o optctx.o strsort.o struniq.o magic.o mime.o mimetype.o signal.o sigflag.o systrace.o error.o errorf.o errormsg.o errorx.o localeconv.o setlocale.o translate.o catopen.o iconv.o lc.o lctab.o mc.o base64.o recfmt.o recstr.o reclen.o fmtrec.o fmtbase.o fmtbuf.o fmtclock.o fmtdev.o fmtelapsed.o fmterror.o fmtesc.o fmtfmt.o fmtfs.o fmtident.o fmtint.o fmtip4.o fmtip6.o fmtls.o fmtmatch.o fmtmode.o fmtnum.o fmtperm.o fmtre.o fmttime.o
exec - ${AR} rc libast.a fmtuid.o fmtgid.o fmtsignal.o fmtscale.o fmttmx.o fmttv.o fmtversion.o strelapsed.o strperm.o struid.o strgid.o strtoip4.o strtoip6.o stack.o stk.o swapget.o swapmem.o swapop.o swapput.o sigdata.o sigcrit.o sigunblock.o procopen.o procclose.o procrun.o procfree.o tmdate.o tmequiv.o tmfix.o tmfmt.o tmform.o tmgoff.o tminit.o tmleap.o tmlex.o tmlocale.o tmmake.o tmpoff.o tmscan.o tmsleep.o tmtime.o tmtype.o tmweek.o tmword.o tmzone.o tmxdate.o tmxduration.o tmxfmt.o tmxgettime.o tmxleap.o tmxmake.o tmxscan.o tmxsettime.o tmxsleep.o tmxtime.o tmxtouch.o tvcmp.o tvgettime.o tvsettime.o tvsleep.o tvtouch.o cmdarg.o vecargs.o vecfile.o vecfree.o vecload.o vecstring.o univdata.o touch.o mnt.o debug.o memccpy.o memchr.o memcmp.o memcpy.o memdup.o memmove.o memset.o mkdir.o mkfifo.o mknod.o rmdir.o remove.o rename.o link.o unlink.o strdup.o strchr.o strrchr.o strstr.o strtod.o strtold.o strtol.o strtoll.o strtoul.o strtoull.o strton.o strtonll.o strntod.o strntold.o strnton.o
exec - ${AR} rc libast.a strntonll.o strntol.o strntoll.o strntoul.o strntoull.o strcasecmp.o strncasecmp.o strerror.o mktemp.o tmpnam.o fsync.o execlp.o execve.o execvp.o execvpe.o spawnveg.o vfork.o killpg.o hsearch.o tsearch.o getlogin.o putenv.o setenv.o unsetenv.o lstat.o statvfs.o eaccess.o gross.o omitted.o readlink.o symlink.o getpgrp.o setpgid.o setsid.o waitpid.o creat64.o fcntl.o open.o atexit.o getdents.o getwd.o dup2.o errno.o getpreroot.o ispreroot.o realopen.o setpreroot.o getgroups.o mount.o system.o iblocks.o modedata.o tmdata.o memfatal.o sfkeyprintf.o sfdcdio.o sfdcdos.o sfdcfilter.o sfdcseekable.o sfdcslow.o sfdcsubstr.o sfdctee.o sfdcunion.o sfdcmore.o sfdcprefix.o wc.o wc2utf8.o basename.o closelog.o dirname.o fmtmsglib.o fnmatch.o ftw.o getdate.o getsubopt.o glob.o nftw.o openlog.o re_comp.o resolvepath.o realpath.o regcmp.o regexp.o setlogmask.o strftime.o strptime.o swab.o syslog.o tempnam.o wordexp.o mktime.o regalloc.o regclass.o regcoll.o regcomp.o regcache.o regdecomp.o regerror.o regexec.o regfatal.o reginit.o
-exec - ${AR} rc libast.a regnexec.o regsubcomp.o regsubexec.o regsub.o regrecord.o regrexec.o regstat.o dtclose.o dtdisc.o dthash.o dtlist.o dtmethod.o dtopen.o dtstrhash.o dttree.o dtview.o dtwalk.o dtnew.o dtcomp.o sfclose.o sfclrlock.o sfdisc.o sfdlen.o sfexcept.o sfgetl.o sfgetu.o sfcvt.o sfecvt.o sffcvt.o sfextern.o sffilbuf.o sfflsbuf.o sfprints.o sfgetd.o sfgetr.o sfllen.o sfmode.o sfmove.o sfnew.o sfpkrd.o sfnotify.o sfnputc.o sfopen.o sfpeek.o sfpoll.o sfpool.o sfpopen.o sfprintf.o sfputd.o sfputl.o sfputr.o sfputu.o sfrd.o sfread.o sfreserve.o sfscanf.o sfseek.o sfset.o sfsetbuf.o sfsetfd.o sfsize.o sfsk.o sfstack.o sfstrtod.o sfsync.o sfswap.o sftable.o sftell.o sftmp.o sfungetc.o sfvprintf.o sfvscanf.o sfwr.o sfwrite.o sfpurge.o sfraise.o sfwalk.o sfgetm.o sfmutex.o sfputm.o sfresize.o _sfclrerr.o _sfeof.o _sferror.o _sffileno.o _sfopen.o _sfstacked.o _sfvalue.o _sfgetc.o _sfgetl.o _sfgetl2.o _sfgetu.o _sfgetu2.o _sfdlen.o _sfllen.o _sfslen.o _sfulen.o _sfputc.o _sfputd.o _sfputl.o _sfputm.o
+exec - ${AR} rc libast.a regnexec.o regsubcomp.o regsubexec.o regsub.o regrecord.o regrexec.o regstat.o dtclose.o dtdisc.o dthash.o dtlist.o dtmethod.o dtopen.o dtstat.o dtstrhash.o dttree.o dtuser.o dtview.o dtwalk.o dtnew.o dtcomp.o sfclose.o sfclrlock.o sfdisc.o sfdlen.o sfexcept.o sfgetl.o sfgetu.o sfcvt.o sfecvt.o sffcvt.o sfextern.o sffilbuf.o sfflsbuf.o sfprints.o sfgetd.o sfgetr.o sfllen.o sfmode.o sfmove.o sfnew.o sfpkrd.o sfnotify.o sfnputc.o sfopen.o sfpeek.o sfpoll.o sfpool.o sfpopen.o sfprintf.o sfputd.o sfputl.o sfputr.o sfputu.o sfrd.o sfread.o sfreserve.o sfscanf.o sfseek.o sfset.o sfsetbuf.o sfsetfd.o sfsize.o sfsk.o sfstack.o sfstrtod.o sfsync.o sfswap.o sftable.o sftell.o sftmp.o sfungetc.o sfvprintf.o sfvscanf.o sfwr.o sfwrite.o sfpurge.o sfraise.o sfwalk.o sfgetm.o sfmutex.o sfputm.o sfresize.o _sfclrerr.o _sfeof.o _sferror.o _sffileno.o _sfopen.o _sfstacked.o _sfvalue.o _sfgetc.o _sfgetl.o _sfgetl2.o _sfgetu.o _sfgetu2.o _sfdlen.o _sfllen.o _sfslen.o _sfulen.o _sfputc.o _sfputd.o _sfputl.o _sfputm.o
exec - ${AR} rc libast.a _sfputu.o clearerr.o fclose.o fdopen.o feof.o ferror.o fflush.o fgetc.o fgetpos.o fgets.o fileno.o fopen.o fprintf.o fpurge.o fputc.o fputs.o fread.o freopen.o fscanf.o fseek.o fseeko.o fsetpos.o ftell.o ftello.o fwrite.o flockfile.o ftrylockfile.o funlockfile.o getc.o getchar.o getw.o pclose.o popen.o printf.o putc.o putchar.o puts.o putw.o rewind.o scanf.o setbuf.o setbuffer.o setlinebuf.o setvbuf.o snprintf.o sprintf.o sscanf.o asprintf.o vasprintf.o tmpfile.o ungetc.o vfprintf.o vfscanf.o vprintf.o vscanf.o vsnprintf.o vsprintf.o vsscanf.o _doprnt.o _doscan.o _filbuf.o _flsbuf.o _stdfun.o _stdopen.o _stdprintf.o _stdscanf.o _stdsprnt.o _stdvbuf.o _stdvsnprnt.o _stdvsprnt.o _stdvsscn.o fgetwc.o fwprintf.o putwchar.o vfwscanf.o wprintf.o fgetws.o fwscanf.o swprintf.o vswprintf.o wscanf.o fputwc.o getwc.o swscanf.o vswscanf.o fputws.o getwchar.o ungetwc.o vwprintf.o fwide.o putwc.o vfwprintf.o vwscanf.o stdio_c99.o fcloseall.o fmemopen.o getdelim.o getline.o frexp.o frexpl.o astcopy.o
exec - ${AR} rc libast.a astconf.o astdynamic.o astlicense.o astquery.o astwinsize.o conftab.o aststatic.o getopt.o getoptl.o aso.o asolock.o asometh.o asorelax.o aso-sem.o aso-fcntl.o vmbest.o vmclear.o vmclose.o vmdcheap.o vmdebug.o vmdisc.o vmexit.o vmlast.o vmopen.o vmpool.o vmprivate.o vmprofile.o vmregion.o vmsegment.o vmset.o vmstat.o vmstrdup.o vmtrace.o vmwalk.o vmmopen.o malloc.o vmgetmem.o a64l.o acosh.o asinh.o atanh.o cbrt.o crypt.o erf.o err.o exp.o exp__E.o expm1.o gamma.o getpass.o lgamma.o log.o log1p.o log__L.o rand48.o random.o rcmd.o rint.o support.o sfstrtmp.o spawn.o
exec - (ranlib libast.a) >/dev/null 2>&1 || true
--- src/lib/libast/cdt/cdtlib.h
+++ src/lib/libast/cdt/cdtlib.h 2013-10-25 13:20:42.807733047 +0000
@@ -58,9 +58,9 @@
/* This struct holds private method data created on DT_OPEN */
struct _dtdata_s
{ unsigned int lock; /* general dictionary lock */
- Dtuser_t user; /* application's data */
unsigned int type; /* method type, control flags */
ssize_t size; /* number of objects */
+ Dtuser_t user; /* application's data */
Dt_t dict; /* when DT_INDATA is requested */
};
@@ -123,7 +123,7 @@ typedef struct _dtlib_s
#endif /* _BLD_cdt */
/* these macros lock/unlock dictionaries. DTRETURN substitutes for "return" */
-#define DTSETLOCK(dt) (((dt)->data->type&DT_SHARE) ? asolock(&(dt)->data->lock,1,ASO_SPINLOCK) : 0 )
+#define DTSETLOCK(dt) (((dt)->data->type&DT_SHARE) ? asolock(&(dt)->data->lock,1,ASO_LOCK) : 0 )
#define DTCLRLOCK(dt) (((dt)->data->type&DT_SHARE) ? asolock(&(dt)->data->lock,1,ASO_UNLOCK) : 0 )
#define DTRETURN(ob,rv) do { (ob) = (rv); goto dt_return; } while(0)
#define DTERROR(dt, mesg) (!((dt)->disc && (dt)->disc->eventf) ? 0 : \
--- src/lib/libast/cdt/dtcomp.c
+++ src/lib/libast/cdt/dtcomp.c 2013-10-25 13:20:42.807733047 +0000
@@ -52,9 +52,3 @@ extern ssize_t dtsize(Dt_t* d)
{
return (ssize_t)(*(_DT(d)->searchf))((d),(Void_t*)(0),DT_STAT);
}
-
-#undef dtstat
-extern ssize_t dtstat(Dt_t* d)
-{
- return (ssize_t)(*(_DT(d)->searchf))((d),(Void_t*)(0),DT_STAT);
-}
--- src/lib/libast/cdt/dthash.c
+++ src/lib/libast/cdt/dthash.c 2013-10-25 13:20:42.807733047 +0000
@@ -52,11 +52,13 @@ static int htable(Dt_t* dt)
if((n = hash->tblz) > 0 && (hash->type&H_FIXED) )
return 0; /* fixed size table */
- if(n == 0 && disc && disc->eventf) /* let user have input */
+ if(disc && disc->eventf) /* let user have input */
{ if((*disc->eventf)(dt, DT_HASHSIZE, &n, disc) > 0 )
{ if(n < 0) /* fix table size */
{ hash->type |= H_FIXED;
- n = -n;
+ n = -n; /* desired table size */
+ if(hash->tblz >= n ) /* table size is fixed now */
+ return 0;
}
}
}
@@ -234,12 +236,13 @@ static Void_t* hstat(Dt_t* dt, Dtstat_t*
for(endt = (t = hash->htbl) + hash->tblz; t < endt; ++t)
{ for(n = 0, l = *t; l; l = l->_rght)
+ { if(n < DT_MAXSIZE)
+ st->lsize[n] += 1;
n += 1;
+ }
st->mlev = n > st->mlev ? n : st->mlev;
if(n < DT_MAXSIZE) /* if chain length is small */
- { st->msize = n > st->msize ? n : st->msize;
- st->lsize[n] += n;
- }
+ st->msize = n > st->msize ? n : st->msize;
}
}
@@ -310,7 +313,7 @@ int type;
hsh = _DTHSH(dt,key,disc);
tbl = hash->htbl + (hsh & (hash->tblz-1));
- pp = ll = NIL(Dtlink_t*);
+ pp = ll = NIL(Dtlink_t*); /* pp is the before, ll is the here */
for(p = NIL(Dtlink_t*), l = *tbl; l; p = l, l = l->_rght)
{ if(hsh == l->_hash)
{ o = _DTOBJ(disc,l); k = _DTKEY(disc,o);
@@ -342,20 +345,41 @@ int type;
_dtfree(dt, ll, type);
DTRETURN(obj, _DTOBJ(disc,ll));
}
+ else if(type & DT_INSTALL )
+ { if(dt->meth->type&DT_BAG)
+ goto do_insert;
+ else if(!(lnk = _dtmake(dt, obj, type)) )
+ DTRETURN(obj, NIL(Void_t*) );
+ else /* replace old object with new one */
+ { if(pp) /* remove old object */
+ pp->_rght = ll->_rght;
+ else *tbl = ll->_rght;
+ o = _DTOBJ(disc,ll);
+ _dtfree(dt, ll, DT_DELETE);
+ DTANNOUNCE(dt, o, DT_DELETE);
+
+ goto do_insert;
+ }
+ }
else
{ /**/DEBUG_ASSERT(type&(DT_INSERT|DT_ATTACH|DT_APPEND|DT_RELINK));
- if(!(dt->meth->type&DT_BAG) )
+ if((dt->meth->type&DT_BAG) )
+ goto do_insert;
+ else
{ if(type&(DT_INSERT|DT_APPEND|DT_ATTACH) )
- type |= DT_SEARCH; /* for announcement */
+ type |= DT_MATCH; /* for announcement */
else if(lnk && (type&DT_RELINK) )
+ { /* remove a duplicate */
+ o = _DTOBJ(disc, lnk);
_dtfree(dt, lnk, DT_DELETE);
+ DTANNOUNCE(dt, o, DT_DELETE);
+ }
DTRETURN(obj, _DTOBJ(disc,ll));
}
- else goto do_insert;
}
}
else /* no matching object */
- { if(!(type&(DT_INSERT|DT_APPEND|DT_ATTACH|DT_RELINK)) )
+ { if(!(type&(DT_INSERT|DT_INSTALL|DT_APPEND|DT_ATTACH|DT_RELINK)) )
DTRETURN(obj, NIL(Void_t*));
do_insert: /* inserting a new object */
--- src/lib/libast/cdt/dtlist.c
+++ src/lib/libast/cdt/dtlist.c 2013-10-25 13:20:42.807733047 +0000
@@ -142,9 +142,9 @@ int type;
}
#if __STD_C
-static Void_t* liststat(Dt_t* dt, Dtstat_t* st)
+static Void_t* listat(Dt_t* dt, Dtstat_t* st)
#else
-static Void_t* liststat(dt, st)
+static Void_t* listat(dt, st)
Dt_t* dt;
Dtstat_t* st;
#endif
@@ -186,7 +186,7 @@ int type;
else if(type&DT_CLEAR)
DTRETURN(obj, lclear(dt));
else if(type&DT_STAT )
- DTRETURN(obj, liststat(dt, (Dtstat_t*)obj));
+ DTRETURN(obj, listat(dt, (Dtstat_t*)obj));
h = list->here; /* save finger to last search object */
list->here = NIL(Dtlink_t*);
@@ -202,8 +202,9 @@ int type;
{ r = (Dtlink_t*)obj;
goto do_insert;
}
- else if(type&(DT_INSERT|DT_APPEND|DT_ATTACH))
- { if(!(r = _dtmake(dt, obj, type)) )
+ else if(type&(DT_INSERT|DT_INSTALL|DT_APPEND|DT_ATTACH))
+ { dt_insert:
+ if(!(r = _dtmake(dt, obj, type)) )
DTRETURN(obj, NIL(Void_t*));
dt->data->size += 1;
@@ -290,7 +291,7 @@ int type;
}
r = h ? h : r;
}
- if(!r)
+ if(!r) /* not found */
DTRETURN(obj, NIL(Void_t*));
if(type&(DT_DELETE|DT_DETACH|DT_REMOVE))
--- src/lib/libast/cdt/dtopen.c
+++ src/lib/libast/cdt/dtopen.c 2013-10-25 13:20:42.808732955 +0000
@@ -153,25 +153,3 @@ void _dtfree(Dt_t* dt, Dtlink_t* l, int
if(disc->link < 0) /* free holder */
(void)(*dt->memoryf)(dt, (Void_t*)l, 0, disc);
}
-
-int dtuserlock(Dt_t* dt, unsigned int key, int type)
-{
- if(type > 0)
- return asolock(&dt->data->user.lock, key, ASO_LOCK);
- else if(type < 0)
- return asolock(&dt->data->user.lock, key, ASO_UNLOCK);
- else return asolock(&dt->data->user.lock, key, ASO_TRYLOCK);
-}
-
-Void_t* dtuserdata(Dt_t* dt, Void_t* data, unsigned int key)
-{
- if(key == 0)
- return dt->data->user.data;
- else if(dtuserlock(dt, key, 1) < 0 )
- return NIL(Void_t*);
- else
- { dt->data->user.data = data;
- dtuserlock(dt, key, -1);
- return data;
- }
-}
--- src/lib/libast/cdt/dtstat.c
+++ src/lib/libast/cdt/dtstat.c 2013-10-25 13:20:42.808732955 +0000
@@ -0,0 +1,54 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Get statistics for a dictionary
+**
+** Written by Kiem-Phong Vo
+*/
+
+ssize_t dtstat(Dt_t* dt, Dtstat_t* dtst)
+{
+ ssize_t sz, k, maxk;
+ char *str;
+ char *end;
+
+ sz = (ssize_t)(*dt->meth->searchf)(dt, (Void_t*)dtst, DT_STAT);
+
+ str = dtst->mesg;
+ end = &dtst->mesg[sizeof(dtst->mesg)] - 1;
+ str += sfsprintf(str, end - str, "Objects=%d Levels=%d(Largest:", dtst->size, dtst->mlev+1);
+
+ /* print top 3 levels */
+ for(k = maxk = 0; k <= dtst->mlev; ++k)
+ if(dtst->lsize[k] > dtst->lsize[maxk])
+ maxk = k;
+ if(maxk > 0)
+ maxk -= 1;
+ for(k = 0; k < 3 && maxk <= dtst->mlev; ++k, ++maxk)
+ str += sfsprintf(str, end - str, " lev[%d]=%d", maxk, dtst->lsize[maxk] );
+ if (str < end)
+ *str++ = ')';
+ *str = 0;
+
+ return sz;
+}
--- src/lib/libast/cdt/dtstrhash.c
+++ src/lib/libast/cdt/dtstrhash.c 2013-10-25 13:20:42.808732955 +0000
@@ -22,40 +22,38 @@
#include "dthdr.h"
/* Hashing a string into an unsigned integer.
-** The basic method is to continuingly accumulate bytes and multiply
-** with some given prime. The length n of the string is added last.
-** The recurrent equation is like this:
-** h[k] = (h[k-1] + bytes)*prime for 0 <= k < n
-** h[n] = (h[n-1] + n)*prime
-** The prime is chosen to have a good distribution of 1-bits so that
-** the multiplication will distribute the bits in the accumulator well.
-** The below code accumulates 2 bytes at a time for speed.
-**
-** Written by Kiem-Phong Vo (02/28/03)
+** This is the FNV (Fowler-Noll-Vo) hash function.
+** Written by Kiem-Phong Vo (01/10/2012)
*/
#if __STD_C
uint dtstrhash(uint h, Void_t* args, ssize_t n)
#else
uint dtstrhash(h,args,n)
-reg uint h;
+uint h;
Void_t* args;
ssize_t n;
#endif
{
unsigned char *s = (unsigned char*)args;
- if(n <= 0)
- { for(; *s != 0; s += s[1] ? 2 : 1)
- h = (h + (s[0]<<8) + s[1])*DT_PRIME;
- n = s - (unsigned char*)args;
+#if _ast_sizeof_int == 8 /* 64-bit hash */
+#define FNV_PRIME ((1<<40) + (1<<8) + 0xb3)
+#define FNV_OFFSET 14695981039346656037
+#else /* 32-bit hash */
+#define FNV_PRIME ((1<<24) + (1<<8) + 0x93)
+#define FNV_OFFSET 2166136261
+#endif
+ h = (h == 0 || h == ~0) ? FNV_OFFSET : h;
+ if(n <= 0) /* see discipline key definition for == 0 */
+ { for(; *s != 0; ++s )
+ h = (h ^ s[0]) * FNV_PRIME;
}
else
{ unsigned char* ends;
- for(ends = s+n-1; s < ends; s += 2)
- h = (h + (s[0]<<8) + s[1])*DT_PRIME;
- if(s <= ends)
- h = (h + (s[0]<<8))*DT_PRIME;
+ for(ends = s+n; s < ends; ++s)
+ h = (h ^ s[0]) * FNV_PRIME;
}
- return (h+n)*DT_PRIME;
+
+ return h;
}
--- src/lib/libast/cdt/dttree.c
+++ src/lib/libast/cdt/dttree.c 2013-10-25 13:20:42.808732955 +0000
@@ -545,7 +545,14 @@ int type;
}
else goto no_root;
}
- else if(type&DT_REMOVE) /* remove a particular element in the tree */
+ else if(type&(DT_DELETE|DT_DETACH))
+ { dt_delete: /* remove an object from the dictionary */
+ obj = _DTOBJ(disc,root);
+ _dtfree(dt, root, type);
+ dt->data->size -= 1;
+ goto no_root;
+ }
+ else if(type&DT_REMOVE) /* remove a particular object */
{ if(_DTOBJ(disc,root) == obj)
goto dt_delete;
else
@@ -555,28 +562,32 @@ int type;
DTRETURN(obj, NIL(Void_t*));
}
}
- else if(type&(DT_DELETE|DT_DETACH))
- { dt_delete: /* remove an object from the dictionary */
- obj = _DTOBJ(disc,root);
- _dtfree(dt, root, type);
- dt->data->size -= 1;
- goto no_root;
- }
else if(type&(DT_INSERT|DT_APPEND|DT_ATTACH))
{ if(dt->meth->type&DT_OSET)
- { type |= DT_SEARCH; /* for announcement */
+ { type |= DT_MATCH; /* for announcement */
goto has_root;
}
- else
+ else /* if(dt->meth->type&DT_OBAG) */
{ root->_left = NIL(Dtlink_t*);
root->_rght = link._left;
link._left = root;
goto dt_insert;
}
}
+ else if(type&DT_INSTALL)
+ { /* remove old object before insert new one */
+ o = _DTOBJ(disc, root);
+ _dtfree(dt, root, DT_DELETE);
+ DTANNOUNCE(dt, o, DT_DELETE);
+ goto dt_insert;
+ }
else if(type&DT_RELINK) /* a duplicate */
{ if(dt->meth->type&DT_OSET)
+ { /* remove object */
+ o = _DTOBJ(disc, me);
_dtfree(dt, me, DT_DELETE);
+ DTANNOUNCE(dt, o, DT_DELETE);
+ }
else
{ me->_left = NIL(Dtlink_t*);
me->_rght = link._left;
@@ -612,7 +623,7 @@ int type;
{ obj = NIL(Void_t*);
goto no_root;
}
- else if(type&(DT_INSERT|DT_APPEND|DT_ATTACH))
+ else if(type&(DT_INSERT|DT_APPEND|DT_ATTACH|DT_INSTALL))
{ dt_insert:
if(!(root = _dtmake(dt, obj, type)) )
{ obj = NIL(Void_t*);
--- src/lib/libast/cdt/dtuser.c
+++ src/lib/libast/cdt/dtuser.c 2013-10-25 13:20:42.808732955 +0000
@@ -0,0 +1,59 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1985-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* Glenn Fowler <gsf@research.att.com> *
+* David Korn <dgk@research.att.com> *
+* Phong Vo <kpv@research.att.com> *
+* *
+***********************************************************************/
+#include "dthdr.h"
+
+/* Perform various functions on the user's behalf.
+**
+** Written by Kiem-Phong Vo (01/05/2012)
+*/
+
+/* managing the lock dt->data->user.lock */
+int dtuserlock(Dt_t* dt, unsigned int key, int type)
+{
+ if(key == 0)
+ return -1;
+ else if(type > 0)
+ return asolock(&dt->data->user.lock, key, ASO_LOCK);
+ else if(type < 0)
+ return asolock(&dt->data->user.lock, key, ASO_UNLOCK);
+ else return asolock(&dt->data->user.lock, key, ASO_TRYLOCK);
+}
+
+/* managing the user data slot dt->data->user.data */
+Void_t* dtuserdata(Dt_t* dt, Void_t* data, int set)
+{
+ if(set == 0) /* just return current value */
+ return asogetptr(&dt->data->user.data);
+ else while(1)
+ { Void_t *current = dt->data->user.data;
+ if(asocasptr(&dt->data->user.data, current, data) == current)
+ return current;
+ }
+}
+
+/* announcing an event on the user's behalf */
+int dtuserevent(Dt_t* dt, int flags, Void_t* data)
+{
+ if(!dt->disc->eventf)
+ return 0;
+ else return (*dt->disc->eventf)(dt, DT_ANNOUNCE|DT_USER|flags, data, dt->disc);
+}
--- src/lib/libast/include/cdt.h
+++ src/lib/libast/include/cdt.h 2013-10-25 13:20:42.809732863 +0000
@@ -164,6 +164,7 @@ struct _dtstat_s
ssize_t msize; /* max #defined elts in below arrays */
ssize_t lsize[DT_MAXSIZE]; /* #objects by level */
ssize_t tsize[DT_MAXSIZE]; /* #tables by level */
+ char mesg[256]; /* digest of top level statistics */
};
/* supported storage methods */
@@ -199,7 +200,8 @@ struct _dtstat_s
#define DT_ATLEAST 0000040000 /* find the least elt >= object */
#define DT_ATMOST 0000100000 /* find the biggest elt <= object */
#define DT_REMOVE 0002000000 /* remove a specific object */
-#define DT_TOANNOUNCE (DT_INSERT|DT_DELETE|DT_SEARCH|DT_NEXT|DT_PREV|DT_FIRST|DT_LAST|DT_MATCH|DT_ATTACH|DT_DETACH|DT_APPEND|DT_ATLEAST|DT_ATMOST|DT_REMOVE)
+#define DT_INSTALL 0004000000 /* install a new object */
+#define DT_TOANNOUNCE (DT_INSERT|DT_DELETE|DT_SEARCH|DT_NEXT|DT_PREV|DT_FIRST|DT_LAST|DT_MATCH|DT_ATTACH|DT_DETACH|DT_APPEND|DT_ATLEAST|DT_ATMOST|DT_REMOVE|DT_INSTALL)
#define DT_RELINK 0000002000 /* re-inserting (dtdisc,dtmethod...) */
#define DT_FLATTEN 0000000040 /* flatten objects into a list */
@@ -216,6 +218,7 @@ struct _dtstat_s
/* the actual event will be this bit */
/* combined with the operation bit */
#define DT_OPTIMIZE 0100000000 /* optimizing data structure */
+#define DT_USER 0200000000 /* an announcement on user's behalf */
/* events for discipline and method event-handling functions */
#define DT_OPEN 1 /* a dictionary is being opened */
@@ -277,7 +280,8 @@ extern int dtwalk _ARG_((Dt_t*, int(*)(
extern int dtcustomize _ARG_((Dt_t*, int, int));
extern unsigned int dtstrhash _ARG_((unsigned int, Void_t*, ssize_t));
extern int dtuserlock _ARG_((Dt_t*, unsigned int, int));
-extern Void_t* dtuserdata _ARG_((Dt_t*, Void_t*, unsigned int));
+extern Void_t* dtuserdata _ARG_((Dt_t*, Void_t*, int));
+extern int dtuserevent _ARG_((Dt_t*, int, Void_t*));
/* deal with upward binary compatibility (operation bit translation, etc.) */
extern Dt_t* _dtopen _ARG_((Dtdisc_t*, Dtmethod_t*, unsigned long));
@@ -334,6 +338,7 @@ _END_EXTERNS_
#define dtsearch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_SEARCH)
#define dtmatch(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_MATCH)
#define dtinsert(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSERT)
+#define dtinstall(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_INSTALL)
#define dtappend(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_APPEND)
#define dtdelete(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_DELETE)
#define dtremove(d,o) (*(_DT(d)->searchf))((d),(Void_t*)(o),DT_REMOVE)
@@ -345,7 +350,6 @@ _END_EXTERNS_
#define dtextract(d) (Dtlink_t*)(*(_DT(d)->searchf))((d),(Void_t*)(0),DT_EXTRACT)
#define dtrestore(d,l) (Dtlink_t*)(*(_DT(d)->searchf))((d),(Void_t*)(l),DT_RESTORE)
-#define dtstat(d,s) (ssize_t)(*(_DT(d)->searchf))((d),(Void_t*)(s),DT_STAT)
#define dtsize(d) (ssize_t)(*(_DT(d)->searchf))((d),(Void_t*)(0),DT_STAT)
#define DT_PRIME 17109811 /* 2#00000001 00000101 00010011 00110011 */

View File

@ -1,17 +1,6 @@
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c 2013-02-15 13:29:57.129444048 +0000
@@ -336,6 +336,8 @@ static void put_restricted(register Namv
int path_scoped = 0, fpath_scoped=0;
Pathcomp_t *pp;
char *name = nv_name(np);
+ if (!shp)
+ shp = sh_getinterp();
if(!(flags&NV_RDONLY) && sh_isoption(SH_RESTRICTED))
errormsg(SH_DICT,ERROR_exit(1),e_restricted,nv_name(np));
if(np==PATHNOD || (path_scoped=(strcmp(name,PATHNOD->nvname)==0)))
--- src/cmd/ksh93/sh/name.c
+++ src/cmd/ksh93/sh/name.c 2012-10-16 12:12:43.000000000 +0000
@@ -2162,7 +2162,7 @@ static void attstore(register Namval_t *
@@ -2264,7 +2264,7 @@ static void attstore(register Namval_t *
if((flag&(NV_UTOL|NV_LTOU|NV_INTEGER)) == (NV_UTOL|NV_LTOU))
{
data = (void*)nv_mapchar(np,0);

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
--- src/cmd/ksh93/sh/jobs.c
+++ src/cmd/ksh93/sh/jobs.c 2012-02-08 10:52:14.000000000 +0000
@@ -845,7 +845,9 @@ static void job_reset(register struct pr
{
+++ src/cmd/ksh93/sh/jobs.c 2014-02-18 14:28:42.330940622 +0000
@@ -894,7 +894,9 @@ static void job_reset(register struct pr
Shell_t *shp = pw->p_shp;
/* save the terminal state for current job */
#ifdef SIGTSTP
- job_fgrp(pw,tcgetpgrp(job.fd));
+ pid_t tgrp;
+ if((tgrp=tcgetpgrp(job.fd))!=job.mypid)
+ job_fgrp(pw,tgrp);
if(tcsetpgrp(job.fd,job.mypid) !=0)
if(sh_isoption(shp,SH_INTERACTIVE) && tcsetpgrp(job.fd,job.mypid) !=0)
return;
#endif /* SIGTSTP */

View File

@ -1,27 +1,3 @@
--- src/lib/libast/misc/optget.c
+++ src/lib/libast/misc/optget.c 2013-01-28 14:52:53.000000000 +0000
@@ -4367,9 +4367,9 @@ optget(register char** argv, const char*
*/
opt_info.assignment = 0;
- num = 1;
- w = v = 0;
- x = 0;
+ nov = no = num = 1;
+ e = w = v = 0;
+ n = x = 0;
for (;;)
{
if (!opt_info.offset)
@@ -5214,7 +5214,7 @@ optget(register char** argv, const char*
if (opt_info.num != LONG_MIN)
opt_info.num = (long)(opt_info.number = num);
- if ((n = *++s == '#') || *s == ':' || w && !nov && v && (optnumber(v, &e, NiL), n = !*e))
+ if ((n = (*++s == '#')) || *s == ':' || w && !nov && v && (optnumber(v, &e, NiL), n = !*e))
{
if (w)
{
--- src/lib/libpp/ppsearch.c
+++ src/lib/libpp/ppsearch.c 2012-03-14 11:40:11.000000000 +0000
@@ -107,6 +107,14 @@ ppmultiple(register struct ppfile* fp, r
@ -63,3 +39,39 @@
/*
* search for an include file
* if (flags&SEARCH_INCLUDE) then
--- src/lib/libcmd/ls.c
+++ src/lib/libcmd/ls.c 2014-02-20 11:11:51.762689002 +0000
@@ -1257,7 +1257,7 @@ ls(State_t* state, register FTSENT* ent)
if (!VISIBLE(state, ent))
{
fts_set(NiL, ent, FTS_SKIP);
- return;
+ return 0;
}
switch (ent->fts_info)
{
@@ -1265,12 +1265,12 @@ ls(State_t* state, register FTSENT* ent)
if (ent->fts_parent->fts_info == FTS_DNX)
break;
error(2, "%s: not found", ent->fts_path);
- return;
+ return 0;
case FTS_DC:
if (state->lsflags & LS_DIRECTORY)
break;
error(2, "%s: directory causes cycle", ent->fts_path);
- return;
+ return 0;
case FTS_DNR:
if (state->lsflags & LS_DIRECTORY)
break;
--- src/lib/libcmd/xargs.c
+++ src/lib/libcmd/xargs.c 2014-02-20 11:23:40.348375000 +0000
@@ -116,6 +116,7 @@ run(int argc, char** argv, Cmddisc_t* di
{
if (((Xargs_t*)disc)->context)
return sh_run(((Xargs_t*)disc)->context, argc, argv);
+ return(argc);
}
int

View File

@ -1,6 +1,6 @@
--- src/cmd/ksh93/sh/lex.c
+++ src/cmd/ksh93/sh/lex.c 2012-01-16 15:09:38.000000000 +0000
@@ -1893,6 +1893,8 @@ static int here_copy(Lex_t *lp,register
@@ -1916,6 +1916,8 @@ static int here_copy(Lex_t *lp,register
sfputc(sp,'\\');
}
}

View File

@ -1,19 +0,0 @@
--- src/cmd/ksh93/sh/lex.c
+++ src/cmd/ksh93/sh/lex.c 2013-02-26 12:21:11.618820739 +0100
@@ -1559,6 +1559,7 @@ static int comsub(register Lex_t *lp, in
register int line=lp->sh->inlineno;
char *first,*cp=fcseek(0),word[5];
int off, messages=0, assignok=lp->assignok, csub;
+ struct ionod *inheredoc = lp->heredoc;
struct lexstate save;
save = lp->lex;
csub = lp->comsub;
@@ -1683,7 +1684,7 @@ done:
lp->lexd.dolparen--;
lp->lex = save;
lp->assignok = (endchar(lp)==RBRACT?assignok:0);
- if(lp->heredoc)
+ if(lp->heredoc && !inheredoc)
errormsg(SH_DICT,ERROR_exit(SYNBAD),e_lexsyntax5,lp->sh->inlineno,lp->heredoc->ioname);
return(messages);
}

View File

@ -1,26 +1,26 @@
--- src/cmd/ksh93/features/math.sh
+++ src/cmd/ksh93/features/math.sh 2012-01-20 14:23:38.000000000 +0000
@@ -130,6 +130,18 @@ echo "#include <math.h>"
+++ src/cmd/ksh93/features/math.sh 2014-02-18 12:40:44.891530835 +0000
@@ -141,6 +141,18 @@ echo "#include <math.h>"
case $_hdr_ieeefp in
1) echo "#include <ieeefp.h>" ;;
esac
+cat <<!
+#if defined(__ia64__) && defined(signbit)
+# if defined __GNUC__ && __GNUC__ >= 4
+# define __signbitl(f) __builtin_signbitl(f)
+# define __signbitl(f) __builtin_signbitl(f)
+# else
+# include <ast_float.h>
+# if _lib_copysignl
+# define __signbitl(f) (int)(copysignl(1.0,(f))<0.0)
+# define __signbitl(f) (int)(copysignl(1.0,(f))<0.0)
+# endif
+# endif
+#endif
+!
echo
: generate the intercept functions and table entries
--- src/lib/libast/sfio/sfcvt.c
+++ src/lib/libast/sfio/sfcvt.c 2013-02-01 17:13:48.305452072 +0000
+++ src/lib/libast/sfio/sfcvt.c 2014-02-18 12:38:56.090667053 +0000
@@ -54,6 +54,16 @@ static char *Zero = "0";
#endif
#endif

View File

@ -1,35 +0,0 @@
--- src/cmd/ksh93/sh/jobs.c
+++ src/cmd/ksh93/sh/jobs.c 2012-12-20 13:33:28.000000000 +0000
@@ -638,12 +638,14 @@ void job_init(Shell_t *shp, int lflag)
/* This should have already been done by rlogin */
register int fd;
register char *ttynam;
+ int err = errno;
#ifndef SIGTSTP
setpgid(0,shp->gd->pid);
#endif /*SIGTSTP */
if(job.mypgid<0 || !(ttynam=ttyname(JOBTTY)))
return;
- close(JOBTTY);
+ while(close(JOBTTY)<0 && errno==EINTR)
+ errno = err;
if((fd = open(ttynam,O_RDWR)) <0)
return;
if(fd!=JOBTTY)
@@ -1110,7 +1112,7 @@ static struct process *job_bystring(regi
int job_kill(register struct process *pw,register int sig)
{
- Shell_t *shp = pw->p_shp;
+ Shell_t *shp;
register pid_t pid;
register int r;
const char *msg;
@@ -1123,6 +1125,7 @@ int job_kill(register struct process *pw
errno = ECHILD;
if(pw==0)
goto error;
+ shp = pw->p_shp;
pid = pw->p_pid;
#if SHOPT_COSHELL
if(pw->p_cojob)

View File

@ -9,23 +9,3 @@
const char* description;
int index;
const char* conf;
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c 2013-02-01 15:53:58.733952540 +0000
@@ -170,7 +170,7 @@ struct match
char *val;
char *rval[2];
regoff_t *match;
- char node[NV_MINSZ+sizeof(char*)];
+ char node[NV_MINSZ+sizeof(char*)+sizeof(Dtlink_t)];
regoff_t first;
int vsize;
int nmatch;
@@ -766,7 +766,7 @@ static int hasgetdisc(register Namfun_t
void sh_setmatch(Shell_t *shp,const char *v, int vsize, int nmatch, regoff_t match[],int index)
{
struct match *mp = &ip->SH_MATCH_init;
- Namval_t *np = nv_namptr(mp->node,0);
+ Namval_t *np = (Namval_t*)(&(mp->node[0]));
register int i,n,x, savesub=shp->subshell;
Namarr_t *ap = nv_arrayptr(SH_MATCHNOD);
shp->subshell = 0;

View File

@ -1,13 +1,6 @@
--- src/lib/libast/path/pathtemp.c
+++ src/lib/libast/path/pathtemp.c 2012-10-25 10:35:14.510345073 +0000
@@ -73,15 +73,49 @@
#include <ls.h>
#include <tv.h>
#include <tm.h>
+#include <error.h>
#define ATTEMPT 10
+++ src/lib/libast/path/pathtemp.c 2014-02-18 15:01:00.750362427 +0000
@@ -85,9 +85,42 @@
#define TMP_ENV "TMPDIR"
#define TMP_PATH_ENV "TMPPATH"
#define TMP1 "/tmp"
@ -23,7 +16,7 @@
+
+ if (!pgsz)
+ pgsz = strtoul(astconf("PAGESIZE",NiL,NiL),NiL,0);
+
+
+ if (!path || !*path)
+ {
+ errno = EFAULT;
@ -36,7 +29,7 @@
+
+ if (ret < 0)
+ goto err;
+
+
+ if (vfs.f_frsize*vfs.f_bavail < pgsz)
+ {
+ errno = ENOSPC;
@ -48,11 +41,11 @@
+ return -1;
+}
+
+#define VALID(d) (*(d)&&!xaccess(d,W_OK|X_OK))
+#define VALID(d) (*(d)&&!xaccess(d,W_OK|X_OK))
static struct
static struct Tmp_s
{
@@ -182,7 +216,7 @@ pathtemp(char* buf, size_t len, const ch
@@ -197,7 +230,7 @@ pathtemp(char* buf, size_t len, const ch
tv.tv_nsec = 0;
else
tvgettime(&tv);
@ -61,7 +54,7 @@
{
if (!tmp.vec)
{
@@ -227,7 +261,7 @@ pathtemp(char* buf, size_t len, const ch
@@ -242,7 +275,7 @@ pathtemp(char* buf, size_t len, const ch
tmp.dir = tmp.vec;
d = *tmp.dir++;
}
@ -71,7 +64,7 @@
}
if (!len)
--- src/lib/libast/sfio/sftmp.c
+++ src/lib/libast/sfio/sftmp.c 2012-10-25 12:09:18.026344912 +0000
+++ src/lib/libast/sfio/sftmp.c 2014-02-18 14:57:17.508587267 +0000
@@ -20,6 +20,14 @@
* *
***********************************************************************/

View File

@ -1,6 +1,6 @@
--- src/cmd/ksh93/sh/main.c
+++ src/cmd/ksh93/sh/main.c 2010-08-17 15:35:18.000000000 +0000
@@ -200,14 +200,38 @@ int sh_main(int ac, char *av[], Shinit_f
+++ src/cmd/ksh93/sh/main.c 2014-02-17 16:18:29.717590155 +0000
@@ -205,14 +205,38 @@ int sh_main(int ac, char *av[], Shinit_f
{
/* system profile */
sh_source(shp, iop, e_sysprofile);
@ -8,12 +8,12 @@
+ /* make sure PWD is set up correctly */
+ path_pwd(shp,1);
+#if SHOPT_SYSRC
+ if(!sh_isoption(SH_NOEXEC))
+ if(!sh_isoption(shp,SH_NOEXEC))
+ {
+ if(!sh_isoption(SH_NOUSRPROFILE) && !sh_isoption(SH_PRIVILEGED) && sh_isoption(SH_RC))
+ if(!sh_isoption(shp,SH_NOUSRPROFILE) && !sh_isoption(shp,SH_PRIVILEGED) && sh_isoption(shp,SH_RC))
+ {
+#if SHOPT_BASH
+ if(sh_isoption(SH_BASH) && !sh_isoption(SH_POSIX))
+ if(sh_isoption(shp,SH_BASH) && !sh_isoption(shp,SH_POSIX))
+ sh_source(shp, iop, e_bash_sysrc);
+ else
+#endif
@ -28,9 +28,9 @@
+ }
+ }
+#endif
+ if(sh_isoption(SH_LOGIN_SHELL) && !sh_isoption(SH_NOPROFILE))
+ if(sh_isoption(shp,SH_LOGIN_SHELL) && !sh_isoption(shp,SH_NOPROFILE))
+ {
if(!sh_isoption(SH_NOUSRPROFILE) && !sh_isoption(SH_PRIVILEGED))
if(!sh_isoption(shp,SH_NOUSRPROFILE) && !sh_isoption(shp,SH_PRIVILEGED))
{
char **files = shp->gd->login_files;
while ((name = *files++) && !sh_source(shp, iop, sh_mactry(shp,name)));
@ -38,12 +38,12 @@
}
- /* make sure PWD is set up correctly */
- path_pwd(shp,1);
if(!sh_isoption(SH_NOEXEC))
if(!sh_isoption(shp,SH_NOEXEC))
{
if(!sh_isoption(SH_NOUSRPROFILE) && !sh_isoption(SH_PRIVILEGED) && sh_isoption(SH_RC))
@@ -215,9 +239,6 @@ int sh_main(int ac, char *av[], Shinit_f
if(!sh_isoption(shp,SH_NOUSRPROFILE) && !sh_isoption(shp,SH_PRIVILEGED) && sh_isoption(shp,SH_RC))
@@ -220,9 +243,6 @@ int sh_main(int ac, char *av[], Shinit_f
#if SHOPT_BASH
if(sh_isoption(SH_BASH) && !sh_isoption(SH_POSIX))
if(sh_isoption(shp,SH_BASH) && !sh_isoption(shp,SH_POSIX))
{
-#if SHOPT_SYSRC
- sh_source(shp, iop, e_bash_sysrc);
@ -51,12 +51,12 @@
sh_source(shp, iop, shp->gd->rcfile ? shp->gd->rcfile : sh_mactry(shp,(char*)e_bash_rc));
}
else
@@ -225,10 +246,6 @@ int sh_main(int ac, char *av[], Shinit_f
@@ -230,10 +250,6 @@ int sh_main(int ac, char *av[], Shinit_f
{
if(name = sh_mactry(shp,nv_getval(ENVNOD)))
name = *name ? strdup(name) : (char*)0;
-#if SHOPT_SYSRC
- if(!strmatch(name, "?(.)/./*"))
- if(!name || !strmatch(name, "?(.)/./*"))
- sh_source(shp, iop, e_sysrc);
-#endif
if(name)

View File

@ -1,13 +0,0 @@
--- src/cmd/ksh93/sh/subshell.c
+++ src/cmd/ksh93/sh/subshell.c 2013-11-29 14:46:37.966735617 +0000
@@ -549,7 +549,9 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
#ifdef _lib_fchdir
for(xp=sp->prev; xp; xp=xp->prev)
{
- if(xp->pwdfd>0 && strcmp(xp->pwd,shp->pwd)==0)
+ if (!shp->pwd)
+ break;
+ if(xp->pwdfd>0 && xp->pwd && strcmp(xp->pwd,shp->pwd)==0)
{
sp->pwdfd = xp->pwdfd;
break;

View File

@ -1,6 +1,6 @@
--- src/cmd/ksh93/edit/edit.c
+++ src/cmd/ksh93/edit/edit.c 2013-02-01 17:18:31.405454238 +0000
@@ -1769,8 +1769,13 @@ int ed_histgen(Edit_t *ep,const char *pa
@@ -1697,8 +1697,13 @@ int ed_histgen(Edit_t *ep,const char *pa
mplast->next = mp;
mplast->next = 0;
}

View File

@ -1,8 +1,8 @@
--- src/cmd/ksh93/bltins/read.c
+++ src/cmd/ksh93/bltins/read.c 2013-02-01 15:29:39.393452098 +0000
@@ -288,6 +288,19 @@ int sh_readline(register Shell_t *shp,ch
+++ src/cmd/ksh93/bltins/read.c 2014-02-18 12:46:08.326103466 +0000
@@ -297,6 +297,20 @@ int sh_readline(register Shell_t *shp,ch
ep->e_nttyparm.c_lflag |= ISIG;
tty_set(fd,TCSADRAIN,&ep->e_nttyparm);
tty_set(sffileno(iop),TCSADRAIN,&ep->e_nttyparm);
}
+#if defined(__linux__)
+ else if ((shp->fdstatus[fd]&(IOTTY|IONOSEEK))==0)
@ -17,6 +17,7 @@
+ }
+ }
+#endif
+
}
binary = nv_isattr(np,NV_BINARY);
if(!binary && !(flags&(N_FLAG|NN_FLAG)))

View File

@ -1,283 +0,0 @@
--- src/lib/libast/include/sfio_t.h
+++ src/lib/libast/include/sfio_t.h 2013-10-11 09:22:41.000000000 +0000
@@ -34,7 +34,7 @@
#define _SFIO_PRIVATE \
Sfoff_t extent; /* current file size */ \
Sfoff_t here; /* current physical location */ \
- unsigned char unused_1;/* unused #1 */ \
+ unsigned char ngetr; /* sfgetr count */ \
unsigned char tiny[1];/* for unbuffered read stream */ \
unsigned short bits; /* private flags */ \
unsigned int mode; /* current io mode */ \
@@ -82,7 +82,7 @@
(ssize_t)(-1), /* val */ \
(Sfoff_t)0, /* extent */ \
(Sfoff_t)0, /* here */ \
- 0, /* getr */ \
+ 0, /* ngetr */ \
{0}, /* tiny */ \
0, /* bits */ \
(unsigned int)(((type)&(SF_RDWR))|SF_INIT), /* mode */ \
@@ -93,7 +93,8 @@
(mutex), /* mutex */ \
(Void_t*)0, /* stdio */ \
(Sfoff_t)0, /* lpos */ \
- (size_t)0 /* iosz */ \
+ (size_t)0, /* iosz */ \
+ 0 /* getr */ \
}
/* function to clear an Sfio_t structure */
@@ -110,7 +111,7 @@
(f)->val = (ssize_t)(-1), /* val */ \
(f)->extent = (Sfoff_t)(-1), /* extent */ \
(f)->here = (Sfoff_t)0, /* here */ \
- (f)->getr = 0, /* getr */ \
+ (f)->ngetr = 0, /* ngetr */ \
(f)->tiny[0] = 0, /* tiny */ \
(f)->bits = 0, /* bits */ \
(f)->mode = 0, /* mode */ \
@@ -121,7 +122,8 @@
(f)->mutex = (mtx), /* mutex */ \
(f)->stdio = (Void_t*)0, /* stdio */ \
(f)->lpos = (Sfoff_t)0, /* lpos */ \
- (f)->iosz = (size_t)0 /* iosz */ \
+ (f)->iosz = (size_t)0, /* iosz */ \
+ (f)->getr = 0 /* getr */ \
)
/* expose next stream inside discipline function; state saved in int f */
--- src/lib/libast/sfio/sfflsbuf.c
+++ src/lib/libast/sfio/sfflsbuf.c 2013-10-18 11:50:01.866235555 +0000
@@ -96,7 +96,7 @@ int c; /* if c>=0, c is also written out
isall = SFISALL(f,isall);
if((w = SFWR(f,data,n,f->disc)) > 0)
{ if((n -= w) > 0) /* save unwritten data, then resume */
- memcpy((char*)f->data,(char*)data+w,n);
+ memmove((char*)f->data,(char*)data+w,n);
written += w;
f->next = f->data+n;
if(c < 0 && (!isall || n == 0))
--- src/lib/libast/sfio/sfmode.c
+++ src/lib/libast/sfio/sfmode.c 2013-10-11 09:26:43.000000000 +0000
@@ -258,7 +258,7 @@ reg Sfio_t* f; /* stream to close */
#endif
{
Sfproc_t* p;
- int pid, status;
+ int status;
if(!(p = f->proc))
return -1;
@@ -279,7 +279,7 @@ reg Sfio_t* f; /* stream to close */
sigcritical(SIG_REG_EXEC|SIG_REG_PROC);
#endif
status = -1;
- while ((pid = waitpid(p->pid,&status,0)) == -1 && errno == EINTR)
+ while (waitpid(p->pid,&status,0) == -1 && errno == EINTR)
;
#if _PACKAGE_ast
status = status == -1 ?
@@ -405,12 +405,16 @@ reg int local; /* a local call */
if(f->mode&SF_GETR)
{ f->mode &= ~SF_GETR;
#ifdef MAP_TYPE
- if((f->bits&SF_MMAP) && (f->tiny[0] += 1) >= (4*SF_NMAP) )
- { /* turn off mmap to avoid page faulting */
- sfsetbuf(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND);
- f->tiny[0] = 0;
+ if(f->bits&SF_MMAP)
+ {
+ if (!++f->ngetr)
+ f->tiny[0]++;
+ if(((f->tiny[0]<<8)|f->ngetr) >= (4*SF_NMAP) )
+ { /* turn off mmap to avoid page faulting */
+ sfsetbuf(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND);
+ f->ngetr = f->tiny[0] = 0;
+ }
}
- else
#endif
if(f->getr)
{ f->next[-1] = f->getr;
--- src/lib/libast/sfio/sfmove.c
+++ src/lib/libast/sfio/sfmove.c 2013-10-18 12:04:03.194735625 +0000
@@ -113,7 +113,11 @@ reg int rc; /* record separator */
/* try reading a block of data */
direct = 0;
- if((r = fr->endb - (next = fr->next)) <= 0)
+ if(fr->rsrv && (r = -fr->rsrv->slen) > 0)
+ { fr->rsrv->slen = 0;
+ next = fr->rsrv->data;
+ }
+ else if((r = fr->endb - (next = fr->next)) <= 0)
{ /* amount of data remained to be read */
if((w = n > MAX_SSIZE ? MAX_SSIZE : (ssize_t)n) < 0)
{ if(fr->extent < 0)
--- src/lib/libast/sfio/sfpoll.c
+++ src/lib/libast/sfio/sfpoll.c 2013-10-18 11:59:50.778735232 +0000
@@ -138,7 +138,7 @@ int tm; /* time in millisecs for select
while((np = SFPOLL(fds,m,tm)) < 0 )
{ if(errno == eintr || errno == EAGAIN)
errno = 0;
- else break;
+ else goto report;
}
if(np > 0) /* poll succeeded */
np = c;
@@ -147,14 +147,14 @@ int tm; /* time in millisecs for select
{ f = fa[check[r]];
if((f->flags&SF_WRITE) && !WRREADY(f) )
- { if(fds[m].revents&POLLOUT)
+ { if(fds[m].revents&(POLLOUT|POLLHUP|POLLERR))
status[check[r]] |= SF_WRITE;
}
if((f->flags&SF_READ) && !RDREADY(f))
{ if((f->mode&SF_WRITE) && HASAUXFD(f))
m += 1;
- if(fds[m].revents&POLLIN)
+ if(fds[m].revents&(POLLIN|POLLHUP|POLLERR))
status[check[r]] |= SF_READ;
}
}
@@ -200,7 +200,7 @@ int tm; /* time in millisecs for select
while((np = select(m+1,&rd,&wr,NIL(fd_set*),tmp)) < 0 )
{ if(errno == eintr)
errno = 0;
- else break;
+ else goto report;
}
if(np > 0)
np = c;
@@ -227,6 +227,7 @@ int tm; /* time in millisecs for select
}
#endif /*_lib_select*/
+ report:
for(r = c = 0; c < n; ++c)
{ if(status[c] == 0)
continue;
--- src/lib/libast/sfio/sfpool.c
+++ src/lib/libast/sfio/sfpool.c 2013-10-18 11:49:25.614237061 +0000
@@ -138,7 +138,7 @@ int n; /* current position in pool */
else /* write failed, recover buffer then quit */
{ if(w > 0)
{ v -= w;
- memcpy(head->data,(head->data+w),v);
+ memmove(head->data,(head->data+w),v);
}
head->next = head->data+v;
goto done;
@@ -147,7 +147,7 @@ int n; /* current position in pool */
/* move data from head to f */
if((head->data+k) != f->data )
- memcpy(f->data,(head->data+k),v);
+ memmove(f->data,(head->data+k),v);
f->next = f->data+v;
}
--- src/lib/libast/sfio/sfsetbuf.c
+++ src/lib/libast/sfio/sfsetbuf.c 2013-10-18 12:02:37.534736056 +0000
@@ -190,7 +190,9 @@ size_t size; /* buffer size, -1 for defa
#ifdef MAP_TYPE
if(f->bits&SF_MMAP)
{ if(f->data)
- { SFMUNMAP(f,f->data,f->endb-f->data);
+ { if(f->getr && (f->mode&SF_GETR) && f->next)
+ f->next[-1] = f->getr;
+ SFMUNMAP(f,f->data,f->endb-f->data);
f->data = NIL(uchar*);
}
} else
@@ -204,6 +206,8 @@ size_t size; /* buffer size, -1 for defa
f->flags &= ~SF_MALLOC;
f->bits &= ~SF_MMAP;
+ f->mode &= ~SF_GETR;
+ f->getr = 0;
/* pure read/string streams must have a valid string */
if((f->flags&(SF_RDWR|SF_STRING)) == SF_RDSTR &&
@@ -254,6 +258,15 @@ size_t size; /* buffer size, -1 for defa
#endif
}
+ /* set page size, this is also the desired default buffer size */
+ if(_Sfpage <= 0)
+ {
+#if _lib_getpagesize
+ if((_Sfpage = (size_t)getpagesize()) <= 0)
+#endif
+ _Sfpage = SF_PAGE;
+ }
+
#if SFSETLINEMODE
if(init)
f->flags |= sfsetlinemode();
@@ -308,15 +325,6 @@ size_t size; /* buffer size, -1 for defa
(void)_sfpopen(f,-1,-1,1);
}
}
-
- /* set page size, this is also the desired default buffer size */
- if(_Sfpage <= 0)
- {
-#if _lib_getpagesize
- if((_Sfpage = (size_t)getpagesize()) <= 0)
-#endif
- _Sfpage = SF_PAGE;
- }
}
#ifdef MAP_TYPE
--- src/lib/libast/string/stropt.c
+++ src/lib/libast/string/stropt.c 2013-01-03 17:20:37.000000000 +0100
@@ -90,7 +90,7 @@ stropt(const char* as, const void* tab,
{
for (p = (char**)tab; t = *p; p = (char**)((char*)p + siz))
{
- for (v = s; *t && *t++ == *v; v++);
+ for (v = s; *t && *t == *v; t++, v++);
if (!*t || isspace(*v) || *v == ',' || *v == '=')
break;
if (*v == ':' && *(v + 1) == '=')
--- src/lib/libast/vmalloc/vmopen.c
+++ src/lib/libast/vmalloc/vmopen.c 2013-10-18 13:54:50.918235639 +0000
@@ -68,19 +68,22 @@ int mode; /* type of region */
Block_t *bp, *np;
Seg_t *seg;
Vmuchar_t *addr;
- int rv;
+ int rv, mt;
if(!meth || !disc || !disc->memoryf )
return NIL(Vmalloc_t*);
GETPAGESIZE(_Vmpagesize);
+ mode = (mode&VM_FLAGS) | meth->meth; /* start with user-settable flags */
+
vmp = &vmproto; /* avoid memory allocation here! */
memset(vmp, 0, sizeof(Vmalloc_t));
memcpy(&vmp->meth, meth, sizeof(Vmethod_t));
+ mt = vmp->meth.meth;
+ vmp->meth.meth = 0;
vmp->disc = disc;
- mode &= VM_FLAGS; /* start with user-settable flags */
size = 0;
if(disc->exceptf)
@@ -155,6 +158,8 @@ int mode; /* type of region */
seg->free = bp;
else vd->wild = bp;
+ vmp->meth.meth = mt;
+
done: /* now make the region handle */
if(vd->mode&VM_MEMORYF)
vm = &init->vm.vm;

View File

@ -1,5 +1,5 @@
--- src/cmd/ksh93/edit/edit.c
+++ src/cmd/ksh93/edit/edit.c 2007-12-20 17:50:28.000000000 +0000
+++ src/cmd/ksh93/edit/edit.c 2014-02-17 15:30:42.426703357 +0000
@@ -28,6 +28,7 @@
*/
@ -8,7 +8,7 @@
#include <errno.h>
#include <ccode.h>
#include "FEATURE/options"
@@ -57,8 +58,20 @@ static char KILL_LINE[20] = { ESC, '[',
@@ -57,8 +58,20 @@ static char *savelex;
#if SHOPT_MULTIBYTE
@ -32,7 +32,7 @@
# define is_cntrl(c) iscntrl(c)
# define is_print(c) isprint(c)
--- src/cmd/ksh93/edit/emacs.c
+++ src/cmd/ksh93/edit/emacs.c 2007-12-20 17:50:28.000000000 +0000
+++ src/cmd/ksh93/edit/emacs.c 2014-02-17 15:30:42.426703357 +0000
@@ -62,6 +62,7 @@ One line screen editor for any program
*/
@ -51,7 +51,7 @@
# define gencpy(a,b) ed_gencpy(a,b)
# define genncpy(a,b,n) ed_genncpy(a,b,n)
# define genlen(str) ed_genlen(str)
@@ -1563,11 +1567,19 @@ static void setcursor(register Emacs_t *
@@ -1567,11 +1571,19 @@ static void setcursor(register Emacs_t *
#if SHOPT_MULTIBYTE
static int print(register int c)
{
@ -72,7 +72,7 @@
}
#endif /* SHOPT_MULTIBYTE */
--- src/cmd/ksh93/edit/vi.c
+++ src/cmd/ksh93/edit/vi.c 2007-12-20 17:50:28.000000000 +0000
+++ src/cmd/ksh93/edit/vi.c 2014-02-17 15:30:42.426703357 +0000
@@ -28,6 +28,8 @@
* cbosgd!pds
-*/
@ -82,7 +82,7 @@
#if KSHELL
# include "defs.h"
@@ -65,10 +67,19 @@
@@ -60,10 +62,19 @@
# define gencpy(a,b) ed_gencpy(a,b)
# define genncpy(a,b,n) ed_genncpy(a,b,n)
# define genlen(str) ed_genlen(str)
@ -105,123 +105,9 @@
# endif
static int _isalph(int);
static int _ismetach(int);
--- src/cmd/ksh93/sh/io.c
+++ src/cmd/ksh93/sh/io.c 2010-06-28 14:09:09.000000000 +0000
@@ -1536,6 +1536,7 @@ static int io_heredoc(Shell_t *shp,regis
if(traceon)
sfprintf(sfstderr,"< %s\n",name);
sfputr(outfile,name,'\n');
+ off = 0;
}
else
{
--- src/cmd/ksh93/sh/macro.c
+++ src/cmd/ksh93/sh/macro.c 2013-03-19 17:16:46.062074381 +0100
@@ -54,6 +54,7 @@
#if SHOPT_MULTIBYTE
# undef isascii
# define isacii(c) ((c)<=UCHAR_MAX)
+# include <lc.h>
#else
# define mbchar(p) (*(unsigned char*)p++)
#endif /* SHOPT_MULTIBYTE */
@@ -2026,6 +2027,11 @@ static void comsubst(Mac_t *mp,register
struct _mac_ savemac;
int savtop = stktell(stkp);
char lastc=0, *savptr = stkfreeze(stkp,0);
+#if SHOPT_MULTIBYTE
+ const Lc_t *lc=lcinfo(LC_CTYPE)->lc;
+ wchar_t lastw=0;
+#endif /* SHOPT_MULTIBYTE */
+ ssize_t len;
int was_history = sh_isstate(SH_HISTORY);
int was_verbose = sh_isstate(SH_VERBOSE);
int was_interactive = sh_isstate(SH_INTERACTIVE);
@@ -2127,7 +2133,7 @@ static void comsubst(Mac_t *mp,register
num = lseek(fd, (off_t)0, SEEK_CUR);
goto out_offset;
}
- if(!(sp=mp->shp->sftable[fd]))
+ if(!(sp=mp->shp->sftable[fd]) || (sffileno(sp)!=fd &&!(sfset(sp,0,0)&SF_STRING)))
sp = sfnew(NIL(Sfio_t*),(char*)malloc(IOBSIZE+1),IOBSIZE,fd,SF_READ|SF_MALLOC);
type = 3;
}
@@ -2209,17 +2215,36 @@ static void comsubst(Mac_t *mp,register
}
else if(lastc)
{
- mac_copy(mp,&lastc,1);
+ char mb[8];
+ mb[0] = lastc;
+ len = 1;
+#if SHOPT_MULTIBYTE
+ if(lastw)
+ len = mbconv(mb, lastw);
+ lastw = 0;
+#endif /* SHOPT_MULTIBYTE */
lastc = 0;
+ mac_copy(mp,mb,len);
}
newlines = nextnewlines;
if(++c < bufsize)
str[c] = 0;
else
{
- ssize_t len = 1;
+ len = 1;
/* can't write past buffer so save last character */
+#if SHOPT_MULTIBYTE
+ if ((lc->flags & LC_utf8)==0 && (len = mbsize(str))>1)
+ {
+ len = mb2wc(lastw,str,len);
+ if (len < 0)
+ {
+ lastw = 0;
+ len = 1;
+ }
+ }
+#endif /* SHOPT_MULTIBYTE */
c -= len;
lastc = str[c];
str[c] = 0;
@@ -2240,8 +2265,16 @@ static void comsubst(Mac_t *mp,register
}
if(lastc)
{
- mac_copy(mp,&lastc,1);
+ char mb[8];
+ mb[0] = lastc;
+ len = 1;
+#if SHOPT_MULTIBYTE
+ if(lastw)
+ len = mbconv(mb, lastw);
+ lastw = 0;
+#endif /* SHOPT_MULTIBYTE */
lastc = 0;
+ mac_copy(mp,mb,len);
}
sfclose(sp);
return;
@@ -2340,13 +2373,13 @@ static void mac_copy(register Mac_t *mp,
if(mp->pattern)
{
char *sp = "&|()";
- while(c = *sp++)
+ while((c = *sp++))
{
if(state[c]==0)
state[c] = S_EPAT;
}
sp = "*?[{";
- while(c = *sp++)
+ while((c = *sp++))
{
if(state[c]==0)
state[c] = S_PAT;
--- src/cmd/ksh93/sh/string.c
+++ src/cmd/ksh93/sh/string.c 2007-12-20 17:51:07.000000000 +0000
@@ -37,7 +37,7 @@
+++ src/cmd/ksh93/sh/string.c 2014-02-17 15:30:52.534784033 +0000
@@ -36,7 +36,7 @@
#endif
#if !_lib_iswprint && !defined(iswprint)
@ -230,7 +116,7 @@
#endif
@@ -245,7 +245,7 @@ void sh_trim(register char *sp)
@@ -244,7 +244,7 @@ void sh_trim(register char *sp)
if(sp)
{
dp = sp;
@ -240,7 +126,7 @@
#if SHOPT_MULTIBYTE
int len;
--- src/cmd/ksh93/tests/sjis.sh
+++ src/cmd/ksh93/tests/sjis.sh 2011-05-20 15:11:29.000000000 +0000
+++ src/cmd/ksh93/tests/sjis.sh 2014-02-17 15:30:52.534784033 +0000
@@ -0,0 +1,77 @@
+########################################################################
+# #
@ -320,7 +206,7 @@
+fi
+exit $err
--- src/lib/libast/comp/setlocale.c
+++ src/lib/libast/comp/setlocale.c 2007-12-20 17:50:28.000000000 +0000
+++ src/lib/libast/comp/setlocale.c 2014-02-17 15:30:52.534784033 +0000
@@ -32,6 +32,7 @@
#include "lclib.h"
@ -329,29 +215,20 @@
#include <ast_wchar.h>
#include <ctype.h>
#include <mc.h>
--- src/lib/libast/comp/wc.c
+++ src/lib/libast/comp/wc.c 2007-12-20 17:50:28.000000000 +0000
@@ -26,6 +26,7 @@
*/
#include <ast.h>
+#include <ast_wchar.h>
#include <wchar.h>
#define STUB 1
--- src/lib/libast/features/wchar
+++ src/lib/libast/features/wchar 2007-12-20 17:50:28.000000000 +0000
@@ -8,7 +8,8 @@ cat{
+++ src/lib/libast/features/wchar 2014-02-17 15:39:52.471093724 +0000
@@ -8,8 +8,9 @@ cat{
#define _AST_WCHAR_H 1
}end
-lib mbstowcs,wctomb,wcrtomb,wcslen,wcstombs,wcwidth stdlib.h stdio.h wchar.h
+lib mbstowcs,wctomb,wcrtomb,wcslen,wcstombs,wcscpy,wcwidth stdlib.h stdio.h wchar.h wctype.h
-lib mbstowcs,wctomb,wcscmp,wcscoll,wcslen,wcstombs,wcsxfrm,wcwidth stdlib.h stdio.h wchar.h
+lib mbstowcs,wctomb,wcscmp,wcscoll,wcslen,wcstombs,wcsxfrm,wcscpy,wcwidth stdlib.h stdio.h wchar.h
lib mbrlen,mbrtowc,mbsrtowcs,wcrtomb,wcsrtombs stdlib.h stdio.h wchar.h
+lib iswprint,iswalpha,iswalnum,iswdigit,iswcntrl stdlib.h stdio.h ctype.h wctype.h
lib towlower,towupper stdlib.h stdio.h wchar.h
typ mbstate_t stdlib.h stdio.h wchar.h
nxt wchar
@@ -68,6 +69,12 @@ cat <<!
@@ -69,6 +70,12 @@ cat <<!
#undef putwc
#undef putwchar
#undef ungetwc
@ -364,7 +241,7 @@
#define fgetwc _ast_fgetwc
#define fgetws _ast_fgetws
@@ -118,6 +125,12 @@ cat <<!
@@ -138,6 +145,12 @@ cat <<!
#if !_lib_wcstombs
extern size_t wcstombs(char*, const wchar_t*, size_t);
#endif
@ -378,36 +255,33 @@
extern int fwprintf(FILE*, const wchar_t*, ...);
extern int fwscanf(FILE*, const wchar_t*, ...);
--- src/lib/libast/include/ast.h
+++ src/lib/libast/include/ast.h 2010-08-17 15:09:21.000000000 +0000
@@ -185,8 +185,6 @@ typedef struct
#define mbwide() (mbmax()>1)
+++ src/lib/libast/include/ast.h 2014-02-17 15:49:44.951821429 +0000
@@ -444,13 +444,21 @@ extern char** environ;
#else
#define mb2wc(w,p,n) (*ast.mb_towc)(&w,(char*)p,n)
-#define mbchar(p) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p+=ast.mb_sync+1,ast.tmp_int)):(*(unsigned char*)(p++)))
-#define mbnchar(p,n) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),n))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p+=ast.mb_sync+1,ast.tmp_int)):(*(unsigned char*)(p++)))
#define mbinit() (mbwide()?(*ast.mb_towc)((wchar_t*)0,(char*)0,mbmax()):0)
#define mbsize(p) (mbwide()?(*ast.mb_len)((char*)(p),mbmax()):((p),1))
#define mbnsize(p,n) (mbwide()?(*ast.mb_len)((char*)(p),n):((p),1))
@@ -195,6 +193,17 @@ typedef struct
#define mbxfrm(t,f,n) (mbcoll()?(*ast.mb_xfrm)((char*)(t),(char*)(f),n):0)
#define mbalpha(w) (ast.mb_alpha?(*ast.mb_alpha)(w):isalpha((w)&0xff))
#define mb2wc(w,p,n) (*ast.mb_towc)(&(w),(char*)(p),(n))
-#define mbchar(p) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p+=ast.mb_sync+1,ast.tmp_int)):(*(unsigned char*)(p++)))
-#define mbnchar(p,n) (mbwide()?((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),n))>0?((p+=ast.tmp_int),ast.tmp_wchar):(p+=ast.mb_sync+1,ast.tmp_int)):(*(unsigned char*)(p++)))
#define mbinit() (mbwide()?(*ast.mb_towc)((wchar_t*)0,(char*)0,mbmax()):0)
#define mbsize(p) (mbwide()?(*ast.mb_len)((char*)(p),mbmax()):((p),1))
#define mbnsize(p,n) (mbwide()?(*ast.mb_len)((char*)(p),n):((p),1))
#define mbconv(s,w) (ast.mb_conv?(*ast.mb_conv)(s,w):((*(s)=(w)),1))
+#define mbchar(p) (mbwide() ? \
+ (((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0) ? \
+ ({p+=ast.tmp_int;ast.tmp_wchar;}) : \
+ ({ast.tmp_int=*(unsigned char*)p;p+=ast.mb_sync+1;ast.tmp_int;})) : \
+ (*(unsigned char*)(p++)))
+#define mbnchar(p,n) (mbwide() ? \
+ (((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),n))>0) ? \
+ ({p+=ast.tmp_int;ast.tmp_wchar;}) : \
+ ({ast.tmp_int=*(unsigned char*)p;p+=ast.mb_sync+1;ast.tmp_int;})) : \
+ (*(unsigned char*)(p++)))
+
/*
* common macros
*/
+#define mbchar(p) (mbwide() ? \
+ (((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),mbmax()))>0) ? \
+ ({p+=ast.tmp_int;ast.tmp_wchar;}) : \
+ ({ast.tmp_int=*(unsigned char*)p;p+=ast.mb_sync+1;ast.tmp_int;})) : \
+ (*(unsigned char*)(p++)))
+#define mbnchar(p,n) (mbwide() ? \
+ (((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),n))>0) ? \
+ ({p+=ast.tmp_int;ast.tmp_wchar;}) : \
+ ({ast.tmp_int=*(unsigned char*)p;p+=ast.mb_sync+1;ast.tmp_int;})): \
+ (*(unsigned char*)(p++)))
#endif
/* generic plugin version support */
--- src/lib/libast/regex/reglib.h
+++ src/lib/libast/regex/reglib.h 2007-12-20 17:50:28.000000000 +0000
+++ src/lib/libast/regex/reglib.h 2014-02-17 15:30:52.538784065 +0000
@@ -57,6 +57,7 @@ typedef struct regsubop_s
char re_rhs[1]; /* substitution rhs */
@ -417,13 +291,13 @@
#include <stk.h>
--- src/lib/libcmd/Mamfile
+++ src/lib/libcmd/Mamfile 2013-02-05 15:11:03.153953100 +0000
@@ -509,7 +509,7 @@ make cat.o
+++ src/lib/libcmd/Mamfile 2014-02-17 15:42:56.236560387 +0000
@@ -592,7 +592,7 @@ make cat.o
prev cat.c
meta cat.o %.c>%.o cat.c cat
prev cat.c
-exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""libcmd"\" -DUSAGE_LICENSE=\""[-author?Glenn Fowler <gsf@research.att.com>][-author?David Korn <dgk@research.att.com>][-copyright?Copyright (c) 1992-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html][--catalog?libcmd]"\" -D_BLD_cmd -D_PACKAGE_ast -c cat.c
+exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""libcmd"\" -DUSAGE_LICENSE=\""[-author?Glenn Fowler <gsf@research.att.com>][-author?David Korn <dgk@research.att.com>][-copyright?Copyright (c) 1992-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html][--catalog?libcmd]"\" -D_BLD_cmd -D_PACKAGE_ast -DSHOPT_MULTIBYTE -c cat.c
-exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""libcmd"\" -DUSAGE_LICENSE=\""[-author?Glenn Fowler <glenn.s.fowler@gmail.com>][-author?David Korn <dgkorn@gmail.com>][-copyright?Copyright (c) 1992-2014 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html][--catalog?libcmd]"\" -D_BLD_cmd -D_PACKAGE_ast -c cat.c
+exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""libcmd"\" -DUSAGE_LICENSE=\""[-author?Glenn Fowler <glenn.s.fowler@gmail.com>][-author?David Korn <dgkorn@gmail.com>][-copyright?Copyright (c) 1992-2014 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html][--catalog?libcmd]"\" -D_BLD_cmd -D_PACKAGE_ast -DSHOPT_MULTIBYTE -c cat.c
done cat.o generated
make chgrp.o
prev chgrp.c

View File

@ -10,41 +10,3 @@
#if defined(SIGCLD) && !defined(SIGCHLD)
# define SIGCHLD SIGCLD
--- src/cmd/ksh93/sh/xec.c
+++ src/cmd/ksh93/sh/xec.c 2007-12-21 12:28:04.000000000 +0000
@@ -3834,6 +3834,7 @@ static pid_t sh_ntfork(Shell_t *shp,cons
{
signal(SIGTTIN,SIG_DFL);
signal(SIGTTOU,SIG_DFL);
+ signal(SIGTSTP,SIG_DFL);
}
#endif /* SIGTSTP */
#ifdef JOBS
@@ -3871,6 +3872,9 @@ static pid_t sh_ntfork(Shell_t *shp,cons
{
signal(SIGTTIN,SIG_IGN);
signal(SIGTTOU,SIG_IGN);
+ if(sh_isstate(SH_INTERACTIVE))
+ signal(SIGTSTP,SIG_IGN);
+ else signal(SIGTSTP,SIG_DFL);
}
#endif /* SIGTSTP */
if(spawnpid>0)
@@ -3951,6 +3955,7 @@ static pid_t sh_ntfork(Shell_t *shp,cons
{
signal(SIGTTIN,SIG_DFL);
signal(SIGTTOU,SIG_DFL);
+ signal(SIGTSTP,SIG_DFL);
jobwasset++;
}
#endif /* SIGTSTP */
@@ -4013,6 +4018,9 @@ static pid_t sh_ntfork(Shell_t *shp,cons
{
signal(SIGTTIN,SIG_IGN);
signal(SIGTTOU,SIG_IGN);
+ if(sh_isstate(SH_INTERACTIVE))
+ signal(SIGTSTP,SIG_IGN);
+ else signal(SIGTSTP,SIG_DFL);
}
#endif /* SIGTSTP */
if(sigwasset)

View File

@ -1,6 +1,6 @@
--- src/cmd/ksh93/data/msg.c
+++ src/cmd/ksh93/data/msg.c 2007-04-02 14:59:19.000000000 +0000
@@ -205,7 +205,11 @@ const char e_bash_profile[] = "$HOME/.ba
+++ src/cmd/ksh93/data/msg.c 2014-02-18 16:08:16.662492587 +0000
@@ -208,7 +208,11 @@ const char e_bash_profile[] = "$HOME/.ba
const char e_crondir[] = "/var/spool/cron";
const char e_prohibited[] = "login setuid/setgid shells prohibited";
#if SHOPT_SUID_EXEC
@ -13,7 +13,7 @@
const char hist_fname[] = "/.sh_history";
const char e_dot[] = ".";
--- src/cmd/ksh93/sh/suid_exec.c
+++ src/cmd/ksh93/sh/suid_exec.c 2012-02-03 08:36:40.000000000 +0000
+++ src/cmd/ksh93/sh/suid_exec.c 2014-02-18 16:10:34.891601497 +0000
@@ -62,10 +62,24 @@
#define FDVERIFY 12 /* used to validate /tmp process */
#undef BLKSIZE
@ -110,8 +110,8 @@
/*
* return true of shell is in <dir> directory
@@ -341,16 +373,30 @@ int eaccess(register const char *name, r
}
@@ -345,16 +377,31 @@ int eaccess(register const char *name, r
#endif
#ifdef _lib_setreuid
-static void setids(int mode,int owner,int group)
@ -120,12 +120,12 @@
+#include <grp.h>
+static void setids(int mode,uid_t owner,gid_t group)
{
- if(mode & S_ISGID)
if(mode & S_ISGID)
- setregid(rgroupid,group);
+ if(mode & S_ISGID) {
+ {
+ struct passwd *pwd;
+
+ if (setregid(rgroupid,group))
+ if (setregid(rgroupid,group) < 0)
+ error_exit(badexec);
+
+ if (((pwd = getpwuid(owner)) == (struct passwd*)0) || !(pwd->pw_name))
@ -140,7 +140,7 @@
* is not set, the value for owner that is passsed should be correct.
*/
- setreuid(ruserid,owner);
+ if (setreuid(ruserid,owner))
+ if (setreuid(ruserid,owner) < 0)
+ error_exit(badexec);
}

View File

@ -1,6 +1,6 @@
--- src/cmd/ksh93/bltins/test.c
+++ src/cmd/ksh93/bltins/test.c 2011-05-20 13:45:25.000000000 +0000
@@ -47,12 +47,12 @@
+++ src/cmd/ksh93/bltins/test.c 2014-02-17 16:21:04.138828304 +0000
@@ -48,12 +48,12 @@
#ifdef S_ISSOCK
# if _pipe_socketpair
# if _socketpair_shutdown_mode
@ -16,8 +16,8 @@
# endif
# define isasock(f,p) (test_stat(f,p)>=0&&S_ISSOCK((p)->st_mode))
#else
@@ -87,7 +87,7 @@ static int test_strmatch(Shell_t *shp,co
regoff_t match[2*(MATCH_MAX+1)],n;
@@ -88,7 +88,7 @@ static int test_strmatch(Shell_t *shp,co
int match[2*(MATCH_MAX+1)],n;
register int c, m=0;
register const char *cp=pat;
- while(c = *cp++)
@ -25,7 +25,7 @@
{
if(c=='(')
m++;
@@ -463,7 +463,7 @@ int test_unop(Shell_t *shp,register int
@@ -470,7 +470,7 @@ int test_unop(Shell_t *shp,register int
int test_binop(Shell_t *shp,register int op,const char *left,const char *right)
{

View File

@ -1,24 +1,6 @@
--- src/cmd/ksh93/bltins/typeset.c
+++ src/cmd/ksh93/bltins/typeset.c 2013-03-19 17:21:08.667413362 +0100
@@ -461,6 +461,7 @@ static void print_value(Sfio_t *iop, Nam
{
char *name;
int aflag=tp->aflag;
+ Namval_t *table;
if(nv_isnull(np))
{
if(!np->nvflag)
@@ -504,7 +505,9 @@ static void print_value(Sfio_t *iop, Nam
sfwrite(iop,"}\n",2);
return;
}
+ table = tp->sh->last_table;
sfputr(iop,nv_name(np),aflag=='+'?'\n':'=');
+ tp->sh->last_table = table;
if(aflag=='+')
return;
if(nv_isarray(np) && nv_arrayptr(np))
@@ -538,7 +541,7 @@ static int setall(char **argv,regist
+++ src/cmd/ksh93/bltins/typeset.c 2014-02-18 15:57:51.077469326 +0000
@@ -549,7 +549,7 @@ static int setall(char **argv,regist
}
else if(*shp->prefix==0)
shp->prefix = 0;
@ -27,20 +9,3 @@
nvflags |= NV_NOADD;
flag &= ~(NV_NOARRAY|NV_NOSCOPE|NV_VARNAME|NV_IDENT|NV_STATIC|NV_COMVAR|NV_IARRAY);
if(argv[1])
@@ -675,6 +678,7 @@ static int setall(char **argv,regist
{
if(comvar || (shp->last_root==shp->var_tree && (tp->tp || (!shp->st.real_fun && (nvflags&NV_STATIC)) || (!(flag&(NV_EXPORT|NV_RDONLY)) && nv_isattr(np,(NV_EXPORT|NV_IMPORT))==(NV_EXPORT|NV_IMPORT)))))
{
+ if((flag&(NV_HOST|NV_INTEGER))!=NV_HOST)
_nv_unset(np,0);
}
}
@@ -790,7 +794,7 @@ static int setall(char **argv,regist
else
{
char *oldname=0;
- int len=strlen(name);
+ size_t len=strlen(name);
if(tp->argnum==1 && newflag==NV_INTEGER && nv_isattr(np,NV_INTEGER))
tp->argnum = 10;
if(np->nvfun && !nv_isarray(np) && name[len-1]=='.')

View File

@ -1,361 +0,0 @@
--- src/cmd/builtin/pty.c
+++ src/cmd/builtin/pty.c 2013-10-25 13:30:22.019295258 +0000
@@ -503,7 +503,7 @@ masterline(Sfio_t* mp, Sfio_t* lp, char*
char* t;
ssize_t n;
ssize_t a;
- size_t promptlen;
+ size_t promptlen = 0;
ptrdiff_t d;
char promptbuf[64];
@@ -773,6 +773,8 @@ dialogue(Sfio_t* mp, Sfio_t* lp, int del
!(master->buf = vmnewof(vm, 0, char, 2 * SF_BUFSIZE, 0)))
{
error(ERROR_SYSTEM|2, "out of space");
+ id = 0;
+ line = 0;
goto done;
}
master->vm = vm;
--- src/cmd/ksh93/edit/edit.c
+++ src/cmd/ksh93/edit/edit.c 2013-10-25 13:30:22.020295166 +0000
@@ -1414,12 +1414,12 @@ int ed_internal(const char *src, genchar
int ed_external(const genchar *src, char *dest)
{
register genchar wc;
- register int c,size;
register char *dp = dest;
char *dpmax = dp+sizeof(genchar)*MAXLINE-2;
if((char*)src == dp)
{
- char buffer[MAXLINE*sizeof(genchar)];
+ int c;
+ char buffer[MAXLINE*sizeof(genchar)] = "";
c = ed_external(src,buffer);
#ifdef _lib_wcscpy
@@ -1431,6 +1431,7 @@ int ed_external(const genchar *src, char
}
while((wc = *src++) && dp<dpmax)
{
+ ssize_t size;
if((size = mbconv(dp, wc)) < 0)
{
/* copy the character as is */
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c 2013-10-25 13:30:22.020295166 +0000
@@ -1264,7 +1264,7 @@ Shell_t *sh_init(register int argc,regis
static int beenhere;
Shell_t *shp;
register int n;
- int type;
+ int type = 0;
static char *login_files[3];
memfatal();
n = strlen(e_version);
@@ -1943,7 +1943,7 @@ static Dt_t *inittree(Shell_t *shp,const
register const struct shtable2 *tp;
register unsigned n = 0;
register Dt_t *treep;
- Dt_t *base_treep, *dict;
+ Dt_t *base_treep, *dict = 0;
for(tp=name_vals;*tp->sh_name;tp++)
n++;
np = (Namval_t*)calloc(n,sizeof(Namval_t));
--- src/cmd/ksh93/sh/macro.c
+++ src/cmd/ksh93/sh/macro.c 2013-10-25 13:30:22.021295073 +0000
@@ -1794,7 +1794,7 @@ retry2:
register int d = (mode=='@'?' ':mp->ifs);
regoff_t match[2*(MATCH_MAX+1)];
int nmatch, nmatch_prev, vsize_last;
- char *vlast;
+ char *vlast=NULL;
while(1)
{
if(!v)
--- src/cmd/ksh93/sh/name.c
+++ src/cmd/ksh93/sh/name.c 2013-10-25 13:30:22.022294981 +0000
@@ -1344,7 +1344,7 @@ Namval_t *nv_open(const char *name, Dt_t
const char *msg = e_varname;
char *fname = 0;
int offset = staktell();
- Dt_t *funroot;
+ Dt_t *funroot = NIL(Dt_t*);
#if NVCACHE
struct Cache_entry *xp;
#endif
@@ -1820,7 +1820,7 @@ void nv_putval(register Namval_t *np, co
else
{
const char *tofree=0;
- int offset,append;
+ int offset=0,append;
#if _lib_pathnative
char buff[PATH_MAX];
#endif /* _lib_pathnative */
--- src/cmd/ksh93/sh/nvdisc.c
+++ src/cmd/ksh93/sh/nvdisc.c 2013-10-25 13:30:22.022294981 +0000
@@ -449,7 +449,7 @@ static Sfdouble_t lookupn(Namval_t *np,
char *nv_setdisc(register Namval_t* np,register const char *event,Namval_t *action,register Namfun_t *fp)
{
register struct vardisc *vp = (struct vardisc*)np->nvfun;
- register int type;
+ register int type = -1;
char *empty = "";
while(vp)
{
@@ -505,6 +505,8 @@ char *nv_setdisc(register Namval_t* np,r
}
return(NIL(char*));
}
+ if (type < 0)
+ return(NIL(char*));
/* Handle GET/SET/APPEND/UNSET disc */
if(vp && vp->fun.disc->putval!=assign)
vp = 0;
--- src/cmd/ksh93/sh/nvtree.c
+++ src/cmd/ksh93/sh/nvtree.c 2013-10-25 13:30:22.023294889 +0000
@@ -583,7 +583,7 @@ void nv_outnode(Namval_t *np, Sfio_t* ou
char *fmtq,*ep,*xp;
Namval_t *mp;
Namarr_t *ap = nv_arrayptr(np);
- int scan,tabs=0,c,more,associative = 0;
+ int scan=0,tabs=0,c,more,associative = 0;
int saveI = Indent;
Indent = indent;
if(ap)
@@ -696,7 +696,7 @@ void nv_outnode(Namval_t *np, Sfio_t* ou
static void outval(char *name, const char *vname, struct Walk *wp)
{
- register Namval_t *np, *nq, *last_table=wp->shp->last_table;
+ register Namval_t *np, *nq=0, *last_table=wp->shp->last_table;
register Namfun_t *fp;
int isarray=0, special=0,mode=0;
if(*name!='.' || vname[strlen(vname)-1]==']')
--- src/cmd/ksh93/sh/nvtype.c
+++ src/cmd/ksh93/sh/nvtype.c 2013-10-25 13:30:22.023294889 +0000
@@ -854,9 +854,10 @@ void nv_newtype(Namval_t *mp)
Namval_t *nv_mktype(Namval_t **nodes, int numnodes)
{
Namval_t *mp=nodes[0], *bp=0, *np, *nq, **mnodes=nodes;
- int i,j,k,m,n,nd=0,nref=0,iref=0,inherit=0;
+ int i,j,k,nd=0,nref=0,iref=0,inherit=0;
int size=sizeof(NV_DATA), dsize=0, nnodes;
- size_t offset=0;
+ size_t offset=0,m;
+ ssize_t n;
char *name=0, *cp, *sp, **help;
Namtype_t *pp,*qp=0,*dp,*tp;
Dt_t *root = nv_dict(mp);
@@ -869,6 +870,7 @@ Namval_t *nv_mktype(Namval_t **nodes, in
_nv_unset(nodes[0],NV_RDONLY);
errormsg(SH_DICT,ERROR_exit(1),e_badtypedef,cp);
}
+ n=strlen(nodes[1]->nvname);
for(nnodes=1,i=1; i <numnodes; i++)
{
np=nodes[i];
@@ -1100,7 +1102,6 @@ Namval_t *nv_mktype(Namval_t **nodes, in
nv_disc(nq, &pp->childfun.fun, NV_LAST);
if(tp = (Namtype_t*)nv_hasdisc(nq, &type_disc))
tp->strsize = -tp->strsize;
-else sfprintf(sfstderr,"tp==NULL\n");
for(r=0; r < dp->numnodes; r++)
{
Namval_t *nr = nv_namptr(dp->nodes,r);
--- src/cmd/ksh93/sh/parse.c
+++ src/cmd/ksh93/sh/parse.c 2013-10-25 13:30:22.024294796 +0000
@@ -301,7 +301,7 @@ static Shnode_t *getanode(Lex_t *lp, str
*/
static Shnode_t *makelist(Lex_t *lexp, int type, Shnode_t *l, Shnode_t *r)
{
- register Shnode_t *t;
+ register Shnode_t *t = NIL(Shnode_t*);
if(!l || !r)
sh_syntax(lexp);
else
@@ -742,7 +742,7 @@ static Shnode_t *funct(Lex_t *lexp)
register Shnode_t *t;
register int flag;
struct slnod *volatile slp=0;
- Stak_t *savstak;
+ Stak_t *savstak = NIL(Stak_t*);
Sfoff_t first, last;
struct functnod *volatile fp;
Sfio_t *iop;
@@ -815,7 +815,7 @@ static Shnode_t *funct(Lex_t *lexp)
{
struct comnod *ac;
char *cp, **argv, **argv0;
- int c;
+ int c=-1;
t->funct.functargs = ac = (struct comnod*)simple(lexp,SH_NOIO|SH_FUNDEF,NIL(struct ionod*));
if(ac->comset || (ac->comtyp&COMSCAN))
errormsg(SH_DICT,ERROR_exit(3),e_lexsyntax4,lexp->sh->inlineno);
--- src/cmd/ksh93/sh/xec.c
+++ src/cmd/ksh93/sh/xec.c 2013-10-25 13:30:22.025294704 +0000
@@ -1507,7 +1507,7 @@ int sh_exec(register const Shnode_t *t,
Namval_t node;
#endif /* SHOPT_NAMESPACE */
struct Namref nr;
- long mode;
+ long mode = 0;
register struct slnod *slp;
if(!np->nvalue.ip)
{
@@ -1916,8 +1916,8 @@ int sh_exec(register const Shnode_t *t,
* don't create a new process, just
* save and restore io-streams
*/
- pid_t pid;
- int jmpval, waitall;
+ pid_t pid = 0;
+ int jmpval, waitall = 0;
int simple = (t->fork.forktre->tre.tretyp&COMMSK)==TCOM;
struct checkpt *buffp = (struct checkpt*)stkalloc(shp->stk,sizeof(struct checkpt));
#if SHOPT_COSHELL
@@ -2409,7 +2409,7 @@ int sh_exec(register const Shnode_t *t,
Shnode_t *tt = t->wh.whtre;
#if SHOPT_FILESCAN
Sfio_t *iop=0;
- int savein;
+ int savein=-1;
#endif /*SHOPT_FILESCAN*/
#if SHOPT_OPTIMIZE
int jmpval = ((struct checkpt*)shp->jmplist)->mode;
@@ -2877,7 +2877,7 @@ int sh_exec(register const Shnode_t *t,
else
{
register int traceon=0;
- register char *right;
+ register char *right = 0;
register char *trap;
char *argv[6];
n = type>>TSHIFT;
@@ -2911,7 +2911,7 @@ int sh_exec(register const Shnode_t *t,
}
else if(type&TBINARY)
{
- char *op;
+ char *op = 0;
int pattern = 0;
if(trap || traceon)
op = (char*)(shtab_testops+(n&037)-1)->sh_name;
@@ -3376,7 +3376,7 @@ int sh_funscope(int argn, char *argv[],i
int jmpval;
volatile int r = 0;
int n;
- char *savstak;
+ char *savstak = 0;
struct funenv *fp = 0;
struct checkpt *buffp = (struct checkpt*)stkalloc(shp->stk,sizeof(struct checkpt));
Namval_t *nspace = shp->namespace;
@@ -3492,10 +3492,10 @@ int sh_funscope(int argn, char *argv[],i
shp->st = *prevscope;
shp->topscope = (Shscope_t*)prevscope;
nv_getval(sh_scoped(shp,IFSNOD));
- if(nsig)
+ if(nsig && savstak)
memcpy((char*)&shp->st.trapcom[0],savstak,nsig);
shp->trapnote=0;
- if(nsig)
+ if(nsig && savstak)
stakset(savstak,0);
shp->options = options;
shp->last_root = last_root;
@@ -3584,11 +3584,11 @@ static void sh_funct(Shell_t *shp,Namval
int sh_fun(Namval_t *np, Namval_t *nq, char *argv[])
{
Shell_t *shp = sh_getinterp();
- register int offset;
+ register int offset = 0;
register char *base;
Namval_t node;
struct Namref nr;
- long mode;
+ long mode = 0;
char *prefix = shp->prefix;
int n=0;
char *av[3];
--- src/lib/libast/sfio/sfstrtof.h
+++ src/lib/libast/sfio/sfstrtof.h 2013-10-25 13:30:22.025294704 +0000
@@ -211,8 +211,8 @@ S2F_function(str, end) char* str; char**
int decimal = 0;
int thousand = 0;
int part = 0;
- int back_part;
- S2F_batch back_n;
+ int back_part = 0;
+ S2F_batch back_n = 0;
S2F_number v;
S2F_number p;
S2F_part_t parts[16];
--- src/lib/libast/sfio/sftable.c
+++ src/lib/libast/sfio/sftable.c 2013-10-25 13:30:22.026294612 +0000
@@ -53,7 +53,7 @@ int type; /* >0: scanf, =0: printf, -1:
#endif
{
int base, fmt, flags, dot, width, precis;
- ssize_t n_str, size;
+ ssize_t n_str, size = 0;
char *t_str, *sp;
int v, n, skip, dollar, decimal, thousand;
Sffmt_t savft;
--- src/lib/libast/sfio/sfvprintf.c
+++ src/lib/libast/sfio/sfvprintf.c 2013-10-25 13:30:22.026294612 +0000
@@ -101,7 +101,7 @@ char* form; /* format to use */
va_list args; /* arg list if !argf */
#endif
{
- int n, v, w, k, n_s, base, fmt, flags;
+ int n, v=0, w, k, n_s, base, fmt, flags;
Sflong_t lv;
char *sp, *ssp, *endsp, *ep, *endep;
int dot, width, precis, sign, decpt;
@@ -129,7 +129,7 @@ va_list args; /* arg list if !argf */
int decimal = 0, thousand = 0;
#if _has_multibyte
- wchar_t* wsp;
+ wchar_t* wsp = 0;
SFMBDCL(fmbs) /* state of format string */
SFMBDCL(mbs) /* state of some string */
#ifdef mbwidth
--- src/lib/libast/string/stropt.c
+++ src/lib/libast/string/stropt.c 2013-10-25 13:30:22.033293966 +0000
@@ -60,13 +60,13 @@ stropt(const char* as, const void* tab,
register char* v;
register char* t;
char** p;
- char* u;
+ char* u = 0;
char* x;
char* e;
int n;
int ql;
int qr;
- int qc;
+ int qc = 0;
if (!as) n = 0;
else if (!(x = s = strdup(as))) n = -1;
--- src/lib/libast/string/strtoi.h
+++ src/lib/libast/string/strtoi.h 2013-10-25 13:30:22.027294520 +0000
@@ -230,13 +230,13 @@ S2I_function(a, e, base) const char* a;
#endif
register S2I_unumber n;
register S2I_unumber x;
- register int c;
+ register int c = 0;
register int shift;
register unsigned char* p;
register unsigned char* cv;
unsigned char* b;
unsigned char* k;
- S2I_unumber v;
+ S2I_unumber v = 0;
#if S2I_multiplier
register int base;
#endif

View File

@ -1,6 +1,6 @@
--- src/cmd/ksh93/sh/xec.c
+++ src/cmd/ksh93/sh/xec.c 2011-07-04 15:42:21.000000000 +0000
@@ -3387,7 +3387,8 @@ int sh_funscope(int argn, char *argv[],i
@@ -4041,7 +4041,8 @@ int sh_funscope_20120720(int argn, char *argv[],i
shp->st.var_local = shp->var_tree;
if(!fun)
{

View File

@ -1,6 +1,6 @@
--- src/cmd/ksh93/edit/vi.c
+++ src/cmd/ksh93/edit/vi.c 2007-03-28 16:41:47.000000000 +0000
@@ -401,6 +401,8 @@ int ed_viread(void *context, int fd, reg
+++ src/cmd/ksh93/edit/vi.c 2014-02-17 15:53:10.873464619 +0000
@@ -396,6 +396,8 @@ int ed_viread(void *context, int fd, reg
if(!yankbuf)
yankbuf = (genchar*)malloc(MAXLINE*CHARSIZE);
@ -9,7 +9,7 @@
if( vp->last_cmd == '\0' )
{
/*** first time for this shell ***/
@@ -410,6 +412,8 @@ int ed_viread(void *context, int fd, reg
@@ -405,6 +407,8 @@ int ed_viread(void *context, int fd, reg
vp->lastmotion = '\0';
vp->lastrepeat = 1;
vp->repeat = 1;
@ -18,7 +18,7 @@
*yankbuf = 0;
}
@@ -1137,7 +1141,7 @@ static void cdelete(Vi_t *vp,register in
@@ -1132,7 +1136,7 @@ static void cdelete(Vi_t *vp,register in
/*** save characters to be deleted ***/
@ -27,7 +27,7 @@
{
i = cp[nchars];
cp[nchars] = 0;
@@ -2169,6 +2173,9 @@ static void save_last(register Vi_t* vp)
@@ -2165,6 +2169,9 @@ static void save_last(register Vi_t* vp)
{
register int i;
@ -37,7 +37,7 @@
if( (i = cur_virt - first_virt + 1) > 0 )
{
/*** save last thing user typed ***/
@@ -2417,6 +2424,11 @@ static int textmod(register Vi_t *vp,reg
@@ -2414,6 +2421,11 @@ static int textmod(register Vi_t *vp,reg
p = yankbuf;
}
@ -49,7 +49,7 @@
addin:
switch( c )
{
@@ -2687,6 +2699,8 @@ yankeol:
@@ -2686,6 +2698,8 @@ yankeol:
vp->lastmotion = c;
if( c == 'y' )
{

View File

@ -1,29 +1,30 @@
--- src/lib/libast/vmalloc/vmhdr.h
+++ src/lib/libast/vmalloc/vmhdr.h 2012-01-19 09:45:14.000000000 +0000
@@ -152,6 +152,9 @@ extern void _vmmessage _ARG_((const cha
#endif /*DEBUG*/
--- src/lib/libast/vmalloc/vmmaddress.c
+++ src/lib/libast/vmalloc/vmmaddress.c 2014-02-18 14:19:22.978507488 +0000
@@ -37,6 +37,10 @@
#endif /*MAP_ANON*/
#endif /*_mem_mmap_anon*/
#define VMPAGESIZE 8192
+#if defined(__linux__) && !defined(_lib_getpagesize)
+#define _lib_getpagesize 1
+#endif
#if _lib_getpagesize
#define GETPAGESIZE(x) ((x) ? (x) : ((x)=getpagesize()) )
#else
--- src/lib/libast/vmalloc/vmmopen.c
+++ src/lib/libast/vmalloc/vmmopen.c 2012-01-20 11:13:12.000000000 +0000
@@ -63,8 +63,10 @@ void _STUB_vmmapopen(){}
+
/* Heuristic to suggest an address usable for mapping shared memory
**
** Written by Kiem-Phong Vo, phongvo@gmail.com, 07/07/2012
--- src/lib/libast/vmalloc/vmdcshare.c
+++ src/lib/libast/vmalloc/vmdcshare.c 2014-04-14 16:28:26.406992119 +0200
@@ -53,8 +53,10 @@
/* magic word signaling file/segment is ready */
#define MM_MAGIC ((unsigned int)(('P'<<24) | ('&'<<16) | ('N'<<8) | ('8')) )
#define MM_MAGIC ((unsigned int)(('P'<<24) | ('&'<<16) | ('N'<<8) | ('8')) ) /* 1344687672 */
+#ifndef __linux__
/* default mimimum region size */
#define MM_MINSIZE (64*_Vmpagesize)
+#endif
/* macros to get the data section and size */
#define MMHEAD(file) ROUND(sizeof(Mmvm_t)+strlen(file), ALIGN)
@@ -166,10 +168,18 @@ static int mminit(Mmdisc_t* mmdc)
/* flags for actions on region closing */
#define MM_DETACH 01 /* detach all attached memory */
@@ -174,10 +176,19 @@
if(mmdc->mmvm) /* already done this */
return 0;
@ -33,13 +34,14 @@
if((size = mmdc->size) < MM_MINSIZE )
size = MM_MINSIZE;
+#else
+ if (sizeof(void*) > 32)
+ extent = ROUND(0x80000,_Vmpagesize);
+ else
+ extent = ROUND(0x40000,_Vmpagesize);
+# if __WORDSIZE == 64
+ extent = 4*1024*1024*sizeof(long);
+# else
+ extent = 512*1024;
+# endif
+ if((size = mmdc->size) < extent)
+ size = extent;
+#endif
size += MMHEAD(mmdc->file) + ALIGN;
size += MMHEAD(mmdc->name) + ALIGN;
size = ROUND(size, _Vmpagesize);

224
ksh93.dif
View File

@ -1,19 +1,18 @@
--- src/cmd/ksh93/bltins/print.c
+++ src/cmd/ksh93/bltins/print.c 2008-05-05 11:20:21.000000000 +0000
@@ -105,7 +105,11 @@ static char* nullarg[] = { 0, 0 };
{
+++ src/cmd/ksh93/bltins/print.c 2014-02-17 14:55:59.193998326 +0000
@@ -104,7 +104,11 @@ int B_echo(int argc, char *argv[],Shb
{
static char bsd_univ;
struct print prdata;
- prdata.options = sh_optecho+5;
+# if defined(__linux__)
+ prdata.options = sh_optecho;
+# else
+ prdata.options = sh_optecho + 5;
prdata.options = sh_optecho+5;
+# endif
prdata.raw = prdata.echon = 0;
prdata.sh = context->shp;
NOT_USED(argc);
@@ -118,7 +122,52 @@ static char* nullarg[] = { 0, 0 };
@@ -117,7 +121,52 @@ int B_echo(int argc, char *argv[],Shb
prdata.sh->universe = 1;
}
if(!bsd_univ)
@ -67,8 +66,8 @@
prdata.raw = 1;
while(argv[1] && *argv[1]=='-')
--- src/cmd/ksh93/data/msg.c
+++ src/cmd/ksh93/data/msg.c 2007-12-20 18:01:26.000000000 +0000
@@ -202,7 +202,7 @@ const char e_bash_login[] = "$HOME/.bash
+++ src/cmd/ksh93/data/msg.c 2014-02-17 14:53:59.613033047 +0000
@@ -205,7 +205,7 @@ const char e_bash_login[] = "$HOME/.bash
const char e_bash_logout[] = "$HOME/.bash_logout";
const char e_bash_profile[] = "$HOME/.bash_profile";
#endif
@ -78,7 +77,7 @@
#if SHOPT_SUID_EXEC
const char e_suidexec[] = "/etc/suid_exec";
--- src/cmd/ksh93/data/variables.c
+++ src/cmd/ksh93/data/variables.c 2008-09-18 17:22:24.000000000 +0000
+++ src/cmd/ksh93/data/variables.c 2014-02-17 14:53:59.613033047 +0000
@@ -69,7 +69,7 @@ const struct shtable2 shtab_variables[]
"OPTARG", 0, (char*)0,
"OPTIND", NV_NOFREE|NV_INTEGER, (char*)0,
@ -89,7 +88,7 @@
"LC_ALL", 0, (char*)0,
"LC_COLLATE", 0, (char*)0,
--- src/cmd/ksh93/features/options
+++ src/cmd/ksh93/features/options 2007-12-20 18:01:26.000000000 +0000
+++ src/cmd/ksh93/features/options 2014-02-17 14:53:59.613033047 +0000
@@ -36,7 +36,7 @@ tst cross{
option TEST_L $?
test -f /etc/ksh.kshrc -o -f /etc/bash.bashrc &&
@ -99,20 +98,9 @@
option UCB $?
}end
--- src/cmd/ksh93/sh.1
+++ src/cmd/ksh93/sh.1 2008-09-22 12:11:56.000000000 +0000
@@ -200,7 +200,7 @@ separated by
.BR \(bv .
The standard output of each command but the last
is connected by a
-.IR pipe (2)
+.IR socketpair (2)
to the standard input of the next command.
Each command,
except possibly the last,
--- src/cmd/ksh93/sh/main.c
+++ src/cmd/ksh93/sh/main.c 2007-12-20 18:01:26.000000000 +0000
@@ -113,9 +113,9 @@ int sh_source(Shell_t *shp, Sfio_t *iop,
+++ src/cmd/ksh93/sh/main.c 2014-02-17 14:59:07.103514563 +0000
@@ -113,9 +113,9 @@ bool sh_source(Shell_t *shp, Sfio_t *iop
}
#ifdef S_ISSOCK
@ -124,18 +112,18 @@
#endif
int sh_main(int ac, char *av[], Shinit_f userinit)
@@ -179,7 +179,7 @@ int sh_main(int ac, char *av[], Shinit_f
@@ -184,7 +184,7 @@ int sh_main(int ac, char *av[], Shinit_f
}
if(!sh_isoption(SH_RC) && (sh_isoption(SH_BASH) && !sh_isoption(SH_POSIX)
if(!sh_isoption(shp,SH_RC) && (sh_isoption(shp,SH_BASH) && !sh_isoption(shp,SH_POSIX)
#if SHOPT_REMOTE
- || !fstat(0, &statb) && REMOTE(statb.st_mode)
+ || !fstat(0, &statb) && REMOTE(statb)
#endif
))
sh_onoption(SH_RC);
sh_onoption(shp,SH_RC);
--- src/cmd/ksh93/sh/xec.c
+++ src/cmd/ksh93/sh/xec.c 2012-01-26 12:07:46.000000000 +0000
@@ -1015,7 +1015,7 @@ int sh_exec(register const Shnode_t *t,
+++ src/cmd/ksh93/sh/xec.c 2014-02-17 15:00:46.556316756 +0000
@@ -978,7 +978,7 @@ int sh_exec(register Shell_t *shp,regist
{
case TCOM:
{
@ -144,17 +132,17 @@
char *trap;
Namval_t *np, *nq, *last_table;
struct ionod *io;
@@ -1131,7 +1131,7 @@ int sh_exec(register const Shnode_t *t,
comn = com[argn-1];
@@ -1097,7 +1097,7 @@ int sh_exec(register Shell_t *shp,regist
}
io = t->tre.treio;
tryagain:
- if(shp->envlist = argp = t->com.comset)
+ if((shp->envlist = argp = t->com.comset))
{
if(argn==0 || (np && nv_isattr(np,(BLT_DCL|BLT_SPC))))
if(argn==0 || (np && (nv_isattr(np,BLT_DCL)||(!command && nv_isattr(np,BLT_SPC)))))
{
--- src/cmd/ksh93/tests/attributes.sh
+++ src/cmd/ksh93/tests/attributes.sh 2009-07-09 13:14:05.000000000 +0000
+++ src/cmd/ksh93/tests/attributes.sh 2014-02-17 14:53:59.617033080 +0000
@@ -199,7 +199,7 @@ hello worldhello worldhello world
[[ $v1 == "$b1" ]] || err_exit "v1=$v1 should be $b1"
[[ $v2 == "$x" ]] || err_exit "v1=$v2 should be $x"
@ -165,7 +153,7 @@
unset var
typeset -b var
--- src/cmd/ksh93/tests/bracket.sh
+++ src/cmd/ksh93/tests/bracket.sh 2012-02-09 14:11:32.000000000 +0000
+++ src/cmd/ksh93/tests/bracket.sh 2014-02-17 14:53:59.617033080 +0000
@@ -221,6 +221,10 @@ done
[[ abcdcdabcde == {5}(ab|cd)e ]] || err_exit 'abcdcdabcd == {5}(ab|cd)e'
) || err_exit 'errors with {..}(...) patterns'
@ -186,7 +174,7 @@
then [[ -L "$file" ]] || err_exit '-L not working'
[[ -L "$file"/ ]] && err_exit '-L with file/ not working'
--- src/cmd/ksh93/tests/builtins.sh
+++ src/cmd/ksh93/tests/builtins.sh 2009-07-09 13:14:50.000000000 +0000
+++ src/cmd/ksh93/tests/builtins.sh 2014-02-17 14:53:59.617033080 +0000
@@ -344,7 +344,7 @@ wait $pid1
(( $? == 1 )) || err_exit "wait not saving exit value"
wait $pid2
@ -197,7 +185,7 @@
for v in ${v//,/ }
do v=${v#*:}
--- src/cmd/ksh93/tests/coprocess.sh
+++ src/cmd/ksh93/tests/coprocess.sh 2013-02-01 15:22:31.000000000 +0000
+++ src/cmd/ksh93/tests/coprocess.sh 2014-02-17 14:53:59.617033080 +0000
@@ -113,15 +113,15 @@ do
cop=$!
exp=Done
@ -278,7 +266,7 @@
$cat |&
pid=$!
--- src/cmd/ksh93/tests/locale.sh
+++ src/cmd/ksh93/tests/locale.sh 2011-05-24 14:46:02.000000000 +0000
+++ src/cmd/ksh93/tests/locale.sh 2014-02-17 15:02:01.480920975 +0000
@@ -62,7 +62,7 @@ done
# this locale is supported by ast on all platforms
# EU for { decimal_point="," thousands_sep="." }
@ -318,8 +306,8 @@
fi
")
got=$*
@@ -336,7 +336,7 @@ then LC_ALL=en_US.UTF-8
[[ $(print -r -- "$x") == $'hello\u[20ac]\xee world' ]] || err_exit '%q with unicode and non-unicode not working'
@@ -342,7 +342,7 @@ then LC_ALL=en_US.UTF-8
LC_ALL=C.UTF-8 eval $'[[ $(print -r -- "$x") == $\'hello\\u[20ac]\\xee world\' ]]' || err_exit '%q with unicode and non-unicode not working'
if [[ $(whence od) ]]
then got='68 65 6c 6c 6f e2 82 ac ee 20 77 6f 72 6c 64 0a'
- [[ $(print -r -- "$x" | od -An -tx1) == "$got" ]] || err_exit "incorrect string from printf %q"
@ -328,7 +316,7 @@
fi
--- src/cmd/ksh93/tests/options.sh
+++ src/cmd/ksh93/tests/options.sh 2012-01-16 16:50:59.000000000 +0000
+++ src/cmd/ksh93/tests/options.sh 2014-02-17 14:53:59.617033080 +0000
@@ -510,7 +510,7 @@ z=$($SHELL 2>&1 -uc 'print ${X2345678901
[[ $z == *X23456789012345:* ]] || err_exit "error message garbled with set -u got $z"
@ -339,7 +327,7 @@
set -o pipefail
(sleep $toolong;kill \$\$> /dev/null) &
--- src/cmd/ksh93/tests/path.sh
+++ src/cmd/ksh93/tests/path.sh 2008-09-11 16:02:46.000000000 +0000
+++ src/cmd/ksh93/tests/path.sh 2014-02-17 14:53:59.621033112 +0000
@@ -269,7 +269,7 @@ builtin getconf
getconf UNIVERSE - att # override sticky default 'UNIVERSE = foo'
@ -350,7 +338,7 @@
PATH=$path
--- src/cmd/ksh93/tests/pty.sh
+++ src/cmd/ksh93/tests/pty.sh 2012-03-15 11:51:40.000000000 +0000
+++ src/cmd/ksh93/tests/pty.sh 2014-02-17 14:53:59.621033112 +0000
@@ -428,15 +428,16 @@ r echo repeat-3
# err_exit #
@ -371,7 +359,7 @@
exit $((Errors<125?Errors:125))
--- src/cmd/ksh93/tests/signal.sh
+++ src/cmd/ksh93/tests/signal.sh 2011-05-20 13:25:48.000000000 +0000
+++ src/cmd/ksh93/tests/signal.sh 2014-02-17 14:53:59.621033112 +0000
@@ -285,10 +285,10 @@ then for exp in TERM VTALRM PIPE
$SHELL <<- EOF
foo() { return 0; }
@ -385,19 +373,30 @@
done > /dev/null
EOF
} 2>> /dev/null
--- src/cmd/ksh93/sh.1
+++ src/cmd/ksh93/sh.1 2014-02-17 14:53:59.613033047 +0000
@@ -200,7 +200,7 @@ separated by
.BR \(bv .
The standard output of each command but the last
is connected by a
-.IR pipe (2)
+.IR socketpair (2)
to the standard input of the next command.
Each command,
except possibly the last,
--- src/lib/libast/disc/memfatal.c
+++ src/lib/libast/disc/memfatal.c 2009-07-09 13:30:39.000000000 +0000
@@ -74,7 +74,7 @@ memfatal(void)
+++ src/lib/libast/disc/memfatal.c 2014-02-17 15:03:10.461477163 +0000
@@ -86,7 +86,7 @@ memfatal_20130509(Vmdisc_t* disc)
{
Vmdisc_t* disc;
- malloc(0);
+ void * ptr = malloc(0);
if (disc = vmdisc(Vmregion, NiL))
disc->exceptf = nomalloc;
}
if (!disc)
{
- malloc(0);
+ void * ptr = malloc(0);
if (!(disc = vmdisc(Vmregion, NiL)))
return -1;
}
--- src/lib/libast/features/align.c
+++ src/lib/libast/features/align.c 2007-12-20 18:01:26.000000000 +0000
+++ src/lib/libast/features/align.c 2014-02-17 14:53:59.621033112 +0000
@@ -32,6 +32,7 @@
#include "FEATURE/common"
@ -407,7 +406,7 @@
union _u_
{
--- src/lib/libast/features/botch.c
+++ src/lib/libast/features/botch.c 2007-12-20 18:01:26.000000000 +0000
+++ src/lib/libast/features/botch.c 2014-02-17 15:03:39.981715158 +0000
@@ -27,6 +27,7 @@
* generate ast traps for botched standard prototypes
*/
@ -415,10 +414,10 @@
+#include <stdio.h>
#include <sys/types.h>
#include "FEATURE/lib"
#include "FEATURE/common"
--- src/lib/libast/features/lib
+++ src/lib/libast/features/lib 2007-12-20 18:01:26.000000000 +0000
@@ -538,14 +538,19 @@ tst lib_utime_now note{ utime works with
+++ src/lib/libast/features/lib 2014-02-17 14:53:59.621033112 +0000
@@ -487,14 +487,19 @@ tst lib_utime_now note{ utime works with
}end
tst cross{
@ -446,8 +445,8 @@
}end
--- src/lib/libast/misc/procopen.c
+++ src/lib/libast/misc/procopen.c 2007-12-20 18:01:26.000000000 +0000
@@ -599,7 +599,7 @@ procopen(const char* cmd, char** argv, c
+++ src/lib/libast/misc/procopen.c 2014-02-17 14:53:59.621033112 +0000
@@ -601,7 +601,7 @@ procopen(const char* cmd, char** argv, c
if (!fork())
{
sfsprintf(path, sizeof(path), "%d", getppid());
@ -457,7 +456,7 @@
}
sleep(2);
--- src/lib/libast/port/astwinsize.c
+++ src/lib/libast/port/astwinsize.c 2012-02-03 08:58:43.000000000 +0000
+++ src/lib/libast/port/astwinsize.c 2014-02-17 15:05:53.702793018 +0000
@@ -29,6 +29,10 @@
#include <ast.h>
#include <ast_tty.h>
@ -467,21 +466,10 @@
+#endif
+
#if defined(__STDPP__directive) && defined(__STDPP__hide)
__STDPP__directive pragma pp:hide ioctl sleep
__STDPP__directive pragma pp:hide sleep
#else
@@ -36,10 +40,6 @@ __STDPP__directive pragma pp:hide ioctl
#define sleep ______sleep
#endif
-#if _sys_ioctl
-#include <sys/ioctl.h>
-#endif
-
#if defined(TIOCGWINSZ)
#if _sys_stream && _sys_ptem
#include <sys/stream.h>
--- src/lib/libast/sfio/sfstrtof.h
+++ src/lib/libast/sfio/sfstrtof.h 2007-12-20 18:01:26.000000000 +0000
+++ src/lib/libast/sfio/sfstrtof.h 2014-02-17 14:53:59.621033112 +0000
@@ -54,7 +54,7 @@
#if !defined(S2F_function)
@ -491,20 +479,9 @@
#define S2F_type 2
#define S2F_scan 1
#ifndef elementsof
--- src/lib/libcmd/Mamfile
+++ src/lib/libcmd/Mamfile 2013-02-05 10:41:01.310073683 +0000
@@ -897,7 +897,7 @@ exec - -e '/^b_[a-z_][a-z_0-9]*(/!d' \
exec - -e 's/^b_//' \
exec - -e 's/(.*//' \
exec - -e 's/.*/CMDLIST(&)/' \
-exec - |
+exec - cmdinit.c basename.c cat.c chgrp.c chmod.c chown.c cksum.c cmp.c comm.c cp.c cut.c dirname.c date.c expr.c fds.c fmt.c fold.c getconf.c head.c id.c join.c ln.c logname.c md5sum.c mkdir.c mkfifo.c mktemp.c mv.c paste.c pathchk.c pids.c rev.c rm.c rmdir.c stty.c sum.c sync.c tail.c tee.c tty.c uname.c uniq.c vmstate.c wc.c revlib.c wclib.c fts_fix.c lib.c |
exec - sort -u
exec - } > 1.${COTEMP}.h
exec - if cmp 2>/dev/null -s 1.${COTEMP}.h cmdlist.h
--- src/lib/libcmd/chmod.c
+++ src/lib/libcmd/chmod.c 2011-05-20 13:28:58.000000000 +0000
@@ -272,7 +272,7 @@ b_chmod(int argc, char** argv, Shbltin_t
+++ src/lib/libcmd/chmod.c 2014-02-17 14:53:59.621033112 +0000
@@ -270,7 +270,7 @@ b_chmod(int argc, char** argv, Shbltin_t
case FTS_SLNONE:
if (chlink)
{
@ -513,3 +490,80 @@
chmodf = lchmod;
goto commit;
#else
--- src/cmd/ksh93/tests/namespace.sh
+++ src/cmd/ksh93/tests/namespace.sh 2014-02-19 12:11:42.493794867 +0000
@@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/}
integer Errors=0
+integer compiled=0
+read -n4 c < $0 2> /dev/null
+[[ $c == *$'\ck'* ]] && let compiled=1
tmp=$(mktemp -dt) || { err_exit mktemp -dt failed; exit 1; }
trap "cd /; rm -rf $tmp" EXIT
@@ -117,6 +120,7 @@ namespace com.foo
}
[[ $(print -v .com.foo.container) == "${.com.foo.exp}" ]] || err_exit 'compound variables defined in a namespace not expanded the same outside and inside'
+if (( compiled==0 )) ; then
namespace a.b
{
typeset -T x_t=(
@@ -126,7 +130,9 @@ namespace a.b
}
.a.b.x_t var
[[ $(var.pi) == 10 ]] || print -u2 'discipline functions for types in namespace not working'
+fi
+if (( compiled==0 )) ; then
namespace com.foo.test1
{
typeset -T x_t=(
@@ -137,6 +143,7 @@ namespace com.foo.test1
}
.com.foo.test1.y_t v
[[ $(v.x.pr) == 9/5 ]] || err_exit '_.__ not working with nested types in a namespace'
+fi
namespace a.b
{
--- src/cmd/ksh93/tests/wchar.sh
+++ src/cmd/ksh93/tests/wchar.sh 2014-02-19 14:09:16.651095254 +0000
@@ -40,7 +40,7 @@ Command=${0##*/}
integer Errors=0
locales="en_US.UTF-8 en_US.ISO-8859-15 zh_CN.GB18030"
-supported="C.UTF-8"
+supported="de_DE.UTF-8"
for lc_all in $locales
do if [[ $($SHELL -c "LC_ALL=$lc_all || echo error" 2>&1) == "" ]]
--- src/cmd/ksh93/tests/treemove.sh
+++ src/cmd/ksh93/tests/treemove.sh 2014-02-19 15:06:17.998369193 +0000
@@ -64,6 +64,9 @@ function err_exit
alias err_exit='err_exit $LINENO'
integer Errors=0
+integer compiled=0
+read -n4 c < $0 2> /dev/null
+[[ $c == *$'\ck'* ]] && let compiled=1
function idempotent
{
@@ -236,6 +239,7 @@ exp='typeset -C res.a=(typeset -l -i val
[[ $(typeset -p res.a) == "$exp" ]] || err_exit 'typeset -m for compound variable in a type not working'
idempotent exp res.a 'typeset -C res'
+if (( compiled != 1 )) ; then
unset c
compound c dummy
objstack_t c.ost
@@ -247,6 +251,7 @@ c.ost.popobj dummy
exp='typeset -C c=(objstack_t ost=(typeset -l -i st_n=1;st[0]=(obj=(typeset -l -i val=5))))'
[[ $(typeset -p c) == "$exp" ]] || err_exit 'typeset -m for types not working'
idempotent exp c "$(typeset -T)"
+fi
unset c
typeset -p c

View File

@ -41,7 +41,7 @@ static void sigother(int sig)
int main(int argc, char* argv[])
{
int ptm, pts;
int ptm, pts, sig;
ssize_t len;
static struct termios o;
static struct winsize w;
@ -168,14 +168,14 @@ int main(int argc, char* argv[])
close(ptm);
if (ioctl (0, TIOCSCTTY, 1) < 0) {
perror("pty: can not get controlling tty");
exit(1);
exit(errno);
}
break;
case -1:
close(pts);
close(ptm);
perror("pty: can not fork");
exit(1);
exit(errno);
default:
dup2(ptm, 0);
close(pts);
@ -190,7 +190,7 @@ int main(int argc, char* argv[])
exit (0);
if (errno == EINTR || errno == EAGAIN)
continue;
return 1;
return errno;
}
ptr += p;
len -= p;
@ -204,24 +204,28 @@ int main(int argc, char* argv[])
(void)sigfillset(&set);
sigprocmask(SIG_UNBLOCK, &set, (sigset_t*)0);
(void)sigemptyset(&set);
(void)sigaddset(&set, SIGCHLD);
sigprocmask(SIG_BLOCK, &set, (sigset_t*)0);
sa.sa_flags = SA_RESTART;
sa.sa_handler = SIG_DFL;
sigemptyset (&sa.sa_mask);
sigaction(SIGHUP, &sa, (struct sigaction*)0);
sigaction(SIGINT, &sa, (struct sigaction*)0);
sigaction(SIGPIPE, &sa, (struct sigaction*)0);
sigaction(SIGTERM, &sa, (struct sigaction*)0);
sigaction(SIGURG, &sa, (struct sigaction*)0);
sigaction(SIGXFSZ, &sa, (struct sigaction*)0);
sigaction(SIGQUIT, &sa, (struct sigaction*)0);
for (sig = 1; sig < _NSIG; sig++) {
if (sig == SIGKILL || sig == SIGSTOP)
continue;
if (sig == SIGQUIT)
continue;
if ((sigaction(sig, &sa, (struct sigaction*)0) < 0))
if (errno != EINVAL)
return errno;
}
sa.sa_handler = SIG_IGN;
sigaction(SIGQUIT, &sa, (struct sigaction*)0);
return execv(argv[1], &argv[1]);
if (setenv("USESIGEXEC", "0", 1) < 0)
return errno;
return execv(argv[1], &argv[1]);
}

View File

@ -1,5 +1,5 @@
--- src/cmd/INIT/Mamfile
+++ src/cmd/INIT/Mamfile 2008-02-14 12:08:37.000000000 +0000
+++ src/cmd/INIT/Mamfile 2014-02-17 15:18:52.481030284 +0000
@@ -5,7 +5,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS
setv ARFLAGS rc
setv AS as
@ -19,8 +19,8 @@
setv TAR tar
setv YACC yacc
--- src/cmd/INIT/iffe.sh
+++ src/cmd/INIT/iffe.sh 2008-02-14 12:15:59.000000000 +0000
@@ -1170,7 +1170,7 @@ case `(getopts '[-][123:xyz]' opt --xyz;
+++ src/cmd/INIT/iffe.sh 2014-02-17 15:18:52.481030284 +0000
@@ -1186,7 +1186,7 @@ case `(getopts '[-][123:xyz]' opt --xyz;
--*) echo $command: $1: unknown option >&2
exit 2
;;
@ -30,7 +30,7 @@
*) break
;;
--- src/cmd/INIT/mamake.c
+++ src/cmd/INIT/mamake.c 2008-02-14 12:08:37.000000000 +0000
+++ src/cmd/INIT/mamake.c 2014-02-17 15:18:52.485030316 +0000
@@ -118,7 +118,7 @@ USAGE_LICENSE
#define set(b,o) ((b)->nxt=(b)->buf+(o))
#define use(b) (*(b)->nxt=0,(b)->nxt=(b)->buf)
@ -85,7 +85,7 @@
}
--- src/cmd/ksh93/Mamfile
+++ src/cmd/ksh93/Mamfile 2012-02-10 14:30:31.000000000 +0000
+++ src/cmd/ksh93/Mamfile 2014-07-02 12:15:12.166235595 +0000
@@ -7,7 +7,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS
setv ARFLAGS rc
setv AS as
@ -104,43 +104,42 @@
setv SILENT
setv TAR tar
setv YACC yacc
@@ -1337,7 +1337,7 @@ prev +ljobs
@@ -1441,7 +1441,7 @@ bind -lshell
prev +ljobs
prev +li
prev ${mam_libsocket}
prev ${mam_libsecdb}
-exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o ksh pmain.o ${mam_libshell} ${mam_libnsl} ${mam_libast}
+exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o ksh pmain.o ${mam_libshell} ${mam_libnsl} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libast}
-exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o ksh pmain.o ${mam_libshell} ${mam_libast}
+exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o ksh pmain.o ${mam_libshell} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libast}
done ksh generated
make shcomp
make shcomp.o
@@ -1361,7 +1361,7 @@ prev ${mam_libsocket}
@@ -1464,7 +1464,7 @@ prev +li
prev ${mam_libsecdb}
setv CC.DLL -UCC.DLL
setv SH_DICT -DSH_DICT="\"libshell\""
-exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o shcomp shcomp.o ${mam_libshell} ${mam_libnsl} ${mam_libast}
+exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o shcomp shcomp.o ${mam_libshell} ${mam_libnsl} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libast}
-exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o shcomp shcomp.o ${mam_libshell} ${mam_libast}
+exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o shcomp shcomp.o ${mam_libshell} ${mam_libcmd} ${mam_libast} ${mam_libm} ${mam_libast}
done shcomp generated
make suid_exec
make suid_exec.o
@@ -1377,14 +1377,14 @@ meta suid_exec.o %.c>%.o sh/suid_exec.c
@@ -1480,13 +1480,13 @@ meta suid_exec.o %.c>%.o sh/suid_exec.c
prev sh/suid_exec.c
setv CC.DLL -UCC.DLL
setv _BLD_shell -U_BLD_shell
-exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DERROR_CONTEXT_T=Error_context_t -D_API_ast=20100309 -D_PACKAGE_ast -c sh/suid_exec.c
+exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -fPIE -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DERROR_CONTEXT_T=Error_context_t -D_API_ast=20100309 -D_PACKAGE_ast -c sh/suid_exec.c
-exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DERROR_CONTEXT_T=Error_context_t -D_API_ast=20130625 -D_PACKAGE_ast -c sh/suid_exec.c
+exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -fPIE -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DERROR_CONTEXT_T=Error_context_t -D_API_ast=20130625 -D_PACKAGE_ast -c sh/suid_exec.c
done suid_exec.o generated
prev +ljobs
prev +li
prev ${mam_libsocket}
prev ${mam_libsecdb}
setv CC.DLL -UCC.DLL
-exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o suid_exec suid_exec.o ${mam_libast} ${mam_libnsl} ${mam_libast}
+exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -pie -o suid_exec suid_exec.o ${mam_libast} ${mam_libnsl} ${mam_libast}
-exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L${INSTALLROOT}/lib} -o suid_exec suid_exec.o ${mam_libast} ${mam_libast}
+exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L${INSTALLROOT}/lib} -pie -o suid_exec suid_exec.o ${mam_libast} ${mam_libast}
done suid_exec generated
make shell
prev libshell.a archive
make bash
prev ksh
--- src/lib/libast/Mamfile
+++ src/lib/libast/Mamfile 2013-02-05 15:08:23.757451837 +0000
+++ src/lib/libast/Mamfile 2014-02-17 15:18:52.485030316 +0000
@@ -5,7 +5,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS
setv ARFLAGS rc
setv AS as
@ -159,7 +158,7 @@
setv SILENT
setv TAR tar
setv YACC yacc
@@ -1003,7 +1003,7 @@ make lcgen
@@ -1095,7 +1095,7 @@ make lcgen
make port/lcgen.c
prev std/stdio.h implicit
done port/lcgen.c
@ -168,7 +167,7 @@
done lcgen generated
make port/lc.tab
done port/lc.tab
@@ -7291,58 +7291,31 @@ exec - test '' = 'misc/magic.tab' || ${S
@@ -7586,58 +7586,31 @@ exec - test '' = 'misc/magic.tab' || ${S
done ${INSTALLROOT}/lib/file/magic generated
prev comp/fmtmsg.h
prev ast_lib.h
@ -231,7 +230,7 @@
make test
done test dontcare virtual
--- src/lib/libcmd/Mamfile
+++ src/lib/libcmd/Mamfile 2013-02-05 15:13:53.797951789 +0000
+++ src/lib/libcmd/Mamfile 2014-02-17 15:18:52.485030316 +0000
@@ -7,7 +7,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS
setv ARFLAGS rc
setv AS as
@ -251,7 +250,7 @@
setv TAR tar
setv YACC yacc
--- src/lib/libdll/Mamfile
+++ src/lib/libdll/Mamfile 2008-02-14 12:08:37.000000000 +0000
+++ src/lib/libdll/Mamfile 2014-02-17 15:18:52.485030316 +0000
@@ -7,7 +7,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS
setv ARFLAGS rc
setv AS as
@ -272,7 +271,7 @@
setv YACC yacc
--- src/lib/libpp/Mamfile
+++ src/lib/libpp/Mamfile 2012-01-24 18:31:22.000000000 +0000
@@ -663,7 +663,7 @@ exec - .
@@ -675,7 +675,7 @@ exec - .
exec - w
exec - q
exec - !
@ -281,7 +280,7 @@
exec - ./${COTEMP}.exe > pp.yacc
exec - rm -f 1.${COTEMP}.c ${COTEMP}.exe
done pp.yacc generated
@@ -705,7 +705,7 @@ exec - .
@@ -717,7 +717,7 @@ exec - .
exec - w
exec - q
exec - !
@ -290,3 +289,42 @@
exec - ./${COTEMP}.exe > ppkey.yacc
exec - rm -f 1.${COTEMP}.c ${COTEMP}.exe
done ppkey.yacc generated
--- src/cmd/builtin/Mamfile
+++ src/cmd/builtin/Mamfile 2014-02-20 11:36:55.598747064 +0000
@@ -384,36 +384,6 @@ done who.o generated
setv CMD_STANDALONE -DCMD_STANDALONE="b_who"
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L${INSTALLROOT}/lib} -o who who.o ${mam_libast} ${mam_libcmd}
done who generated
-make ln
-make cp
-done cp
-exec - if silent test -f "ln"
-exec - then ${STDRM} -f ln
-exec - fi
-exec - ${STDLN} cp ln
-done ln generated
-make mv
-prev cp
-exec - if silent test -f "mv"
-exec - then ${STDRM} -f mv
-exec - fi
-exec - ${STDLN} cp mv
-done mv generated
-make md5sum
-make cksum
-done cksum
-exec - if silent test -f "md5sum"
-exec - then ${STDRM} -f md5sum
-exec - fi
-exec - ${STDLN} cksum md5sum
-done md5sum generated
-make sum
-prev cksum
-exec - if silent test -f "sum"
-exec - then ${STDRM} -f sum
-exec - fi
-exec - ${STDLN} cksum sum
-done sum generated
make ${INSTALLROOT}/bin
exec - if silent test ! -d ${INSTALLROOT}/bin
exec - then mkdir -p ${INSTALLROOT}/bin