Dr. Werner Fink 2015-05-05 10:23:49 +00:00 committed by Git OBS Bridge
parent 9ff6e6ec17
commit dcc34b4ff4
12 changed files with 470 additions and 387 deletions

View File

@ -1,21 +0,0 @@
--- tc.str.c
+++ tc.str.c 2012-05-10 07:57:01.358065084 +0000
@@ -590,10 +590,14 @@ bb_cleanup(void *xbb)
struct blk_buf *bb;
size_t i;
- bb = xbb;
- for (i = 0; i < bb->len; i++)
- xfree(bb->vec[i]);
- xfree(bb->vec);
+ bb = (struct blk_buf *)xbb;
+ if (bb->vec) {
+ for (i = 0; i < bb->len; i++)
+ xfree(bb->vec[i]);
+ xfree(bb->vec);
+ }
+ bb->vec = (Char**)0;
+ bb->len = 0;
}
void

View File

@ -1,38 +0,0 @@
--- sh.hist.c
+++ sh.hist.c 2013-10-15 17:04:45.518796367 +0000
@@ -107,7 +107,7 @@ hremove(struct Hist *hp)
/* Prune length of history list to specified size by history variable. */
PG_STATIC void
-discardExcess(int histlen)
+discardExcess(int histlen, int flg)
{
struct Hist *hp, *np;
if (histTail == NULL) {
@@ -124,7 +124,7 @@ discardExcess(int histlen)
break;
}
while (histCount > (unsigned)histlen && (np = histTail) != &Histlist) {
- if (eventno - np->Href >= histlen || histlen == 0)
+ if ((eventno - np->Href >= histlen || histlen == 0) && ! (flg & HIST_MERGE))
hremove(np), hfree(np);
else
break;
@@ -133,7 +133,7 @@ discardExcess(int histlen)
return; /* don't bother doing the full scan */
for (hp = &Histlist; histCount > (unsigned)histlen &&
(np = hp->Hnext) != NULL;)
- if (eventno - np->Href >= histlen || histlen == 0)
+ if ((eventno - np->Href >= histlen || histlen == 0) || flg & HIST_MERGE)
hremove(np), hfree(np);
else
hp = np;
@@ -161,7 +161,7 @@ savehist(
}
if (sp)
(void) enthist(++eventno, sp, 1, flg, histlen);
- discardExcess(histlen);
+ discardExcess(histlen, flg);
}
#define USE_JENKINS_HASH 1

View File

@ -1,11 +0,0 @@
--- ed.inputl.c
+++ ed.inputl.c 2012-05-25 16:31:24.130065248 +0000
@@ -683,7 +683,7 @@ GetNextCommand(KEYCMD *cmdnum, Char *ch)
#ifdef DSPMBYTE
_enable_mbdisp &&
#else
- MB_CUR_MAX == 1 &&
+ MB_LEN_MAX == 1 &&
#endif
!adrof(STRnokanji) && (*ch & META)) {
MetaNext = 0;

View File

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

View File

@ -1,6 +1,134 @@
---
nls/Makefile.in | 48 ++++++++++++++++++++++++------------------------
sh.c | 6 +++---
2 files changed, 27 insertions(+), 27 deletions(-)
--- nls/Makefile.in
+++ nls/Makefile.in 2015-05-04 14:58:34.999037547 +0000
@@ -16,96 +16,96 @@ CATGEN= ${srcdir}/catgen
all: ${CATALOGS}
-INSTALLED+=${localedir}/C/LC_MESSAGES/tcsh.cat
-${localedir}/C/LC_MESSAGES/tcsh.cat: C.cat
+INSTALLED+=${localedir}/C/LC_MESSAGES/tcsh
+${localedir}/C/LC_MESSAGES/tcsh: C.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
C.cat: ${srcdir}/C/charset ${srcdir}/C/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/et/LC_MESSAGES/tcsh.cat
-${localedir}/et/LC_MESSAGES/tcsh.cat: et.cat
+INSTALLED+=${localedir}/et/LC_MESSAGES/tcsh
+${localedir}/et/LC_MESSAGES/tcsh: et.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
et.cat: ${srcdir}/et/charset ${srcdir}/et/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/fi/LC_MESSAGES/tcsh.cat
-${localedir}/fi/LC_MESSAGES/tcsh.cat: finnish.cat
+INSTALLED+=${localedir}/fi/LC_MESSAGES/tcsh
+${localedir}/fi/LC_MESSAGES/tcsh: finnish.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
finnish.cat: ${srcdir}/finnish/charset ${srcdir}/finnish/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/fr/LC_MESSAGES/tcsh.cat
-${localedir}/fr/LC_MESSAGES/tcsh.cat: french.cat
+INSTALLED+=${localedir}/fr/LC_MESSAGES/tcsh
+${localedir}/fr/LC_MESSAGES/tcsh: french.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
french.cat: ${srcdir}/french/charset ${srcdir}/french/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/de/LC_MESSAGES/tcsh.cat
-${localedir}/de/LC_MESSAGES/tcsh.cat: german.cat
+INSTALLED+=${localedir}/de/LC_MESSAGES/tcsh
+${localedir}/de/LC_MESSAGES/tcsh: german.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
german.cat: ${srcdir}/german/charset ${srcdir}/german/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/gr/LC_MESSAGES/tcsh.cat
-${localedir}/gr/LC_MESSAGES/tcsh.cat: greek.cat
+INSTALLED+=${localedir}/el_GR/LC_MESSAGES/tcsh
+${localedir}/el_GR/LC_MESSAGES/tcsh: greek.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
greek.cat: ${srcdir}/greek/charset ${srcdir}/greek/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/it/LC_MESSAGES/tcsh.cat
-${localedir}/it/LC_MESSAGES/tcsh.cat: italian.cat
+INSTALLED+=${localedir}/it/LC_MESSAGES/tcsh
+${localedir}/it/LC_MESSAGES/tcsh: italian.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
italian.cat: ${srcdir}/italian/charset ${srcdir}/italian/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/ja/LC_MESSAGES/tcsh.cat
-${localedir}/ja/LC_MESSAGES/tcsh.cat: ja.cat
+INSTALLED+=${localedir}/ja/LC_MESSAGES/tcsh
+${localedir}/ja/LC_MESSAGES/tcsh: ja.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
ja.cat: ${srcdir}/ja/charset ${srcdir}/ja/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/pl/LC_MESSAGES/tcsh.cat
-${localedir}/pl/LC_MESSAGES/tcsh.cat: pl.cat
+INSTALLED+=${localedir}/pl/LC_MESSAGES/tcsh
+${localedir}/pl/LC_MESSAGES/tcsh: pl.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
pl.cat: ${srcdir}/pl/charset ${srcdir}/pl/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/ru/LC_MESSAGES/tcsh.cat
-${localedir}/ru/LC_MESSAGES/tcsh.cat: russian.cat
+INSTALLED+=${localedir}/ru_RU/LC_MESSAGES/tcsh
+${localedir}/ru_RU/LC_MESSAGES/tcsh: russian.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
russian.cat: ${srcdir}/russian/charset ${srcdir}/russian/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/es/LC_MESSAGES/tcsh.cat
-${localedir}/es/LC_MESSAGES/tcsh.cat: spanish.cat
+INSTALLED+=${localedir}/es/LC_MESSAGES/tcsh
+${localedir}/es/LC_MESSAGES/tcsh: spanish.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
spanish.cat: ${srcdir}/spanish/charset ${srcdir}/spanish/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/ru_UA/LC_MESSAGES/tcsh.cat
-${localedir}/ru_UA/LC_MESSAGES/tcsh.cat: ukrainian.cat
+INSTALLED+=${localedir}/ru_UA.koi8u/LC_MESSAGES/tcsh
+${localedir}/ru_UA.koi8u/LC_MESSAGES/tcsh: ukrainian.cat
mkdir -p $(@D)
$(INSTALL) $> $^ $@
--- sh.c --- sh.c
+++ sh.c 2011-11-17 08:28:47.027646998 +0000 +++ sh.c 2011-11-17 08:28:47.000000000 +0000
@@ -168,8 +168,8 @@ static void st_restore (void *); @@ -169,8 +169,8 @@ static void st_restore (void *);
static void static void
add_localedir_to_nlspath(const char *path) add_localedir_to_nlspath(const char *path)
{ {
@ -11,7 +139,7 @@
char *old; char *old;
char *new, *new_p; char *new, *new_p;
size_t len; size_t len;
@@ -181,7 +181,7 @@ add_localedir_to_nlspath(const char *pat @@ -182,7 +182,7 @@ add_localedir_to_nlspath(const char *pat
if (path == NULL) if (path == NULL)
return; return;
@ -20,126 +148,3 @@
path); path);
if (stat(trypath, &st) == -1) if (stat(trypath, &st) == -1)
return; return;
--- nls/Makefile.in
+++ nls/Makefile.in 2012-01-10 16:53:02.899145576 +0000
@@ -16,96 +16,96 @@ CATGEN= ${srcdir}/catgen
all: ${CATALOGS}
-INSTALLED+=${localedir}/C/LC_MESSAGES/tcsh.cat
-${localedir}/C/LC_MESSAGES/tcsh.cat: C.cat
+INSTALLED+=${localedir}/C/LC_MESSAGES/tcsh
+${localedir}/C/LC_MESSAGES/tcsh: C.cat
mkdir -p $(@D)
$(INSTALL) $< $@
C.cat: ${srcdir}/C/charset ${srcdir}/C/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/et/LC_MESSAGES/tcsh.cat
-${localedir}/et/LC_MESSAGES/tcsh.cat: et.cat
+INSTALLED+=${localedir}/et/LC_MESSAGES/tcsh
+${localedir}/et/LC_MESSAGES/tcsh: et.cat
mkdir -p $(@D)
$(INSTALL) $< $@
et.cat: ${srcdir}/et/charset ${srcdir}/et/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/fi/LC_MESSAGES/tcsh.cat
-${localedir}/fi/LC_MESSAGES/tcsh.cat: finnish.cat
+INSTALLED+=${localedir}/fi/LC_MESSAGES/tcsh
+${localedir}/fi/LC_MESSAGES/tcsh: finnish.cat
mkdir -p $(@D)
$(INSTALL) $< $@
finnish.cat: ${srcdir}/finnish/charset ${srcdir}/finnish/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/fr/LC_MESSAGES/tcsh.cat
-${localedir}/fr/LC_MESSAGES/tcsh.cat: french.cat
+INSTALLED+=${localedir}/fr/LC_MESSAGES/tcsh
+${localedir}/fr/LC_MESSAGES/tcsh: french.cat
mkdir -p $(@D)
$(INSTALL) $< $@
french.cat: ${srcdir}/french/charset ${srcdir}/french/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/de/LC_MESSAGES/tcsh.cat
-${localedir}/de/LC_MESSAGES/tcsh.cat: german.cat
+INSTALLED+=${localedir}/de/LC_MESSAGES/tcsh
+${localedir}/de/LC_MESSAGES/tcsh: german.cat
mkdir -p $(@D)
$(INSTALL) $< $@
german.cat: ${srcdir}/german/charset ${srcdir}/german/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/gr/LC_MESSAGES/tcsh.cat
-${localedir}/gr/LC_MESSAGES/tcsh.cat: greek.cat
+INSTALLED+=${localedir}/el/LC_MESSAGES/tcsh
+${localedir}/el/LC_MESSAGES/tcsh: greek.cat
mkdir -p $(@D)
$(INSTALL) $< $@
greek.cat: ${srcdir}/greek/charset ${srcdir}/greek/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/it/LC_MESSAGES/tcsh.cat
-${localedir}/it/LC_MESSAGES/tcsh.cat: italian.cat
+INSTALLED+=${localedir}/it/LC_MESSAGES/tcsh
+${localedir}/it/LC_MESSAGES/tcsh: italian.cat
mkdir -p $(@D)
$(INSTALL) $< $@
italian.cat: ${srcdir}/italian/charset ${srcdir}/italian/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/ja/LC_MESSAGES/tcsh.cat
-${localedir}/ja/LC_MESSAGES/tcsh.cat: ja.cat
+INSTALLED+=${localedir}/ja/LC_MESSAGES/tcsh
+${localedir}/ja/LC_MESSAGES/tcsh: ja.cat
mkdir -p $(@D)
$(INSTALL) $< $@
ja.cat: ${srcdir}/ja/charset ${srcdir}/ja/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/pl/LC_MESSAGES/tcsh.cat
-${localedir}/pl/LC_MESSAGES/tcsh.cat: pl.cat
+INSTALLED+=${localedir}/pl/LC_MESSAGES/tcsh
+${localedir}/pl/LC_MESSAGES/tcsh: pl.cat
mkdir -p $(@D)
$(INSTALL) $< $@
pl.cat: ${srcdir}/pl/charset ${srcdir}/pl/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/ru/LC_MESSAGES/tcsh.cat
-${localedir}/ru/LC_MESSAGES/tcsh.cat: russian.cat
+INSTALLED+=${localedir}/ru_RU/LC_MESSAGES/tcsh
+${localedir}/ru_RU/LC_MESSAGES/tcsh: russian.cat
mkdir -p $(@D)
$(INSTALL) $< $@
russian.cat: ${srcdir}/russian/charset ${srcdir}/russian/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/es/LC_MESSAGES/tcsh.cat
-${localedir}/es/LC_MESSAGES/tcsh.cat: spanish.cat
+INSTALLED+=${localedir}/es/LC_MESSAGES/tcsh
+${localedir}/es/LC_MESSAGES/tcsh: spanish.cat
mkdir -p $(@D)
$(INSTALL) $< $@
spanish.cat: ${srcdir}/spanish/charset ${srcdir}/spanish/*set[0-9]*
@${CATGEN} $(GENCAT) $@ $^ $>
-INSTALLED+=${localedir}/ru_UA.koi8u/LC_MESSAGES/tcsh.cat
-${localedir}/ru_UA.koi8u/LC_MESSAGES/tcsh.cat: ukrainian.cat
+INSTALLED+=${localedir}/uk_UA/LC_MESSAGES/tcsh
+${localedir}/uk_UA/LC_MESSAGES/tcsh: ukrainian.cat
mkdir -p $(@D)
$(INSTALL) $< $@

View File

@ -1,5 +1,9 @@
---
tw.color.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
--- tw.color.c --- tw.color.c
+++ tw.color.c 2010-12-10 16:07:59.000000000 +0000 +++ tw.color.c 2015-05-04 13:33:41.521518502 +0000
@@ -89,6 +89,7 @@ static Variable variables[] = { @@ -89,6 +89,7 @@ static Variable variables[] = {
VAR(NOS, "hl", "44;37"), /* Reg file extra hard links, obsolete? */ VAR(NOS, "hl", "44;37"), /* Reg file extra hard links, obsolete? */
VAR(NOS, "mh", "44;37"), /* Reg file extra hard links */ VAR(NOS, "mh", "44;37"), /* Reg file extra hard links */
@ -7,8 +11,8 @@
+ VAR(NOS, "cl", ""), /* CLRTOEOL */ + VAR(NOS, "cl", ""), /* CLRTOEOL */
}; };
enum FileType { #define nvariables (sizeof(variables)/sizeof(variables[0]))
@@ -177,7 +178,7 @@ parseLS_COLORS(const Char *value) @@ -328,7 +329,7 @@ parseLS_COLORS(const Char *value)
size_t i, len; size_t i, len;
const Char *v; /* pointer in value */ const Char *v; /* pointer in value */
char *c; /* pointer in colors */ char *c; /* pointer in colors */
@ -17,7 +21,7 @@
jmp_buf_t osetexit; jmp_buf_t osetexit;
size_t omark; size_t omark;
@@ -240,13 +241,10 @@ parseLS_COLORS(const Char *value) @@ -385,13 +386,10 @@ parseLS_COLORS(const Char *value)
if ((Char)variables[i].variable[0] == (v[0] & CHAR) && if ((Char)variables[i].variable[0] == (v[0] & CHAR) &&
(Char)variables[i].variable[1] == (v[1] & CHAR)) (Char)variables[i].variable[1] == (v[1] & CHAR))
break; break;
@ -34,7 +38,7 @@
} }
break; break;
} }
@@ -301,12 +303,13 @@ print_color(const Char *fname, size_t le @@ -450,12 +448,13 @@ print_color(const Char *fname, size_t le
break; break;
} }
if (i == nvariables) { if (i == nvariables) {
@ -43,14 +47,14 @@
- && strncmp(last - extensions[i].extension.len, - && strncmp(last - extensions[i].extension.len,
- extensions[i].extension.s, - extensions[i].extension.s,
- extensions[i].extension.len) == 0) { - extensions[i].extension.len) == 0) {
- color = &extensions[i].color; - colorp = &extensions[i].color;
+ int j; + int j;
+ for (j = 0; j < nextensions; j++) + for (j = 0; j < nextensions; j++)
+ if (len >= extensions[j].extension.len + if (len >= extensions[j].extension.len
+ && strncmp(last - extensions[j].extension.len, + && strncmp(last - extensions[j].extension.len,
+ extensions[j].extension.s, + extensions[j].extension.s,
+ extensions[j].extension.len) == 0) { + extensions[j].extension.len) == 0) {
+ color = &extensions[j].color; + colorp = &extensions[j].color;
break; break;
} }
} }

