Deleted Added
full compact
sh.hist.c (316957) sh.hist.c (354195)
1/* $Header: /p/tcsh/cvsroot/tcsh/sh.hist.c,v 3.61 2015/06/06 21:19:08 christos Exp $ */
2/*
3 * sh.hist.c: Shell history expansions and substitutions
4 */
5/*-
6 * Copyright (c) 1980, 1991 The Regents of the University of California.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without

--- 16 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33#include "sh.h"
1/*
2 * sh.hist.c: Shell history expansions and substitutions
3 */
4/*-
5 * Copyright (c) 1980, 1991 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 16 unchanged lines hidden (view full) ---

25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32#include "sh.h"
34
35RCSID("$tcsh: sh.hist.c,v 3.61 2015/06/06 21:19:08 christos Exp $")
36
37#include <stdio.h> /* for rename(2), grr. */
38#include <assert.h>
39#include "tc.h"
40#include "dotlock.h"
41
42extern int histvalid;
43extern struct Strbuf histline;
44Char HistLit = 0;

--- 1235 unchanged lines hidden (view full) ---

1280 for (i = 1; shist->vec[i]; i++) {
1281 if (eq(shist->vec[i], STRmerge))
1282 merge++;
1283 if (eq(shist->vec[i], STRlock))
1284 lock++;
1285 }
1286
1287 if (merge) {
33#include <stdio.h> /* for rename(2), grr. */
34#include <assert.h>
35#include "tc.h"
36#include "dotlock.h"
37
38extern int histvalid;
39extern struct Strbuf histline;
40Char HistLit = 0;

--- 1235 unchanged lines hidden (view full) ---

1276 for (i = 1; shist->vec[i]; i++) {
1277 if (eq(shist->vec[i], STRmerge))
1278 merge++;
1279 if (eq(shist->vec[i], STRlock))
1280 lock++;
1281 }
1282
1283 if (merge) {
1284 jmp_buf_t osetexit;
1288 if (lock) {
1289#ifndef WINNT_NATIVE
1290 char *lockpath = strsave(short2str(fname));
1291 cleanup_push(lockpath, xfree);
1292 /* Poll in 100 miliseconds interval to obtain the lock. */
1293 if ((dot_lock(lockpath, 100) == 0))
1294 cleanup_push(lockpath, dotlock_cleanup);
1295#endif
1296 }
1285 if (lock) {
1286#ifndef WINNT_NATIVE
1287 char *lockpath = strsave(short2str(fname));
1288 cleanup_push(lockpath, xfree);
1289 /* Poll in 100 miliseconds interval to obtain the lock. */
1290 if ((dot_lock(lockpath, 100) == 0))
1291 cleanup_push(lockpath, dotlock_cleanup);
1292#endif
1293 }
1297 loadhist(fname, 1);
1294 getexit(osetexit);
1295 if (setexit())
1296 loadhist(fname, 1);
1297 resexit(osetexit);
1298 }
1299 }
1300 rs = randsuf();
1301 xsnprintf(path, sizeof(path), "%S.%S", fname, rs);
1302 xfree(rs);
1303
1304 fp = xcreat(path, 0600);
1305 if (fp == -1) {

--- 12 unchanged lines hidden (view full) ---

1318#endif
1319 ftmp = SHOUT;
1320 SHOUT = fp;
1321 dumphist[2] = snum;
1322 dohist(dumphist, NULL);
1323 xclose(fp);
1324 SHOUT = ftmp;
1325 didfds = oldidfds;
1298 }
1299 }
1300 rs = randsuf();
1301 xsnprintf(path, sizeof(path), "%S.%S", fname, rs);
1302 xfree(rs);
1303
1304 fp = xcreat(path, 0600);
1305 if (fp == -1) {

--- 12 unchanged lines hidden (view full) ---

1318#endif
1319 ftmp = SHOUT;
1320 SHOUT = fp;
1321 dumphist[2] = snum;
1322 dohist(dumphist, NULL);
1323 xclose(fp);
1324 SHOUT = ftmp;
1325 didfds = oldidfds;
1326#ifndef WINNT_NATIVE
1326 (void)rename(path, short2str(fname));
1327 (void)rename(path, short2str(fname));
1328#else
1329 (void)ReplaceFile( short2str(fname),path,NULL,0,NULL,NULL);
1330#endif
1327 cleanup_until(fname);
1328}
1329
1330
1331/* This is the entry point for loading history data from a file. */
1332void
1333loadhist(Char *fname, int mflg)
1334{

--- 29 unchanged lines hidden ---
1331 cleanup_until(fname);
1332}
1333
1334
1335/* This is the entry point for loading history data from a file. */
1336void
1337loadhist(Char *fname, int mflg)
1338{

--- 29 unchanged lines hidden ---