Deleted Added
sdiff udiff text old ( 316957 ) new ( 354195 )
full compact
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"
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;
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 }
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;
1326#ifndef WINNT_NATIVE
1327 (void)rename(path, short2str(fname));
1328#else
1329 (void)ReplaceFile( short2str(fname),path,NULL,0,NULL,NULL);
1330#endif
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 ---