From 208c45da25799baee85b0d7e5d9c8eb09ea89ed4 Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 10 Nov 2006 04:22:13 +0000 Subject: [PATCH] more cleanup; incidentally, replacing libc function with syscall maybe speedup 9t 4d 1i --- histrap.c | 5 ++--- var.c | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/histrap.c b/histrap.c index 9be2611..1136c22 100644 --- a/histrap.c +++ b/histrap.c @@ -3,7 +3,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.29 2006/11/10 04:03:59 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.30 2006/11/10 04:22:13 tg Exp $"); #if !defined(__sun__) #define DO_HISTORY @@ -247,8 +247,7 @@ c_fc(char **wp) return 1; } - n = fstat(shf_fileno(shf), &statb) < 0 ? 128 : - statb.st_size + 1; + n = stat(tf->name, &statb) < 0 ? 128 : statb.st_size + 1; Xinit(xs, xp, n, hist_source->areap); while ((n = shf_read(xp, Xnleft(xs, xp), shf)) > 0) { xp += n; diff --git a/var.c b/var.c index 7eaa72a..9396edb 100644 --- a/var.c +++ b/var.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.24 2006/11/10 01:13:52 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.25 2006/11/10 04:22:13 tg Exp $"); /* * Variables @@ -910,8 +910,12 @@ getspec(struct tbl *vp) * has been set - don't do anything in this case * (see initcoms[] in main.c). */ - if (vp->flag & ISSET) - setint(vp, (long) (time(NULL) - seconds)); + if (vp->flag & ISSET) { + struct timeval tv; + + gettimeofday(&tv, NULL); + setint(vp, tv.tv_sec - seconds); + } vp->flag |= SPECIAL; break; case V_RANDOM: @@ -1007,7 +1011,12 @@ setspec(struct tbl *vp) break; case V_SECONDS: vp->flag &= ~SPECIAL; - seconds = time(NULL) - intval(vp); + { + struct timeval tv; + + gettimeofday(&tv, NULL); + seconds = tv.tv_sec - intval(vp); + } vp->flag |= SPECIAL; break; case V_TMOUT: