optimise more :)

This commit is contained in:
tg 2007-10-25 15:34:30 +00:00
parent f9a4d9605c
commit 5e02cce898
3 changed files with 7 additions and 18 deletions

6
eval.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.35 2007/09/09 18:06:39 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.36 2007/10/25 15:34:29 tg Exp $");
#ifdef MKSH_SMALL
#define MKSH_NOPWNAM
@ -1243,9 +1243,7 @@ tilde(char *cp)
dp = homedir(cp);
#endif
/* If HOME, PWD or OLDPWD are not set, don't expand ~ */
if (dp == null)
dp = NULL;
return dp;
return (dp == null ? NULL : dp);
}
#ifndef MKSH_NOPWNAM

View File

@ -3,7 +3,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.56 2007/09/09 19:12:09 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.57 2007/10/25 15:34:30 tg Exp $");
Trap sigtraps[NSIG + 1];
static struct sigaction Sigact_ign;
@ -377,9 +377,7 @@ hist_get_newest(int allow_cur)
bi_errorf("no history (yet)");
return NULL;
}
if (allow_cur)
return histptr;
return histptr - 1;
return (allow_cur ? histptr : histptr - 1);
}
/* Return a pointer to the newest command in the history */
@ -421,7 +419,7 @@ histpos(void)
int
histnum(int n)
{
int last = histptr - history;
int last = histptr - history;
if (n < 0 || n >= last) {
current = histptr;

11
syn.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.17 2007/08/19 23:12:23 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.18 2007/10/25 15:34:30 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */
@ -14,7 +14,6 @@ static struct op *pipeline(int);
static struct op *andor(void);
static struct op *c_list(int);
static struct ioword *synio(int);
static void musthave(int, int);
static struct op *nested(int, int, int);
static struct op *get_command(int);
static struct op *dogroup(void);
@ -49,6 +48,7 @@ static int symbol; /* yylex value */
#define ACCEPT (reject = 0)
#define token(cf) ((reject) ? (ACCEPT, symbol) : (symbol = yylex(cf)))
#define tpeek(cf) ((reject) ? (symbol) : (REJECT, symbol = yylex(cf)))
#define musthave(c,cf) do { if (token(cf) != (c)) syntaxerr(NULL); } while (0)
static void
yyparse(void)
@ -164,13 +164,6 @@ synio(int cf)
return iop;
}
static void
musthave(int c, int cf)
{
if ((token(cf)) != c)
syntaxerr(NULL);
}
static struct op *
nested(int type, int smark, int emark)
{