diff --git a/include/dbm.h b/include/dbm.h deleted file mode 100644 index bb1685f..0000000 --- a/include/dbm.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 1980 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. - * - * @(#)dbm.h 5.1 (Berkeley) 3/27/86 - */ - -#ifndef NULL -/* - * this is lunacy, we no longer use it (and never should have - * unconditionally defined it), but, this whole file is for - * backwards compatability - someone may rely on this. - */ -#define NULL ((char *) 0) -#endif - -#include - -datum fetch(); -datum firstkey(); -datum nextkey(); -#if 0 -datum makdatum(); -datum firsthash(); -long calchash(); -long hashinc(); -#endif diff --git a/include/limits.h b/include/limits.h index 53174cf..2f6e061 100644 --- a/include/limits.h +++ b/include/limits.h @@ -36,36 +36,6 @@ #ifndef _LIMITS_H_ #define _LIMITS_H_ -/* - * We don't need this crud at the moment so save on abuse of the C - * preprocessor by not doing the defines. - -#define _POSIX_ARG_MAX 4096 -#define _POSIX_CHILD_MAX 6 -#define _POSIX_LINK_MAX 8 -#define _POSIX_MAX_CANON 255 -#define _POSIX_MAX_INPUT 255 -#define _POSIX_NAME_MAX 14 -#define _POSIX_NGROUPS_MAX 0 -#define _POSIX_OPEN_MAX 16 -#define _POSIX_PATH_MAX 255 -#define _POSIX_PIPE_BUF 512 -#define _POSIX_SSIZE_MAX 32767 -#define _POSIX_STREAM_MAX 8 -#define _POSIX_TZNAME_MAX 3 - -#define _POSIX2_BC_BASE_MAX 99 -#define _POSIX2_BC_DIM_MAX 2048 -#define _POSIX2_BC_SCALE_MAX 99 -#define _POSIX2_BC_STRING_MAX 1000 -#define _POSIX2_EQUIV_CLASS_MAX 2 -#define _POSIX2_EXPR_NEST_MAX 32 -#define _POSIX2_LINE_MAX 2048 -#define _POSIX2_RE_DUP_MAX 255 - -*/ - #include -/* #include */ #endif /* !_LIMITS_H_ */ diff --git a/include/pcc.h b/include/pcc.h deleted file mode 100644 index efc6da5..0000000 --- a/include/pcc.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. - * - * @(#)pcc.h 5.1 (Berkeley) 5/30/85 - */ - -/* - * This file contains definitions for all the constants and structures - * needed to use the intermediate code files generated and read by - * the Portable C Compiler and related compilers. - * - * Rules for changing this code: - * 1) All op values must be integer constants -- this permits us to run - * a 'sed' script on this file to create %term declarations for yacc. - * 2) Because the PCC uses fancy ASG and UNARY macros, assignment - * operators must have values 1 greater than corresponding normal - * operators, and unary operators must have values 2 greater ditto. - * 3) Ops used only by f1 must have values >= 150 (PCCF_FORTOPS). - * 4) Other language-dependent ops must have values >= 200. - */ - -# ifndef PCC_TOKENS - -# define PCC_TOKENS 0 - -# define PCC_ERROR 1 /* an error node */ -# define PCC_FREE 2 /* an unused node */ - -/* - * Constants. - */ -# define PCC_STRING 3 /* a string constant */ -# define PCC_ICON 4 /* an integer constant */ -# define PCC_FCON 5 /* a floating point constant */ -# define PCC_DCON 6 /* a double precision f.p. constant */ - -/* - * Leaf types. - */ -# define PCC_NAME 7 /* an identifier */ -# define PCC_REG 8 /* a register */ -# define PCC_OREG 9 /* register and offset */ -# define PCC_CCODES 10 /* condition codes */ -# define PCC_FLD 11 /* a bit field */ - -/* - * Arithmetic operators. - */ -# define PCC_PLUS 12 /* + */ -# define PCC_PLUSEQ 13 /* += */ -# define PCC_UPLUS 14 /* unary + (for completeness) */ -# define PCC_MINUS 15 /* - */ -# define PCC_MINUSEQ 16 /* -= */ -# define PCC_UMINUS 17 /* unary - */ -# define PCC_MUL 18 /* * */ -# define PCC_MULEQ 19 /* *= */ -/* Reserve a slot for 'unary *', which is PCC jargon for PCC_DEREF (yech) */ -# define PCC_DIV 21 /* / */ -# define PCC_DIVEQ 22 /* /= */ -# define PCC_MOD 23 /* % */ -# define PCC_MODEQ 24 /* %= */ -# define PCC_INCR 25 /* ++ */ -# define PCC_DECR 26 /* -- */ -# define PCC_ASSIGN 27 /* = (these last 3 are stretching it) */ - -/* - * Bit operators. - */ -# define PCC_AND 28 /* & */ -# define PCC_ANDEQ 29 /* &= */ -/* Reserve a slot for 'unary &', jargon for PCC_ADDROF */ -# define PCC_OR 31 /* | */ -# define PCC_OREQ 32 /* |= */ -# define PCC_ER 33 /* ^ */ -# define PCC_EREQ 34 /* ^= */ -# define PCC_LS 35 /* << */ -# define PCC_LSEQ 36 /* <<= */ -# define PCC_RS 37 /* >> */ -# define PCC_RSEQ 38 /* >>= */ -# define PCC_COMPL 39 /* ~ */ - -/* - * Booleans. - */ -# define PCC_EQ 40 /* == */ -# define PCC_NE 41 /* != */ -# define PCC_LE 42 /* <= */ -# define PCC_LT 43 /* < */ -# define PCC_GE 44 /* >= */ -# define PCC_GT 45 /* > */ -# define PCC_ULE 46 /* unsigned <= */ -# define PCC_ULT 47 /* unsigned < */ -# define PCC_UGE 48 /* unsigned >= */ -# define PCC_UGT 49 /* unsigned > */ -# define PCC_QUEST 50 /* ? (for conditional expressions) */ -# define PCC_COLON 51 /* : (for conditional expressions) */ -# define PCC_ANDAND 52 /* && */ -# define PCC_OROR 53 /* || */ -# define PCC_NOT 54 /* ! */ - -/* - * Function calls. - */ -# define PCC_CALL 55 /* call by value */ -/* no ASG */ -# define PCC_UCALL 57 /* call with no arguments */ -# define PCC_FORTCALL 58 /* call by reference? */ -/* no ASG */ -# define PCC_UFORTCALL 60 /* ??? */ -# ifdef INLINE -# define PCC_INLINE 61 /* inline function */ -/* no ASG */ -# define PCC_UINLINE 63 /* inline with no arguments */ -# endif INLINE - -/* - * Referencing and dereferencing. - */ -# define PCC_DEREF 20 /* * */ -# define PCC_ADDROF 30 /* & */ - -/* - * Special structure operators. - */ -# define PCC_DOT 64 /* . */ -# define PCC_STREF 65 /* -> */ -# define PCC_STASG 66 /* structure assignment */ -# define PCC_STARG 67 /* an argument of type structure */ -# define PCC_STCALL 68 /* a function of type structure */ -/* no ASG */ -# define PCC_USTCALL 70 /* unary structure function */ - -/* - * Conversions. - */ -# define PCC_SCONV 71 /* scalar conversion */ -# define PCC_PCONV 72 /* pointer conversion */ -# define PCC_PMCONV 73 /* pointer multiply conversion */ -# define PCC_PVCONV 74 /* pointer divide conversion */ -# define PCC_CAST 75 /* redundant? */ - -/* - * Bracket types. - */ -# define PCC_LB 76 /* [ */ -# define PCC_RB 77 /* ] */ - -/* - * Comma nodes. - */ -# define PCC_COMOP 78 /* , (in expressions) */ -# define PCC_CM 79 /* , (in argument lists) */ - -/* - * Miscellaneous. - */ -# define PCC_FORCE 80 /* result of last expression goes in r0 */ -# define PCC_GOTO 81 /* unconditional goto */ -# define PCC_CBRANCH 82 /* goto label if !test */ -# define PCC_RETURN 83 /* return from function */ -# define PCC_INIT 84 /* initialized data */ -# define PCC_TYPE 85 /* a type */ -# define PCC_CLASS 86 /* a storage class */ - -# define PCC_MAXOP 86 /* highest numbered PCC op */ - -/* - * Special codes for interfacing to /lib/f1. - */ -# define PCCF_FORTOPS 150 -# define PCCF_FTEXT 150 /* pass literal assembler text */ -# define PCCF_FEXPR 151 /* a statement */ -# define PCCF_FSWITCH 152 /* not implemented */ -# define PCCF_FLBRAC 153 /* beginning of subroutine */ -# define PCCF_FRBRAC 154 /* end of subroutine */ -# define PCCF_FEOF 155 /* end of file */ -# define PCCF_FARIF 156 /* not implemented */ -# define PCCF_FLABEL 157 /* an f77 label */ - -# endif PCC_TOKENS - - -/* - * Types, as encoded in intermediate file cookies. - */ -# define PCCT_UNDEF 0 -# define PCCT_FARG 1 /* function argument */ -# define PCCT_CHAR 2 -# define PCCT_SHORT 3 -# define PCCT_INT 4 -# define PCCT_LONG 5 -# define PCCT_FLOAT 6 -# define PCCT_DOUBLE 7 -# define PCCT_STRTY 8 -# define PCCT_UNIONTY 9 -# define PCCT_ENUMTY 10 -# define PCCT_MOETY 11 /* member of enum */ -# define PCCT_UCHAR 12 -# define PCCT_USHORT 13 -# define PCCT_UNSIGNED 14 -# define PCCT_ULONG 15 - -/* - * Type modifiers. - */ -# define PCCTM_PTR 020 -# define PCCTM_FTN 040 -# define PCCTM_ARY 060 -# define PCCTM_BASETYPE 017 -# define PCCTM_TYPESHIFT 2 - - -/* - * Useful macros. 'PCCOM' macros apply to ops. - */ -# define PCCOM_ASG 1+ -# define PCCOM_UNARY 2+ -# define PCCOM_NOASG (-1)+ -# define PCCOM_NOUNARY (-2)+ - -# define PCCM_TRIPLE(op, var, type) \ - ((op) | ((var) << 8) | (long) (type) << 16) -# define PCCM_TEXT(s) \ - PCCM_TRIPLE(PCCF_FTEXT, (strlen(s) + 3) / 4, 0) -# define PCCM_ADDTYPE(t, m) \ - ((((t) &~ PCCTM_BASETYPE) << PCCTM_TYPESHIFT) | \ - (m) | ((t) & PCCTM_BASETYPE)) diff --git a/lib/libc/Makefile b/lib/libc/Makefile index d01b709..7340edb 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -87,10 +87,10 @@ OBJS += inet_addr.o inet_network.o inet_netof.o \ inet_ntoa.o inet_lnaof.o inet_maddr.o # libc/compat -OBJS += creat.o ftime.o gethostid.o gtty.o memccpy.o memchr.o \ +OBJS += creat.o ftime.o gethostid.o memccpy.o memchr.o \ memcmp.o memcpy.o memset.o nice.o pause.o rand.o \ sethostid.o setregid.o setreuid.o setrgid.o setruid.o \ - sigcompat.o strchr.o strrchr.o stty.o times.o tmpnam.o \ + sigcompat.o strchr.o strrchr.o times.o tmpnam.o \ utime.o # libc/runtime diff --git a/rootfs.manifest b/rootfs.manifest index c88d0d6..853ab15 100644 --- a/rootfs.manifest +++ b/rootfs.manifest @@ -757,7 +757,6 @@ file /include/arpa/inet.h file /include/assert.h file /include/ctype.h file /include/curses.h -file /include/dbm.h file /include/fcntl.h file /include/float.h file /include/fstab.h @@ -785,7 +784,6 @@ file /include/mtab.h file /include/ndbm.h file /include/nlist.h file /include/paths.h -file /include/pcc.h file /include/psout.h file /include/pwd.h file /include/ranlib.h diff --git a/src/cmd/ls/ls.c b/src/cmd/ls/ls.c index f709ed5..b6d102e 100644 --- a/src/cmd/ls/ls.c +++ b/src/cmd/ls/ls.c @@ -17,7 +17,6 @@ #include #include #include -//#include #include #define kbytes(size) (((size) + 1023) / 1024) @@ -79,7 +78,7 @@ main(argc, argv) twidth = 80; if (isatty(1)) { qflg = Cflg = 1; - (void) gtty(1, &sgbuf); + ioctl(1, TIOCGETP, &sgbuf); if (ioctl(1, TIOCGWINSZ, &win) != -1) twidth = (win.ws_col == 0 ? 80 : win.ws_col); if ((sgbuf.sg_flags & XTABS) != XTABS) diff --git a/src/cmd/more/more.c b/src/cmd/more/more.c index a864778..99c1b02 100644 --- a/src/cmd/more/more.c +++ b/src/cmd/more/more.c @@ -1455,7 +1455,8 @@ initterm () struct winsize win; retry: - if (!(no_tty = gtty(fileno(stdout), &otty))) { + no_tty = ioctl(fileno(stdout), TIOCGETP, &otty); + if (no_tty == 0) { if (ioctl(fileno(stdout), TIOCLGET, &lmode) < 0) { perror("TIOCLGET"); exit(1); @@ -1548,8 +1549,8 @@ retry: if ((shell = getenv("SHELL")) == NULL) shell = _PATH_BSHELL; } - no_intty = gtty(fileno(stdin), &otty); - gtty(fileno(stderr), &otty); + no_intty = ioctl(fileno(stdin), TIOCGETP, &otty); + ioctl(fileno(stderr), TIOCGETP, &otty); savetty = otty; hardtabs = !(otty.sg_flags & XTABS); if (! no_tty) { diff --git a/src/cmd/picoc/Makefile b/src/cmd/picoc/Makefile index 6716b5e..8e14ef8 100644 --- a/src/cmd/picoc/Makefile +++ b/src/cmd/picoc/Makefile @@ -2,43 +2,36 @@ TOPSRC = $(shell cd ../../..; pwd) include $(TOPSRC)/target.mk #CC=gcc -CFLAGS+= -g -DUNIX_HOST -DVER='"1.0"' -DFILENAME_MAX=64 -DL_tmpnam=30 -DCLOCKS_PER_SEC=80000000 -DPATH_MAX=200 -Os -Werror -LIBS=-lm -lc +CFLAGS += -g -DUNIX_HOST -DVER='"1.0"' -DFILENAME_MAX=64 \ + -DL_tmpnam=30 -DCLOCKS_PER_SEC=80000000 -DPATH_MAX=200 \ + -DNO_FP -Os -Werror -mips16 +LIBS = -lm -lc -TARGET = picoc -SRCS = picoc.c table.c lex.c parse.c expression.c heap.c type.c \ - variable.c clibrary.c platform.c include.c debug.c \ - platform/platform_unix.c platform/library_unix.c \ - cstdlib/stdio.c cstdlib/math.c cstdlib/string.c cstdlib/stdlib.c \ - cstdlib/time.c cstdlib/errno.c cstdlib/ctype.c cstdlib/stdbool.c \ - cstdlib/unistd.c retrobsd.c -OBJS := $(SRCS:%.c=%.o) +TARGET = picoc +SRCS = picoc.c table.c lex.c parse.c expression.c heap.c type.c \ + variable.c clibrary.c platform.c include.c debug.c \ + platform/platform_unix.c platform/library_unix.c \ + cstdlib/stdio.c cstdlib/math.c cstdlib/string.c cstdlib/stdlib.c \ + cstdlib/time.c cstdlib/errno.c cstdlib/ctype.c cstdlib/stdbool.c \ + cstdlib/unistd.c retrobsd.c +OBJS := $(SRCS:%.c=%.o) -all: $(TARGET) +all: $(TARGET) -$(TARGET): $(OBJS) - ${CC} ${LDFLAGS} -o ${TARGET}.elf ${OBJS} ${LIBS} - ${OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis - ${SIZE} ${TARGET}.elf - ${ELF2AOUT} ${TARGET}.elf $@ +$(TARGET): $(OBJS) + ${CC} ${LDFLAGS} -o ${TARGET}.elf ${OBJS} ${LIBS} + ${OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis + ${SIZE} ${TARGET}.elf + ${ELF2AOUT} ${TARGET}.elf $@ -install: $(TARGET) - cp $(TARGET) $(TOPSRC)/bin +install: $(TARGET) + cp $(TARGET) $(TOPSRC)/bin -test: all - (cd tests; make test) +test: all + (cd tests; make test) clean: - rm -f $(TARGET) $(OBJS) *~ *.elf *.dis - -count: - @echo "Core:" - @cat picoc.h interpreter.h picoc.c table.c lex.c parse.c expression.c platform.c heap.c type.c variable.c include.c debug.c | grep -v '^[ ]*/\*' | grep -v '^[ ]*$$' | wc - @echo "" - @echo "Everything:" - @cat $(SRCS) *.h */*.h | wc - -.PHONY: clibrary.c + rm -f $(TARGET) *.o */*.o *~ *.elf *.dis picoc.o: picoc.c picoc.h table.o: table.c interpreter.h platform.h diff --git a/src/games/boggle/Makefile b/src/games/boggle/Makefile index 16ac5b9..dfa2294 100644 --- a/src/games/boggle/Makefile +++ b/src/games/boggle/Makefile @@ -9,7 +9,7 @@ TOPSRC = $(shell cd ../../..; pwd) include $(TOPSRC)/target.mk #include $(TOPSRC)/cross.mk -CFLAGS += -O +CFLAGS += -O -Wall -Werror OBJS = boggle.o MAN = boggle.0 MANSRC = boggle.6 diff --git a/src/games/boggle/boggle.c b/src/games/boggle/boggle.c index eaa0046..a407ae1 100644 --- a/src/games/boggle/boggle.c +++ b/src/games/boggle/boggle.c @@ -17,16 +17,16 @@ #include /* basic parameters */ -#define N 4 -#define SSIZE 200 -#define MAXWORDS 1000 -#define CWIDTH 10 -#define LWIDTH 80 +#define N 4 +#define SSIZE 200 +#define MAXWORDS 1000 +#define CWIDTH 10 +#define LWIDTH 80 /* parameters defined in terms of above */ -#define BSIZE (N*N) -#define row(x) (x/N) -#define col(x) (x%N) +#define BSIZE (N*N) +#define row(x) (x/N) +#define col(x) (x%N) /* word being searched for */ int wlength; @@ -63,8 +63,8 @@ FILE *dict; /* structures for doing matching */ struct frame { - struct frame *parent; - int place; + struct frame *parent; + int place; }; struct frame stack [SSIZE]; struct frame *level [BSIZE+1]; @@ -78,10 +78,10 @@ char occurs [26]; /* the boggle cubes */ char *cube [BSIZE] = { - "forixb", "moqabj", "gurilw", "setupl", - "cmpdae", "acitao", "slcrae", "romash", - "nodesw", "hefiye", "onudtk", "tevign", - "anedvz", "pinesh", "abilyt", "gkyleu" + "forixb", "moqabj", "gurilw", "setupl", + "cmpdae", "acitao", "slcrae", "romash", + "nodesw", "hefiye", "onudtk", "tevign", + "anedvz", "pinesh", "abilyt", "gkyleu" }; /* storage for words found */ @@ -92,557 +92,572 @@ char space[10000]; void endline () { - if (column != 0) { - putchar('\n'); - column = 0; - } + if (column != 0) { + putchar('\n'); + column = 0; + } } void timeout () { - if (*timept > 0) { - signal (SIGALRM, timeout); - alarm(*timept++); - } - putchar('\007'); + if (*timept > 0) { + signal (SIGALRM, timeout); + alarm(*timept++); + } + putchar('\007'); } void interrupt () { - signal(SIGINT, interrupt); - if (delct++ >= 1) - longjmp(env, 1); - timept = &zero; + signal(SIGINT, interrupt); + if (delct++ >= 1) + longjmp(env, 1); + timept = &zero; } void goodbye (stat) int stat; { - if (master != 0) { - wait(&status); - if ( ctlecho & LCTLECH ) { - ioctl( fileno(stdin), TIOCLBIS, &lctlech ); - } - stty(fileno(stdin), &origttyb); - } - exit(stat); + if (master != 0) { + wait(&status); + if ( ctlecho & LCTLECH ) { + ioctl( fileno(stdin), TIOCLBIS, &lctlech ); + } + /* Restore original tty parameters. */ + ioctl(fileno(stdin), TIOCSETP, &origttyb); + } + exit(stat); } void clearscreen () { - stty (fileno(stdin), &tempttyb); - printf("\n\f\r"); + /* Set tty parameters. */ + ioctl(fileno(stdin), TIOCSETP, &tempttyb); + printf("\n\f\r"); } int wordcomp (p, q) register char *p, *q; { - if (*p=='0' && *q!='0') - return(-1); - if (*p!='0' && *q=='0') - return(1); - while (*++p == *++q && isalpha(*p)) ; - if (!isalpha(*p)) - return(-isalpha(*q)); - if (!isalpha(*q)) - return(1); - return(*p-*q); + if (*p=='0' && *q!='0') + return(-1); + if (*p!='0' && *q=='0') + return(1); + while (*++p == *++q && isalpha(*p)) ; + if (!isalpha(*p)) + return(-isalpha(*q)); + if (!isalpha(*q)) + return(1); + return(*p-*q); } int compare (a, b) char **a, **b; { - return(wordcomp(*a, *b)); + return(wordcomp(*a, *b)); } void printinst () { - stty (fileno(stdin), &tempttyb); - printf("instructions?"); - if (getchar() == 'y') { - clearscreen(); - printf(" The object of Boggle (TM Parker Bros.) is to find, within 3\n"); - printf("minutes, as many words as possible in a 4 by 4 grid of letters. Words\n"); - printf("may be formed from any sequence of 3 or more adjacent letters in the\n"); - printf("grid. The letters may join horizontally, vertically, or diagonally.\n"); - printf("However, no position in the grid may be used more than once within any\n"); - printf("one word. In competitive play amongst humans, each player is given\n"); - printf("credit for those of his words which no other player has found.\n"); - printf(" This program is intended for people wishing to sharpen their\n"); - printf("skills at Boggle. If you invoke the program with 4 arguments of 4\n"); - printf("letters each, (e.g. \"boggle appl epie moth erhd\") the program forms the\n"); - printf("obvious Boggle grid and lists all the words from /share/dict/words found\n"); - printf("therein. If you invoke the program without arguments, it will generate\n"); - printf("a board for you, let you enter words for 3 minutes, and then tell you\n"); - printf("how well you did relative to /share/dict/words.\n"); - printf(" In interactive play, enter your words separated by spaces, tabs,\n"); - printf("or newlines. A bell will ring when there is 2:00, 1:00, 0:10, 0:02,\n"); - printf("0:01, and 0:00 time left. You may complete any word started before the\n"); - printf("expiration of time. You can surrender before time is up by hitting\n"); - printf("'break'. While entering words, your erase character is only effective\n"); - printf("within the current word and your line kill character is ignored.\n"); - printf(" Advanced players may wish to invoke the program with 1 or 2 +'s as\n"); - printf("the first argument. The first + removes the restriction that positions\n"); - printf("can only be used once in each word. The second + causes a position to\n"); - printf("be considered adjacent to itself as well as its (up to) 8 neighbors.\n"); - printf("Hit any key to begin.\n"); - stty (fileno(stdin), &tempttyb); - getchar(); - } - stty (fileno(stdin), &tempttyb); + /* Set tty parameters. */ + ioctl(fileno(stdin), TIOCSETP, &tempttyb); + + printf("instructions?"); + if (getchar() == 'y') { + clearscreen(); + printf(" The object of Boggle (TM Parker Bros.) is to find, within 3\n"); + printf("minutes, as many words as possible in a 4 by 4 grid of letters. Words\n"); + printf("may be formed from any sequence of 3 or more adjacent letters in the\n"); + printf("grid. The letters may join horizontally, vertically, or diagonally.\n"); + printf("However, no position in the grid may be used more than once within any\n"); + printf("one word. In competitive play amongst humans, each player is given\n"); + printf("credit for those of his words which no other player has found.\n"); + printf(" This program is intended for people wishing to sharpen their\n"); + printf("skills at Boggle. If you invoke the program with 4 arguments of 4\n"); + printf("letters each, (e.g. \"boggle appl epie moth erhd\") the program forms the\n"); + printf("obvious Boggle grid and lists all the words from /share/dict/words found\n"); + printf("therein. If you invoke the program without arguments, it will generate\n"); + printf("a board for you, let you enter words for 3 minutes, and then tell you\n"); + printf("how well you did relative to /share/dict/words.\n"); + printf(" In interactive play, enter your words separated by spaces, tabs,\n"); + printf("or newlines. A bell will ring when there is 2:00, 1:00, 0:10, 0:02,\n"); + printf("0:01, and 0:00 time left. You may complete any word started before the\n"); + printf("expiration of time. You can surrender before time is up by hitting\n"); + printf("'break'. While entering words, your erase character is only effective\n"); + printf("within the current word and your line kill character is ignored.\n"); + printf(" Advanced players may wish to invoke the program with 1 or 2 +'s as\n"); + printf("the first argument. The first + removes the restriction that positions\n"); + printf("can only be used once in each word. The second + causes a position to\n"); + printf("be considered adjacent to itself as well as its (up to) 8 neighbors.\n"); + printf("Hit any key to begin.\n"); + + /* Set tty parameters. */ + ioctl(fileno(stdin), TIOCSETP, &tempttyb); + getchar(); + } + /* Set tty parameters. */ + ioctl(fileno(stdin), TIOCSETP, &tempttyb); } void setup () { - register int i, j; - int rd, cd, k; - for (i=0; i=2 ? 1 : 0; - adj[BSIZE][i] = 1; - for (j=0; j=2 ? 1 : 0; + adj[BSIZE][i] = 1; + for (j=0; j0 && (isspace(c=getchar()) || c==EOF)); - if (*timept == 0) - return(0); - word[wcount++] = freesp; - *freesp++ = '0'; - r = &wbuff[1]; - q = p = freesp; - *p++ = c; - while (!isspace(c = getchar())) { - if (c == EOF) - continue; - if (c == origttyb.sg_erase) { - if (p > q) - p--; - continue; - } - *p++ = c; - } - freesp = p; - for (p=q; p0 && (isspace(c=getchar()) || c==EOF)); + if (*timept == 0) + return(0); + word[wcount++] = freesp; + *freesp++ = '0'; + r = &wbuff[1]; + q = p = freesp; + *p++ = c; + while (!isspace(c = getchar())) { + if (c == EOF) + continue; + if (c == origttyb.sg_erase) { + if (p > q) + p--; + continue; + } + *p++ = c; + } + freesp = p; + for (p=q; p=10 ? '*' : '0'+ways; + *word[wcount-1] = ways>=10 ? '*' : '0'+ways; } void aputword (ways) int ways; { - /* store (wbuff, ways) in next slot in space */ - register int i; - *freesp++ = ways>=10 ? '*' : '0'+ways; - for (i=1; i<= wlength; i++) - *freesp++ = wbuff[i]; - word[++wcount] = freesp; + /* store (wbuff, ways) in next slot in space */ + register int i; + *freesp++ = ways>=10 ? '*' : '0'+ways; + for (i=1; i<= wlength; i++) + *freesp++ = wbuff[i]; + word[++wcount] = freesp; } void outword (p) register char *p; { - register int newcol; - register char *q; - for (q=p+1; isalpha(*q); ) { - putchar(*q); - if (*q++ == 'q') { - putchar('u'); - column++; - } - } - column += q-p-1; - if (column > LWIDTH-CWIDTH) { - putchar('\n'); - column = 0; - return; - } - newcol = ((column+CWIDTH)/CWIDTH)*CWIDTH; - while (((column+8)/8)*8 <= newcol) { - putchar('\t'); - column = ((column+8)/8)*8; - } - while (column < newcol) { - putchar(' '); - column++; - } + register int newcol; + register char *q; + for (q=p+1; isalpha(*q); ) { + putchar(*q); + if (*q++ == 'q') { + putchar('u'); + column++; + } + } + column += q-p-1; + if (column > LWIDTH-CWIDTH) { + putchar('\n'); + column = 0; + return; + } + newcol = ((column+CWIDTH)/CWIDTH)*CWIDTH; + while (((column+8)/8)*8 <= newcol) { + putchar('\t'); + column = ((column+8)/8)*8; + } + while (column < newcol) { + putchar(' '); + column++; + } } void tputword (ways) int ways; { - /* print (wbuff, ways) on terminal */ - wbuff[wlength+1] = '0'; - wbuff[0] = ways>=10 ? '*' : '0'+ways; - outword(&wbuff[0]); + /* print (wbuff, ways) on terminal */ + wbuff[wlength+1] = '0'; + wbuff[0] = ways>=10 ? '*' : '0'+ways; + outword(&wbuff[0]); } void printdiff () { - register int c, d, u; - char both, donly, uonly; - word[wcount] = freesp; - *freesp = '0'; - both = donly = uonly = column = d = 0; - u = ustart; - while (d < ubotch) { - c = u 0) - return(last-leaf); - count = 0; - present[BSIZE] = 1; - while (leaf < last) { - for (p = &present[0]; p < &present[BSIZE]; *p++ = 0); - for (node = leaf; present[node->place]++ == 0; node = node->parent); - if (node == &stack[0]) - count++; - leaf++; - } - return(count); + int count; + register char *p; + register struct frame *node; + if (super > 0) + return(last-leaf); + count = 0; + present[BSIZE] = 1; + while (leaf < last) { + for (p = &present[0]; p < &present[BSIZE]; *p++ = 0); + for (node = leaf; present[node->place]++ == 0; node = node->parent); + if (node == &stack[0]) + count++; + leaf++; + } + return(count); } int evalboard (getword, putword) int (*getword)(); void (*putword)(); { - register struct frame *top; - register int l, q; - int fo, found; - struct frame *parent, *lastparent; - char *padj; + register struct frame *top; + register int l, q; + int fo, found; + struct frame *parent, *lastparent; + char *padj; - numsame = found = 0; - makelists (); + numsame = found = 0; + makelists (); - while (1) { - l = numsame; - if (!(*getword) ()) - break; - top = level[l+1]; + while (1) { + l = numsame; + if (!(*getword) ()) + break; + top = level[l+1]; - while (1) { - level[l+1] = lastparent = top; - /* wbuff[1]...wbuff[l] have been matched */ - /* level[0],...,level[l] of tree built */ - if (l == wlength) { - if (wlength >= 3 && (q = numways(level[l], top)) != 0) { - (*putword) (q); - found++; - } - l = BSIZE+1; - break; - } - if ((fo = occurs[wbuff[++l]-'a']) == BSIZE) - break; - /* wbuff[1]...wbuff[l-1] have been matched */ - /* level[0],...,level[l-1] of tree built */ - for (parent=level[l-1]; parentplace][0]; - for (q=fo; q!=BSIZE; q=olink[q]) - if (padj[q]) { - top->parent = parent; - top->place = q; - if (++top >= &stack[SSIZE]) { - printf("stack overflow\n"); - goodbye(1); - } - } - } - /* were any nodes added? */ - if (top == lastparent) - break; - } + while (1) { + level[l+1] = lastparent = top; + /* wbuff[1]...wbuff[l] have been matched */ + /* level[0],...,level[l] of tree built */ + if (l == wlength) { + if (wlength >= 3 && (q = numways(level[l], top)) != 0) { + (*putword) (q); + found++; + } + l = BSIZE+1; + break; + } + if ((fo = occurs[wbuff[++l]-'a']) == BSIZE) + break; + /* wbuff[1]...wbuff[l-1] have been matched */ + /* level[0],...,level[l-1] of tree built */ + for (parent=level[l-1]; parentplace][0]; + for (q=fo; q!=BSIZE; q=olink[q]) + if (padj[q]) { + top->parent = parent; + top->place = q; + if (++top >= &stack[SSIZE]) { + printf("stack overflow\n"); + goodbye(1); + } + } + } + /* were any nodes added? */ + if (top == lastparent) + break; + } - /* advance until first l characters of next word are different */ - while (numsame >= l && (*getword)()) ; - } - return(found); + /* advance until first l characters of next word are different */ + while (numsame >= l && (*getword)()) ; + } + return(found); } int main (argc, argv) int argc; char **argv; { - char *q; - register char *p; - register int i, c; + char *q; + register char *p; + register int i, c; - gtty (fileno(stdin), &origttyb); - setbuf(stdin, NULL); - tempttyb = origttyb; - if (setjmp(env) != 0) - goodbye(0); - signal (SIGINT, interrupt); - timein = time(0L); - if (argv[0][0] != 'a' && (logfile = open("/games/lib/boglog", 1)) >= 0) { - p = &logbuff[5]; - q = getlogin(); - while ((*p++ = *q++)); - p[-1] = '\t'; - q = ctime(&timein); - while ((*p++ = *q++)); - logloc = lseek(logfile, 0L, 2); - write(logfile, &logbuff[0], p-&logbuff[1]); - } - if ((dict = fopen(dictname, "r")) == NULL) { - printf("can't open %s\n", dictname); - goodbye (2); - } - while ( argc > 1 && ( argv[1][0] == '+' || argv[1][0] == '-' ) ) { - if (argv[1][0]=='+') { - while(*(argv[1]++) == '+') - super++; - argc--; - argv++; - } - if ( argv[1][0] == '-' ) { - timeint[0] = 60 * ( atol( &argv[1][1] ) - 2 ); - if ( timeint[0] <= 0 ) { - timeint[0] = 60; - } - argc--; - argv++; - } - } - setup (); - switch (argc) { - default: punt: - printf("usage: boggle [+[+]] [row1 row2 row3 row4]\n"); - goodbye (3); - case 5: - for (i=0; i= 0) { - strncpy(&logbuff[0], "eval", 4); - lseek(logfile, logloc, 0); - write(logfile, &logbuff[0], 4); - } - goodbye(0); - case 1: - tempttyb.sg_flags |= CBREAK; - if ( ioctl( fileno(stdin), TIOCLGET, &ctlecho ) == 0 ) { - if ( ctlecho & LCTLECH ) { - ioctl( fileno(stdin), TIOCLBIC, &lctlech ); - } - } - printinst(); - srand((int) timein); - while (setjmp(env) == 0) { - errno = 0; - if (pipe(&pipefd[0]) != 0) { - printf("can't create pipe\n"); - goodbye(4); - } - genboard(); - delct = wcount = 0; - word[0] = freesp = &space[0]; - if ((master = fork()) == 0) { - close(pipefd[0]); - clearscreen(); - printboard(); - signal(SIGALRM, timeout); - timept = &timeint[0]; - alarm(*timept++); - evalboard(getuword, aputuword); - clearscreen(); - qsort(&word[0], wcount, sizeof (int), compare); - for (i=0; i= 0) { - sprintf(&logbuff[0], "%4d", games); - lseek(logfile, logloc, 0); - write(logfile, &logbuff[0], 4); - } - stty (fileno(stdin), &tempttyb); - printf("\nanother game?"); - if (getchar() != 'y') { - putchar('\n'); - break; - } - stty (fileno(stdin), &tempttyb); - } - goodbye(0); - } + /* Get tty parameters. */ + ioctl(fileno(stdin), TIOCGETP, &origttyb); + + setbuf(stdin, NULL); + tempttyb = origttyb; + if (setjmp(env) != 0) + goodbye(0); + signal (SIGINT, interrupt); + timein = time(0L); + if (argv[0][0] != 'a' && (logfile = open("/games/lib/boglog", 1)) >= 0) { + p = &logbuff[5]; + q = getlogin(); + while ((*p++ = *q++)); + p[-1] = '\t'; + q = ctime(&timein); + while ((*p++ = *q++)); + logloc = lseek(logfile, 0L, 2); + write(logfile, &logbuff[0], p-&logbuff[1]); + } + if ((dict = fopen(dictname, "r")) == NULL) { + printf("can't open %s\n", dictname); + goodbye (2); + } + while ( argc > 1 && ( argv[1][0] == '+' || argv[1][0] == '-' ) ) { + if (argv[1][0]=='+') { + while(*(argv[1]++) == '+') + super++; + argc--; + argv++; + } + if ( argv[1][0] == '-' ) { + timeint[0] = 60 * ( atol( &argv[1][1] ) - 2 ); + if ( timeint[0] <= 0 ) { + timeint[0] = 60; + } + argc--; + argv++; + } + } + setup (); + switch (argc) { + default: punt: + printf("usage: boggle [+[+]] [row1 row2 row3 row4]\n"); + goodbye (3); + case 5: + for (i=0; i= 0) { + strncpy(&logbuff[0], "eval", 4); + lseek(logfile, logloc, 0); + write(logfile, &logbuff[0], 4); + } + goodbye(0); + case 1: + tempttyb.sg_flags |= CBREAK; + if ( ioctl( fileno(stdin), TIOCLGET, &ctlecho ) == 0 ) { + if ( ctlecho & LCTLECH ) { + ioctl( fileno(stdin), TIOCLBIC, &lctlech ); + } + } + printinst(); + srand((int) timein); + while (setjmp(env) == 0) { + errno = 0; + if (pipe(&pipefd[0]) != 0) { + printf("can't create pipe\n"); + goodbye(4); + } + genboard(); + delct = wcount = 0; + word[0] = freesp = &space[0]; + if ((master = fork()) == 0) { + close(pipefd[0]); + clearscreen(); + printboard(); + signal(SIGALRM, timeout); + timept = &timeint[0]; + alarm(*timept++); + evalboard(getuword, aputuword); + clearscreen(); + qsort(&word[0], wcount, sizeof (int), compare); + for (i=0; i= 0) { + sprintf(&logbuff[0], "%4d", games); + lseek(logfile, logloc, 0); + write(logfile, &logbuff[0], 4); + } + /* Set tty parameters. */ + ioctl(fileno(stdin), TIOCSETP, &tempttyb); + + printf("\nanother game?"); + if (getchar() != 'y') { + putchar('\n'); + break; + } + /* Set tty parameters. */ + ioctl(fileno(stdin), TIOCSETP, &tempttyb); + } + goodbye(0); + } + return 0; } diff --git a/src/games/boggle/comp.c b/src/games/boggle/comp.c index d61eec6..310b4f6 100644 --- a/src/games/boggle/comp.c +++ b/src/games/boggle/comp.c @@ -11,19 +11,19 @@ char new[MAX], old[MAX]; int main () { - register int i, j; + register int i, j; - old[0] = '\0'; - while (fgets(&new[0], MAX, stdin) != NULL) { - for (i=0; i= MAX) { - fprintf(stderr, "long word\n"); - return 1; - } - putc(i, stdout); - for (j=0; (old[j]=new[j]) != '\n'; j++); - old[j] = '\0'; - fputs(&old[i], stdout); - } - return 0; + old[0] = '\0'; + while (fgets(&new[0], MAX, stdin) != NULL) { + for (i=0; i= MAX) { + fprintf(stderr, "long word\n"); + return 1; + } + putc(i, stdout); + for (j=0; (old[j]=new[j]) != '\n'; j++); + old[j] = '\0'; + fputs(&old[i], stdout); + } + return 0; } diff --git a/src/games/cribbage/Makefile b/src/games/cribbage/Makefile index e7ba584..a6d38ce 100644 --- a/src/games/cribbage/Makefile +++ b/src/games/cribbage/Makefile @@ -12,6 +12,7 @@ include $(TOPSRC)/target.mk #include $(TOPSRC)/cross.mk #CFLAGS = -O -Werror -DCROSS +CFLAGS += -Wall -Werror OBJS = extern.o crib.o support.o cards.o score.o io.o TOBJS = test.o cards.o score.o io.o extern.o MAN = cribbage.0 diff --git a/src/games/cribbage/crib.c b/src/games/cribbage/crib.c index b836b99..f22853e 100644 --- a/src/games/cribbage/crib.c +++ b/src/games/cribbage/crib.c @@ -130,7 +130,7 @@ BOOLEAN cut(mycrib, pos) BOOLEAN mycrib; int pos; { - register int i, cardx; + register int i; BOOLEAN win = FALSE; if (mycrib) { @@ -193,7 +193,7 @@ BOOLEAN mycrib; register int i, j, k; register int l; register int cnum, pnum, sum; - register BOOLEAN myturn, mego, ugo, last, played; + register BOOLEAN myturn, mego, ugo, last, played = 0; cnum = pnum = CINHAND; for (i = 0; i < CINHAND; i++) { /* make copies of hands */ @@ -366,7 +366,6 @@ BOOLEAN playhand(mycrib) BOOLEAN mycrib; { register int deckpos; - extern char Msgbuf[]; werase(Compwin); @@ -486,7 +485,6 @@ int main(argc, argv) int argc; char *argv[]; { - register char *p; BOOLEAN playing; char *s; /* for reading arguments */ char bust; /* flag for arg reader */ @@ -567,4 +565,5 @@ char *argv[]; } bye(0); + return 0; } diff --git a/src/games/cribbage/io.c b/src/games/cribbage/io.c index 68f4651..52bc764 100644 --- a/src/games/cribbage/io.c +++ b/src/games/cribbage/io.c @@ -289,8 +289,8 @@ int infrom(hand, n, prompt) */ int readchar() { - register int cnt, y, x; - auto char c; + register int cnt; + char c; over: cnt = 0; @@ -495,7 +495,6 @@ void wait_for(ch) */ void do_wait() { - register int line; static char prompt[] = { '-', '-', 'M', 'o', 'r', 'e', '-', '-', '\0' }; if (Mpos + sizeof prompt < MSG_X) diff --git a/src/libc/compat/Makefile b/src/libc/compat/Makefile index 917649e..d019eea 100644 --- a/src/libc/compat/Makefile +++ b/src/libc/compat/Makefile @@ -8,14 +8,14 @@ include $(TOPSRC)/target.mk CFLAGS += ${DEFS} -Os -SRCS = creat.c ftime.c gethostid.c gtty.c memccpy.c memchr.c memcmp.c \ +SRCS = creat.c ftime.c gethostid.c memccpy.c memchr.c memcmp.c \ memcpy.c memset.c nice.c pause.c rand.c sethostid.c \ setregid.c setreuid.c setrgid.c setruid.c sigcompat.c \ - strchr.c strrchr.c stty.c times.c tmpnam.c utime.c -OBJS = creat.o ftime.o gethostid.o gtty.o memccpy.o memchr.o memcmp.o \ + strchr.c strrchr.c times.c tmpnam.c utime.c +OBJS = creat.o ftime.o gethostid.o memccpy.o memchr.o memcmp.o \ memcpy.o memset.o nice.o pause.o rand.o sethostid.o \ setregid.o setreuid.o setrgid.o setruid.o sigcompat.o \ - strchr.o strrchr.o stty.o times.o tmpnam.o utime.o + strchr.o strrchr.o times.o tmpnam.o utime.o compat.a: ${OBJS} @echo "buiding compat.a" diff --git a/src/libc/compat/gtty.c b/src/libc/compat/gtty.c deleted file mode 100644 index c064413..0000000 --- a/src/libc/compat/gtty.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 1980 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. - */ - -/* - * Writearound to old gtty system call. - */ -#include - -int -gtty(fd, ap) - struct sgtty *ap; -{ - return ioctl(fd, TIOCGETP, ap); -} diff --git a/src/libc/compat/stty.c b/src/libc/compat/stty.c deleted file mode 100644 index b1f95aa..0000000 --- a/src/libc/compat/stty.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 1980 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. - */ - -/* - * Writearound to old stty system call. - */ -#include - -int -stty(fd, ap) - struct sgtty *ap; -{ - return ioctl (fd, TIOCSETP, ap); -}