View File

@ -1,4 +1,4 @@
From f813180f2fc1d682dd097e4a05ef4d15000204ad Mon Sep 17 00:00:00 2001 Based on f813180f2fc1d682dd097e4a05ef4d15000204ad Mon Sep 17 00:00:00 2001
From: Roman Kollar <rkollar@redhat.com> From: Roman Kollar <rkollar@redhat.com>
Date: Mon, 29 Oct 2012 17:52:52 +0100 Date: Mon, 29 Oct 2012 17:52:52 +0100
Subject: [PATCH] Add .history file locking - shared readers, exclusive writer Subject: [PATCH] Add .history file locking - shared readers, exclusive writer
@ -14,11 +14,19 @@ https://bugzilla.redhat.com/show_bug.cgi?id=879371
Changes by Fridolin Pokorny <fpokorny@redhat.com> Changes by Fridolin Pokorny <fpokorny@redhat.com>
--- ---
sh.c | 102 +++++++++++++++++++++++++++++++++++++--------------
sh.decls.h | 4 +-
sh.dol.c | 2 -
sh.err.c | 16 ++++++++
sh.h | 18 +++++++++
sh.hist.c | 122 ++++++++++++++++++++++++++++++-------------------------------
sh.lex.c | 8 ++--
sh.sem.c | 2 -
8 files changed, 178 insertions(+), 96 deletions(-)
diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c --- sh.c
--- tcsh-6.18.00_orig/sh.c 2013-03-28 10:06:17.969859477 +0100 +++ sh.c 2015-05-04 13:53:54.000000000 +0000
+++ tcsh-6.18.00_work/sh.c 2013-03-28 10:07:21.155082032 +0100 @@ -141,6 +141,7 @@ struct saved_state {
@@ -140,6 +140,7 @@ struct saved_state {
int cantell; int cantell;
struct Bin B; struct Bin B;
int justpr; int justpr;
@ -26,7 +34,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
}; };
static int srccat (Char *, Char *); static int srccat (Char *, Char *);
@@ -1369,7 +1370,7 @@ main(int argc, char **argv) @@ -1378,7 +1379,7 @@ main(int argc, char **argv)
/* /*
* Source history before .login so that it is available in .login * Source history before .login so that it is available in .login
*/ */
@ -35,7 +43,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
#ifndef LOGINFIRST #ifndef LOGINFIRST
if (loginsh) if (loginsh)
(void) srccat(varval(STRhome), STRsldotlogin); (void) srccat(varval(STRhome), STRsldotlogin);
@@ -1492,7 +1493,7 @@ static int @@ -1501,7 +1502,7 @@ static int
srccat(Char *cp, Char *dp) srccat(Char *cp, Char *dp)
{ {
if (cp[0] == '/' && cp[1] == '\0') if (cp[0] == '/' && cp[1] == '\0')
@ -44,7 +52,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
else { else {
Char *ep; Char *ep;
char *ptr; char *ptr;
@@ -1508,7 +1509,7 @@ srccat(Char *cp, Char *dp) @@ -1517,7 +1518,7 @@ srccat(Char *cp, Char *dp)
cleanup_push(ep, xfree); cleanup_push(ep, xfree);
ptr = short2str(ep); ptr = short2str(ep);
@ -53,7 +61,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
cleanup_until(ep); cleanup_until(ep);
return rv; return rv;
} }
@@ -1522,20 +1523,49 @@ static int @@ -1531,20 +1532,49 @@ static int
#else #else
int int
#endif /*WINNT_NATIVE*/ #endif /*WINNT_NATIVE*/
@ -61,7 +69,8 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
+srcfile(const char *f, int onlyown, int flg, Char **av) +srcfile(const char *f, int onlyown, int flg, Char **av)
{ {
- int unit; - int unit;
- + int *unit;
- if ((unit = xopen(f, O_RDONLY|O_LARGEFILE)) == -1) - if ((unit = xopen(f, O_RDONLY|O_LARGEFILE)) == -1)
- return 0; - return 0;
- cleanup_push(&unit, open_cleanup); - cleanup_push(&unit, open_cleanup);
@ -72,8 +81,6 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
- (void) close_on_exec(unit, 1); - (void) close_on_exec(unit, 1);
- srcunit(unit, onlyown, flag, av); - srcunit(unit, onlyown, flag, av);
- return 1; - return 1;
+ int *unit;
+
+ unit = xmalloc(sizeof(*unit)); + unit = xmalloc(sizeof(*unit));
+ cleanup_push(unit, xfree); + cleanup_push(unit, xfree);
+ *unit = xopen(f, O_LARGEFILE | + *unit = xopen(f, O_LARGEFILE |
@ -116,7 +123,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
} }
@@ -1544,7 +1574,7 @@ srcfile(const char *f, int onlyown, int @@ -1553,7 +1583,7 @@ srcfile(const char *f, int onlyown, int
* fd. * fd.
*/ */
static void static void
@ -125,7 +132,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
{ {
st->insource = insource; st->insource = insource;
st->SHIN = SHIN; st->SHIN = SHIN;
@@ -1593,10 +1623,14 @@ st_save(struct saved_state *st, int unit @@ -1602,10 +1632,14 @@ st_save(struct saved_state *st, int unit
st->onelflg = onelflg; st->onelflg = onelflg;
st->enterhist = enterhist; st->enterhist = enterhist;
st->justpr = justpr; st->justpr = justpr;
@ -141,7 +148,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
st->cantell = cantell; st->cantell = cantell;
cpybin(st->B, B); cpybin(st->B, B);
@@ -1635,7 +1669,7 @@ st_save(struct saved_state *st, int unit @@ -1644,7 +1678,7 @@ st_save(struct saved_state *st, int unit
evalp = 0; evalp = 0;
alvec = al; alvec = al;
alvecp = 0; alvecp = 0;
@ -150,7 +157,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
if (enterhist) if (enterhist)
HIST = '\0'; HIST = '\0';
insource = 1; insource = 1;
@@ -1668,7 +1702,8 @@ st_restore(void *xst) @@ -1677,7 +1711,8 @@ st_restore(void *xst)
} }
cpybin(B, st->B); cpybin(B, st->B);
@ -160,7 +167,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
insource = st->insource; insource = st->insource;
SHIN = st->SHIN; SHIN = st->SHIN;
@@ -1704,7 +1739,7 @@ st_restore(void *xst) @@ -1713,7 +1748,7 @@ st_restore(void *xst)
* we don't chance it. This occurs on ".cshrc"s and the like. * we don't chance it. This occurs on ".cshrc"s and the like.
*/ */
static void static void
@ -169,7 +176,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
{ {
struct saved_state st; struct saved_state st;
@@ -1730,7 +1765,7 @@ srcunit(int unit, int onlyown, int hflg, @@ -1739,7 +1774,7 @@ srcunit(int unit, int onlyown, int hflg,
} }
/* Save the current state and move us to a new state */ /* Save the current state and move us to a new state */
@ -178,7 +185,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
/* /*
* Now if we are allowing commands to be interrupted, we let ourselves be * Now if we are allowing commands to be interrupted, we let ourselves be
@@ -2069,7 +2104,7 @@ process(int catch) @@ -2078,7 +2113,7 @@ process(int catch)
* elsewhere... * elsewhere...
*/ */
if (enterhist || (catch && intty && !whyles && !tellwhat && !arun)) if (enterhist || (catch && intty && !whyles && !tellwhat && !arun))
@ -187,7 +194,7 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
if (Expand && seterr) if (Expand && seterr)
Expand = 0; Expand = 0;
@@ -2156,21 +2191,28 @@ process(int catch) @@ -2165,21 +2200,28 @@ process(int catch)
void void
dosource(Char **t, struct command *c) dosource(Char **t, struct command *c)
{ {
@ -219,16 +226,15 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
} }
f = globone(*t++, G_ERROR); f = globone(*t++, G_ERROR);
@@ -2178,9 +2220,16 @@ dosource(Char **t, struct command *c) @@ -2188,9 +2230,15 @@ dosource(Char **t, struct command *c)
cleanup_push(file, xfree);
xfree(f); xfree(f);
t = glob_all_or_error(t); t = glob_all_or_error(t);
cleanup_push(t, blk_cleanup);
- if ((!srcfile(file, 0, hflg, t)) && (!hflg) && (!bequiet)) - if ((!srcfile(file, 0, hflg, t)) && (!hflg) && (!bequiet))
+ fd = srcfile(file, 0, (flg | newflg), t); + fd = srcfile(file, 0, (flg | newflg), t);
+ if ((!fd) && (!newflg) && (!bequiet)) + if ((!fd) && (!newflg) && (!bequiet))
stderror(ERR_SYSTEM, file, strerror(errno)); stderror(ERR_SYSTEM, file, strerror(errno));
- cleanup_until(file); - cleanup_until(file);
+
+ /* We need to preserve fd and it's cleaning routines on the top of the + /* We need to preserve fd and it's cleaning routines on the top of the
+ * cleaning stack. Don't call cleanup_until() but clean it manually. */ + * cleaning stack. Don't call cleanup_until() but clean it manually. */
+ cleanup_ignore(file); + cleanup_ignore(file);
@ -238,9 +244,8 @@ diff -upr tcsh-6.18.00_orig/sh.c tcsh-6.18.00_work/sh.c
} }
/* /*
diff -upr tcsh-6.18.00_orig/sh.decls.h tcsh-6.18.00_work/sh.decls.h --- sh.decls.h
--- tcsh-6.18.00_orig/sh.decls.h 2013-03-28 10:06:17.988859538 +0100 +++ sh.decls.h 2015-05-04 13:56:16.000000000 +0000
+++ tcsh-6.18.00_work/sh.decls.h 2013-03-28 10:06:42.897948590 +0100
@@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
*/ */
extern Char *gethdir (const Char *); extern Char *gethdir (const Char *);
@ -249,7 +254,7 @@ diff -upr tcsh-6.18.00_orig/sh.decls.h tcsh-6.18.00_work/sh.decls.h
extern void exitstat (void); extern void exitstat (void);
extern void goodbye (Char **, struct command *); extern void goodbye (Char **, struct command *);
extern void importpath (Char *); extern void importpath (Char *);
@@ -98,6 +99,7 @@ extern void cleanup_until_mark(void); @@ -99,6 +100,7 @@ extern void cleanup_until_mark(void);
extern size_t cleanup_push_mark(void); extern size_t cleanup_push_mark(void);
extern void cleanup_pop_mark(size_t); extern void cleanup_pop_mark(size_t);
extern void open_cleanup(void *); extern void open_cleanup(void *);
@ -257,19 +262,18 @@ diff -upr tcsh-6.18.00_orig/sh.decls.h tcsh-6.18.00_work/sh.decls.h
extern void opendir_cleanup(void *); extern void opendir_cleanup(void *);
extern void sigint_cleanup(void *); extern void sigint_cleanup(void *);
extern void sigprocmask_cleanup(void *); extern void sigprocmask_cleanup(void *);
@@ -219,7 +221,7 @@ extern struct Hist *enthist (int, str @@ -220,7 +222,7 @@ extern struct Hist *enthist (int, str
extern void savehist (struct wordent *, int); extern void savehist (struct wordent *, int);
extern char *fmthist (int, ptr_t); extern char *fmthist (int, ptr_t);
extern void rechist (Char *, int); extern void rechist (Char *, int);
-extern void loadhist (Char *, int); -extern void loadhist (Char *, int);
+extern int loadhist (Char *, int); +extern int loadhist (Char *, int);
extern void displayHistStats(const char *); extern void displayHistStats(const char *);
extern void sethistory (int);
/* --- sh.dol.c
diff -upr tcsh-6.18.00_orig/sh.dol.c tcsh-6.18.00_work/sh.dol.c +++ sh.dol.c 2013-03-28 09:06:43.000000000 +0000
--- tcsh-6.18.00_orig/sh.dol.c 2013-03-28 10:06:17.988859538 +0100 @@ -1120,6 +1120,6 @@ again:
+++ tcsh-6.18.00_work/sh.dol.c 2013-03-28 10:06:42.898948594 +0100
@@ -1110,6 +1110,6 @@ again:
*obp = 0; *obp = 0;
tmp = short2str(obuf); tmp = short2str(obuf);
(void) xwrite(0, tmp, strlen (tmp)); (void) xwrite(0, tmp, strlen (tmp));
@ -277,9 +281,8 @@ diff -upr tcsh-6.18.00_orig/sh.dol.c tcsh-6.18.00_work/sh.dol.c
+ (void) lseek(0, (off_t) 0, SEEK_SET); + (void) lseek(0, (off_t) 0, SEEK_SET);
cleanup_until(&inheredoc); cleanup_until(&inheredoc);
} }
diff -upr tcsh-6.18.00_orig/sh.err.c tcsh-6.18.00_work/sh.err.c --- sh.err.c
--- tcsh-6.18.00_orig/sh.err.c 2013-03-28 10:06:17.972859480 +0100 +++ sh.err.c 2013-03-28 09:06:43.000000000 +0000
+++ tcsh-6.18.00_work/sh.err.c 2013-03-28 10:06:42.824948331 +0100
@@ -514,6 +514,22 @@ open_cleanup(void *xptr) @@ -514,6 +514,22 @@ open_cleanup(void *xptr)
} }
@ -303,9 +306,8 @@ diff -upr tcsh-6.18.00_orig/sh.err.c tcsh-6.18.00_work/sh.err.c
opendir_cleanup(void *xdir) opendir_cleanup(void *xdir)
{ {
DIR *dir; DIR *dir;
diff -upr tcsh-6.18.00_orig/sh.h tcsh-6.18.00_work/sh.h --- sh.h
--- tcsh-6.18.00_orig/sh.h 2013-03-28 10:06:17.988859538 +0100 +++ sh.h 2013-03-28 09:06:43.000000000 +0000
+++ tcsh-6.18.00_work/sh.h 2013-03-28 10:06:42.899948597 +0100
@@ -50,6 +50,24 @@ @@ -50,6 +50,24 @@
# include <inttypes.h> # include <inttypes.h>
#endif #endif
@ -331,10 +333,18 @@ diff -upr tcsh-6.18.00_orig/sh.h tcsh-6.18.00_work/sh.h
#if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H) && !defined(WINNT_NATIVE) #if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H) && !defined(WINNT_NATIVE)
typedef unsigned long intptr_t; typedef unsigned long intptr_t;
#endif #endif
diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c --- sh.hist.c
--- tcsh-6.18.00_orig/sh.hist.c 2013-03-28 10:06:17.967859465 +0100 +++ sh.hist.c 2015-05-04 14:51:57.995328370 +0000
+++ tcsh-6.18.00_work/sh.hist.c 2013-03-28 10:06:42.815948309 +0100 @@ -36,6 +36,8 @@ RCSID("$tcsh: sh.hist.c,v 3.60 2015/02/2
@@ -44,14 +44,6 @@ Char HistLit = 0;
#include <stdio.h> /* for rename(2), grr. */
#include <assert.h>
+#include <unistd.h>
+#include <sys/types.h>
#include "tc.h"
#include "dotlock.h"
@@ -46,14 +48,6 @@ Char HistLit = 0;
static int heq (const struct wordent *, const struct wordent *); static int heq (const struct wordent *, const struct wordent *);
static void hfree (struct Hist *); static void hfree (struct Hist *);
@ -349,34 +359,32 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
/* /*
* C shell * C shell
*/ */
@@ -143,7 +135,7 @@ discardExcess(int histlen) @@ -145,13 +139,13 @@ discardExcess(int hlen)
void void
savehist( savehist(
struct wordent *sp, struct wordent *sp,
- int mflg) /* true if -m (merge) specified */ - int mflg) /* true if -m (merge) specified */
+ int flg) + int flg) /* true if -m (merge) specified */
{ {
int histlen = 0; /* throw away null lines */
Char *cp; if (sp && sp->next->word[0] == '\n')
@@ -160,7 +152,7 @@ savehist( return;
histlen = histlen * 10 + *cp++ - '0';
}
if (sp) if (sp)
- (void) enthist(++eventno, sp, 1, mflg, histlen); - (void) enthist(++eventno, sp, 1, mflg, histlen);
+ (void) enthist(++eventno, sp, 1, flg, histlen); + (void) enthist(++eventno, sp, 1, flg, histlen);
discardExcess(histlen); discardExcess(histlen);
} }
@@ -933,7 +925,7 @@ enthist( @@ -923,7 +917,7 @@ enthist(
int event, /* newly incremented global eventno */ int event, /* newly incremented global eventno */
struct wordent *lp, struct wordent *lp,
int docopy, int docopy,
- int mflg, /* true if merge requested */ - int mflg, /* true if merge requested */
+ int flg, + int flg, /* true if merge requested */
int histlen) /* -1 if unknown */ int hlen) /* -1 if unknown */
{ {
struct Hist *p = NULL, *pp = &Histlist, *pTime = NULL; struct Hist *p = NULL, *pp = &Histlist, *pTime = NULL;
@@ -953,7 +945,7 @@ enthist( @@ -943,7 +937,7 @@ enthist(
Htime = p->Htime; Htime = p->Htime;
/* If we are merging, and the old entry is at the place we want /* If we are merging, and the old entry is at the place we want
* to insert the new entry, then remember the place. */ * to insert the new entry, then remember the place. */
@ -385,7 +393,7 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
pTime = p->Hprev; pTime = p->Hprev;
if (!fastMergeErase) if (!fastMergeErase)
renumberHist(p); /* Reset Href of subsequent entries */ renumberHist(p); /* Reset Href of subsequent entries */
@@ -1012,7 +1004,7 @@ enthist( @@ -1002,7 +996,7 @@ enthist(
/* The head of history list is the default insertion point. /* The head of history list is the default insertion point.
If merging, advance insertion point, in pp, according to Htime. */ If merging, advance insertion point, in pp, according to Htime. */
/* XXX -- In histdup=all, Htime values can be non-monotonic. */ /* XXX -- In histdup=all, Htime values can be non-monotonic. */
@ -394,19 +402,21 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
pp = mergeInsertionPoint(np, pTime); pp = mergeInsertionPoint(np, pTime);
for (p = pp->Hnext; p && p->Htime == np->Htime; pp = p, p = p->Hnext) { for (p = pp->Hnext; p && p->Htime == np->Htime; pp = p, p = p->Hnext) {
if (heq(&p->Hlex, &np->Hlex)) { if (heq(&p->Hlex, &np->Hlex)) {
@@ -1051,9 +1043,9 @@ hfree(struct Hist *hp) @@ -1041,11 +1035,11 @@ hfree(struct Hist *hp)
} }
PG_STATIC void PG_STATIC void
-phist(struct Hist *hp, int hflg) -phist(struct Hist *hp, int hflg)
+phist(struct Hist *hp, int flg) +phist(struct Hist *hp, int flg)
{ {
if (hp->Href < 0)
return;
- if (hflg & HIST_ONLY) { - if (hflg & HIST_ONLY) {
+ if (flg & HIST_ONLY) { + if (flg & HIST_ONLY) {
int old_output_raw; int old_output_raw;
/* /*
@@ -1065,7 +1057,7 @@ phist(struct Hist *hp, int hflg) @@ -1057,7 +1051,7 @@ phist(struct Hist *hp, int hflg)
old_output_raw = output_raw; old_output_raw = output_raw;
output_raw = 1; output_raw = 1;
cleanup_push(&old_output_raw, output_raw_restore); cleanup_push(&old_output_raw, output_raw_restore);
@ -415,7 +425,7 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
/* /*
* Make file entry with history time in format: * Make file entry with history time in format:
* "+NNNNNNNNNN" (10 digits, left padded with ascii '0') * "+NNNNNNNNNN" (10 digits, left padded with ascii '0')
@@ -1096,7 +1088,7 @@ phist(struct Hist *hp, int hflg) @@ -1088,7 +1082,7 @@ phist(struct Hist *hp, int hflg)
} }
PG_STATIC void PG_STATIC void
@ -424,7 +434,7 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
{ {
struct Hist *hp; struct Hist *hp;
if (setintr) { if (setintr) {
@@ -1105,7 +1097,7 @@ dophist(int n, int hflg) @@ -1097,7 +1091,7 @@ dophist(int n, int hflg)
pintr_push_enable(&old_pintr_disabled); pintr_push_enable(&old_pintr_disabled);
cleanup_until(&old_pintr_disabled); cleanup_until(&old_pintr_disabled);
} }
@ -433,7 +443,7 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
/* Since the history list is stored most recent first, non-reversing /* Since the history list is stored most recent first, non-reversing
* print needs to print (backwards) up the list. */ * print needs to print (backwards) up the list. */
if ((unsigned)n >= histCount) if ((unsigned)n >= histCount)
@@ -1119,10 +1111,10 @@ dophist(int n, int hflg) @@ -1111,10 +1105,10 @@ dophist(int n, int hflg)
if (hp == NULL) if (hp == NULL)
return; /* nothing to print */ return; /* nothing to print */
for (; hp != &Histlist; hp = hp->Hprev) for (; hp != &Histlist; hp = hp->Hprev)
@ -446,7 +456,7 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
} }
} }
@@ -1130,7 +1122,7 @@ dophist(int n, int hflg) @@ -1122,7 +1116,7 @@ dophist(int n, int hflg)
void void
dohist(Char **vp, struct command *c) dohist(Char **vp, struct command *c)
{ {
@ -455,7 +465,7 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
USE(c); USE(c);
if (getn(varval(STRhistory)) == 0) if (getn(varval(STRhistory)) == 0)
@@ -1141,40 +1133,40 @@ dohist(Char **vp, struct command *c) @@ -1133,40 +1127,40 @@ dohist(Char **vp, struct command *c)
while (*++vp2) while (*++vp2)
switch (*vp2) { switch (*vp2) {
case 'c': case 'c':
@ -507,7 +517,7 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
rechist(*vp, 1); rechist(*vp, 1);
else { else {
if (*vp) if (*vp)
@@ -1182,7 +1174,7 @@ dohist(Char **vp, struct command *c) @@ -1174,7 +1168,7 @@ dohist(Char **vp, struct command *c)
else { else {
n = getn(varval(STRhistory)); n = getn(varval(STRhistory));
} }
@ -516,53 +526,24 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
} }
} }
@@ -1224,8 +1216,8 @@ fmthist(int fmt, ptr_t ptr) @@ -1222,10 +1216,9 @@ dotlock_cleanup(void* lockpath)
void void
rechist(Char *fname, int ref) rechist(Char *fname, int ref)
{ {
- Char *snum; - Char *snum, *rs;
- int fp, ftmp, oldidfds; - int fp, ftmp, oldidfds;
+ Char *snum; + Char *snum;
+ int fd = -1, ftmp, oldidfds; + int fd = -1, ftmp, oldidfds;
struct varent *shist; struct varent *shist;
- char path[MAXPATHLEN];
struct stat st;
static Char *dumphist[] = {STRhistory, STRmhT, 0, 0}; static Char *dumphist[] = {STRhistory, STRmhT, 0, 0};
@@ -1255,15 +1247,12 @@ rechist(Char *fname, int ref) @@ -1294,46 +1287,49 @@ rechist(Char *fname, int ref)
* with numerous shells being in simultaneous use. Imagine cleanup_push(lockpath, dotlock_cleanup);
* any kind of window system. All these shells 'share' the same #endif
* ~/.history file for recording their command line history. }
- * Currently the automatic merge can only succeed when the shells
- * nicely quit one after another.
- *
- * Users that like to nuke their environment require here an atomic
- * loadhist-creat-dohist(dumphist)-close
- * sequence.
*
- * jw.
- */
+ * Atomic merge loadhist-creat/ftrunc-dohist(dumphist)-close
+ * implemented using fcntl (shared readers, exclusive writer)
+ * by Vojtech Vitek (V-Teq) <vvitek@redhat.com>.
+ */
+
/*
* We need the didfds stuff before loadhist otherwise
* exec in a script will fail to print if merge is set.
@@ -1271,32 +1260,42 @@ rechist(Char *fname, int ref)
*/
oldidfds = didfds;
didfds = 0;
- if ((shist = adrof(STRsavehist)) != NULL && shist->vec != NULL)
- if (shist->vec[1] && eq(shist->vec[1], STRmerge))
- loadhist(fname, 1); - loadhist(fname, 1);
-
- fp = xcreat(short2str(fname), 0600);
- cleanup_until(fname);
- if (fp == -1) {
- didfds = oldidfds;
- return;
+ if (((shist = adrof(STRsavehist)) != NULL && shist->vec != NULL) &&
+ (shist->vec[1] && eq(shist->vec[1], STRmerge))) {
+ /* Read .history file, leave it's fd open for writing. */ + /* Read .history file, leave it's fd open for writing. */
+ fd = loadhist(fname, HIST_MERGE|HIST_FILE_WRLCK|HIST_FILE_OPEN|HIST_FILE_LOCK); + fd = loadhist(fname, HIST_MERGE|HIST_FILE_WRLCK|HIST_FILE_OPEN|HIST_FILE_LOCK);
+ if (fd > 0) { + if (fd > 0) {
@ -570,29 +551,50 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
+ (void) ftruncate(fd, 0); + (void) ftruncate(fd, 0);
+ (void) lseek(fd, (off_t) 0, SEEK_SET); + (void) lseek(fd, (off_t) 0, SEEK_SET);
+ } + }
+ } }
}
- rs = randsuf();
- xsnprintf(path, sizeof(path), "%S.%S", fname, rs);
- xfree(rs);
-
- fp = xcreat(path, 0600);
- if (fp == -1) {
- didfds = oldidfds;
- cleanup_until(fname);
- return;
+ if (fd <= 0) { + if (fd <= 0) {
+ /* Open .history file for writing (if not open yet). */ + /* Open .history file for writing (if not open yet). */
+ fd = xopen(short2str(fname), O_LARGEFILE|O_CREAT|O_WRONLY|O_TRUNC, 0600); + fd = xopen(short2str(fname), O_LARGEFILE|O_CREAT|O_WRONLY|O_TRUNC, 0600);
+ if (fd != -1) + if (fd != -1)
+ cleanup_push(&fd, open_cleanup); + cleanup_push(&fd, open_cleanup);
+ }
+ if (fd != -1) {
+ ftmp = SHOUT;
+ SHOUT = fd;
+ dumphist[2] = snum;
+ /* Write history to the .history file. */
+ dohist(dumphist, NULL);
+ SHOUT = ftmp;
} }
/* Try to preserve ownership and permissions of the original history file */
#ifndef WINNT_NATIVE
if (stat(short2str(fname), &st) != -1) {
- TCSH_IGNORE(fchown(fp, st.st_uid, st.st_gid));
- TCSH_IGNORE(fchmod(fp, st.st_mode));
+ TCSH_IGNORE(fchown(fd, st.st_uid, st.st_gid));
+ TCSH_IGNORE(fchmod(fd, st.st_mode));
}
#else
UNREFERENCED_PARAMETER(st);
#endif
- ftmp = SHOUT; - ftmp = SHOUT;
- SHOUT = fp; - SHOUT = fp;
- dumphist[2] = snum; - dumphist[2] = snum;
- dohist(dumphist, NULL); - dohist(dumphist, NULL);
- xclose(fp); - xclose(fp);
- SHOUT = ftmp; - SHOUT = ftmp;
+ if (fd != -1) {
+ ftmp = SHOUT;
+ SHOUT = fd;
+ dumphist[2] = snum;
+ dohist(dumphist, NULL);
+ SHOUT = ftmp;
+ }
didfds = oldidfds; didfds = oldidfds;
+ cleanup_until(fname); - (void)rename(path, short2str(fname));
cleanup_until(fname);
} }
@ -609,7 +611,7 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
if (fname != NULL) if (fname != NULL)
loadhist_cmd[2] = fname; loadhist_cmd[2] = fname;
@@ -1305,15 +1304,17 @@ loadhist(Char *fname, int mflg) @@ -1342,17 +1338,19 @@ loadhist(Char *fname, int mflg)
else else
loadhist_cmd[2] = STRtildothist; loadhist_cmd[2] = STRtildothist;
@ -631,9 +633,10 @@ diff -upr tcsh-6.18.00_orig/sh.hist.c tcsh-6.18.00_work/sh.hist.c
+ +
+ return fd; /* Valid/invalid file descriptor (>FSAVE, -1). Zero on error. */ + return fd; /* Valid/invalid file descriptor (>FSAVE, -1). Zero on error. */
} }
diff -upr tcsh-6.18.00_orig/sh.lex.c tcsh-6.18.00_work/sh.lex.c
--- tcsh-6.18.00_orig/sh.lex.c 2013-03-28 10:06:17.971859478 +0100 void
+++ tcsh-6.18.00_work/sh.lex.c 2013-03-28 10:06:42.820948316 +0100 --- sh.lex.c
+++ sh.lex.c 2013-03-28 09:06:43.000000000 +0000
@@ -1595,7 +1595,7 @@ wide_read(int fildes, Char *buf, size_t @@ -1595,7 +1595,7 @@ wide_read(int fildes, Char *buf, size_t
/* Throwing away possible partial multibyte characters on error if the /* Throwing away possible partial multibyte characters on error if the
stream is not seekable */ stream is not seekable */
@ -670,10 +673,9 @@ diff -upr tcsh-6.18.00_orig/sh.lex.c tcsh-6.18.00_work/sh.lex.c
return; return;
fbuf = xcalloc(2, sizeof(Char **)); fbuf = xcalloc(2, sizeof(Char **));
fblocks = 1; fblocks = 1;
diff -upr tcsh-6.18.00_orig/sh.sem.c tcsh-6.18.00_work/sh.sem.c --- sh.sem.c
--- tcsh-6.18.00_orig/sh.sem.c 2013-03-28 10:06:17.970859477 +0100 +++ sh.sem.c 2013-03-28 09:06:43.000000000 +0000
+++ tcsh-6.18.00_work/sh.sem.c 2013-03-28 10:06:42.819948308 +0100 @@ -903,7 +903,7 @@ doio(struct command *t, int *pipein, int
@@ -892,7 +892,7 @@ doio(struct command *t, int *pipein, int
fd = xopen(tmp, O_WRONLY|O_APPEND|O_LARGEFILE); fd = xopen(tmp, O_WRONLY|O_APPEND|O_LARGEFILE);
#else /* !O_APPEND */ #else /* !O_APPEND */
fd = xopen(tmp, O_WRONLY|O_LARGEFILE); fd = xopen(tmp, O_WRONLY|O_LARGEFILE);

View File

@ -0,0 +1,60 @@
---
sh.hist.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
--- sh.hist.c
+++ sh.hist.c 2015-05-05 07:16:26.382084939 +0000
@@ -103,7 +103,7 @@ hremove(struct Hist *hp)
/* Prune length of history list to specified size by history variable. */
PG_STATIC void
-discardExcess(int hlen)
+discardExcess(int hlen, int flg)
{
struct Hist *hp, *np;
if (histTail == NULL) {
@@ -114,7 +114,7 @@ discardExcess(int hlen)
* the list is still too long scan the whole list as before. But only do a
* full scan if the list is more than 6% (1/16th) too long. */
while (histCount > (unsigned)hlen && (np = Histlist.Hnext)) {
- if (eventno - np->Href >= hlen || hlen == 0)
+ if ((eventno - np->Href >= hlen || hlen == 0) && ! (flg & HIST_MERGE))
hremove(np), hfree(np);
else
break;
@@ -129,7 +129,7 @@ discardExcess(int hlen)
return; /* don't bother doing the full scan */
for (hp = &Histlist; histCount > (unsigned)hlen &&
(np = hp->Hnext) != NULL;)
- if (eventno - np->Href >= hlen || hlen == 0)
+ if ((eventno - np->Href >= hlen || hlen == 0) || flg & HIST_MERGE)
hremove(np), hfree(np);
else
hp = np;
@@ -146,7 +146,7 @@ savehist(
return;
if (sp)
(void) enthist(++eventno, sp, 1, flg, histlen);
- discardExcess(histlen);
+ discardExcess(histlen, flg);
}
#define USE_JENKINS_HASH 1
@@ -1357,5 +1357,16 @@ void
sethistory(int n)
{
histlen = n;
- discardExcess(histlen);
+ int merge = 0;
+ struct varent *shist;
+ if ((shist = adrof(STRsavehist)) != NULL && shist->vec != NULL) {
+ size_t i;
+ for (i = 1; shist->vec[i]; i++) {
+ if (eq(shist->vec[i], STRmerge)) {
+ merge = HIST_MERGE;
+ break;
+ }
+ }
+ }
+ discardExcess(histlen, merge);
}

View File

@ -1,13 +1,21 @@
--- Makefile.in ---
+++ Makefile.in 2011-11-16 12:12:02.000000000 +0000 config/linux | 7 +++++++
@@ -599,7 +599,6 @@ install: tcsh$(EXEEXT) install.catalogs config_f.h | 13 +++++++++----
-mkdir -p ${DESTBIN} configure | 2 +-
-mv -f ${DESTBIN}/tcsh$(EXEEXT) ${DESTBIN}/tcsh.old configure.ac | 2 +-
cp tcsh$(EXEEXT) ${DESTBIN}/tcsh$(EXEEXT) glob.h | 3 ++-
- -strip ${DESTBIN}/tcsh$(EXEEXT) pathnames.h | 2 +-
chmod 755 ${DESTBIN}/tcsh$(EXEEXT) sh.c | 3 +++
sh.h | 2 +-
sh.print.c | 8 ++++----
tc.alloc.c | 10 ++++++----
tc.func.c | 8 ++++++--
tc.str.c | 2 +-
tc.who.c | 3 +++
tcsh.man | 2 +-
tw.h | 4 ++++
15 files changed, 50 insertions(+), 21 deletions(-)
install.catalogs:
--- config/linux --- config/linux
+++ config/linux 2011-11-16 12:15:09.000000000 +0000 +++ config/linux 2011-11-16 12:15:09.000000000 +0000
@@ -132,4 +132,11 @@ @@ -132,4 +132,11 @@
@ -67,7 +75,7 @@
# else # else
--- configure --- configure
+++ configure 2011-11-16 10:49:20.000000000 +0000 +++ configure 2011-11-16 10:49:20.000000000 +0000
@@ -3794,7 +3794,7 @@ return tgetent (); @@ -4277,7 +4277,7 @@ return tgetent ();
return 0; return 0;
} }
_ACEOF _ACEOF
@ -76,9 +84,9 @@
if test -z "$ac_lib"; then if test -z "$ac_lib"; then
ac_res="none required" ac_res="none required"
else else
--- configure.in --- configure.ac
+++ configure.in 2011-11-16 10:49:09.000000000 +0000 +++ configure.ac 2015-05-04 14:27:52.000000000 +0000
@@ -298,7 +298,7 @@ fi @@ -309,7 +309,7 @@ fi
dnl Checks for libraries dnl Checks for libraries
AC_SEARCH_LIBS(crypt, crypt) AC_SEARCH_LIBS(crypt, crypt)
AC_SEARCH_LIBS(getspnam, sec) AC_SEARCH_LIBS(getspnam, sec)
@ -119,7 +127,7 @@
--- sh.c --- sh.c
+++ sh.c 2010-12-10 16:10:45.000000000 +0000 +++ sh.c 2010-12-10 16:10:45.000000000 +0000
@@ -1353,6 +1353,9 @@ main(int argc, char **argv) @@ -1365,6 +1365,9 @@ main(int argc, char **argv)
setintr = osetintr; setintr = osetintr;
parintr = oparintr; parintr = oparintr;
} }
@ -129,36 +137,79 @@
#ifdef LOGINFIRST #ifdef LOGINFIRST
if (loginsh) if (loginsh)
(void) srccat(varval(STRhome), STRsldotlogin); (void) srccat(varval(STRhome), STRsldotlogin);
--- sh.h
+++ sh.h 2015-05-05 07:20:23.946019208 +0000
@@ -580,7 +580,7 @@ EXTERN int neednote IZERO; /* Need to
EXTERN int noexec IZERO; /* Don't execute, just syntax check */
EXTERN int pjobs IZERO; /* want to print jobs if interrupted */
EXTERN int setintr IZERO; /* Set interrupts on/off -> Wait intr... */
-EXTERN int handle_intr IZERO;/* Are we currently handling an interrupt? */
+EXTERN int handle_interrupt IZERO;/* Are we currently handling an interrupt? */
EXTERN int havhash IZERO; /* path hashing is available */
EXTERN int editing IZERO; /* doing filename expansion and line editing */
EXTERN int noediting IZERO; /* initial $term defaulted to noedit */
--- sh.print.c
+++ sh.print.c 2015-05-05 07:21:25.381518880 +0000
@@ -231,13 +231,13 @@ flush(void)
return;
if (GettingInput && !Tty_raw_mode && linp < &linbuf[sizeof linbuf - 10])
return;
- if (handle_intr)
+ if (handle_interrupt)
exitset = 1;
if (interrupted) {
interrupted = 0;
linp = linbuf; /* avoid recursion as stderror calls flush */
- if (handle_intr)
+ if (handle_interrupt)
fixerror();
else
stderror(ERR_SILENT);
@@ -298,11 +298,11 @@ flush(void)
case EDQUOT:
#endif
/* Nothing to do, but die */
- if (handle_intr == 0)
+ if (handle_interrupt == 0)
xexit(1);
/*FALLTHROUGH*/
default:
- if (handle_intr)
+ if (handle_interrupt)
fixerror();
else
stderror(ERR_SILENT);
--- tc.alloc.c --- tc.alloc.c
+++ tc.alloc.c 2006-04-25 12:58:31.000000000 +0000 +++ tc.alloc.c 2015-05-04 14:29:30.000000000 +0000
@@ -489,7 +489,7 @@ smalloc(size_t n) @@ -514,7 +514,7 @@ smalloc(size_t n)
{ {
ptr_t ptr; ptr_t ptr;
- n = n ? n : 1; - n = n ? n : 1;
+ n = n ? n+1 : 1; + n = n ? n+1 : 1;
#ifdef HAVE_SBRK #ifdef USE_SBRK
if (membot == NULL) if (membot == NULL)
@@ -512,7 +512,7 @@ srealloc(ptr_t p, size_t n) @@ -537,7 +537,7 @@ srealloc(ptr_t p, size_t n)
{ {
ptr_t ptr; ptr_t ptr;
- n = n ? n : 1; - n = n ? n : 1;
+ n = n ? n+1 : 1; + n = n ? n+1 : 1;
#ifdef HAVE_SBRK #ifdef USE_SBRK
if (membot == NULL) if (membot == NULL)
@@ -536,7 +536,7 @@ scalloc(size_t s, size_t n) @@ -561,7 +561,7 @@ scalloc(size_t s, size_t n)
ptr_t ptr; ptr_t ptr;
n *= s; n *= s;
- n = n ? n : 1; - n = n ? n : 1;
+ n = n ? n+1 : 1; + n = n ? n+1 : 1;
#ifdef HAVE_SBRK #ifdef USE_SBRK
if (membot == NULL) if (membot == NULL)
@@ -561,8 +561,10 @@ scalloc(size_t s, size_t n) @@ -586,8 +586,10 @@ scalloc(size_t s, size_t n)
void void
sfree(ptr_t p) sfree(ptr_t p)
{ {
@ -172,7 +223,7 @@
#endif /* SYSMALLOC */ #endif /* SYSMALLOC */
--- tc.func.c --- tc.func.c
+++ tc.func.c 2007-07-13 11:15:03.000000000 +0000 +++ tc.func.c 2007-07-13 11:15:03.000000000 +0000
@@ -689,9 +689,13 @@ auto_lock(void) @@ -714,9 +714,13 @@ auto_lock(void)
handle_pending_signals(); handle_pending_signals();
errno = 0; errno = 0;
} }
@ -187,7 +238,7 @@
#else #else
@@ -1905,7 +1909,7 @@ getremotehost(int dest_fd) @@ -1933,7 +1937,7 @@ getremotehost(int dest_fd)
* have not caught up yet. * have not caught up yet.
*/ */
addr.s_addr = inet_addr(name); addr.s_addr = inet_addr(name);
@ -198,7 +249,7 @@
if (sptr != name) { if (sptr != name) {
--- tc.str.c --- tc.str.c
+++ tc.str.c 2006-04-25 12:58:31.000000000 +0000 +++ tc.str.c 2006-04-25 12:58:31.000000000 +0000
@@ -336,7 +336,7 @@ s_strlen(const Char *str) @@ -342,7 +342,7 @@ s_strlen(const Char *str)
{ {
size_t n; size_t n;
@ -208,8 +259,8 @@
return (n); return (n);
} }
--- tc.who.c --- tc.who.c
+++ tc.who.c 2012-01-16 09:55:14.275144702 +0000 +++ tc.who.c 2012-01-16 09:55:14.000000000 +0000
@@ -277,6 +277,9 @@ watch_login(int force) @@ -280,6 +280,9 @@ watch_login(int force)
} }
stlast = sta.st_mtime; stlast = sta.st_mtime;
#if defined(HAVE_GETUTENT) || defined(HAVE_GETUTXENT) #if defined(HAVE_GETUTENT) || defined(HAVE_GETUTXENT)
@ -221,7 +272,7 @@
if ((utmpfd = xopen(TCSH_PATH_UTMP, O_RDONLY|O_LARGEFILE)) < 0) { if ((utmpfd = xopen(TCSH_PATH_UTMP, O_RDONLY|O_LARGEFILE)) < 0) {
--- tcsh.man --- tcsh.man
+++ tcsh.man 2006-04-25 12:58:31.000000000 +0000 +++ tcsh.man 2006-04-25 12:58:31.000000000 +0000
@@ -578,7 +578,7 @@ Repeating \fIdabbrev-expand\fR without a @@ -579,7 +579,7 @@ Repeating \fIdabbrev-expand\fR without a
changes to the next previous word etc., skipping identical matches changes to the next previous word etc., skipping identical matches
much like \fIhistory-search-backward\fR does. much like \fIhistory-search-backward\fR does.
.TP 8 .TP 8

3
tcsh-6.18.04.tar.gz Normal file
View File

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

View File

@ -1,3 +1,37 @@
-------------------------------------------------------------------
Tue May 5 10:16:14 UTC 2015 - werner@suse.de
- Update tcsh to patch level 6.18.04 - 20150504
* revert fix echo "\1", it is incorrect.
* revert fix to PR/437, breaks short strings.
-------------------------------------------------------------------
Mon May 4 10:16:14 UTC 2015 - werner@suse.de
- Update tcsh to patch level 6.18.03 - 20150503
* PR/437: Nakajima Akira: Fix segmentation fault reading input files
* PR/291: Print job status messages to stderr.
* Fridolin Pokorny NUL in `` does not mean EOF.
* Pavel Raiskup fix hang with:
while (1)
( date & ; wait )
end
* Add cdtohome special variable (Martin Tournoij)
* Fix root prompt char for windows (Corinna Vinschen)
* For "next" completion matches only consider exact matches of the
previous word (Jamie Landeg-Jones)
* Fix echo "\1" for echo_style=both where the first character was
not processed properly (Gary Duzan)
- Remove patches now upstream
* tcsh-6.18.01-blk_buf.patch
* tcsh-6.18.01-metakey.patch
- Rename patches
tcsh-6.17.03-colorls.dif becomes tcsh-6.18.03-colorls.dif
tcsh-6.17.10-catalogs.dif becomes tcsh-6.18.03-catalogs.dif
tcsh-6.18.00-history-file-locking.patch becomes tcsh-6.18.03-history-file-locking.patch
tcsh-6.18.01-history-merge.dif becomes tcsh-6.18.03-history-merge.dif
tcsh-6.18.00.dif becomes tcsh-6.18.03.dif
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Jan 30 13:15:39 UTC 2015 - werner@suse.de Fri Jan 30 13:15:39 UTC 2015 - werner@suse.de

View File

@ -17,26 +17,24 @@
Name: tcsh Name: tcsh
Version: 6.18.01 Version: 6.18.04
Release: 0 Release: 0
Summary: The C SHell Summary: The C SHell
License: BSD-3-Clause License: BSD-3-Clause
Group: System/Shells Group: System/Shells
Url: http://www.tcsh.org/ Url: http://www.tcsh.org/
Source: ftp.astron.com:/pub/tcsh/tcsh-6.18.01.tar.gz Source: ftp.astron.com:/pub/tcsh/tcsh-6.18.04.tar.gz
Source2: bindkey.tcsh Source2: bindkey.tcsh
Source3: complete.tcsh Source3: complete.tcsh
Patch0: tcsh-6.18.00.dif Patch0: tcsh-6.18.03.dif
Patch1: tcsh-6.15.00-pipe.dif Patch1: tcsh-6.15.00-pipe.dif
Patch2: tcsh-6.16.00-norm-cmd.dif Patch2: tcsh-6.16.00-norm-cmd.dif
Patch4: tcsh-6.17.03-colorls.dif Patch4: tcsh-6.18.03-colorls.dif
Patch5: tcsh-6.17.06-dspmbyte.dif Patch5: tcsh-6.17.06-dspmbyte.dif
Patch6: tcsh-6.17.10-catalogs.dif Patch6: tcsh-6.18.03-catalogs.dif
Patch7: tcsh-6.18.01-blk_buf.patch
Patch8: tcsh-6.18.01-metakey.patch
# PATCH-FIX-SUSE add history file locking (bsc#901076) # PATCH-FIX-SUSE add history file locking (bsc#901076)
Patch9: tcsh-6.18.00-history-file-locking.patch Patch9: tcsh-6.18.03-history-file-locking.patch
Patch10: tcsh-6.18.01-history-merge.dif Patch10: tcsh-6.18.03-history-merge.dif
BuildRequires: autoconf BuildRequires: autoconf
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
BuildRequires: screen BuildRequires: screen
@ -61,13 +59,12 @@ correction, a history mechanism, job control, and a C-like syntax.
%patch4 -b .colorls %patch4 -b .colorls
%patch5 -b .dspmbyte %patch5 -b .dspmbyte
%patch6 -b .catalogs %patch6 -b .catalogs
%patch7 -b .blk_buf %patch9 -b .histlock
%patch8 -b .metakey
%patch9 -p1 -b .histlock
%patch10 -b .histmerg %patch10 -b .histmerg
%patch0 -b .0 %patch0 -b .0
%build %build
cflags () cflags ()
{ {
local flag=$1; shift local flag=$1; shift