#include "sh.h"
-__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.193.2.5 2015/04/19 19:18:19 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.204 2015/07/05 19:53:46 tg Exp $");
/*
* states while lexing word
goto no_iop;
if (!ksh_isdigit(dp[c2 + 1]))
goto no_iop;
- iop->unit = (iop->unit * 10) + dp[c2 + 1] - '0';
+ iop->unit = iop->unit * 10 + ksh_numdig(dp[c2 + 1]);
if (iop->unit >= FDBASE)
goto no_iop;
}
if (s->type == SFILE)
shf_fdclose(s->u.shf);
s->str = NULL;
- } else if (interactive && *s->str &&
- (cur_prompt != PS1 || !ctype(*s->str, C_IFS | C_IFSWS))) {
- histsave(&s->line, s->str, true, true);
+ } else if (interactive && *s->str) {
+ if (cur_prompt != PS1)
+ histsave(&s->line, s->str, HIST_APPEND, true);
+ else if (!ctype(*s->str, C_IFS | C_IFSWS))
+ histsave(&s->line, s->str, HIST_QUEUE, true);
#if !defined(MKSH_SMALL) && HAVE_PERSISTENT_HISTORY
+ else
+ goto check_for_sole_return;
} else if (interactive && cur_prompt == PS1) {
+ check_for_sole_return:
cp = Xstring(s->xs, xp);
while (*cp && ctype(*cp, C_IFSWS))
++cp;
- if (!*cp)
+ if (!*cp) {
+ histsave(&s->line, NULL, HIST_FLUSH, true);
histsync();
+ }
#endif
}
if (interactive)
struct shf *shf;
char * volatile ps1;
Area *saved_atemp;
+ int saved_lineno;
ps1 = str_val(global("PS1"));
shf = shf_sopen(NULL, strlen(ps1) * 2,
shf_fprintf(shf, "%lu", s ?
(unsigned long)s->line + 1 : 0UL);
ps1 = shf_sclose(shf);
+ saved_lineno = current_lineno;
+ if (s)
+ current_lineno = s->line + 1;
saved_atemp = ATEMP;
newenv(E_ERRH);
if (kshsetjmp(e->jbuf)) {
char *cp = substitute(ps1, 0);
strdupx(prompt, cp, saved_atemp);
}
+ current_lineno = saved_lineno;
quitenv(NULL);
}
break;