"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "sh.hist.c" between
tcsh-6.22.02.tar.gz and tcsh-6.22.03.tar.gz

About: Tcsh is a version of the Berkeley C-Shell, with the addition of: A command line editor, command and file name completion, listing, ...

sh.hist.c  (tcsh-6.22.02):sh.hist.c  (tcsh-6.22.03)
skipping to change at line 1221 skipping to change at line 1221
dotlock_cleanup(void* lockpath) dotlock_cleanup(void* lockpath)
{ {
dot_unlock((char*)lockpath); dot_unlock((char*)lockpath);
} }
/* Save history before exiting the shell. */ /* Save history before exiting the shell. */
void void
rechist(Char *fname, int ref) rechist(Char *fname, int ref)
{ {
Char *snum, *rs; Char *snum, *rs;
int fp, ftmp, oldidfds; int fp, ftmp, oldidfds, ophup_disabled;
struct varent *shist; struct varent *shist;
char path[MAXPATHLEN]; char path[MAXPATHLEN];
struct stat st; struct stat st;
static Char *dumphist[] = {STRhistory, STRmhT, 0, 0}; static Char *dumphist[] = {STRhistory, STRmhT, 0, 0};
if (fname == NULL && !ref) if (fname == NULL && !ref)
return; return;
ophup_disabled = phup_disabled;
phup_disabled = 1;
/* /*
* If $savehist is just set, we use the value of $history * If $savehist is just set, we use the value of $history
* else we use the value in $savehist * else we use the value in $savehist
*/ */
if (((snum = varval(STRsavehist)) == STRNULL) && if (((snum = varval(STRsavehist)) == STRNULL) &&
((snum = varval(STRhistory)) == STRNULL)) ((snum = varval(STRhistory)) == STRNULL))
snum = STRmaxint; snum = STRmaxint;
if (fname == NULL) { if (fname == NULL) {
if ((fname = varval(STRhistfile)) == STRNULL) if ((fname = varval(STRhistfile)) == STRNULL)
skipping to change at line 1293 skipping to change at line 1297
if (lock) { if (lock) {
#ifndef WINNT_NATIVE #ifndef WINNT_NATIVE
char *lockpath = strsave(short2str(fname)); char *lockpath = strsave(short2str(fname));
cleanup_push(lockpath, xfree); cleanup_push(lockpath, xfree);
/* Poll in 100 miliseconds interval to obtain the lock. */ /* Poll in 100 miliseconds interval to obtain the lock. */
if ((dot_lock(lockpath, 100) == 0)) if ((dot_lock(lockpath, 100) == 0))
cleanup_push(lockpath, dotlock_cleanup); cleanup_push(lockpath, dotlock_cleanup);
#endif #endif
} }
getexit(osetexit); getexit(osetexit);
if (setexit()) if (setexit() == 0)
loadhist(fname, 1); loadhist(fname, 1);
resexit(osetexit); resexit(osetexit);
} }
} }
rs = randsuf(); rs = randsuf();
xsnprintf(path, sizeof(path), "%S.%S", fname, rs); xsnprintf(path, sizeof(path), "%S.%S", fname, rs);
xfree(rs); xfree(rs);
fp = xcreat(path, 0600); fp = xcreat(path, 0600);
if (fp == -1) { if (fp == -1) {
didfds = oldidfds; didfds = oldidfds;
cleanup_until(fname); cleanup_until(fname);
phup_disabled = ophup_disabled;
return; return;
} }
/* Try to preserve ownership and permissions of the original history file */ /* Try to preserve ownership and permissions of the original history file */
#ifndef WINNT_NATIVE #ifndef WINNT_NATIVE
if (stat(short2str(fname), &st) != -1) { if (stat(short2str(fname), &st) != -1) {
TCSH_IGNORE(fchown(fp, st.st_uid, st.st_gid)); TCSH_IGNORE(fchown(fp, st.st_uid, st.st_gid));
TCSH_IGNORE(fchmod(fp, st.st_mode)); TCSH_IGNORE(fchmod(fp, st.st_mode));
} }
#else #else
UNREFERENCED_PARAMETER(st); UNREFERENCED_PARAMETER(st);
skipping to change at line 1330 skipping to change at line 1335
dohist(dumphist, NULL); dohist(dumphist, NULL);
xclose(fp); xclose(fp);
SHOUT = ftmp; SHOUT = ftmp;
didfds = oldidfds; didfds = oldidfds;
#ifndef WINNT_NATIVE #ifndef WINNT_NATIVE
(void)rename(path, short2str(fname)); (void)rename(path, short2str(fname));
#else #else
(void)ReplaceFile( short2str(fname),path,NULL,0,NULL,NULL); (void)ReplaceFile( short2str(fname),path,NULL,0,NULL,NULL);
#endif #endif
cleanup_until(fname); cleanup_until(fname);
phup_disabled = ophup_disabled;
} }
/* This is the entry point for loading history data from a file. */ /* This is the entry point for loading history data from a file. */
void void
loadhist(Char *fname, int mflg) loadhist(Char *fname, int mflg)
{ {
static Char *loadhist_cmd[] = {STRsource, NULL, NULL, NULL}; static Char *loadhist_cmd[] = {STRsource, NULL, NULL, NULL};
loadhist_cmd[1] = mflg ? STRmm : STRmh; loadhist_cmd[1] = mflg ? STRmm : STRmh;
if (fname != NULL) if (fname != NULL)
 End of changes. 5 change blocks. 
2 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)