* sh.h: note that file descriptors SHALL be <100

* syn.c: fix bashiop-4 regression test; failed due to me using a
  simple string when a wdstring was expected, sorry; the new code
  assumes file descriptors take up a maximum of two characters
This commit is contained in:
tg 2008-12-02 13:20:40 +00:00
parent ef5a465acd
commit a19bf7253a
2 changed files with 14 additions and 3 deletions

3
sh.h
View File

@ -103,7 +103,7 @@
#define __SCCSID(x) __IDSTRING(sccsid,x)
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.263 2008/12/02 12:39:38 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.264 2008/12/02 13:20:39 tg Exp $");
#endif
#define MKSH_VERSION "R36 2008/12/02"
@ -260,6 +260,7 @@ extern int __cdecl setegid(gid_t);
/* Table flag type - needs > 16 and < 32 bits */
typedef int32_t Tflag;
/* these shall be smaller than 100 */
#ifdef MKSH_SMALL
#define NUFILE 32 /* Number of user-accessible files */
#define FDBASE 10 /* First file usable by Shell */

14
syn.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.30 2008/11/12 00:54:51 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.31 2008/12/02 13:20:40 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */
@ -170,12 +170,22 @@ synio(int cf)
iop->name = yylval.cp;
if (iop->flag & IOBASH) {
char *cp;
nextiop = alloc(1, sizeof (*iop), ATEMP);
nextiop->name = cp = alloc(5, 1, ATEMP);
if (iop->unit > 9) {
*cp++ = CHAR;
*cp++ = '0' + (iop->unit / 10);
}
*cp++ = CHAR;
*cp++ = '0' + (iop->unit % 10);
*cp = EOS;
iop->flag &= ~IOBASH;
nextiop->unit = 2;
nextiop->flag = IODUP;
nextiop->name = shf_smprintf("%d", iop->unit);
nextiop->delim = NULL;
nextiop->heredoc = NULL;
}