Changeset 879 for trunk/src


Ignore:
Timestamp:
Apr 21, 2007, 8:33:35 AM (18 years ago)
Author:
bird
Message:

hacking...

Location:
trunk/src/ash-messup
Files:
4 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ash-messup/alias.h

    r626 r879  
    4444};
    4545
    46 struct alias *lookupalias(char *, int);
    47 char *get_alias_text(char *);
    48 int aliascmd(int, char **);
    49 int unaliascmd(int, char **);
    50 void rmaliases(void);
     46struct alias *lookupalias(struct shinstance *, char *, int);
     47char *get_alias_text(struct shinstance *, char *);
     48int aliascmd(struct shinstance *, int, char **);
     49int unaliascmd(struct shinstance *, int, char **);
     50void rmaliases(struct shinstance *);
  • trunk/src/ash-messup/cd.h

    r626 r879  
    3131 */
    3232
    33 void    getpwd(int);
    34 int     cdcmd(int, char **);
    35 int     pwdcmd(int, char **);
     33void    getpwd(struct shinstance *, int);
     34int     cdcmd(struct shinstance *, int, char **);
     35int     pwdcmd(struct shinstance *, int, char **);
    3636#ifdef PC_DRIVE_LETTERS
    3737#define IS_ROOT(path) (   *(path) == '/' \
  • trunk/src/ash-messup/error.h

    r632 r879  
    6262};
    6363
     64/*
    6465extern struct jmploc *handler;
    6566extern int exception;
    66 extern int exerrno;     /* error for EXEXEC */
     67extern int exerrno;*/   /* error for EXEXEC */
    6768
    6869/* exceptions */
     
    8081 */
    8182
    82 extern volatile int suppressint;
    83 extern volatile int intpending;
     83/*extern volatile int suppressint;
     84extern volatile int intpending;*/
    8485
    85 #define INTOFF suppressint++
    86 #define INTON { if (--suppressint == 0 && intpending) onint(); }
    87 #define FORCEINTON {suppressint = 0; if (intpending) onint();}
    88 #define CLEAR_PENDING_INT intpending = 0
    89 #define int_pending() intpending
     86#define INTOFF psh->suppressint++
     87#define INTON { if (--psh->suppressint == 0 && psh->intpending) onint(psh); }
     88#define FORCEINTON {suppressint = 0; if (psh->intpending) onint(psh);}
     89#define CLEAR_PENDING_INT psh->intpending = 0
     90#define int_pending() psh->intpending
    9091
    91 void exraise(int) __attribute__((__noreturn__));
    92 void onint(void);
    93 void error(const char *, ...) __attribute__((__noreturn__));
    94 void exerror(int, const char *, ...) __attribute__((__noreturn__));
    95 const char *errmsg(int, int);
     92void exraise(struct shinstance *, int) __attribute__((__noreturn__));
     93void onint(struct shinstance *);
     94void error(struct shinstance *, const char *, ...) __attribute__((__noreturn__));
     95void exerror(struct shinstance *, int, const char *, ...) __attribute__((__noreturn__));
     96const char *errmsg(struct shinstance *, int, int);
    9697
    97 void sh_err(int, const char *, ...) __attribute__((__noreturn__));
    98 void sh_verr(int, const char *, va_list) __attribute__((__noreturn__));
    99 void sh_errx(int, const char *, ...) __attribute__((__noreturn__));
    100 void sh_verrx(int, const char *, va_list) __attribute__((__noreturn__));
    101 void sh_warn(const char *, ...);
    102 void sh_vwarn(const char *, va_list);
    103 void sh_warnx(const char *, ...);
    104 void sh_vwarnx(const char *, va_list);
     98void sh_err(struct shinstance *, int, const char *, ...) __attribute__((__noreturn__));
     99void sh_verr(struct shinstance *, int, const char *, va_list) __attribute__((__noreturn__));
     100void sh_errx(struct shinstance *, int, const char *, ...) __attribute__((__noreturn__));
     101void sh_verrx(struct shinstance *, int, const char *, va_list) __attribute__((__noreturn__));
     102void sh_warn(struct shinstance *, const char *, ...);
     103void sh_vwarn(struct shinstance *, const char *, va_list);
     104void sh_warnx(struct shinstance *, const char *, ...);
     105void sh_vwarnx(struct shinstance *, const char *, va_list);
    105106
    106 void sh_exit(int) __attribute__((__noreturn__));
     107void sh_exit(struct shinstance *, int) __attribute__((__noreturn__));
    107108
    108109
  • trunk/src/ash-messup/eval.h

    r626 r879  
    3535 */
    3636
    37 extern char *commandname;       /* currently executing command */
    38 extern int exitstatus;          /* exit status of last command */
    39 extern int back_exitstatus;     /* exit status of backquoted command */
    40 extern struct strlist *cmdenviron;  /* environment for builtin command */
     37/*extern char *commandname;*/   /* currently executing command */
     38/*extern int exitstatus;*/              /* exit status of last command */
     39/*extern int back_exitstatus;*/ /* exit status of backquoted command */
     40/*extern struct strlist *cmdenviron;*/  /* environment for builtin command */
    4141
    4242
     
    4848};
    4949
    50 void evalstring(char *, int);
     50void evalstring(struct shinstance *, char *, int);
    5151union node;     /* BLETCH for ansi C */
    52 void evaltree(union node *, int);
    53 void evalbackcmd(union node *, struct backcmd *);
     52void evaltree(struct shinstance *, union node *, int);
     53void evalbackcmd(struct shinstance *, union node *, struct backcmd *);
    5454
    5555/* in_function returns nonzero if we are currently evaluating a function */
    56 #define in_function()   funcnest
    57 extern int funcnest;
    58 extern int evalskip;
     56#define in_function()   psh->funcnest
     57/*extern int funcnest;
     58extern int evalskip;*/
    5959
    6060/* reasons for skipping commands (see comment on breakcmd routine) */
  • trunk/src/ash-messup/exec.h

    r626 r879  
    6060#define DO_ALTBLTIN     0x20    /* %builtin in alt. path */
    6161
    62 extern const char *pathopt;     /* set by padvance */
     62/*extern const char *pathopt;*/ /* set by padvance */
    6363
    64 void shellexec(char **, char **, const char *, int, int)
     64void shellexec(struct shinstance *, char **, char **, const char *, int, int)
    6565    __attribute__((__noreturn__));
    66 char *padvance(const char **, const char *);
    67 int hashcmd(int, char **);
    68 void find_command(char *, struct cmdentry *, int, const char *);
    69 int (*find_builtin(char *))(int, char **);
    70 int (*find_splbltin(char *))(int, char **);
    71 void hashcd(void);
    72 void changepath(const char *);
    73 void deletefuncs(void);
    74 void getcmdentry(char *, struct cmdentry *);
    75 void addcmdentry(char *, struct cmdentry *);
    76 void defun(char *, union node *);
    77 int unsetfunc(char *);
    78 int typecmd(int, char **);
    79 void hash_special_builtins(void);
     66char *padvance(struct shinstance *, const char **, const char *);
     67int hashcmd(struct shinstance *, int, char **);
     68void find_command(struct shinstance *, char *, struct cmdentry *, int, const char *);
     69int (*find_builtin(struct shinstance *, char *))(struct shinstance *, int, char **);
     70int (*find_splbltin(struct shinstance *, char *))(struct shinstance *, int, char **);
     71void hashcd(struct shinstance *);
     72void changepath(struct shinstance *, const char *);
     73void deletefuncs(struct shinstance *);
     74void getcmdentry(struct shinstance *, char *, struct cmdentry *);
     75void addcmdentry(struct shinstance *, char *, struct cmdentry *);
     76void defun(struct shinstance *, char *, union node *);
     77int unsetfunc(struct shinstance *, char *);
     78int typecmd(struct shinstance *, int, char **);
     79void hash_special_builtins(struct shinstance *);
  • trunk/src/ash-messup/expand.h

    r626 r879  
    5858
    5959union node;
    60 void expandhere(union node *, int);
    61 void expandarg(union node *, struct arglist *, int);
    62 void expari(int);
    63 int patmatch(char *, char *, int);
    64 void rmescapes(char *);
    65 int casematch(union node *, char *);
    66 int wordexpcmd(int, char **);
     60void expandhere(struct shinstance *, union node *, int);
     61void expandarg(struct shinstance *, union node *, struct arglist *, int);
     62void expari(struct shinstance *, int);
     63int patmatch(struct shinstance *, char *, char *, int);
     64void rmescapes(struct shinstance *, char *);
     65int casematch(struct shinstance *, union node *, char *);
     66int wordexpcmd(struct shinstance *, int, char **);
    6767
    6868/* From arith.y */
  • trunk/src/ash-messup/init.h

    r626 r879  
    3535 */
    3636
    37 void init(void);
    38 void reset(void);
    39 void initshellproc(void);
     37void init(struct shinstance *);
     38void reset(struct shinstance *);
     39void initshellproc(struct shinstance *);
  • trunk/src/ash-messup/input.h

    r626 r879  
    4747extern int init_editline;       /* 0 == not setup, 1 == OK, -1 == failed */
    4848
    49 char *pfgets(char *, int);
    50 int pgetc(void);
    51 int preadbuffer(void);
    52 void pungetc(void);
    53 void pushstring(char *, int, void *);
    54 void popstring(void);
    55 void setinputfile(const char *, int);
    56 void setinputfd(int, int);
    57 void setinputstring(char *, int);
    58 void popfile(void);
    59 void popallfiles(void);
    60 void closescript(int);
     49char *pfgets(struct shinstance *, char *, int);
     50int pgetc(struct shinstance *);
     51int preadbuffer(struct shinstance *);
     52void pungetc(struct shinstance *);
     53void pushstring(struct shinstance *, char *, int, void *);
     54void popstring(struct shinstance *);
     55void setinputfile(struct shinstance *, const char *, int);
     56void setinputfd(struct shinstance *, int, int);
     57void setinputstring(struct shinstance *, char *, int);
     58void popfile(struct shinstance *);
     59void popallfiles(struct shinstance *);
     60void closescript(struct shinstance *, int);
    6161
    62 #define pgetc_macro()   (--parsenleft >= 0? *parsenextc++ : preadbuffer())
     62#define pgetc_macro()   (--psh->parsenleft >= 0? *psh->parsenextc++ : preadbuffer(psh))
  • trunk/src/ash-messup/jobs.h

    r626 r879  
    8383};
    8484
    85 extern pid_t backgndpid;        /* pid of last background process */
    86 extern int job_warning;         /* user was warned about stopped jobs */
     85/*extern pid_t backgndpid;*/    /* pid of last background process */
     86/*extern int job_warning;*/             /* user was warned about stopped jobs */
    8787
    88 void setjobctl(int);
    89 int fgcmd(int, char **);
    90 int bgcmd(int, char **);
    91 int jobscmd(int, char **);
    92 void showjobs(struct output *, int);
    93 int waitcmd(int, char **);
    94 int jobidcmd(int, char **);
    95 struct job *makejob(union node *, int);
    96 int forkshell(struct job *, union node *, int);
    97 void forkchild(struct job *, union node *, int, int);
    98 int forkparent(struct job *, union node *, int, pid_t);
    99 int waitforjob(struct job *);
    100 int stoppedjobs(void);
    101 void commandtext(struct procstat *, union node *);
    102 int getjobpgrp(const char *);
     88void setjobctl(struct shinstance *, int);
     89int fgcmd(struct shinstance *, int, char **);
     90int bgcmd(struct shinstance *, int, char **);
     91int jobscmd(struct shinstance *, int, char **);
     92void showjobs(struct shinstance *, struct output *, int);
     93int waitcmd(struct shinstance *, int, char **);
     94int jobidcmd(struct shinstance *, int, char **);
     95struct job *makejob(struct shinstance *, union node *, int);
     96int forkshell(struct shinstance *, struct job *, union node *, int);
     97void forkchild(struct shinstance *, struct job *, union node *, int, int);
     98int forkparent(struct shinstance *, struct job *, union node *, int, pid_t);
     99int waitforjob(struct shinstance *, struct job *);
     100int stoppedjobs(struct shinstance *);
     101void commandtext(struct shinstance *, struct procstat *, union node *);
     102int getjobpgrp(struct shinstance *, const char *);
    103103
    104104#if ! JOBS
    105 #define setjobctl(on)   /* do nothing */
     105#define setjobctl(psh, on)      /* do nothing */
    106106#endif
  • trunk/src/ash-messup/mail.h

    r626 r879  
    3535 */
    3636
    37 void chkmail(int);
     37void chkmail(struct shinstance *, int);
  • trunk/src/ash-messup/main.c

    r809 r879  
    8585STATIC union node *curcmd;
    8686STATIC union node *prevcmd;
    87 #if PROFILE
    88 short profile_buf[16384];
    89 extern int etext();
    90 #endif
    9187
    9288STATIC void read_profile(const char *);
     
    105101main(int argc, char **argv)
    106102{
     103        shinstance *psh;
     104
     105        setlocale(LC_ALL, "");
     106
     107        /*
     108         * Create the root shell instance.
     109         */
     110        psh = create_root_shell(NULL, argc, argv);
     111        if (!psh)
     112                return 2;
     113        return shell_main(psh, argc);
     114}       
     115
     116int
     117shell_main(shinstance *psh, int argc, char **argv)
     118{
    107119        struct jmploc jmploc;
    108120        struct stackmark smark;
     
    110122        char *shinit;
    111123
    112         setlocale(LC_ALL, "");
    113 
    114 #if PROFILE
    115         monitor(4, etext, profile_buf, sizeof profile_buf, 50);
    116 #endif
    117124        state = 0;
    118125        if (setjmp(jmploc.loc)) {
     
    166173                        goto state4;
    167174        }
    168         handler = &jmploc;
     175        psh->handler = &jmploc;
    169176#ifdef DEBUG
    170177#if DEBUG == 2
     
    174181        trputs("Shell args:  ");  trargs(argv);
    175182#endif
    176         rootpid = getpid();
    177         rootshell = 1;
     183        psh->rootpid = getpid();
     184        psh->rootshell = 1;
    178185#ifdef _MSC_VER
    179186    {
     
    187194        if (argv[0] && argv[0][0] == '-') {
    188195                state = 1;
    189                 read_profile("/etc/profile");
     196                read_profile(psh, "/etc/profile");
    190197state1:
    191198                state = 2;
    192                 read_profile(".profile");
     199                read_profile(psh, ".profile");
    193200        }
    194201state2:
    195202        state = 3;
    196203        if (getuid() == geteuid() && getgid() == getegid()) {
    197                 if ((shinit = lookupvar("ENV")) != NULL && *shinit != '\0') {
     204                if ((shinit = lookupvar(psh, "ENV")) != NULL && *shinit != '\0') {
    198205                        state = 3;
    199                         read_profile(shinit);
     206                        read_profile(psh, shinit);
    200207                }
    201208        }
     
    214221
    215222                for (i = 0; i < SIGSSIZE; i++)
    216                     setsignal(sigs[i], 0);
    217         }
    218 
    219         if (minusc)
    220                 evalstring(minusc, 0);
    221 
    222         if (sflag || minusc == NULL) {
     223                    setsignal(psh, sigs[i], 0);
     224        }
     225
     226        if (psh->minusc)
     227                evalstring(psh, psh->minusc, 0);
     228
     229        if (psh->sflag || minusc == NULL) {
    223230state4: /* XXX ??? - why isn't this before the "if" statement */
    224                 cmdloop(1);
    225         }
    226 #if PROFILE
    227         monitor(0);
    228 #endif
    229         exitshell(exitstatus);
     231                cmdloop(psh, 1);
     232        }
     233        exitshell(psh, psh->exitstatus);
    230234        /* NOTREACHED */
    231235}
  • trunk/src/ash-messup/main.h

    r626 r879  
    3535 */
    3636
    37 extern int rootpid;     /* pid of main shell */
    38 extern int rootshell;   /* true if we aren't a child of the main shell */
     37/*extern int rootpid;*/ /* pid of main shell */
     38/*extern int rootshell;*/       /* true if we aren't a child of the main shell */
    3939
    40 void readcmdfile(char *);
    41 void cmdloop(int);
    42 int dotcmd(int, char **);
    43 int exitcmd(int, char **);
     40void readcmdfile(struct shinstance *, char *);
     41void cmdloop(struct shinstance *, int);
     42int dotcmd(struct shinstance *, int, char **);
     43int exitcmd(struct shinstance *, int, char **);
  • trunk/src/ash-messup/memalloc.h

    r626 r879  
    4343
    4444
    45 extern char *stacknxt;
     45/*extern char *stacknxt;
    4646extern int stacknleft;
    4747extern int sstrnleft;
    48 extern int herefd;
     48extern int herefd;*/
    4949
    5050pointer ckmalloc(int);
    5151pointer ckrealloc(pointer, int);
    5252char *savestr(const char *);
    53 pointer stalloc(int);
    54 void stunalloc(pointer);
    55 void setstackmark(struct stackmark *);
    56 void popstackmark(struct stackmark *);
    57 void growstackblock(void);
    58 void grabstackblock(int);
    59 char *growstackstr(void);
    60 char *makestrspace(void);
    61 void ungrabstackstr(char *, char *);
     53pointer stalloc(struct shinstance *, int);
     54void stunalloc(struct shinstance *, pointer);
     55void setstackmark(struct shinstance *, struct stackmark *);
     56void popstackmark(struct shinstance *, struct stackmark *);
     57void growstackblock(struct shinstance *);
     58void grabstackblock(struct shinstance *, int);
     59char *growstackstr(struct shinstance *);
     60char *makestrspace(struct shinstance *);
     61void ungrabstackstr(struct shinstance *, char *, char *);
    6262
    6363
    6464
    65 #define stackblock() stacknxt
    66 #define stackblocksize() stacknleft
    67 #define STARTSTACKSTR(p)        p = stackblock(), sstrnleft = stackblocksize()
    68 #define STPUTC(c, p)    (--sstrnleft >= 0? (*p++ = (c)) : (p = growstackstr(), *p++ = (c)))
    69 #define CHECKSTRSPACE(n, p)     { if (sstrnleft < n) p = makestrspace(); }
    70 #define USTPUTC(c, p)   (--sstrnleft, *p++ = (c))
    71 #define STACKSTRNUL(p)  (sstrnleft == 0? (p = growstackstr(), *p = '\0') : (*p = '\0'))
    72 #define STUNPUTC(p)     (++sstrnleft, --p)
     65#define stackblock() psh->stacknxt
     66#define stackblocksize() psh->stacknleft
     67#define STARTSTACKSTR(p)        p = stackblock(), psh->sstrnleft = stackblocksize()
     68#define STPUTC(c, p)    (--psh->sstrnleft >= 0? (*p++ = (c)) : (p = growstackstr(psh), *p++ = (c)))
     69#define CHECKSTRSPACE(n, p)     { if (psh->sstrnleft < n) p = makestrspace(psh); }
     70#define USTPUTC(c, p)   (--psh->sstrnleft, *p++ = (c))
     71#define STACKSTRNUL(p)  (psh->sstrnleft == 0? (p = growstackstr(psh), *p = '\0') : (*p = '\0'))
     72#define STUNPUTC(p)     (++psh->sstrnleft, --p)
    7373#define STTOPC(p)       p[-1]
    74 #define STADJUST(amount, p)     (p += (amount), sstrnleft -= (amount))
    75 #define grabstackstr(p) stalloc(stackblocksize() - sstrnleft)
     74#define STADJUST(amount, p)     (p += (amount), psh->sstrnleft -= (amount))
     75#define grabstackstr(p) stalloc(stackblocksize() - psh->sstrnleft)
    7676
    7777#define ckfree(p)       free((pointer)(p))
  • trunk/src/ash-messup/miscbltin.h

    r626 r879  
    2727 */
    2828
    29 int readcmd(int, char **);
    30 int umaskcmd(int, char **);
    31 int ulimitcmd(int, char **);
     29int readcmd(struct shinstance *, int, char **);
     30int umaskcmd(struct shinstance *, int, char **);
     31int ulimitcmd(struct shinstance *, int, char **);
  • trunk/src/ash-messup/myhistedit.h

    r626 r879  
    3535#include <histedit.h>
    3636
    37 extern History *hist;
    38 extern EditLine *el;
     37/*extern History *hist;
     38extern EditLine *el;*/
    3939#endif
    40 extern int displayhist;
     40/*extern int displayhist;*/
    4141
    42 void histedit(void);
    43 void sethistsize(const char *);
    44 void setterm(const char *);
    45 int histcmd(int, char **);
    46 int inputrc(int, char **);
    47 int not_fcnumber(char *);
    48 int str_to_event(const char *, int);
     42void histedit(struct shinstance *);
     43void sethistsize(struct shinstance *, const char *);
     44void setterm(struct shinstance *, const char *);
     45int histcmd(struct shinstance *, int, char **);
     46int inputrc(struct shinstance *, int, char **);
     47int not_fcnumber(struct shinstance *, char *);
     48int str_to_event(struct shinstance *, const char *, int);
    4949
  • trunk/src/ash-messup/options.h

    r626 r879  
    5454/* Those marked [U] are required by posix, but have no effect! */
    5555
     56#ifdef DEBUG
     57# define NOPTS 21
     58#else
     59# define NOPTS 20
     60#endif
     61
    5662#ifdef DEFINE_OPTIONS
    5763#define DEF_OPTS(name, letter, opt_set) {name, letter, opt_set, 0},
    58 struct optent optlist[] = {
     64const struct optent ro_optlist[NOPTS] = {
    5965#else
    6066#define DEF_OPTS(name, letter, opt_set)
     
    6369
    6470DEF_OPT( "errexit",     'e' )   /* exit on error */
    65 #define eflag optlist[0].val
     71#define eflag psh->optlist[0].val
    6672DEF_OPT( "noglob",      'f' )   /* no pathname expansion */
    67 #define fflag optlist[1].val
     73#define fflag psh->optlist[1].val
    6874DEF_OPT( "ignoreeof",   'I' )   /* do not exit on EOF */
    69 #define Iflag optlist[2].val
     75#define Iflag psh->optlist[2].val
    7076DEF_OPT( "interactive",'i' )    /* interactive shell */
    71 #define iflag optlist[3].val
     77#define iflag psh->optlist[3].val
    7278DEF_OPT( "monitor",     'm' )   /* job control */
    73 #define mflag optlist[4].val
     79#define mflag psh->optlist[4].val
    7480DEF_OPT( "noexec",      'n' )   /* [U] do not exec commands */
    75 #define nflag optlist[5].val
     81#define nflag psh->optlist[5].val
    7682DEF_OPT( "stdin",       's' )   /* read from stdin */
    77 #define sflag optlist[6].val
     83#define sflag psh->optlist[6].val
    7884DEF_OPT( "xtrace",      'x' )   /* trace after expansion */
    79 #define xflag optlist[7].val
     85#define xflag psh->optlist[7].val
    8086DEF_OPT( "verbose",     'v' )   /* trace read input */
    81 #define vflag optlist[8].val
     87#define vflag psh->optlist[8].val
    8288DEF_OPTS( "vi",         'V', 'V' )      /* vi style editing */
    83 #define Vflag optlist[9].val
     89#define Vflag psh->optlist[9].val
    8490DEF_OPTS( "emacs",      'E', 'V' )      /* emacs style editing */
    85 #define Eflag optlist[10].val
     91#define Eflag psh->optlist[10].val
    8692DEF_OPT( "noclobber",   'C' )   /* do not overwrite files with > */
    87 #define Cflag optlist[11].val
     93#define Cflag psh->optlist[11].val
    8894DEF_OPT( "allexport",   'a' )   /* export all variables */
    89 #define aflag optlist[12].val
     95#define aflag psh->optlist[12].val
    9096DEF_OPT( "notify",      'b' )   /* [U] report completion of background jobs */
    91 #define bflag optlist[13].val
     97#define bflag psh->optlist[13].val
    9298DEF_OPT( "nounset",     'u' )   /* error expansion of unset variables */
    93 #define uflag optlist[14].val
     99#define uflag psh->optlist[14].val
    94100DEF_OPT( "quietprofile", 'q' )
    95 #define qflag optlist[15].val
     101#define qflag psh->optlist[15].val
    96102DEF_OPT( "nolog",       0 )     /* [U] no functon defs in command history */
    97 #define nolog optlist[16].val
     103#define nolog psh->optlist[16].val
    98104DEF_OPT( "cdprint",     0 )     /* always print result of cd */
    99 #define cdprint optlist[17].val
     105#define cdprint psh->optlist[17].val
    100106DEF_OPT( "tabcomplete", 0 )     /* <tab> causes filename expansion */
    101 #define tabcomplete optlist[18].val
     107#define tabcomplete psh->optlist[18].val
    102108#ifdef DEBUG
    103109DEF_OPT( "debug",       0 )     /* enable debug prints */
    104 #define debug optlist[19].val
     110#define debug psh->optlist[19].val
    105111#endif
    106112
     
    108114        { 0, 0, 0, 0 },
    109115};
    110 #define NOPTS (sizeof optlist / sizeof optlist[0] - 1)
    111 int sizeof_optlist = sizeof optlist;
    112116#else
    113 extern struct optent optlist[];
    114 extern int sizeof_optlist;
     117extern const struct optent ro_optlist[];
    115118#endif
     119#define sizeof_optlist (NOPTS * sizeof(struct optent))
    116120
    117121
    118 extern char *minusc;            /* argument to -c option */
    119 extern char *arg0;              /* $0 */
    120 extern struct shparam shellparam;  /* $@ */
    121 extern char **argptr;           /* argument list for builtin commands */
    122 extern char *optionarg;         /* set by nextopt */
    123 extern char *optptr;            /* used by nextopt */
     122/*extern char *minusc;*/                /* argument to -c option */
     123/*extern char *arg0;*/          /* $0 */
     124/*extern struct shparam shellparam;*/  /* $@ */
     125/*extern char **argptr;*/               /* argument list for builtin commands */
     126/*extern char *optionarg;*/             /* set by nextopt */
     127/*extern char *optptr;*/                /* used by nextopt */
    124128
    125 void procargs(int, char **);
    126 void optschanged(void);
    127 void setparam(char **);
    128 void freeparam(volatile struct shparam *);
    129 int shiftcmd(int, char **);
    130 int setcmd(int, char **);
    131 int getoptscmd(int, char **);
    132 int nextopt(const char *);
    133 void getoptsreset(const char *);
     129void procargs(struct shinstance *, int, char **);
     130void optschanged(struct shinstance *);
     131void setparam(struct shinstance *, char **);
     132void freeparam(struct shinstance *, volatile struct shparam *);
     133int shiftcmd(struct shinstance *, int, char **);
     134int setcmd(struct shinstance *, int, char **);
     135int getoptscmd(struct shinstance *, int, char **);
     136int nextopt(struct shinstance *, const char *);
     137void getoptsreset(struct shinstance *, const char *);
  • trunk/src/ash-messup/output.h

    r626 r879  
    4646        short fd;
    4747        short flags;
     48        struct shinstance *psh;
    4849};
    4950
    50 extern struct output output;
     51/*extern struct output output;
    5152extern struct output errout;
    5253extern struct output memout;
    5354extern struct output *out1;
    54 extern struct output *out2;
     55extern struct output *out2;*/
    5556
    56 void open_mem(char *, int, struct output *);
    57 void out1str(const char *);
    58 void out2str(const char *);
     57void open_mem(struct shinstance *, char *, int, struct output *);
     58void out1str(struct shinstance *, const char *);
     59void out2str(struct shinstance *, const char *);
    5960void outstr(const char *, struct output *);
    6061void emptyoutbuf(struct output *);
    61 void output_flushall(void);
     62void output_flushall(struct shinstance *);
    6263void flushout(struct output *);
    63 void freestdout(void);
     64void freestdout(struct shinstance *);
    6465void outfmt(struct output *, const char *, ...)
     66    __attribute__((__format__(__printf__,3,4)));
     67void out1fmt(struct shinstance *, const char *, ...)
    6568    __attribute__((__format__(__printf__,2,3)));
    66 void out1fmt(const char *, ...)
    67     __attribute__((__format__(__printf__,1,2)));
    68 void dprintf(const char *, ...)
    69     __attribute__((__format__(__printf__,1,2)));
    70 void fmtstr(char *, size_t, const char *, ...)
    71     __attribute__((__format__(__printf__,3,4)));
     69void dprintf(struct shinstance *, const char *, ...)
     70    __attribute__((__format__(__printf__,2,3)));
     71void fmtstr(struct shinstance *, char *, size_t, const char *, ...)
     72    __attribute__((__format__(__printf__,4,5)));
    7273void doformat(struct output *, const char *, va_list);
    7374int xwrite(int, char *, int);
    7475int xioctl(int, unsigned long, char *);
    7576
    76 #define outc(c, file)   (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))
    77 #define out1c(c)        outc(c, out1);
    78 #define out2c(c)        outc(c, out2);
     77#define outc(c, file)   (--(file)->nleft < 0? (emptyoutbuf(psh, file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))
     78#define out1c(c)        outc(c, psh->out1);
     79#define out2c(c)        outc(c, psh->out2);
    7980
    8081#define OUTPUT_INCL
  • trunk/src/ash-messup/parser.h

    r626 r879  
    7272 * happens to be handy.
    7373 */
    74 extern int tokpushback;
    75 #define NEOF ((union node *)&tokpushback)
    76 extern int whichprompt;         /* 1 == PS1, 2 == PS2 */
     74/*extern int tokpushback;*/
     75#define NEOF ((union node *)&psh->tokpushback)
     76/*extern int whichprompt;*/             /* 1 == PS1, 2 == PS2 */
    7777
    7878
    79 union node *parsecmd(int);
    80 void fixredir(union node *, const char *, int);
    81 int goodname(char *);
    82 const char *getprompt(void *);
     79union node *parsecmd(struct shinstance *, int);
     80void fixredir(struct shinstance *, union node *, const char *, int);
     81int goodname(struct shinstance *, char *);
     82const char *getprompt(struct shinstance *, void *);
  • trunk/src/ash-messup/redir.h

    r626 r879  
    4141
    4242union node;
    43 void redirect(union node *, int);
    44 void popredir(void);
    45 int fd0_redirected_p(void);
    46 void clearredir(int);
    47 int copyfd(int, int);
     43void redirect(struct shinstance *, union node *, int);
     44void popredir(struct shinstance *);
     45int fd0_redirected_p(struct shinstance *);
     46void clearredir(struct shinstance *, int);
     47int copyfd(struct shinstance *, int, int);
    4848
  • trunk/src/ash-messup/show.h

    r626 r879  
    3535
    3636union node;
    37 void showtree(union node *);
    38 void trace(const char *, ...);
    39 void tracev(const char *, va_list);
    40 void trargs(char **);
     37void showtree(struct shinstance *, union node *);
     38void trace(struct shinstance *, const char *, ...);
     39void tracev(struct shinstance *, const char *, va_list);
     40void trargs(struct shinstance *, char **);
    4141#ifdef DEBUG
    4242void trputc(int);
  • trunk/src/ash-messup/trap.h

    r626 r879  
    3535 */
    3636
    37 extern int pendingsigs;
     37/*extern int pendingsigs;*/
    3838
    39 int trapcmd(int, char **);
    40 void clear_traps(int);
    41 long setsignal(int, int);
    42 void ignoresig(int, int);
    43 void onsig(int);
    44 void dotrap(void);
    45 void setinteractive(int);
    46 void exitshell(int) __attribute__((__noreturn__));
     39int trapcmd(struct shinstance *, int, char **);
     40void clear_traps(struct shinstance *, int);
     41long setsignal(struct shinstance *, int, int);
     42void ignoresig(struct shinstance *, int, int);
     43void onsig(struct shinstance *, int);
     44void dotrap(struct shinstance *, void);
     45void setinteractive(struct shinstance *, int);
     46void exitshell(struct shinstance *, int) __attribute__((__noreturn__));
  • trunk/src/ash-messup/var.h

    r637 r879  
    7171};
    7272
    73 
     73/*
    7474struct localvar *localvars;
    7575
     
    9292extern struct var vhistsize;
    9393#endif
     94*/
    9495
    9596/*
     
    99100 */
    100101
    101 #define ifsval()        (vifs.text + 4)
    102 #define ifsset()        ((vifs.flags & VUNSET) == 0)
    103 #define mailval()       (vmail.text + 5)
    104 #define mpathval()      (vmpath.text + 9)
     102#define ifsval()        (psh->vifs.text + 4)
     103#define ifsset()        ((psh->vifs.flags & VUNSET) == 0)
     104#define mailval()       (psh->vmail.text + 5)
     105#define mpathval()      (psh->vmpath.text + 9)
    105106#ifdef _MSC_VER
    106 #define pathval()       (vpath.text[5] ? &vpath.text[5] : &vpath2.text[5])
     107#define pathval()       (psh->vpath.text[5] ? &psh->vpath.text[5] : &psh->vpath2.text[5])
    107108#else
    108 #define pathval()       (vpath.text + 5)
     109#define pathval()       (psh->vpath.text + 5)
    109110#endif
    110 #define ps1val()        (vps1.text + 4)
    111 #define ps2val()        (vps2.text + 4)
    112 #define ps4val()        (vps4.text + 4)
    113 #define optindval()     (voptind.text + 7)
     111#define ps1val()        (psh->vps1.text + 4)
     112#define ps2val()        (psh->vps2.text + 4)
     113#define ps4val()        (psh->vps4.text + 4)
     114#define optindval()     (psh->voptind.text + 7)
    114115#ifndef SMALL
    115 #define histsizeval()   (vhistsize.text + 9)
    116 #define termval()       (vterm.text + 5)
     116#define histsizeval()   (psh->vhistsize.text + 9)
     117#define termval()       (psh->vterm.text + 5)
    117118#endif
    118119
    119120#if ATTY
    120 #define attyset()       ((vatty.flags & VUNSET) == 0)
     121#define attyset()       ((psh->vatty.flags & VUNSET) == 0)
    121122#endif
    122 #define mpathset()      ((vmpath.flags & VUNSET) == 0)
     123#define mpathset()      ((psh->vmpath.flags & VUNSET) == 0)
    123124
    124 void initvar(void);
    125 void setvar(const char *, const char *, int);
    126 void setvareq(char *, int);
     125void initvar(struct shinstance *);
     126void setvar(struct shinstance *, const char *, const char *, int);
     127void setvareq(struct shinstance *, char *, int);
    127128struct strlist;
    128 void listsetvar(struct strlist *, int);
    129 char *lookupvar(const char *);
    130 char *bltinlookup(const char *, int);
    131 char **environment(void);
    132 void shprocvar(void);
    133 int showvars(const char *, int, int);
    134 int exportcmd(int, char **);
    135 int localcmd(int, char **);
    136 void mklocal(const char *, int);
    137 void listmklocal(struct strlist *, int);
    138 void poplocalvars(void);
    139 int setvarcmd(int, char **);
    140 int unsetcmd(int, char **);
    141 int unsetvar(const char *, int);
    142 int setvarsafe(const char *, const char *, int);
    143 void print_quoted(const char *);
     129void listsetvar(struct shinstance *, struct strlist *, int);
     130char *lookupvar(struct shinstance *, const char *);
     131char *bltinlookup(struct shinstance *, const char *, int);
     132char **environment(struct shinstance *);
     133void shprocvar(struct shinstance *);
     134int showvars(struct shinstance *, const char *, int, int);
     135int exportcmd(struct shinstance *, int, char **);
     136int localcmd(struct shinstance *, int, char **);
     137void mklocal(struct shinstance *, const char *, int);
     138void listmklocal(struct shinstance *, struct strlist *, int);
     139void poplocalvars(struct shinstance *);
     140int setvarcmd(struct shinstance *, int, char **);
     141int unsetcmd(struct shinstance *, int, char **);
     142int unsetvar(struct shinstance *, const char *, int);
     143int setvarsafe(struct shinstance *, const char *, const char *, int);
     144void print_quoted(struct shinstance *, const char *);
Note: See TracChangeset for help on using the changeset viewer.