grr@cbmvax.commodore.com (George Robbins) (01/15/90)
The following shar contains an example of code which seems to confuse the version of the RISC c compiler shiped with 3.1C. The code is from the "rh" program distributed in the sources group a while back. Anybody want to try it on one of those field test compilers to see if it's already fixed before I zip it to the support center? Oh...It does compile fine with the usual vax 3.1 c compiler and with vcc. #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # rh.h # rhcmds.c # typescript # what.ccom # This archive created: Mon Jan 15 02:45:29 1990 export PATH; PATH=/bin:$PATH echo shar: extracting "'rh.h'" '(4290 characters)' if test -f 'rh.h' then echo shar: will not over-write existing file "'rh.h'" else sed 's/^ X//' << \SHAR_EOF > 'rh.h' X X/* ---------------------------------------------------------------------- X * FILE: rh.h X * (c) 1989 Ken Stauffer X * This header contains the #define's for the tokens. X * It also contains the initialized arrays. By having X * rh.c define a symbol MAIN, the space is allocated for these globals X * only once. X * X * ---------------------------------------------------------------------- */ X X#include <stdio.h> X X#define START 256 X#define OR 256 /* || */ X#define AND 257 /* && */ X#define LE 258 /* <= */ X#define LT 259 /* < */ X#define GE 260 /* >= */ X#define GT 261 /* > */ X#define NE 262 /* != */ X#define EQ 263 /* == */ X#define BOR 264 /* | */ X#define BAND 265 /* & */ X#define BXOR 266 /* ^ */ X#define NOT 267 /* ! */ X#define PLUS 268 /* + */ X#define MUL 269 /* * */ X#define MINUS 270 /* - */ X#define DIV 271 /* / */ X#define MOD 272 /* % */ X#define BNOT 273 /* ~ */ X#define UNIMINUS 274 /* - */ X#define SHIFTL 275 /* << */ X#define SHIFTR 276 /* >> */ X#define QM 277 /* ? */ X#define COLON 278 /* : */ X#define NOP 279 /* */ X X#define NUMBER 280 /* eg. 1234,NOW,IFDIR */ X#define STAR 281 /* eg. "*.BAK" */ X#define FIELD 282 /* mode, uid */ X#define MACRONAME 283 X#define UNKNOWN 284 X X#define NOW_INDEX 1 /* where to place the current time */ X#define MACRO_INDEX 0 /* where the macro name goes */ X X#define LENGTH 100 /* size of stack program */ X#define MEM 20 /* size of stack */ X#define IDLENGTH 20 X#define STARLEN 1000 /* total chars available for strings */ X X#if BSD || SUN X#define DEPTH getdtablesize() X#endif X X#if XENIX || SYSV X/* This value was arbitrarily chosen */ X#define DEPTH 24 X#endif X Xstruct instr { X int i_type; X long i_value; X}; X X#ifdef MAIN X Xextern c_or(), c_and(), c_le(), c_lt(), c_ge(), X c_gt(), c_ne(), c_eq(), c_bor(), c_band(), X c_bxor(), c_not(), c_plus(), c_mul(), c_minus(), X c_div(), c_mod(), c_number(), c_atime(), c_ctime(), X c_dev(), c_gid(), c_ino(), c_mode(), c_mtime(), X c_nlink(), c_rdev(), c_size(), c_uid(), c_star(), X c_bnot(), c_uniminus(), c_lshift(), c_rshift(), c_qm(), X c_colon(), c_nop(); X X#if SUN || BSD Xchar *identifiers[]={ "", "NOW" , "IFBLK", "IFCHR", "IFDIR", "IFLNK", "IFMT", X "IFREG", "IFSOCK", "ISGID", "ISUID", "ISVTX", X "atime", "ctime", "dev", "gid", "ino", X "mode", "mtime", "nlink", "rdev", "size", "uid", X NULL }; X Xlong constants[]={ 0,0, X S_IFBLK, S_IFCHR, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, S_IFSOCK, X S_ISGID, S_ISUID, S_ISVTX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; X#endif X X#if XENIX || SYSV Xchar *identifiers[]={ "", "NOW", "IFBLK", "IFCHR", "IFDIR", "IFMT", X "IFREG", "IFIFO", "ISGID", "ISUID", "ISVTX", X "atime", "ctime", "dev", "gid", "ino", X "mode", "mtime", "nlink", "rdev", "size", "uid", X NULL }; X Xlong constants[]={ 0,0, X S_IFBLK, S_IFCHR, S_IFDIR, S_IFMT, S_IFREG, S_IFIFO, X S_ISGID, S_ISUID, S_ISVTX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; X#endif X Xint (*commands[])()= { X c_or, c_and, c_le, c_lt, c_ge, X c_gt, c_ne, c_eq, c_bor, c_band, X c_bxor, c_not, c_plus, c_mul, c_minus, X c_div, c_mod, c_bnot, c_uniminus,c_lshift, X c_rshift, c_qm, c_colon, c_nop, c_number, X c_star, c_atime, c_ctime, c_dev, c_gid, X c_ino, c_mode, c_mtime, c_nlink, c_rdev, X c_size, c_uid }; X X long tokenval; X long token; X X struct instr StackProgram[ LENGTH ]; X int PC; X X long Stack[ MEM ]; X int SP; X X struct stat *globuf; X char *fname; X int dashf; X int dashl; X int dashe; X int dashr; X int dashh; X int dashm; X int dasha; X char *expstr; X FILE *expfile; X X char Starbuf[ STARLEN ]; X int starfree=0; X X#else X extern long constants[]; X extern char *identifiers[]; X extern int (*commands[])(); X X extern long tokenval; X extern long token; X extern struct instr StackProgram[]; X extern int PC; X extern long Stack[]; X extern int SP; X extern struct stat *globuf; X extern char *fname; X extern char Starbuf[]; X extern int starfree; X extern int dashf; X extern int dashl; X extern int dashe; X extern int dashr; X extern int dashh; X extern int dashm; X extern int dasha; X extern char *expstr; X extern FILE *expfile; X#endif SHAR_EOF if test 4290 -ne "`wc -c < 'rh.h'`" then echo shar: error transmitting "'rh.h'" '(should have been 4290 characters)' fi fi # end of overwriting check echo shar: extracting "'rhcmds.c'" '(3879 characters)' if test -f 'rhcmds.c' then echo shar: will not over-write existing file "'rhcmds.c'" else sed 's/^ X//' << \SHAR_EOF > 'rhcmds.c' X X/* ---------------------------------------------------------------------- X * FILE: rhcmds.c X * (c) 1989 Ken Stauffer X * This file contains the functions that do the evaluation of X * the stack program. X * These functions are simple, and behave like RPN operators, that is X * they use the last two values on that stack, apply an operator X * and push the result. Similarly for unary ops. X * X * ---------------------------------------------------------------------- */ X X#include "rh.h" X#include <sys/types.h> X#include <sys/stat.h> X Xc_or(i) long i; { Stack[SP-2]=Stack[SP-2] || Stack[SP-1]; SP--; } Xc_and(i) long i; { Stack[SP-2]=Stack[SP-2] && Stack[SP-1]; SP--; } Xc_le(i) long i; { Stack[SP-2]=Stack[SP-2] <= Stack[SP-1]; SP--; } Xc_lt(i) long i; { Stack[SP-2]=Stack[SP-2] < Stack[SP-1]; SP--; } Xc_ge(i) long i; { Stack[SP-2]=Stack[SP-2] >= Stack[SP-1]; SP--; } Xc_gt(i) long i; { Stack[SP-2]=Stack[SP-2] > Stack[SP-1]; SP--; } Xc_ne(i) long i; { Stack[SP-2]=Stack[SP-2] != Stack[SP-1]; SP--; } Xc_eq(i) long i; { Stack[SP-2]=Stack[SP-2] == Stack[SP-1]; SP--; } Xc_bor(i) long i; { Stack[SP-2]=Stack[SP-2] | Stack[SP-1]; SP--; } Xc_band(i) long i; { Stack[SP-2]=Stack[SP-2] & Stack[SP-1]; SP--; } Xc_bxor(i) long i; { Stack[SP-2]=Stack[SP-2] ^ Stack[SP-1]; SP--; } Xc_plus(i) long i; { Stack[SP-2]=Stack[SP-2] + Stack[SP-1];SP--; } Xc_mul(i) long i; { Stack[SP-2]=Stack[SP-2] * Stack[SP-1]; SP--; } Xc_minus(i)long i; { Stack[SP-2]=Stack[SP-2] - Stack[SP-1]; SP--; } Xc_div(i) long i; { Stack[SP-2]=Stack[SP-2] / Stack[SP-1]; SP--; } Xc_mod(i) long i; { Stack[SP-2]=Stack[SP-2] % Stack[SP-1]; SP--; } Xc_lshift(i) long i; { Stack[SP-2]=Stack[SP-2] << Stack[SP-1]; SP--; } Xc_rshift(i) long i; { Stack[SP-2]=Stack[SP-2] >> Stack[SP-1]; SP--; } X X/* unary instructions */ X Xc_not(i) long i; { Stack[SP-1]= ! Stack[SP-1]; } Xc_bnot(i) long i; { Stack[SP-1]= ~ Stack[SP-1]; } Xc_uniminus(i) long i; { Stack[SP-1]= - Stack[SP-1]; } X X/* trinary operator ?: */ X Xc_qm(i) long i; { PC = (Stack[SP-1]) ? PC : i; SP--; } Xc_colon(i) long i; { PC = i; } Xc_nop(i) long i; { } X X/* operand functions */ X Xc_number(i) long i; { Stack[SP++] = i; } Xc_atime(i) long i; { Stack[SP++] = globuf->st_atime; } Xc_ctime(i) long i; { Stack[SP++] = globuf->st_ctime; } Xc_dev(i) long i; { Stack[SP++] = globuf->st_dev; } Xc_gid(i) long i; { Stack[SP++] = globuf->st_gid; } Xc_ino(i) long i; { Stack[SP++] = globuf->st_ino; } Xc_mode(i) long i; { Stack[SP++] = globuf->st_mode; } Xc_mtime(i) long i; { Stack[SP++] = globuf->st_mtime; } Xc_nlink(i) long i; { Stack[SP++] = globuf->st_nlink; } Xc_rdev(i) long i; { Stack[SP++] = globuf->st_rdev; } Xc_size(i) long i; { Stack[SP++] = globuf->st_size; } Xc_uid(i) long i; { Stack[SP++] = globuf->st_uid; } X X X/* ---------------------------------------------------------------------- X * star: X * This implements the trivial regular expression stuff. X * Since people may want to upgrade this, I will explain the X * parameter. 'i' is an index into the array Startbuf[]. The X * string contained there is the actual '\0' terminated X * string that occured in the expression (eg "*.BAK" ), minus X * the "'s. X * The reasons for the simplistic regular expressions is X * because it was easy, because lots of unix systems do X * regexp() in lots of ways and this method is fairly fast. X * X */ X Xc_star(i) Xlong i; X{ X X register int ri,ii; X X if( Starbuf[i]=='*') { X ii=strlen(fname)-1; X ri=strlen(Starbuf+i)-1+i; X while( fname[ii]==Starbuf[ri] && ri>i ) { X ri--; ii--; X } X Stack[SP++] = (ri==i); X } X else { X int x=0; X ii=0; X while( fname[x] ) { X if(fname[x]=='/') ii=x; X x++; X } X ii++; X ri=i; X while( fname[ii]==Starbuf[ri] && Starbuf[ri]!='*' X && fname[ii] && Starbuf[ri]) { X ri++; ii++; X } X Stack[SP++]=!(fname[ii]+Starbuf[ri]) || Starbuf[ri]=='*'; X } X} X SHAR_EOF if test 3879 -ne "`wc -c < 'rhcmds.c'`" then echo shar: error transmitting "'rhcmds.c'" '(should have been 3879 characters)' fi fi # end of overwriting check echo shar: extracting "'typescript'" '(201 characters)' if test -f 'typescript' then echo shar: will not over-write existing file "'typescript'" else sed 's/^ X//' << \SHAR_EOF > 'typescript' XScript started on Mon Jan 15 02:30:24 1990 Xcsh> cc -DBSD rhcmds.c X(ccom): rhcmds.c, line 107: ccom: Internal: wasted space: 2002074560 X } X ^ Xcsh> Xscript done on Mon Jan 15 02:30:43 1990 SHAR_EOF if test 201 -ne "`wc -c < 'typescript'`" then echo shar: error transmitting "'typescript'" '(should have been 201 characters)' fi fi # end of overwriting check echo shar: extracting "'what.ccom'" '(842 characters)' if test -f 'what.ccom' then echo shar: will not over-write existing file "'what.ccom'" else sed 's/^ X//' << \SHAR_EOF > 'what.ccom' X/usr/lib/ccom1.31 X yaccpar 4.1 (Berkeley) 2/11/83 X sprintf.c 1.1 (ULTRIX) 2/21/89 X data.c 1.1 (ULTRIX) 2/21/89 X freopen.c 1.1 ULTRIX 2/21/89 X signal.c 1.1 ULTRIX 2/21/89 X ctype.c 1.1 ULTRIX 2/21/89 X malloc.c 1.1 (ULTRIX) 2/21/89 X fprintf.c 1.1 (ULTRIX) 2/21/89 X strlen.c 1.1 (ULTRIX) 2/21/89 X printf.c 1.1 (ULTRIX) 2/21/89 X strncpy.c 1.1 (ULTRIX) 2/21/89 X calloc.c 1.1 (ULTRIX) 2/21/89 X fputs.c 1.1 (ULTRIX) 2/21/89 X atof.c 1.1 (ULTRIX) 2/21/89 X flsbuf.c 1.1 (ULTRIX) 2/21/89 X ftell.c 1.1 (ULTRIX) 2/21/89 X fseek.c 1.1 (ULTRIX) 2/21/89 X fread.c 1.1 (ULTRIX) 2/21/89 X fwrite.c 1.1 (ULTRIX) 2/21/89 X doprnt.c 1.1 (ULTRIX) 2/21/89 X fclose.c 1.1 (ULTRIX) 2/21/89 X doopen.c 1.1 ULTRIX 2/21/89 X filbuf.c 1.1 ULTRIX 2/21/89 X fdopen.c 1.1 ULTRIX 2/21/89 X getstdiobuf.c 1.1 (ULTRIX) 2/21/89 X _locale.c 1.1 ULTRIX 2/21/89 X findiop.c 1.1 ULTRIX 2/21/89 SHAR_EOF if test 842 -ne "`wc -c < 'what.ccom'`" then echo shar: error transmitting "'what.ccom'" '(should have been 842 characters)' fi fi # end of overwriting check # End of shell archive exit 0 -- George Robbins - now working for, uucp: {uunet|pyramid|rutgers}!cbmvax!grr but no way officially representing arpa: cbmvax!grr@uunet.uu.net Commodore, Engineering Department fone: 215-431-9255 (only by moonlite)