home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / gnu / gcc / bug / 2145 < prev    next >
Encoding:
Text File  |  1992-08-18  |  28.0 KB  |  2,982 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!princeton.edu!lrr
  3. From: lrr@princeton.edu (Lawrence R. Rogers)
  4. Subject: Unaligned access on DECStation under Ultrix 4.2A
  5. Message-ID: <9208181239.AA00378@nascar.Princeton.EDU>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Tue, 18 Aug 1992 04:39:07 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 2969
  12.  
  13. % gcc -v
  14. Reading specs from /usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/specs
  15. gcc version 2.2.1
  16.  
  17. configure run with decstation-ultrix4.2 as the argument.
  18. No modifications to the source.  Everything installed in
  19. /usr/princeton/lib instead of the standard locations.  Works fine on
  20. other architectures (sun3, sun4) also installed in the same locations.
  21.  
  22.  
  23.  
  24. I get the following compiling the public domain ksh under ultrix:
  25.  
  26. gcc -g -O -g -O -D_BSD -I../std/h  -c expr.c
  27. pid 11630 (cc1) was killed on an unaligned access, at pc 0x46e32c
  28. gcc: Internal compiler error: program cc1 got fatal signal 10
  29.  
  30. Here is the output of gcc -E -D_BSD -I../std/h  -c expr.c
  31.  
  32. # 1 "expr.c"
  33.  
  34.  
  35.  
  36.  
  37.  
  38. static char *RCSid = "$Id: expr.c,v 1.2 1992/04/25 08:33:28 sjg Exp $";
  39.  
  40.  
  41. # 1 "stdh.h" 1
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. # 1 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/stdio.h" 1 3
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. # 1 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/ansi_compat.h" 1 3
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214. # 116 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/ansi_compat.h" 3
  215.  
  216. # 89 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/stdio.h" 2 3
  217.  
  218.  
  219.  
  220. typedef unsigned int    size_t;         
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.              
  231.  
  232.  
  233.  
  234.  
  235. extern    struct    _iobuf {
  236.     int    _cnt;
  237.     char    *_ptr;
  238.     char    *_base;
  239.     int    _bufsiz;
  240.     short    _flag;
  241.     short    _file;
  242. } _iob[3 ];
  243. typedef    struct _iobuf    FILE;
  244.  
  245. typedef    long    fpos_t;
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276. extern int     getc( FILE *__stream );
  277. extern int    getchar( void );
  278. extern int    putc( int __c, FILE *__stream);
  279. extern int    putchar( int __c);
  280. extern int    feof( FILE *__stream );
  281. extern int    ferror( FILE *__stream );
  282. extern int    fileno( FILE *__stream );
  283. extern int    _filbuf( FILE *p);
  284. extern int    _flsbuf( unsigned char x , FILE *p);
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301. typedef char *va_list;
  302.  
  303.  
  304.  
  305.  
  306.  
  307. extern void    clearerr( FILE *__stream); 
  308. extern int    fclose( FILE *__stream );
  309. extern FILE *    fdopen( int __filedes, char *__type );
  310. extern int    fflush( FILE *__stream );
  311. extern int    fgetc( FILE *__stream );
  312. extern int    fgetpos( FILE *__stream, fpos_t *__pos );
  313. extern char *    fgets( char *__s, int __n, FILE *__stream );
  314. extern FILE *    fopen( const char *__filename, const char *__type );
  315. extern int    fprintf( FILE *__stream, const char *__format, ... );
  316. extern int    fputc( int __c, FILE *__stream );
  317. extern int    fputs( const char *__s, FILE *__stream );
  318. extern size_t    fread( void *__ptr, size_t __size,
  319.             size_t __nitems, FILE *__stream ); 
  320. extern FILE *    freopen( const char *__filename, const char *__type,
  321.             FILE *__stream );
  322. extern int    fscanf( FILE *__stream, const char *__format, ... );
  323. extern int    fseek( FILE *__stream, long __offset, int __ptrname );
  324. extern int    fsetpos( FILE *__stream, const fpos_t *__pos );
  325. extern long    ftell( FILE *__stream );
  326. extern size_t    fwrite( const void *__ptr, size_t __size,
  327.             size_t __nitems, FILE *__stream );
  328. extern char *    gets( char *__s );    
  329. extern void    perror( const char *__s );
  330. extern FILE  *    popen(const char *__command, const char *__type );
  331. extern int    printf( const char *__format, ... );    
  332. extern int    puts( const char *__s );    
  333. extern int    remove( const char *__filename );
  334. extern int    rename( const char *__from, const char *__to );
  335. extern void    rewind( FILE *__stream );
  336. extern int    scanf( const char *__format, ... );    
  337. extern void    setbuf( FILE *__stream, char *__buf );
  338. extern int    setvbuf( FILE *__stream, char *__buf,
  339.             int __type, size_t __size );
  340. extern int    sscanf( const char *__s, const char *__format, ... );
  341. extern FILE *    tmpfile( void );    
  342. extern char *    tmpnam( char *__s );
  343. extern int    ungetc( int __c, FILE *__stream );
  344. extern int    vfprintf( FILE *__stream, const char *__format, va_list __ap );
  345. extern int    vprintf( const char *__format, va_list __ap );
  346. extern int    vsprintf( char *__s, const char *__format, va_list __ap);
  347.  
  348.  
  349. extern char *    tempnam( const char *__dir, const char *__pfx);
  350. extern int    putw( int __w, FILE *__stream );
  351. extern int    getw(FILE *__stream);
  352. extern int    pclose( FILE *__stream );
  353.  
  354.  
  355. # 299 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/stdio.h" 3
  356.  
  357.  
  358.  
  359.  
  360. extern int    sprintf( char *__s, const char *__format, ... );
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380. # 39 "stdh.h" 2
  381.  
  382.  
  383.  
  384.  
  385.  
  386. # 1 "../std/h/stddef.h" 1 3
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403. # 28 "../std/h/stddef.h" 3
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419. extern    int errno;         
  420.  
  421.  
  422.  
  423. # 44 "stdh.h" 2
  424.  
  425. # 1 "../std/h/stdlib.h" 1 3
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433. # 1 "../std/h/stddef.h" 1 3
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446. # 45 "../std/h/stddef.h" 3
  447.  
  448.  
  449. # 8 "../std/h/stdlib.h" 2 3
  450.  
  451.  
  452. double    atof (const char *s) ;
  453. int    atoi (const char *s) ;
  454. long    atol (const char *s) ;
  455. double    strtod (const char *s, char **) ;
  456. long    strtol (const char *s, char **, int base) ;
  457. unsigned long    strtoul (const char *s, char **, int base) ;
  458. int    rand (void) ;
  459. void    srand (unsigned int seed) ;
  460. void   *malloc (size_t size) ;
  461. void   *realloc (void *ptr, size_t size) ;
  462. void   *calloc (size_t n, size_t size) ;
  463. void    free (void *ptr) ;
  464. void    abort (void) ;
  465. int    atexit (void (*func)(void)) ;
  466. void    exit (int status) ;
  467. char   *getenv (const char *name) ;
  468. int    system (const char *cmd) ;
  469. void   *bsearch (const void *key, const void *base, size_t n, size_t size,
  470.                int (*compar)(const void *, const void *)) ;
  471. void   *qsort (const void *base, size_t n, size_t size,
  472.              int (*compar)(const void *, const void *)) ;
  473.  
  474.  
  475.  
  476.  
  477. # 45 "stdh.h" 2
  478.  
  479. # 1 "../std/h/string.h" 1 3
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486. # 1 "../std/h/stddef.h" 1 3
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499. # 45 "../std/h/stddef.h" 3
  500.  
  501.  
  502. # 7 "../std/h/string.h" 2 3
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510. void   *memmove (void *s1, const void *s2, size_t) ;
  511. void   *memchr (const void *s, int c, size_t) ;
  512. void   *memset (void *s, int c, size_t) ;
  513. char   *strcpy (char *s1, const char *s2) ;
  514. char   *strncpy (char *s1, const char *s2, size_t) ;
  515. char   *strcat (char *s1, const char *s2) ;
  516. char   *strncat (char *s1, const char *s2, size_t) ;
  517. int    strcmp (const char *s1, const char *s2) ;
  518. int    strncmp (const char *s1, const char *s2, size_t) ;
  519. char   *strchr (const char *s1, int c) ;
  520. char   *strrchr (const char *s1, int c) ;
  521. size_t    strspn (const char *s1, const char *s2) ;
  522. size_t    strcspn (const char *s1, const char *s2) ;
  523. char   *strpbrk (const char *s1, const char *s2) ;
  524. char   *strstr (const char *s1, const char *s2) ;
  525. char   *strtok (char *s1, const char *s2) ;
  526. char   *strerror (int errno) ;
  527.  
  528.  
  529.  
  530. # 46 "stdh.h" 2
  531.  
  532. # 1 "../std/h/sys/types.h" 1 3
  533.  
  534.  
  535.  
  536. # 1 "../std/h/stddef.h" 1 3
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549. # 45 "../std/h/stddef.h" 3
  550.  
  551.  
  552. # 4 "../std/h/sys/types.h" 2 3
  553.  
  554. # 1 "../std/h/time.h" 1 3
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561. # 1 "../std/h/stddef.h" 1 3
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574. # 45 "../std/h/stddef.h" 3
  575.  
  576.  
  577. # 7 "../std/h/time.h" 2 3
  578.  
  579.  
  580.  
  581.  
  582. typedef long time_t;
  583.  
  584. typedef long clock_t;         
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599. struct tm {
  600.     int    tm_sec, tm_min, tm_hour;
  601.     int    tm_mday, tm_mon, tm_year, tm_wday, tm_yday;
  602.     int    tm_isdst;
  603.     long    tm_gmtoff;     
  604.     char   *tm_zone;     
  605. };
  606.  
  607. clock_t    clock (void) ;
  608. time_t    time (time_t *tp) ;
  609.  
  610. time_t    mktime (struct tm *tmp) ;
  611. char   *asctime (const struct tm *tmp) ;
  612. char   *ctime (const time_t *tp) ;
  613. struct tm *gmtime (const time_t *tp) ;
  614. struct tm *localtime (const time_t *tp) ;
  615. size_t    strftime (char *buf, size_t len, const char *fmt, const struct tm *tmp) ;
  616.  
  617.  
  618.  
  619. # 5 "../std/h/sys/types.h" 2 3
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626. # 1 "/./usr/include/sys/types.h" 1
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705. # 1 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/ansi_compat.h" 1 3
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750. # 116 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/ansi_compat.h" 3
  751.  
  752. # 79 "/./usr/include/sys/types.h" 2
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770. typedef    unsigned char    u_char;
  771. typedef    unsigned short    u_short;
  772. typedef    unsigned int    u_int;
  773. typedef    unsigned int    uint;         
  774. typedef    unsigned long    u_long;
  775. typedef    unsigned short    ushort;         
  776.  
  777. typedef    volatile char        v_char;
  778. typedef    volatile short        v_short;
  779. typedef    volatile long        v_long;
  780. typedef    volatile unsigned char    vu_char;
  781. typedef    volatile unsigned short    vu_short;
  782. typedef    volatile unsigned long    vu_long;
  783.  
  784. typedef
  785.  
  786.     signed
  787.  
  788.         char    s_char;
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798. typedef    struct    _physadr { int r[1]; } *physadr;
  799.  
  800.  
  801.  
  802.  
  803. typedef    struct    label_t    {
  804.     int    val[12];
  805. } label_t;
  806.  
  807.  
  808. typedef    struct    _quad { long val[2]; } quad;
  809. typedef    long    daddr_t;
  810. typedef    char *    caddr_t;
  811. typedef u_long    gno_t;
  812. typedef short    cnt_t;             
  813. typedef    long    swblk_t;
  814. typedef long    paddr_t;         
  815. typedef    long    audit_ID_t;
  816.  
  817.  
  818. typedef    short    dev_t;
  819. typedef short    gid_t;             
  820. typedef    unsigned long    ino_t;
  821. typedef unsigned short    mode_t;         
  822. typedef short    nlink_t;         
  823. typedef    int    off_t;
  824.  
  825.  
  826. typedef int    pid_t;             
  827.  
  828. typedef short    uid_t;             
  829.  
  830.  
  831. typedef int    _time_t ;
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841. typedef int    _clock_t ;             
  842.  
  843. typedef long    key_t;             
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872. typedef long    fd_mask;
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879. typedef    struct fd_set {
  880.     fd_mask    fds_bits[(((4096     )+(( (sizeof(fd_mask) * 8        )    )-1))/( (sizeof(fd_mask) * 8        )    )) ];
  881. } fd_set;
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890. # 11 "../std/h/sys/types.h" 2 3
  891.  
  892.  
  893.  
  894.  
  895.  
  896. # 47 "stdh.h" 2
  897.  
  898. # 80 "stdh.h"
  899.  
  900.   
  901.  
  902.  
  903.  
  904.  
  905.  
  906. # 9 "expr.c" 2
  907.  
  908. # 1 "/usr/include/errno.h" 1 3
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.      
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.      
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.      
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092. extern int errno;
  1093.  
  1094. # 10 "expr.c" 2
  1095.  
  1096. # 1 "/usr/include/setjmp.h" 1 3
  1097.  
  1098. # 1 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/ansi_compat.h" 1 3
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143. # 116 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/ansi_compat.h" 3
  1144.  
  1145. # 2 "/usr/include/setjmp.h" 2 3
  1146.  
  1147.  
  1148.  
  1149. # 47 "/usr/include/setjmp.h" 3
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266. typedef    int    jmp_buf[(34+1+48) ];
  1267.  
  1268. typedef int sigjmp_buf[(34+1+48) ];
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282. extern void    longjmp( jmp_buf __env, int __val );
  1283. extern int    setjmp( jmp_buf __env );
  1284. extern int    sigsetjmp(sigjmp_buf __env, int __savemask);
  1285. extern void     siglongjmp(const sigjmp_buf __env, int __val);
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297. # 11 "expr.c" 2
  1298.  
  1299. # 1 "sh.h" 1
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306. # 1 "config.h" 1
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325. # 1 "/usr/include/signal.h" 1 3
  1326.  
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399. # 1 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/ansi_compat.h" 1 3
  1400.  
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444. # 116 "/usr/princeton/lib/gnu/gcc-lib/decstation-ultrix4.2/2.2.1/include/ansi_compat.h" 3
  1445.  
  1446. # 74 "/usr/include/signal.h" 2 3
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.  
  1462.  
  1463.  
  1464.  
  1465.                      
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555. typedef long    sig_atomic_t;
  1556. typedef int sigset_t;     
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562. struct    sigvec {
  1563.     void     (*sv_handler)();     
  1564.     sigset_t sv_mask;         
  1565.     int    sv_flags;         
  1566. };
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573. struct    sigaction {
  1574.     void     (*sa_handler)();     
  1575.     sigset_t sa_mask;         
  1576.     int     sa_flags;         
  1577. };
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603. struct    sigstack {
  1604.     char    *ss_sp;             
  1605.     int    ss_onstack;         
  1606. };
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624. struct    sigcontext {
  1625.  
  1626.      
  1627.  
  1628.  
  1629.  
  1630.  
  1631.     int    sc_onstack;         
  1632.     int    sc_mask;         
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.     int    sc_pc;             
  1640.      
  1641.  
  1642.  
  1643.     int    sc_regs[32];     
  1644.     int    sc_mdlo;     
  1645.     int    sc_mdhi;     
  1646.      
  1647.  
  1648.  
  1649.     int    sc_ownedfp;     
  1650.     int    sc_fpregs[32];     
  1651.     int    sc_fpc_csr;     
  1652.     int    sc_fpc_eir;     
  1653.      
  1654.  
  1655.  
  1656.  
  1657.      
  1658.  
  1659.  
  1660.     int    sc_cause;     
  1661.     int    sc_badvaddr;     
  1662.     int    sc_badpaddr;     
  1663.  
  1664. };
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692. extern void    (*signal(int __sig, void(*__func)(int)))(int);
  1693. int    raise( int __sig );
  1694. int     kill( pid_t __pid, int __sig );
  1695. int     sigemptyset( sigset_t *__set );
  1696. int     sigfillset( sigset_t *__set );
  1697. int     sigaddset( sigset_t *__set, int __signo );
  1698. int    sigdelset( sigset_t *__set, int __signo );
  1699. int    sigismember( const sigset_t *__set, int __signo );
  1700. int     sigaction( int __sig, const struct sigaction *__act,
  1701.         struct sigaction *__oact );
  1702. int     sigprocmask( int __how, const sigset_t *__set, sigset_t *__oset );
  1703. int    sigpending( sigset_t *__set );
  1704. int    sigsuspend( const sigset_t *__sigmask );
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726. # 19 "config.h" 2
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761. # 7 "sh.h" 2
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796. typedef int bool_t;
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815. extern     int    kshpid;         
  1816. extern     int    exstat;         
  1817. extern     int    async;         
  1818. extern     volatile int sigchld_caught;     
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825. typedef struct Area {
  1826.     struct Block *free;     
  1827. } Area;
  1828.  
  1829. extern    Area    aperm;         
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836. extern     struct    env {
  1837.     int    type;             
  1838.     Area    area;             
  1839.     struct    block *loc;         
  1840.     short  *savefd;             
  1841.     struct    env *oenv;         
  1842.     jmp_buf    jbuf;             
  1843.     int    interactive;         
  1844.     struct temp *temps;         
  1845. } e;
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880. extern     char flag [32 ];
  1881. int    option (const char *name)    ;
  1882. char   *getoptions (void)    ;
  1883. void    printoptions (void)    ;
  1884.  
  1885. extern    char    null [];     
  1886.  
  1887.  
  1888.  
  1889.  
  1890. char * substitute (char const *, int)    ;
  1891. char   *search();
  1892. struct tbl *findcom();
  1893. char   *strsave (char *, Area *)    ;
  1894. char   *ulton (unsigned long n, int base)    ;
  1895. int    xstrcmp();
  1896. void    qsortp (void **base, size_t n, int (*compare)(void *, void *))    ;
  1897. long    evaluate (const char *expr)    ;
  1898. void    resetopts();
  1899. void    histsave();
  1900. void    histlist();
  1901.  
  1902. void    j_init (void)    ;
  1903. void    j_exit (void)    ;
  1904. void    j_notify (void)    ;
  1905. void    j_kill (int job, int sig)    ;
  1906.  
  1907. void    j_change (void)    ;
  1908. int    j_resume (int job, int bg)    ;
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914. void    leave();     
  1915.  
  1916.  
  1917.  
  1918.  
  1919. typedef    void (*handler_t)();     
  1920.  
  1921.  
  1922. struct    temp {
  1923.     struct    temp * next;
  1924.     char   *name;
  1925. };
  1926. struct temp *maketemp (Area *ap)    ;
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933. extern    FILE *    shf [10        ];     
  1934.  
  1935. void    fopenshf();
  1936. void    flushshf();
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945. int    shellf (const char *fmt, ...)    ;  
  1946. int    errorf (const char *fmt, ...)    ;  
  1947.  
  1948.  
  1949.  
  1950.  
  1951. extern    int ttyfd;         
  1952.  
  1953. int    savefd (int fd)    ;     
  1954. void    restfd (int fd, int ofd)    ;
  1955. void    openpipe (int [2])    ;
  1956. void    closepipe (int [2])    ;
  1957.  
  1958.  
  1959.  
  1960.  
  1961. typedef struct trap {
  1962.     int    signal;         
  1963.     char   *name;         
  1964.     char   *mess;         
  1965.     char   *trap;         
  1966.     int    volatile set;     
  1967.     int    ourtrap;     
  1968.     int    sig_dfl;     
  1969. } Trap;
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988. extern  struct sigaction Sigact, Sigact_dfl, Sigact_ign, Sigact_trap;
  1989.  
  1990.  
  1991. extern     int volatile trap;     
  1992. extern    Trap    sigtraps[32  ];
  1993. Trap    *gettrap (char *)    ;  
  1994. void    trapsig (int sig)    ;  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006. extern    char ctypes [];
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016. # 1 "table.h" 1
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023. struct table {
  2024.     Area   *areap;         
  2025.     int    size, free;     
  2026.     struct    tbl **tbls;     
  2027. };
  2028.  
  2029. struct tbl {             
  2030.     int    flag;         
  2031.     int    type;         
  2032.     union {
  2033.         char *s;     
  2034.         long i;         
  2035.         int (*f) (char**)    ;  
  2036.         struct op *t;     
  2037.     } val;             
  2038.     char    name[4];     
  2039. };
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  
  2062. void tinit (struct table *, Area *)    ;  
  2063. unsigned int hash();         
  2064. struct tbl *tsearch();         
  2065. struct tbl *tenter();         
  2066. void tdelete();             
  2067. void twalk();             
  2068. struct tbl *tnext();         
  2069. struct tbl **tsort();         
  2070.  
  2071.  
  2072.  
  2073.  
  2074. struct block {
  2075.     Area    area;         
  2076.     int    argc;         
  2077.     char **    argv;         
  2078.     struct    table vars;     
  2079.     struct    table funs;     
  2080.  
  2081.     char *    error;         
  2082.     char *    exit;         
  2083.  
  2084.  
  2085.  
  2086.     struct    block *next;     
  2087. };
  2088.  
  2089. extern     struct block globals;     
  2090. extern     struct table commands;     
  2091. extern     struct table builtins;     
  2092. extern     struct table lexicals;     
  2093. extern     struct table homedirs;     
  2094.  
  2095. struct builtin {
  2096.     char   *name;
  2097.     int  (*func)();
  2098. };
  2099.  
  2100.  
  2101.  
  2102. extern const struct builtin shbuiltins [], kshbuiltins [];
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114. extern     Area   *lastarea;     
  2115. extern     char   *path;         
  2116. extern     char   *prompt;         
  2117.  
  2118. void    newblock();
  2119. void    popblock();
  2120. struct tbl *global( );
  2121. struct tbl *local( );
  2122. struct tbl *typeset( );
  2123. struct tbl *setvar( );
  2124. struct tbl *strint( );
  2125. long    intval( );
  2126. void    setint( );
  2127. char   *strval( );
  2128. void    setstr( );
  2129. void    unset( );
  2130. int    import( );
  2131. char  **makenv();
  2132. int    isassign( );
  2133.  
  2134. # 261 "sh.h" 2
  2135.  
  2136. # 1 "tree.h" 1
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150. struct op {
  2151.     int    type;             
  2152.     char  **args;             
  2153.     char  **vars;             
  2154.     struct ioword    **ioact;     
  2155.     struct op *left, *right;      
  2156.     char   *str;         
  2157. };
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195. struct ioword {
  2196.     int    unit;     
  2197.     int    flag;     
  2198.     char   *name;     
  2199. };
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234. # 116 "tree.h"
  2235.  
  2236. # 262 "sh.h" 2
  2237.  
  2238. # 1 "lex.h" 1
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247. typedef struct source Source;
  2248. struct source {
  2249.     char   *str;         
  2250.     int    type;         
  2251.     union {
  2252.         char  **strv;     
  2253.         FILE   *file;     
  2254.         struct tbl *tblp;  
  2255.     } u;
  2256.     int    line;         
  2257.     char   *file;         
  2258.     int    echo;         
  2259.     Source *next;         
  2260. };
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273. Source *pushs (int stype)    ;      
  2274. struct op *compile (Source *s)    ;     
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288. extern     int    multiline;     
  2289.  
  2290. typedef union {
  2291.     int    i;
  2292.     char   *cp;
  2293.     char  **wp;
  2294.     struct op *o;
  2295.     struct ioword *iop;
  2296. } YYSTYPE;
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332. extern     char    line [256        +1];     
  2333. extern     Source *source;         
  2334. extern     YYSTYPE    yylval;         
  2335. extern     int    yynerrs;
  2336. extern     struct ioword *heres [10        ], **herep;
  2337. extern     char    ident [64 +1];
  2338.  
  2339. extern    int    yylex (int flags)    ;
  2340. extern    void    yyerror (const char *msg)    ;
  2341.  
  2342.  
  2343.  
  2344. extern    char   *history [100        ];     
  2345. extern    char  **histptr;     
  2346. extern    int    histpush;     
  2347.  
  2348. extern    char    **histget();
  2349. extern  char    **histpos();
  2350. extern    int    histnum();
  2351. extern    char    *findhist();
  2352. extern    int    histN();
  2353.  
  2354.  
  2355.  
  2356. extern    void    x_init (void)    ;     
  2357. extern    void    x_init_emacs (void)    ;
  2358. extern    void    x_emacs_keys ();
  2359. extern    void    x_bind();
  2360.  
  2361. extern    int    x_read (int fd, char *buf, size_t len)    ;
  2362. extern    int    x_emacs (char *buf, size_t len)    ;
  2363. extern    int    x_vi (char *buf, size_t len)    ;
  2364.  
  2365. extern    bool_t    x_mode (bool_t)    ;     
  2366. extern    int    x_getc();         
  2367. extern    void    x_flush(), x_putc(), x_puts();  
  2368.  
  2369. extern    int    x_cols;         
  2370.  
  2371.  
  2372. # 263 "sh.h" 2
  2373.  
  2374. # 1 "proto.h" 1
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  
  2386.  
  2387.  
  2388.  
  2389. Area *    ainit         (Area *ap)    ;
  2390. void     afreeall     (Area *ap)    ;
  2391. void *    alloc         (size_t size, Area *ap)    ;
  2392. void *    aresize         (void *ptr, size_t size, Area *ap)    ;
  2393. void     afree         (void *ptr, Area *ap)    ;
  2394.  
  2395. int     c_hash         (char **wp)    ;
  2396. int     c_cd         (char **wp)    ;
  2397. int     c_print         (char **wp)    ;
  2398. int     c_whence     (char **wp)    ;
  2399. int     c_typeset     (char **wp)    ;
  2400. int     c_alias         (char **wp)    ;
  2401. int     c_unalias     (char **wp)    ;
  2402. int     c_let         (char **wp)    ;
  2403. int     c_jobs         (char **wp)    ;
  2404. int     c_fgbg         (char **wp)    ;
  2405. int     c_kill         (char **wp)    ;
  2406. int     c_bind         (char **wp)    ;
  2407.  
  2408. int     c_label         (char **wp)    ;
  2409. int     c_shift         (char **wp)    ;
  2410. int     c_umask         (char **wp)    ;
  2411. int     c_dot         (char **wp)    ;
  2412. int     c_wait         (char **wp)    ;
  2413. int     c_read         (char **wp)    ;
  2414. int     c_eval         (char **wp)    ;
  2415. int     c_trap         (char **wp)    ;
  2416. void     setsig         (struct trap *p, void (*f)())    ;
  2417. int     c_return     (char **wp)    ;
  2418. int     c_brkcont     (char **wp)    ;
  2419. int     c_exit         (char **wp)    ;
  2420. int     c_set         (char **wp)    ;
  2421. int     c_unset         (char **wp)    ;
  2422. int     c_ulimit     (char **wp)    ;
  2423. int     c_times         (char **wp)    ;
  2424. int     timex         (struct op *t, int f)    ;
  2425. int     c_exec         (char **wp)    ;
  2426. int     c_builtin     (char **wp)    ;
  2427.  
  2428. int     c_test         (char **wp)    ;
  2429. int     oexpr         (int n)    ;
  2430. int     aexpr         (int n)    ;
  2431. int     nexpr         (int n)    ;
  2432. int     primary         (int n)    ;
  2433. int     filstat         (char *nm, int mode)    ;
  2434. int     t_lex         (char *s)    ;
  2435. int     newerf         (char *f1, char *f2)    ;
  2436. int     olderf         (char *f1, char *f2)    ;
  2437. int     equalf         (char *f1, char *f2)    ;
  2438.  
  2439. int     do_ulimit     (char *a1, char *a2)    ;
  2440.  
  2441. int     x_read         (int fd, char *buf, size_t len)    ;
  2442. int     x_getc         (void)    ;
  2443. void     x_flush         (void)    ;
  2444. void     x_adjust     (void)    ;
  2445. void     x_putc         (int c)    ;
  2446. void     x_puts         (char *s)    ;
  2447. void     x_init         (void)    ;
  2448. bool_t     x_mode         (bool_t onoff)    ;
  2449. int     promptlen     (char *cp)    ;
  2450. int     init_editmode     (void)    ;
  2451.  
  2452. int     x_emacs         (char *buf, size_t len)    ;
  2453. void     x_redraw     (int limit)    ;
  2454. void     x_bind         (char *a1, char *a2, int macro)    ;
  2455. void     x_init_emacs     (void)    ;
  2456. void     x_emacs_keys     (int erase, int kill, int werase, int intr, int quit)    ;
  2457. char *    x_lastcp     (void)    ;
  2458.  
  2459. char *    substitute     (char const *cp, int f)    ;
  2460. char **    eval         (char **ap, int f)    ;
  2461. char *    evalstr         (char *cp, int f)    ;
  2462.  
  2463. int     execute         (struct op *t, volatile int flags)    ;
  2464. int     shcomexec     (char **wp)    ;
  2465. int     define         (char *name, struct op *t)    ;
  2466. int     builtin         (char *name, int (*func)())    ;
  2467. struct tbl *    findcom     (char *name, int insert)    ;
  2468. int     flushcom     (int all)    ;
  2469. char *    search         (char *name, char *path, int mode)    ;
  2470.  
  2471. void     evalerr         (char *err)    ;
  2472. long     evaluate     (const char *expr)    ;
  2473.  
  2474. void     resetopts     (void)    ;
  2475. int     c_getopts     (char **wp)    ;
  2476.  
  2477. int     c_fc          (register char **wp)    ;
  2478. void     histbackup     (void)    ;
  2479. void     histsave     (char *cmd)    ;
  2480. char **    histget          (char *str)    ;
  2481. char *    histrpl          (char *s, char *pat, char *rep, int global)    ;
  2482. void     hist_init     (Source *s)    ;
  2483. void     hist_finish     (void)    ;
  2484. char **    histpos          (void)    ;
  2485. int     histN          (void)    ;
  2486. int     histnum          (int n)    ;
  2487. char *    findhist     (int start, int fwd, char *str)    ;
  2488.  
  2489. int     errorf         (const char *fmt, ...)    ;
  2490. int     shellf         (const char *fmt, ...)    ;
  2491. void     fopenshf     (int fd)    ;
  2492. void     flushshf     (int fd)    ;
  2493. int     savefd         (int fd)    ;
  2494. void     restfd         (int fd, int ofd)    ;
  2495. void     openpipe     (int *pv)    ;
  2496. void     closepipe     (int *pv)    ;
  2497. struct temp *    maketemp (Area *ap)    ;
  2498.  
  2499. void     j_init         (void)    ;
  2500. void     j_exit         (void)    ;
  2501. void     j_change     (void)    ;
  2502. int     exchild         (struct op *t, int flags)    ;
  2503. int     waitlast     (void)    ;
  2504. int     j_reapchld     (void)    ;
  2505. int     j_reap         (void)    ;
  2506. int     waitfor         (int job)    ;
  2507. void     j_kill         (int job, int sig)    ;
  2508. int     j_resume     (int job, int bg)    ;
  2509. void     j_jobs         (void)    ;
  2510. void     j_notify     (void)    ;
  2511. int     j_lookup     (char *cp)    ;
  2512. int     j_stopped     (void)    ;
  2513.  
  2514. int     yylex         (int cf)    ;
  2515. int     gethere         (void)    ;
  2516. void     yyerror         (const char *msg)    ;
  2517. Source * pushs         (int type)    ;
  2518. int     pprompt         (char *cp)    ;
  2519.  
  2520. void     mcheck         (void)    ;
  2521. void     mbset         (char *p)    ;
  2522. void     mpset         (char *mptoparse)    ;
  2523. void     mprint         (void)    ;
  2524.  
  2525. int     main         (int argc, char **argv, char **envp)    ;
  2526. int     include         (char *name)    ;
  2527.  
  2528.  
  2529.  
  2530. int     shell         (Source *s)    ;
  2531. void     leave         (int rv)    ;
  2532. int     error         (void)    ;
  2533. int     unwind         (void)    ;
  2534. int     newenv         (int type)    ;
  2535. int     quitenv         (void)    ;
  2536. void     aerror         (Area *ap, const char *msg)    ;
  2537.  
  2538. void     setctypes     ( char *s, int t)    ;
  2539. void     initctypes     (void)    ;
  2540. char *    ulton         (unsigned long n, int base)    ;
  2541. char *    strsave         (char *s, Area *ap)    ;
  2542. int     option         (const char *n)    ;
  2543. char *    getoptions     (void)    ;
  2544. void     printoptions     (void)    ;
  2545. int     getn         (char *as)    ;
  2546. char *    strerror     (int i)    ;
  2547. int     gmatch         (char *s, char *p)    ;
  2548. void     qsortp         (void **base, size_t n, int (*f)())    ;
  2549. int     qsort1         (void **base, void **lim, int (*f)())    ;
  2550. int     xstrcmp         (void *p1, void *p2)    ;
  2551. void     cleanpath     (char *pwd, char *dir, char *clean)    ;
  2552.  
  2553. int     yyparse         (void)    ;
  2554. int     keywords     (void)    ;
  2555. struct op * compile     (Source *s)    ;
  2556.  
  2557. unsigned int     hash     (char *n)    ;
  2558. void     tinit         (struct table *tp, Area *ap)    ;
  2559. struct tbl *    tsearch     (struct table *tp, char *n, unsigned int h)    ;
  2560. struct tbl *    tenter     (struct table *tp, char *n, unsigned int h)    ;
  2561. void     tdelete         (struct tbl *p)    ;
  2562. void     twalk         (struct table *tp)    ;
  2563. struct tbl *    tnext     (void)    ;
  2564. struct tbl **    tsort     (struct table *tp)    ;
  2565.  
  2566.  
  2567. Trap *    gettrap         (char *name)    ;
  2568. void     trapsig         (int i)    ;
  2569. int     runtraps     (void)    ;
  2570. int     runtrap         (Trap *p)    ;
  2571. int     cleartraps     (void)    ;
  2572. int     ignoresig     (int i)    ;
  2573. int     restoresigs     (void)    ;
  2574.  
  2575. void     ptree         (struct op *t, FILE *f)    ;
  2576. int     pioact         (FILE *f, struct ioword *iop)    ;
  2577. int     fptreef         (FILE *f, char *fmt, ...)    ;
  2578. int     snptreef     (char *s, int n, char *fmt, ...)    ;
  2579. struct op *    tcopy     (struct op *t, Area *ap)    ;
  2580. char *    wdcopy         (char *wp, Area *ap)    ;
  2581. char *    wdscan         (char *wp, int c)    ;
  2582. void     tfree         (struct op *t, Area *ap)    ;
  2583.  
  2584. void     newblock     (void)    ;
  2585. void     popblock     (void)    ;
  2586. struct tbl *    global     (char *n)    ;
  2587. struct tbl *    local     (char *n)    ;
  2588. char *    strval         (struct tbl *vp)    ;
  2589. long     intval         (struct tbl *vp)    ;
  2590. void     setstr         (struct tbl *vq, char *s)    ;
  2591. struct tbl *    strint     (struct tbl *vq, struct tbl *vp)    ;
  2592. void     setint         (struct tbl *vq, long n)    ;
  2593. int     import         (char *thing)    ;
  2594. struct tbl *    typeset     (char *var, int set, int clr)    ;
  2595. void     unset         (struct tbl *vp)    ;
  2596. int     isassign     (char *s)    ;
  2597. char **    makenv         (void)    ;
  2598.  
  2599.  
  2600. void     vi_reset     (char *buf, int len)    ;
  2601. int     vi_hook         (int ch)    ;
  2602. int     save_cbuf     (void)    ;
  2603. int     restore_cbuf     (void)    ;
  2604. int     x_vi         (char *buf, size_t len)    ;
  2605. int     getch         (void)    ;
  2606. char **    globstr         (char *stuff)    ;
  2607.  
  2608.  
  2609. # 264 "sh.h" 2
  2610.  
  2611.   
  2612.  
  2613.  
  2614.  
  2615.  
  2616. # 1 "trace.h" 1
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665. # 57 "trace.h"
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679. # 86 "trace.h"
  2680.  
  2681.    
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701. # 270 "sh.h" 2
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707. # 12 "expr.c" 2
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719. static const char *expression;     
  2720. static const char *tokp;     
  2721. static int tok;             
  2722. static struct tbl *val;         
  2723.  
  2724. static struct tbl *asn      (void)    ;
  2725. static struct tbl *e6       (void)    ;
  2726. static struct tbl *e5       (void)    ;
  2727. static struct tbl *e3       (void)    ;
  2728. static struct tbl *e2       (void)    ;
  2729. static struct tbl *e0       (void)    ;
  2730. static void     token       (void)    ;
  2731. static struct tbl *tempvar  (void)    ;
  2732. static struct tbl *intvar   (struct tbl *vp)    ;
  2733.  
  2734.  
  2735.  
  2736.  
  2737. void
  2738. evalerr(err)
  2739.     char *err;
  2740. {
  2741.     errorf("%s: %s\n", expression, err);
  2742. }
  2743.  
  2744. long
  2745. evaluate(expr)
  2746.     const char *expr;
  2747. {
  2748.     struct tbl *v;
  2749.  
  2750.     expression = tokp = expr;
  2751.     token();
  2752.     v = intvar(asn());
  2753.     if (!(tok == 0))
  2754.         evalerr("bad expression");
  2755.     return v->val.i;
  2756. }
  2757.  
  2758. static struct tbl *
  2759. asn()
  2760. {
  2761.     register struct tbl *vl, *vr;
  2762.  
  2763.     vr = vl = e6();
  2764.     if ((tok == '=')) {
  2765.         Area * olastarea = lastarea;
  2766.         token();
  2767.         if ((vl->flag&(1<<(8))            ))  
  2768.             evalerr("bad assignment");
  2769.         vr = intvar(asn());
  2770.         lastarea = olastarea;
  2771.         setint(vl, vr->val.i);
  2772.         if ((vl->flag&(1<<(4))            ) && vl->type == 0)  
  2773.             vl->type = vr->type;
  2774.     }
  2775.     return vr;
  2776. }
  2777.  
  2778. static struct tbl *
  2779. e6()
  2780. {
  2781.     register struct tbl *vl, *vr;
  2782.  
  2783.     vl = e5();
  2784.     while ((tok == 0x03 ) || (tok == 0x04 )) {
  2785.         int op = tok;
  2786.         token();
  2787.         vl = intvar(vl);
  2788.         vr = intvar(e5());
  2789.         vl->val.i = vl->val.i == vr->val.i;
  2790.         if (op == 0x04 )
  2791.             vl->val.i = ! vl->val.i;
  2792.     }
  2793.     return vl;
  2794. }
  2795.  
  2796. static struct tbl *
  2797. e5()
  2798. {
  2799.     register struct tbl *vl, *vr;
  2800.  
  2801.     vl = e3();
  2802.     while ((tok == 0x05 ) || (tok == '<') || (tok == '>') || (tok == 0x06 )) {
  2803.         int op = tok;
  2804.         token();
  2805.         vl = intvar(vl);
  2806.         vr = intvar(e3());
  2807.         if (op == 0x05 )
  2808.             vl->val.i = vl->val.i <= vr->val.i;
  2809.         else if         (op == '<')
  2810.             vl->val.i = vl->val.i < vr->val.i;
  2811.         else if         (op == 0x06 )
  2812.             vl->val.i = vl->val.i >= vr->val.i;
  2813.         else if         (op == '>')
  2814.             vl->val.i = vl->val.i > vr->val.i;
  2815.     }
  2816.     return vl;
  2817. }
  2818.  
  2819. static struct tbl *
  2820. e3()
  2821. {
  2822.     register struct tbl *vl, *vr;
  2823.  
  2824.     vl = e2();
  2825.     while ((tok == '+') || (tok == '-')) {
  2826.         int op = tok;
  2827.         token();
  2828.         vl = intvar(vl);
  2829.         vr = intvar(e2());
  2830.         if (op == '+')
  2831.             vl->val.i += vr->val.i;
  2832.         else if         (op == '-')
  2833.             vl->val.i -= vr->val.i;
  2834.     }
  2835.     return vl;
  2836. }
  2837.  
  2838. static struct tbl *
  2839. e2()
  2840. {
  2841.     register struct tbl *vl, *vr;
  2842.  
  2843.     vl = e0();
  2844.     while ((tok == '*') || (tok == '/') || (tok == '%')) {
  2845.         int op = tok;
  2846.         token();
  2847.         vl = intvar(vl);
  2848.         vr = intvar(e0());
  2849.         if (op != '*' && vr->val.i == 0)
  2850.             evalerr("zero divisor");
  2851.         if (op == '*')
  2852.             vl->val.i *= vr->val.i;
  2853.         else if         (op == '/')
  2854.             vl->val.i /= vr->val.i;
  2855.         else if         (op == '%')
  2856.             vl->val.i %= vr->val.i;
  2857.     }
  2858.     return vl;
  2859. }
  2860.  
  2861. static struct tbl *
  2862. e0()
  2863. {
  2864.     register struct tbl *v;
  2865.  
  2866.     if ((tok == '!') || (tok == '-')) {
  2867.         int op = tok;
  2868.         token();
  2869.         v = intvar(e0());
  2870.         if (op == '!')
  2871.             v->val.i = !v->val.i;
  2872.         else if         (op == '-')
  2873.             v->val.i = -v->val.i;
  2874.     } else
  2875.     if ((tok == '(')) {
  2876.         token();
  2877.         v = asn();
  2878.         if (!(tok == ')'))
  2879.             evalerr("missing )");
  2880.         token();
  2881.     } else
  2882.     if ((tok == 0x01 ) || (tok == 0x02 )) {
  2883.         v = val;
  2884.         token();
  2885.     } else
  2886.         evalerr("bad expression");
  2887.     return v;
  2888. }
  2889.  
  2890. static void
  2891. token()
  2892. {
  2893.     register char *cp = (char *) tokp;
  2894.     register int c, c2;
  2895.  
  2896.      
  2897.     do c = *cp++;    while (c != '\0' && (c == ' ' || c == '\t'));
  2898.     tokp = cp-1;
  2899.  
  2900.     if (!!(ctypes[(unsigned char)(c)]&( 0x01        ))  ) {
  2901.         for (; !!(ctypes[(unsigned char)(c)]&( 0x01        |0x02        ))  ; c = *cp++)
  2902.             ;
  2903.         c = *--cp;
  2904.         *cp = 0;
  2905.         val = global(tokp);
  2906.         *cp = c;
  2907.         tok = 0x01 ;
  2908.     } else
  2909.     if (!!(ctypes[(unsigned char)(c)]&( 0x02        ))  ) {
  2910.         for (; !!(ctypes[(unsigned char)(c)]&( 0x01        |0x02        ))   || c == '#'; c = *cp++)
  2911.             ;
  2912.         c = *--cp;
  2913.         *cp = 0;
  2914.         val = tempvar();
  2915.         setstr(val, tokp);
  2916.         val->flag |= (1<<(8))            ;
  2917.         *cp = c;
  2918.         tok = 0x02 ;
  2919.     } else {
  2920.         c2 = *cp++;
  2921.         if (c == '=' && c2 == '=')
  2922.             c = 0x03 ;
  2923.         else if         (c == '!' && c2 == '=')
  2924.             c = 0x04 ;
  2925.         else if         (c == '<' && c2 == '=')
  2926.                 c = 0x05 ;
  2927.         else if         (c == '>' && c2 == '=')
  2928.                 c = 0x06 ;
  2929.         else
  2930.             cp--;
  2931.         tok = c;
  2932.     }
  2933.     tokp = cp;
  2934. }
  2935.  
  2936. static struct tbl *
  2937. tempvar()
  2938. {
  2939.     register struct tbl *vp;
  2940.  
  2941.     vp = (struct tbl*) alloc(sizeof(struct tbl), &e.area );
  2942.     lastarea = &e.area ;
  2943.     vp->flag = (1<<(2))            |(1<<(4))            ;
  2944.     vp->type = 0;
  2945.     vp->name[0] = '\0';
  2946.     return vp;
  2947. }
  2948.  
  2949.  
  2950. static struct tbl *
  2951. intvar(vp)
  2952.     register struct tbl *vp;
  2953. {
  2954.     register struct tbl *vq;
  2955.  
  2956.     vq = tempvar();
  2957.     vq->type = 10;
  2958.     if (strint(vq, vp) == 0 ) {
  2959.         if ((vp->flag&(1<<(2))            ) && vp->val.s && *(vp->val.s)) {
  2960.             evalerr("bad number");
  2961.         } else {
  2962.             vq->flag |= ((1<<(2))            |(1<<(4))            );
  2963.             vq->type = 10;
  2964.             vq->val.i = 0;
  2965.         }
  2966.     }
  2967.     return vq;
  2968. }
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  =====   ======= =======    Larry Rogers
  2974. =     =     =       =         Manager, UNIX Systems
  2975. =           =       =         Princeton University
  2976. =           =       =         87 Prospect Street, Room 201
  2977. =           =       =         Princeton, NJ 08544
  2978. =           =       =         lrr@Princeton.EDU, princeton!lrr
  2979. =     =     =       =         Phone: 609-258-6483/6000
  2980.  =====   =======    =         FAX:   609-258-1069/3943
  2981.  
  2982.