From dd51ffa5b4b9759af2667df8e4505f117b8e2b23 Mon Sep 17 00:00:00 2001 From: Jun-ichi Takimoto Date: Wed, 22 Sep 2021 13:36:57 +0900 Subject: 49422: improve support of --disable-dynamic-nss see also 49392 (Vincent) and 49412 (Axel) --- Src/Modules/parameter.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Src/Modules/parameter.c') diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index ef9148d7b..b44555323 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -2011,6 +2011,9 @@ scanpmdissaliases(HashTable ht, ScanFunc func, int flags) /**/ static Groupset get_all_groups(void) { +#ifdef DISABLE_DYNAMIC_NSS + return NULL; +#else Groupset gs = zhalloc(sizeof(*gs)); Groupmap gaptr; gid_t *list, *lptr, egid; @@ -2063,6 +2066,7 @@ static Groupset get_all_groups(void) } return gs; +#endif /* DISABLE_DYNAMIC_NSS */ } /* Standard hash element lookup. */ @@ -2081,7 +2085,11 @@ getpmusergroups(UNUSED(HashTable ht), const char *name) pm->gsu.s = &nullsetscalar_gsu; if (!gs) { +#ifdef DISABLE_DYNAMIC_NSS + zerr("parameter 'usergroups' not available: NSS is disabled"); +#else zerr("failed to retrieve groups for user: %e", errno); +#endif pm->u.str = dupstring(""); pm->node.flags |= (PM_UNSET|PM_SPECIAL); return &pm->node; @@ -2113,7 +2121,11 @@ scanpmusergroups(UNUSED(HashTable ht), ScanFunc func, int flags) Groupmap gaptr; if (!gs) { +#ifdef DISABLE_DYNAMIC_NSS + zerr("parameter 'usergroups' not available: NSS is disabled"); +#else zerr("failed to retrieve groups for user: %e", errno); +#endif return; } -- cgit v1.2.3 From 45182eb4d447a6fbf5f76538326e1a944880ea52 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 22 Feb 2022 13:09:33 +0000 Subject: unposted: Fix some typos and markup. --- ChangeLog | 5 +++++ Doc/Zsh/contrib.yo | 4 ++-- Src/Modules/parameter.c | 2 +- Src/string.c | 5 ++++- Src/zsh.h | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) (limited to 'Src/Modules/parameter.c') diff --git a/ChangeLog b/ChangeLog index 401ec9379..5dc07937f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2022-02-22 Daniel Shahaf + + * unposted: Doc/Zsh/contrib.yo, Src/Modules/parameter.c, + Src/string.c, Src/zsh.h: Fix some typos and markup. + 2022-02-22 Peter Stephenson * 49672: Doc/Zsh/expn.yo: document "tied" output in parameter diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 0adef7334..0ef59dbc9 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -1159,7 +1159,7 @@ This is used by the Perforce backend (tt(p4)) to decide if it should contact the Perforce server to find out if a directory is managed by Perforce. This is the only reliable way of doing this, but runs the risk of a delay if the server name cannot be found. If the -server (more specifically, the tt(host)tt(:)tt(port) pair describing the +server (more specifically, the var(host)tt(:)var(port) pair describing the server) cannot be contacted, its name is put into the associative array tt(vcs_info_p4_dead_servers) and is not contacted again during the session until it is removed by hand. If you do not set this style, the tt(p4) @@ -1318,7 +1318,7 @@ tt(%Q) expando. item(tt(%Q))( Quilt series information. When quilt is used (either in `addon' mode or as a `standalone' backend), -this expando is set to quilt series' tt(patch-format) string. +this expando is set to the quilt series' tt(patch-format) string. The tt(set-patch-format) hook and tt(nopatch-format) style are honoured. See ifzman(tt(Quilt Support))ifnzman(noderef(vcs_info Quilt Support)) below for details. diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index b44555323..c5cb5ce62 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -592,7 +592,7 @@ getpmfunction_source(HashTable ht, const char *name) return getfunction_source(ht, name, 0); } -/* Param table entry for retrieving ds_functions_source element */ +/* Param table entry for retrieving dis_functions_source element */ /**/ static HashNode diff --git a/Src/string.c b/Src/string.c index 9e14ef949..5f439926e 100644 --- a/Src/string.c +++ b/Src/string.c @@ -103,7 +103,10 @@ wcs_ztrdup(const wchar_t *s) #endif /* MULTIBYTE_SUPPORT */ -/* concatenate s1, s2, and s3 in dynamically allocated buffer */ +/* Concatenate s1, s2, and s3 into dynamically allocated buffer. + * + * To concatenate four or more strings, see zjoin(). + */ /**/ mod_export char * diff --git a/Src/zsh.h b/Src/zsh.h index af9b4fb67..641d9c95c 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1448,7 +1448,7 @@ struct builtin { int minargs; /* minimum number of arguments */ int maxargs; /* maximum number of arguments, or -1 for no limit */ int funcid; /* xbins (see above) for overloaded handlerfuncs */ - char *optstr; /* string of legal options */ + char *optstr; /* string of legal options (see execbuiltin()) */ char *defopts; /* options set by default for overloaded handlerfuncs */ }; -- cgit v1.2.3 From 6a8aa2aa5a07c46a6b6d5c481a18a12e7ab6047a Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 1 Mar 2022 17:27:42 +0000 Subject: 49783: Consistently use old job table in parameter module --- ChangeLog | 3 ++ Src/Modules/parameter.c | 96 +++++++++++++++++++++++++++++-------------------- Src/jobs.c | 34 +++++++++++++----- 3 files changed, 85 insertions(+), 48 deletions(-) (limited to 'Src/Modules/parameter.c') diff --git a/ChangeLog b/ChangeLog index 6371cb85d..5635e5068 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2022-03-01 Peter Stephenson + * 49783: Src/jobs.c, Src/Modules/parameter.c: Consistently use + old job table in parmaeter module. + * users/27536: Doc/Zsh/builtins.yo: Clarify interaction of history matching and numeric indices. diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index c5cb5ce62..dbb61e474 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -1244,19 +1244,19 @@ histwgetfn(UNUSED(Param pm)) /**/ static char * -pmjobtext(int job) +pmjobtext(Job jtab, int job) { Process pn; int len = 1; char *ret; - for (pn = jobtab[job].procs; pn; pn = pn->next) + for (pn = jtab[job].procs; pn; pn = pn->next) len += strlen(pn->text) + 3; ret = (char *) zhalloc(len); ret[0] = '\0'; - for (pn = jobtab[job].procs; pn; pn = pn->next) { + for (pn = jtab[job].procs; pn; pn = pn->next) { strcat(ret, pn->text); if (pn->next) strcat(ret, " | "); @@ -1269,22 +1269,25 @@ static HashNode getpmjobtext(UNUSED(HashTable ht), const char *name) { Param pm = NULL; - int job; + int job, jmax; char *pend; + Job jtab; pm = (Param) hcalloc(sizeof(struct param)); pm->node.nam = dupstring(name); pm->node.flags = PM_SCALAR | PM_READONLY; pm->gsu.s = &nullsetscalar_gsu; + selectjobtab(&jtab, &jmax); + job = strtod(name, &pend); /* Non-numeric keys are looked up by job name */ if (*pend) job = getjob(name, NULL); - if (job >= 1 && job <= maxjob && - jobtab[job].stat && jobtab[job].procs && - !(jobtab[job].stat & STAT_NOPRINT)) - pm->u.str = pmjobtext(job); + if (job >= 1 && job <= jmax && + jtab[job].stat && jtab[job].procs && + !(jtab[job].stat & STAT_NOPRINT)) + pm->u.str = pmjobtext(jtab, job); else { pm->u.str = dupstring(""); pm->node.flags |= (PM_UNSET|PM_SPECIAL); @@ -1297,22 +1300,25 @@ static void scanpmjobtexts(UNUSED(HashTable ht), ScanFunc func, int flags) { struct param pm; - int job; + int job, jmax; char buf[40]; + Job jtab; memset((void *)&pm, 0, sizeof(struct param)); pm.node.flags = PM_SCALAR | PM_READONLY; pm.gsu.s = &nullsetscalar_gsu; - for (job = 1; job <= maxjob; job++) { - if (jobtab[job].stat && jobtab[job].procs && - !(jobtab[job].stat & STAT_NOPRINT)) { + selectjobtab(&jtab, &jmax); + + for (job = 1; job <= jmax; job++) { + if (jtab[job].stat && jtab[job].procs && + !(jtab[job].stat & STAT_NOPRINT)) { if (func != scancountparams) { sprintf(buf, "%d", job); pm.node.nam = dupstring(buf); if ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) || !(flags & SCANPM_WANTKEYS)) - pm.u.str = pmjobtext(job); + pm.u.str = pmjobtext(jtab, job); } func(&pm.node, flags); } @@ -1323,7 +1329,7 @@ scanpmjobtexts(UNUSED(HashTable ht), ScanFunc func, int flags) /**/ static char * -pmjobstate(int job) +pmjobstate(Job jtab, int job) { Process pn; char buf[256], buf2[128], *ret, *state, *cp; @@ -1335,14 +1341,14 @@ pmjobstate(int job) else cp = ":"; - if (jobtab[job].stat & STAT_DONE) + if (jtab[job].stat & STAT_DONE) ret = dyncat("done", cp); - else if (jobtab[job].stat & STAT_STOPPED) + else if (jtab[job].stat & STAT_STOPPED) ret = dyncat("suspended", cp); else ret = dyncat("running", cp); - for (pn = jobtab[job].procs; pn; pn = pn->next) { + for (pn = jtab[job].procs; pn; pn = pn->next) { if (pn->status == SP_RUNNING) state = "running"; @@ -1371,21 +1377,24 @@ static HashNode getpmjobstate(UNUSED(HashTable ht), const char *name) { Param pm = NULL; - int job; + int job, jmax; char *pend; + Job jtab; pm = (Param) hcalloc(sizeof(struct param)); pm->node.nam = dupstring(name); pm->node.flags = PM_SCALAR | PM_READONLY; pm->gsu.s = &nullsetscalar_gsu; + selectjobtab(&jtab, &jmax); + job = strtod(name, &pend); if (*pend) job = getjob(name, NULL); - if (job >= 1 && job <= maxjob && - jobtab[job].stat && jobtab[job].procs && - !(jobtab[job].stat & STAT_NOPRINT)) - pm->u.str = pmjobstate(job); + if (job >= 1 && job <= jmax && + jtab[job].stat && jtab[job].procs && + !(jtab[job].stat & STAT_NOPRINT)) + pm->u.str = pmjobstate(jtab, job); else { pm->u.str = dupstring(""); pm->node.flags |= (PM_UNSET|PM_SPECIAL); @@ -1398,22 +1407,25 @@ static void scanpmjobstates(UNUSED(HashTable ht), ScanFunc func, int flags) { struct param pm; - int job; + int job, jmax; + Job jtab; char buf[40]; + selectjobtab(&jtab, &jmax); + memset((void *)&pm, 0, sizeof(struct param)); pm.node.flags = PM_SCALAR | PM_READONLY; pm.gsu.s = &nullsetscalar_gsu; - for (job = 1; job <= maxjob; job++) { - if (jobtab[job].stat && jobtab[job].procs && - !(jobtab[job].stat & STAT_NOPRINT)) { + for (job = 1; job <= jmax; job++) { + if (jtab[job].stat && jtab[job].procs && + !(jtab[job].stat & STAT_NOPRINT)) { if (func != scancountparams) { sprintf(buf, "%d", job); pm.node.nam = dupstring(buf); if ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) || !(flags & SCANPM_WANTKEYS)) - pm.u.str = pmjobstate(job); + pm.u.str = pmjobstate(jtab, job); } func(&pm.node, flags); } @@ -1424,11 +1436,11 @@ scanpmjobstates(UNUSED(HashTable ht), ScanFunc func, int flags) /**/ static char * -pmjobdir(int job) +pmjobdir(Job jtab, int job) { char *ret; - ret = dupstring(jobtab[job].pwd ? jobtab[job].pwd : pwd); + ret = dupstring(jtab[job].pwd ? jtab[job].pwd : pwd); return ret; } @@ -1437,21 +1449,24 @@ static HashNode getpmjobdir(UNUSED(HashTable ht), const char *name) { Param pm = NULL; - int job; + int job, jmax; char *pend; + Job jtab; pm = (Param) hcalloc(sizeof(struct param)); pm->node.nam = dupstring(name); pm->node.flags = PM_SCALAR | PM_READONLY; pm->gsu.s = &nullsetscalar_gsu; + selectjobtab(&jtab, &jmax); + job = strtod(name, &pend); if (*pend) job = getjob(name, NULL); - if (job >= 1 && job <= maxjob && - jobtab[job].stat && jobtab[job].procs && - !(jobtab[job].stat & STAT_NOPRINT)) - pm->u.str = pmjobdir(job); + if (job >= 1 && job <= jmax && + jtab[job].stat && jtab[job].procs && + !(jtab[job].stat & STAT_NOPRINT)) + pm->u.str = pmjobdir(jtab, job); else { pm->u.str = dupstring(""); pm->node.flags |= (PM_UNSET|PM_SPECIAL); @@ -1464,22 +1479,25 @@ static void scanpmjobdirs(UNUSED(HashTable ht), ScanFunc func, int flags) { struct param pm; - int job; + int job, jmax; char buf[40]; + Job jtab; memset((void *)&pm, 0, sizeof(struct param)); pm.node.flags = PM_SCALAR | PM_READONLY; pm.gsu.s = &nullsetscalar_gsu; - for (job = 1; job <= maxjob; job++) { - if (jobtab[job].stat && jobtab[job].procs && - !(jobtab[job].stat & STAT_NOPRINT)) { + selectjobtab(&jtab, &jmax); + + for (job = 1; job <= jmax; job++) { + if (jtab[job].stat && jtab[job].procs && + !(jtab[job].stat & STAT_NOPRINT)) { if (func != scancountparams) { sprintf(buf, "%d", job); pm.node.nam = dupstring(buf); if ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) || !(flags & SCANPM_WANTKEYS)) - pm.u.str = pmjobdir(job); + pm.u.str = pmjobdir(jtab, job); } func(&pm.node, flags); } diff --git a/Src/jobs.c b/Src/jobs.c index f0b337110..18e43f03c 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -98,10 +98,12 @@ mod_export int jobtabsize; mod_export int maxjob; /* If we have entered a subshell, the original shell's job table. */ -static struct job *oldjobtab; +/**/ +mod_export struct job *oldjobtab; /* The size of that. */ -static int oldmaxjob; +/**/ +mod_export int oldmaxjob; /* shell timings */ @@ -1894,6 +1896,26 @@ setcurjob(void) } } +/* Find the job table for reporting jobs */ + +/**/ +mod_export void +selectjobtab(Job *jtabp, int *jmaxp) +{ + if (oldjobtab) + { + /* In subshell --- use saved job table to report */ + *jtabp = oldjobtab; + *jmaxp = oldmaxjob; + } + else + { + /* Use main job table */ + *jtabp = jobtab; + *jmaxp = maxjob; + } +} + /* Convert a job specifier ("%%", "%1", "%foo", "%?bar?", etc.) * * to a job number. */ @@ -1904,13 +1926,7 @@ getjob(const char *s, const char *prog) int jobnum, returnval, mymaxjob; Job myjobtab; - if (oldjobtab) { - myjobtab = oldjobtab; - mymaxjob = oldmaxjob; - } else { - myjobtab= jobtab; - mymaxjob = maxjob; - } + selectjobtab(&myjobtab, &mymaxjob); /* if there is no %, treat as a name */ if (*s != '%') -- cgit v1.2.3