more cleanup; incidentally, replacing libc function with syscall maybe speedup

9t 4d 1i
This commit is contained in:
tg 2006-11-10 04:22:13 +00:00
parent 5dff5df5e5
commit 208c45da25
2 changed files with 15 additions and 7 deletions

View File

@ -3,7 +3,7 @@
#include "sh.h" #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__) #if !defined(__sun__)
#define DO_HISTORY #define DO_HISTORY
@ -247,8 +247,7 @@ c_fc(char **wp)
return 1; return 1;
} }
n = fstat(shf_fileno(shf), &statb) < 0 ? 128 : n = stat(tf->name, &statb) < 0 ? 128 : statb.st_size + 1;
statb.st_size + 1;
Xinit(xs, xp, n, hist_source->areap); Xinit(xs, xp, n, hist_source->areap);
while ((n = shf_read(xp, Xnleft(xs, xp), shf)) > 0) { while ((n = shf_read(xp, Xnleft(xs, xp), shf)) > 0) {
xp += n; xp += n;

17
var.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #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 * Variables
@ -910,8 +910,12 @@ getspec(struct tbl *vp)
* has been set - don't do anything in this case * has been set - don't do anything in this case
* (see initcoms[] in main.c). * (see initcoms[] in main.c).
*/ */
if (vp->flag & ISSET) if (vp->flag & ISSET) {
setint(vp, (long) (time(NULL) - seconds)); struct timeval tv;
gettimeofday(&tv, NULL);
setint(vp, tv.tv_sec - seconds);
}
vp->flag |= SPECIAL; vp->flag |= SPECIAL;
break; break;
case V_RANDOM: case V_RANDOM:
@ -1007,7 +1011,12 @@ setspec(struct tbl *vp)
break; break;
case V_SECONDS: case V_SECONDS:
vp->flag &= ~SPECIAL; vp->flag &= ~SPECIAL;
seconds = time(NULL) - intval(vp); {
struct timeval tv;
gettimeofday(&tv, NULL);
seconds = tv.tv_sec - intval(vp);
}
vp->flag |= SPECIAL; vp->flag |= SPECIAL;
break; break;
case V_TMOUT: case V_TMOUT: