From a4d3b8f676c336e4504d5f400e98fb55aba78a37 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 21 May 2013 17:42:57 +0100 Subject: 31419: Add time zone and year to string formatted time output from zstat --- Src/Modules/stat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Src/Modules') diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c index a3e95bb59..edae0841e 100644 --- a/Src/Modules/stat.c +++ b/Src/Modules/stat.c @@ -339,7 +339,7 @@ statprint(struct stat *sbuf, char *outbuf, char *fname, int iwhich, int flags) * -H hash: as for -A array, but returns a hash with the keys being those * from stat -l * -F fmt: specify a $TIME-like format for printing times; the default - * is the (CTIME-like) "%a %b %e %k:%M:%S". This option implies + * is the (CTIME-like) "%a %b %e %k:%M:%S %Z %Y". This option implies * -s as it is not useful for numerical times. * * +type selects just element type of stat buffer (-l gives list): @@ -361,7 +361,7 @@ bin_stat(char *name, char **args, Options ops, UNUSED(int func)) struct stat statbuf; int found = 0, nargs; - timefmt = "%a %b %e %k:%M:%S"; + timefmt = "%a %b %e %k:%M:%S %Z %Y"; for (; *args && (**args == '+' || **args == '-'); args++) { char *arg = *args+1; -- cgit v1.2.3 From f75904a3809bf3d9ef4f644ee5add09326a207a7 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 25 Aug 2013 20:48:52 +0100 Subject: 31665: zpty should attach terminal on slave. Also add test. --- ChangeLog | 5 +++++ Src/Modules/zpty.c | 3 +++ Test/.distfiles | 1 + Test/V08zpty.ztst | 20 ++++++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 Test/V08zpty.ztst (limited to 'Src/Modules') diff --git a/ChangeLog b/ChangeLog index 74e0ebeb5..63c9be0a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-08-25 Peter Stephenson + + * Src/Modules/zpty.c, Test/V08zpty.ztst, Test/.distfiles: zpty + should attach terminal on slave. + 2013-08-17 Barton E. Schaefer * 31637: Src/builtin.c: change of directory should not be retried diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 25ec7dfea..382119483 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -344,6 +344,8 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) if (get_pty(0, &slave)) exit(1); + SHTTY = slave; + attachtty(mypid); #ifdef TIOCGWINSZ /* Set the window size before associating with the terminal * * so that we don't get hit with a SIGWINCH. I'm paranoid. */ @@ -398,6 +400,7 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) opts[INTERACTIVE] = 0; execode(prog, 1, 0, "zpty"); stopmsg = 2; + mypid = 0; /* trick to ensure we _exit() */ zexit(lastval, 0); } master = movefd(master); diff --git a/Test/.distfiles b/Test/.distfiles index 689b69587..ab92153b0 100644 --- a/Test/.distfiles +++ b/Test/.distfiles @@ -40,6 +40,7 @@ V04features.ztst V05styles.ztst V06parameter.ztst V07pcre.ztst +V08zpty.ztst Y01completion.ztst Y02compmatch.ztst Y03arguments.ztst diff --git a/Test/V08zpty.ztst b/Test/V08zpty.ztst new file mode 100644 index 000000000..d9d24c5e8 --- /dev/null +++ b/Test/V08zpty.ztst @@ -0,0 +1,20 @@ +# zpty is required by tests of interactive modes of the shell itself. +# This tests some extra things. + +%prep + + if ! zmodload zsh/zpty 2>/dev/null + then + ZTST_unimplemented="the zsh/zpty module is not available" + return 0 + fi + +%test + + zpty cat cat + print a line of text | zpty -w cat + var= + zpty -r cat var && print -r -- ${var%%$'\r\n'} + zpty -d cat +0:zpty with a process that does not set up the terminal +>a line of text -- cgit v1.2.3 From b0a0441902f848da4284e107c29e43e222252959 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 26 Aug 2013 21:01:17 +0100 Subject: 31672: Add test that was failing and fix zpty set-up race --- ChangeLog | 5 +++++ Src/Modules/zpty.c | 30 ++++++++++++++++++++++++++++-- Test/V08zpty.ztst | 10 +++++++++- 3 files changed, 42 insertions(+), 3 deletions(-) (limited to 'Src/Modules') diff --git a/ChangeLog b/ChangeLog index 08b8abdc4..8f594b45b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-08-26 Peter Stephenson + + * 31672: Src/Modules/zpty.c, Test/V08zpty.ztst: add test that + was failing and fix race when setting up pty. + 2013-08-25 Peter Stephenson * 31665: Src/Modules/zpty.c, Test/V08zpty.ztst, Test/.distfiles: diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 382119483..fca0cc172 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -293,8 +293,8 @@ static int newptycmd(char *nam, char *pname, char **args, int echo, int nblock) { Ptycmd p; - int master, slave, pid, oineval = ineval; - char *oscriptname = scriptname; + int master, slave, pid, oineval = ineval, ret; + char *oscriptname = scriptname, syncch; Eprog prog; /* code borrowed from bin_eval() */ @@ -398,6 +398,20 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) setsparam("TTY", ztrdup(ttystrname)); opts[INTERACTIVE] = 0; + + syncch = 0; + do { + ret = write(1, &syncch, 1); + } while (ret != 1 && ( +#ifdef EWOULDBLOCK + errno == EWOULDBLOCK || +#else +#ifdef EAGAIN + errno == EAGAIN || +#endif +#endif + errno == EINTR)); + execode(prog, 1, 0, "zpty"); stopmsg = 2; mypid = 0; /* trick to ensure we _exit() */ @@ -433,6 +447,18 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) scriptname = oscriptname; ineval = oineval; + do { + ret = read(master, &syncch, 1); + } while (ret != 1 && ( +#ifdef EWOULDBLOCK + errno == EWOULDBLOCK || +#else +#ifdef EAGAIN + errno == EAGAIN || +#endif +#endif + errno == EINTR)); + return 0; } diff --git a/Test/V08zpty.ztst b/Test/V08zpty.ztst index d9d24c5e8..5b08fc281 100644 --- a/Test/V08zpty.ztst +++ b/Test/V08zpty.ztst @@ -11,10 +11,18 @@ %test + zpty cat cat + zpty -w cat a line of text + var= + zpty -r cat var && print -r -- ${var%%$'\r\n'} + zpty -d cat +0:zpty with a process that does not set up the terminal: internal write +>a line of text + zpty cat cat print a line of text | zpty -w cat var= zpty -r cat var && print -r -- ${var%%$'\r\n'} zpty -d cat -0:zpty with a process that does not set up the terminal +0:zpty with a process that does not set up the terminal: write via stdin >a line of text -- cgit v1.2.3 From fa033326357218652310c4510898be622b871c4f Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 9 Oct 2013 17:57:03 +0200 Subject: 31805: Add $patchars and $dis_patchars to zsh/parameter module --- Doc/Zsh/mod_parameter.yo | 8 ++++++++ Src/Modules/parameter.c | 40 ++++++++++++++++++++++++++++++++++++++++ Src/Modules/parameter.mdd | 2 +- Src/pattern.c | 3 ++- Test/V01zmodload.ztst | 2 ++ 5 files changed, 53 insertions(+), 2 deletions(-) (limited to 'Src/Modules') diff --git a/Doc/Zsh/mod_parameter.yo b/Doc/Zsh/mod_parameter.yo index 5948d74f2..32d4796f7 100644 --- a/Doc/Zsh/mod_parameter.yo +++ b/Doc/Zsh/mod_parameter.yo @@ -57,6 +57,14 @@ vindex(dis_reswords) item(tt(dis_reswords))( Like tt(reswords) but for disabled reserved words. ) +vindex(patchars) +item(tt(patchars))( +This array contains the enabled pattern characters. +) +vindex(dis_patchars) +item(tt(dis_patchars))( +Like tt(patchars) but for disabled pattern characters. +) vindex(aliases) item(tt(aliases))( This maps the names of the regular aliases currently enabled to their diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index a029c9cb4..22148f991 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -759,6 +759,38 @@ disreswordsgetfn(UNUSED(Param pm)) return getreswords(DISABLED); } +/* Functions for the patchars special parameter. */ + +/**/ +static char ** +getpatchars(int dis) +{ + int i; + char **ret, **p; + + p = ret = (char **) zhalloc(ZPC_COUNT * sizeof(char *)); + + for (i = 0; i < ZPC_COUNT; i++) + if (zpc_strings[i] && !dis == !zpc_disables[i]) + *p++ = dupstring(zpc_strings[i]); + + *p = NULL; + + return ret; +} + +static char ** +patcharsgetfn(UNUSED(Param pm)) +{ + return getpatchars(0); +} + +static char ** +dispatcharsgetfn(UNUSED(Param pm)) +{ + return getpatchars(1); +} + /* Functions for the options special parameter. */ /**/ @@ -2018,6 +2050,10 @@ static const struct gsu_array reswords_gsu = { reswordsgetfn, arrsetfn, stdunsetfn }; static const struct gsu_array disreswords_gsu = { disreswordsgetfn, arrsetfn, stdunsetfn }; +static const struct gsu_array patchars_gsu = +{ patcharsgetfn, arrsetfn, stdunsetfn }; +static const struct gsu_array dispatchars_gsu = +{ dispatcharsgetfn, arrsetfn, stdunsetfn }; static const struct gsu_array dirs_gsu = { dirsgetfn, dirssetfn, stdunsetfn }; static const struct gsu_array historywords_gsu = @@ -2038,6 +2074,8 @@ static struct paramdef partab[] = { &pmdisfunctions_gsu, getpmdisfunction, scanpmdisfunctions), SPECIALPMDEF("dis_galiases", 0, &pmdisgaliases_gsu, getpmdisgalias, scanpmdisgaliases), + SPECIALPMDEF("dis_patchars", PM_ARRAY|PM_READONLY, + &dispatchars_gsu, NULL, NULL), SPECIALPMDEF("dis_reswords", PM_ARRAY|PM_READONLY, &disreswords_gsu, NULL, NULL), SPECIALPMDEF("dis_saliases", 0, @@ -2072,6 +2110,8 @@ static struct paramdef partab[] = { &pmoptions_gsu, getpmoption, scanpmoptions), SPECIALPMDEF("parameters", PM_READONLY, NULL, getpmparameter, scanpmparameters), + SPECIALPMDEF("patchars", PM_ARRAY|PM_READONLY, + &patchars_gsu, NULL, NULL), SPECIALPMDEF("reswords", PM_ARRAY|PM_READONLY, &reswords_gsu, NULL, NULL), SPECIALPMDEF("saliases", 0, diff --git a/Src/Modules/parameter.mdd b/Src/Modules/parameter.mdd index eb48d5f2a..a91a5dc09 100644 --- a/Src/Modules/parameter.mdd +++ b/Src/Modules/parameter.mdd @@ -2,6 +2,6 @@ name=zsh/parameter link=either load=yes -autofeatures="p:parameters p:commands p:functions p:dis_functions p:funcfiletrace p:funcsourcetrace p:funcstack p:functrace p:builtins p:dis_builtins p:reswords p:dis_reswords p:options p:modules p:dirstack p:history p:historywords p:jobtexts p:jobdirs p:jobstates p:nameddirs p:userdirs p:aliases p:dis_aliases p:galiases p:dis_galiases p:saliases p:dis_saliases" +autofeatures="p:parameters p:commands p:functions p:dis_functions p:funcfiletrace p:funcsourcetrace p:funcstack p:functrace p:builtins p:dis_builtins p:reswords p:dis_reswords p:patchars p:dis_patchars p:options p:modules p:dirstack p:history p:historywords p:jobtexts p:jobdirs p:jobstates p:nameddirs p:userdirs p:aliases p:dis_aliases p:galiases p:dis_galiases p:saliases p:dis_saliases" objects="parameter.o" diff --git a/Src/pattern.c b/Src/pattern.c index 4f0166bfa..609a9e372 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -236,7 +236,8 @@ static const char zpc_chars[ZPC_COUNT] = { * Corresponding strings used in enable/disable -p. * NULL means no way of turning this on or off. */ -static const char *zpc_strings[ZPC_COUNT] = { +/**/ +const char *zpc_strings[ZPC_COUNT] = { NULL, NULL, "|", NULL, "~", "(", "?", "*", "[", "<", "^", "#", NULL, "?(", "*(", "+(", "!(", "@(" }; diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst index ea908e952..3580bacea 100644 --- a/Test/V01zmodload.ztst +++ b/Test/V01zmodload.ztst @@ -183,6 +183,7 @@ >p:dis_builtins >p:dis_functions >p:dis_galiases +>p:dis_patchars >p:dis_reswords >p:dis_saliases >p:funcfiletrace @@ -200,6 +201,7 @@ >p:nameddirs >p:options >p:parameters +>p:patchars >p:reswords >p:saliases >p:userdirs -- cgit v1.2.3 From ef4d20ad6fde1ca519a19ad60f2c31d86f5b1d98 Mon Sep 17 00:00:00 2001 From: Jun T Date: Sun, 27 Oct 2013 00:41:03 +0900 Subject: 31902: rationalise use of gamma function. Make zsh/mathfunc consistent across systems and use tgamma() where available --- ChangeLog | 5 +++++ Doc/Zsh/mod_mathfunc.yo | 2 +- Src/Modules/mathfunc.c | 9 +++++++++ Test/V03mathfunc.ztst | 6 ++++++ configure.ac | 2 +- 5 files changed, 22 insertions(+), 2 deletions(-) (limited to 'Src/Modules') diff --git a/ChangeLog b/ChangeLog index 0561a3e0c..db0177eeb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-10-26 Peter Stephenson + + * Jun T: 31902: rationalise gamma function in mathfunc for + consistency with various libraries and user expectations. + 2013-10-25 Peter Stephenson * 31890 (with Mikael's fixes in 31891): NEWS: add descriptions diff --git a/Doc/Zsh/mod_mathfunc.yo b/Doc/Zsh/mod_mathfunc.yo index dda4f36fd..5239da5f8 100644 --- a/Doc/Zsh/mod_mathfunc.yo +++ b/Doc/Zsh/mod_mathfunc.yo @@ -33,7 +33,7 @@ returns an integer. The function tt(signgam) takes no arguments, and returns an integer, which is the C variable of the same name, as described in manref(gamma)(3). Note that it is therefore only useful immediately after a call to tt(gamma) or -tt(lgamma). Note also that `tt(signgam+LPAR()RPAR)' and `tt(signgam)' are +tt(lgamma). Note also that `tt(signgam+LPAR()RPAR())' and `tt(signgam)' are distinct expressions. The following functions take two floating point arguments: tt(copysign), diff --git a/Src/Modules/mathfunc.c b/Src/Modules/mathfunc.c index 04483b555..efadd86ff 100644 --- a/Src/Modules/mathfunc.c +++ b/Src/Modules/mathfunc.c @@ -340,7 +340,16 @@ math_func(char *name, int argc, mnumber *argv, int id) break; case MF_GAMMA: +#ifdef HAVE_TGAMMA + retd = tgamma(argd); +#else +#ifdef HAVE_SIGNGAM + retd = lgamma(argd); + retd = signgam*exp(retd); +#else /*XXX assume gamma(x) returns Gamma(x), not log(|Gamma(x)|) */ retd = gamma(argd); +#endif +#endif break; case MF_HYPOT: diff --git a/Test/V03mathfunc.ztst b/Test/V03mathfunc.ztst index 069059da4..ab383db43 100644 --- a/Test/V03mathfunc.ztst +++ b/Test/V03mathfunc.ztst @@ -136,3 +136,9 @@ F:This test fails if your math library doesn't have erand48(). done (( ok )) 0:Test random number generator distributions are not grossly broken + + float -F 5 g l + (( g = gamma(2), l = lgamma(2) )) + print $g, $l +0:Test Gamma function gamma and lgamma +>1.00000, 0.00000 diff --git a/configure.ac b/configure.ac index c3debd8ad..c3093f20d 100644 --- a/configure.ac +++ b/configure.ac @@ -1222,7 +1222,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \ getrlimit getrusage \ setlocale \ uname \ - signgam \ + signgam tgamma \ putenv getenv setenv unsetenv xw\ brk sbrk \ pathconf sysconf \ -- cgit v1.2.3