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" #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 #ifdef MKSH_SMALL
#define MKSH_NOPWNAM #define MKSH_NOPWNAM
@ -1243,9 +1243,7 @@ tilde(char *cp)
dp = homedir(cp); dp = homedir(cp);
#endif #endif
/* If HOME, PWD or OLDPWD are not set, don't expand ~ */ /* If HOME, PWD or OLDPWD are not set, don't expand ~ */
if (dp == null) return (dp == null ? NULL : dp);
dp = NULL;
return dp;
} }
#ifndef MKSH_NOPWNAM #ifndef MKSH_NOPWNAM

View File

@ -3,7 +3,7 @@
#include "sh.h" #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]; Trap sigtraps[NSIG + 1];
static struct sigaction Sigact_ign; static struct sigaction Sigact_ign;
@ -377,9 +377,7 @@ hist_get_newest(int allow_cur)
bi_errorf("no history (yet)"); bi_errorf("no history (yet)");
return NULL; return NULL;
} }
if (allow_cur) return (allow_cur ? histptr : histptr - 1);
return histptr;
return histptr - 1;
} }
/* Return a pointer to the newest command in the history */ /* Return a pointer to the newest command in the history */
@ -421,7 +419,7 @@ histpos(void)
int int
histnum(int n) histnum(int n)
{ {
int last = histptr - history; int last = histptr - history;
if (n < 0 || n >= last) { if (n < 0 || n >= last) {
current = histptr; current = histptr;

11
syn.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #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 { struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */ 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 *andor(void);
static struct op *c_list(int); static struct op *c_list(int);
static struct ioword *synio(int); static struct ioword *synio(int);
static void musthave(int, int);
static struct op *nested(int, int, int); static struct op *nested(int, int, int);
static struct op *get_command(int); static struct op *get_command(int);
static struct op *dogroup(void); static struct op *dogroup(void);
@ -49,6 +48,7 @@ static int symbol; /* yylex value */
#define ACCEPT (reject = 0) #define ACCEPT (reject = 0)
#define token(cf) ((reject) ? (ACCEPT, symbol) : (symbol = yylex(cf))) #define token(cf) ((reject) ? (ACCEPT, symbol) : (symbol = yylex(cf)))
#define tpeek(cf) ((reject) ? (symbol) : (REJECT, 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 static void
yyparse(void) yyparse(void)
@ -164,13 +164,6 @@ synio(int cf)
return iop; return iop;
} }
static void
musthave(int c, int cf)
{
if ((token(cf)) != c)
syntaxerr(NULL);
}
static struct op * static struct op *
nested(int type, int smark, int emark) nested(int type, int smark, int emark)
{ {