Browse Source

Finishing ANSI C frontend

Manoel Trapier 11 years ago
parent
commit
2830ec90b1
70 changed files with 1144 additions and 882 deletions
  1. 1 1
      lang/cem/cemcom.ansi/LLlex.c
  2. 1 1
      lang/cem/cemcom.ansi/blocks.c
  3. 8 1
      lang/cem/cemcom.ansi/ch3mon.c
  4. 9 0
      lang/cem/cemcom.ansi/code.c
  5. 3 0
      lang/cem/cemcom.ansi/code_c.h
  6. 1 0
      lang/cem/cemcom.ansi/conversion.c
  7. 2 0
      lang/cem/cemcom.ansi/cstoper.c
  8. 11 0
      lang/cem/cemcom.ansi/dataflow.h
  9. 11 2
      lang/cem/cemcom.ansi/declar.g
  10. 4 0
      lang/cem/cemcom.ansi/declar.str
  11. 12 20
      lang/cem/cemcom.ansi/declarator.c
  12. 16 0
      lang/cem/cemcom.ansi/declarator.h
  13. 3 2
      lang/cem/cemcom.ansi/decspecs.c
  14. 49 56
      lang/cem/cemcom.ansi/domacro.c
  15. 15 16
      lang/cem/cemcom.ansi/domacro.h
  16. 8 12
      lang/cem/cemcom.ansi/error.c
  17. 6 0
      lang/cem/cemcom.ansi/estack.str
  18. 56 43
      lang/cem/cemcom.ansi/eval.c
  19. 11 0
      lang/cem/cemcom.ansi/eval.g.h
  20. 20 0
      lang/cem/cemcom.ansi/eval.h
  21. 31 58
      lang/cem/cemcom.ansi/expr.c
  22. 9 0
      lang/cem/cemcom.ansi/expr.str
  23. 12 12
      lang/cem/cemcom.ansi/expr_loc.h
  24. 9 2
      lang/cem/cemcom.ansi/expression.g
  25. 9 14
      lang/cem/cemcom.ansi/field.c
  26. 13 0
      lang/cem/cemcom.ansi/field_loc.h
  27. 4 2
      lang/cem/cemcom.ansi/fltcstoper.c
  28. 1 1
      lang/cem/cemcom.ansi/fltcstoper.h
  29. 45 66
      lang/cem/cemcom.ansi/idf.c
  30. 4 0
      lang/cem/cemcom.ansi/idf.str
  31. 12 12
      lang/cem/cemcom.ansi/idf_loc.h
  32. 11 5
      lang/cem/cemcom.ansi/init.c
  33. 12 0
      lang/cem/cemcom.ansi/init.h
  34. 7 0
      lang/cem/cemcom.ansi/input.c
  35. 5 0
      lang/cem/cemcom.ansi/input.h
  36. 57 82
      lang/cem/cemcom.ansi/ival.g
  37. 66 0
      lang/cem/cemcom.ansi/ival.h
  38. 6 5
      lang/cem/cemcom.ansi/label.c
  39. 9 0
      lang/cem/cemcom.ansi/label.h
  40. 29 26
      lang/cem/cemcom.ansi/main.c
  41. 20 0
      lang/cem/cemcom.ansi/main.h
  42. 15 16
      lang/cem/cemcom.ansi/options.c
  43. 12 0
      lang/cem/cemcom.ansi/options.h
  44. 5 5
      lang/cem/cemcom.ansi/pragma.c
  45. 12 0
      lang/cem/cemcom.ansi/pragma.h
  46. 9 2
      lang/cem/cemcom.ansi/program.g
  47. 16 0
      lang/cem/cemcom.ansi/program.h
  48. 35 40
      lang/cem/cemcom.ansi/proto.c
  49. 19 0
      lang/cem/cemcom.ansi/proto_loc.h
  50. 67 89
      lang/cem/cemcom.ansi/replace.c
  51. 11 11
      lang/cem/cemcom.ansi/replace_loc.h
  52. 8 8
      lang/cem/cemcom.ansi/skip.c
  53. 13 0
      lang/cem/cemcom.ansi/skip.h
  54. 11 24
      lang/cem/cemcom.ansi/stab.c
  55. 14 0
      lang/cem/cemcom.ansi/stab.h
  56. 26 23
      lang/cem/cemcom.ansi/stack.c
  57. 4 0
      lang/cem/cemcom.ansi/stack.str
  58. 16 0
      lang/cem/cemcom.ansi/stack_loc.h
  59. 7 1
      lang/cem/cemcom.ansi/statement.g
  60. 44 52
      lang/cem/cemcom.ansi/struct.c
  61. 6 6
      lang/cem/cemcom.ansi/struct_loc.h
  62. 22 23
      lang/cem/cemcom.ansi/switch.c
  63. 16 0
      lang/cem/cemcom.ansi/switch_loc.h
  64. 2 2
      lang/cem/cemcom.ansi/tokenname.c
  65. 6 0
      lang/cem/cemcom.ansi/tokenname.h
  66. 42 67
      lang/cem/cemcom.ansi/type.c
  67. 23 0
      lang/cem/cemcom.ansi/type_loc.h
  68. 21 31
      lang/cem/cemcom.ansi/util.c
  69. 7 7
      lang/cem/cemcom.ansi/util_loc.h
  70. 37 36
      lang/cem/cpp.ansi/replace.c

+ 1 - 1
lang/cem/cemcom.ansi/LLlex.c

@@ -24,7 +24,7 @@
 #include	"sizes.h"
 #include	"error.h"
 #include	"domacro.h"
-#include	"replace.h"
+#include	"replace_loc.h"
 #include	"specials.h"	/* registration of special identifiers */
 
 /* Data about the token yielded */

+ 1 - 1
lang/cem/cemcom.ansi/blocks.c

@@ -18,7 +18,7 @@
 #include "label.h"
 #include "stack.h"
 #include "Lpars.h"
-#include "util.h"
+#include "util_loc.h"
 #include "error.h"
 #include "idf_loc.h"
 #include "def.h"

+ 8 - 1
lang/cem/cemcom.ansi/ch3mon.c

@@ -20,7 +20,14 @@
 #include	"sizes.h"
 #include 	"ch3.h"
 #include 	"ch3mon.h"
-#include    <symbol2str.h>
+#include	"error.h"
+#include	"expr_loc.h"
+#include	"stab.h"
+#include	"util.h"
+#include	"struct_loc.h"
+#include	"dataflow.h"
+
+#include	<symbol2str.h>
 
 extern char options[];
 extern arith full_mask[/*MAXSIZE + 1*/];	/* cstoper.c */

+ 9 - 0
lang/cem/cemcom.ansi/code.c

@@ -43,6 +43,15 @@
 #include 	"blocks.h"
 #include	"code_c.h"
 #include	"conversion.h"
+#include	"util_loc.h"
+#include	"stab.h"
+#include	"error.h"
+#include	"struct_loc.h"
+#include	"ch3.h"
+#include	"idf_loc.h"
+#include	"expr_loc.h"
+#include	"ival.h"
+#include	"eval.h"
 
 #include <symbol2str.h>
 

+ 3 - 0
lang/cem/cemcom.ansi/code_c.h

@@ -23,6 +23,9 @@ void code_break();
 void code_continue();
 void stack_stmt(label break_label, label cont_label);
 void unstack_stmt();
+void formal_cvt(int hasproto, struct def *df);
+
+
 
 #ifdef DBSYMTAB
 void db_line(char *file, unsigned int line);

+ 1 - 0
lang/cem/cemcom.ansi/conversion.c

@@ -13,6 +13,7 @@
 #include	"type.h"
 #include	"sizes.h"
 #include	"Lpars.h"
+#include	"error.h"
 
 #define	T_SIGNED		1
 #define	T_UNSIGNED		2

+ 2 - 0
lang/cem/cemcom.ansi/cstoper.c

@@ -16,6 +16,8 @@
 #include	"Lpars.h"
 #include	"assert.h"
 #include	"cstoper.h"
+#include	"error.h"
+#include	"expr_loc.h"
 
 /* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
 arith full_mask[MAXSIZE + 1];

+ 11 - 0
lang/cem/cemcom.ansi/dataflow.h

@@ -0,0 +1,11 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_DATAFLOW_H
+#define LANG_CEM_CEMCOM_ANSI_DATAFLOW_H
+
+/* lang/cem/cemcom.ansi/dataflow.c */
+
+#endif /* LANG_CEM_CEMCOM_ANSI_DATAFLOW_H */
+

+ 11 - 2
lang/cem/cemcom.ansi/declar.g

@@ -17,18 +17,27 @@
 #include	"label.h"
 #include	"code.h"
 #include	"idf.h"
+#include	"idf_loc.h"
 #include	"type.h"
+#include	"type_loc.h"
 #include	"proto.h"
+#include	"proto_loc.h"
 #include	"struct.h"
+#include	"struct_loc.h"
 #include	"field.h"
 #include	"decspecs.h"
 #include	"def.h"
 #include	"declar.h"
 #include	"label.h"
 #include	"expr.h"
+#include	"expr_loc.h"
 #include	"sizes.h"
 #include	"level.h"
-#include "code_c.h"
+#include	"code_c.h"
+#include	"error.h"
+#include	"stab.h"
+#include	"declarator.h"
+
 #ifdef	LINT
 #include	"l_lint.h"
 #endif	/* LINT */
@@ -713,7 +722,7 @@ parameter_declarator(register struct declarator *dc;)
 
 primary_parameter_declarator(register struct declarator *dc;)
 :
-[%if (AHEAD == ')' || first_of_parameter_type_list(AHEAD)
+[%if ((AHEAD == ')' || first_of_parameter_type_list(AHEAD))
 				    && (AHEAD != IDENTIFIER))
 	/* empty */
 |

+ 4 - 0
lang/cem/cemcom.ansi/declar.str

@@ -4,6 +4,8 @@
  */
 /* $Id$ */
 /* DEFINITION OF DECLARATOR DESCRIPTORS */
+#ifndef LANG_CEM_CEMCOM_ANSI_DECLARE_STR
+#define LANG_CEM_CEMCOM_ANSI_DECLARE_STR
 
 /*	A 'declarator' consists of an idf and a linked list of
 	language-defined unary operations: *, [] and (), called
@@ -39,3 +41,5 @@ struct decl_unary	{
 
 extern struct type *declare_type();
 extern struct declarator null_declarator;
+
+#endif /* LANG_CEM_CEMCOM_ANSI_DECLARE_STR */

+ 12 - 20
lang/cem/cemcom.ansi/declarator.c

@@ -20,14 +20,14 @@
 #include	"expr.h"
 #include	"sizes.h"
 #include	"level.h"
+#include	"error.h"
+#include	"idf_loc.h"
+#include	"proto_loc.h"
 
 extern char options[];
 struct declarator null_declarator;
 
-struct type *
-declare_type(tp, dc)
-	struct type *tp;
-	struct declarator *dc;
+struct type *declare_type(struct type *tp, struct declarator *dc)
 {
 	/*	Applies the decl_unary list starting at dc->dc_decl_unary
 		to the type tp and returns the result.
@@ -35,7 +35,7 @@ declare_type(tp, dc)
 		are purely prototypes. Simply add the type list to the
 		function node.
 	*/
-	register struct decl_unary *du = dc->dc_decl_unary;
+	struct decl_unary *du = dc->dc_decl_unary;
 
 	while (du)	{
 		tp = construct_type(du->du_fund, tp, du->du_typequal,
@@ -45,18 +45,13 @@ declare_type(tp, dc)
 	return tp;
 }
 
-add_decl_unary(dc, fund, qual,  count, fm, pl)
-	register struct declarator *dc;
-	int qual;
-	arith count;
-	struct formal *fm;
-	struct proto *pl;
+void add_decl_unary(struct declarator *dc, int fund, int qual, arith count, struct formal *fm, struct proto *pl)
 {
 	/*	A decl_unary describing a constructor with fundamental
 		type fund and with size count is inserted in front of the
 		declarator dc.
 	*/
-	register struct decl_unary *new = new_decl_unary();
+	struct decl_unary *new = new_decl_unary();
 
 	new->next = dc->dc_decl_unary;
 	new->du_fund = fund;
@@ -77,13 +72,12 @@ add_decl_unary(dc, fund, qual,  count, fm, pl)
 	dc->dc_decl_unary = new;
 }
 
-remove_declarator(dc)
-	struct declarator *dc;
+void remove_declarator(struct declarator *dc)
 {
 	/*	The decl_unary list starting at dc->dc_decl_unary is
 		removed.
 	*/
-	register struct decl_unary *du = dc->dc_decl_unary;
+	struct decl_unary *du = dc->dc_decl_unary;
 
 	while (du)	{
 		struct decl_unary *old_du = du;
@@ -93,15 +87,14 @@ remove_declarator(dc)
 	}
 }
 
-reject_params(dc)
-	register struct declarator *dc;
+void reject_params(struct declarator *dc)
 {
 	/*	The declarator is checked to have no parameters, if it
 		is an old-style function.  If it is a new-style function,
 		the identifiers are removed.  The function is not called in
 		case of a function definition.
 	*/
-	register struct decl_unary *du = dc->dc_decl_unary;
+	struct decl_unary *du = dc->dc_decl_unary;
 	int	err_given = 0;
 
 	if (dc->dc_formal)	{
@@ -122,8 +115,7 @@ reject_params(dc)
 	}
 }
 
-check_array_subscript(expr)
-	register struct expr *expr;
+void check_array_subscript(struct expr *expr)
 {
 	arith size = expr->VL_VALUE;
 

+ 16 - 0
lang/cem/cemcom.ansi/declarator.h

@@ -0,0 +1,16 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_DECLARATOR_H
+#define LANG_CEM_CEMCOM_ANSI_DECLARATOR_H
+
+/* lang/cem/cemcom.ansi/declarator.c */
+struct type *declare_type(struct type *tp, struct declarator *dc);
+void add_decl_unary(struct declarator *dc, int fund, int qual, arith count, struct formal *fm, struct proto *pl);
+void remove_declarator(struct declarator *dc);
+void reject_params(struct declarator *dc);
+void check_array_subscript(struct expr *expr);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_DECLARATOR_H */
+

+ 3 - 2
lang/cem/cemcom.ansi/decspecs.c

@@ -12,11 +12,12 @@
 #include	"type.h"
 #include	"level.h"
 #include	"def.h"
+#include	"error.h"
+
+#include	<symbol2str.h>
 
 extern char options[];
 extern int level;
-extern char *symbol2str();
-extern struct type *qualifier_type();
 
 struct decspecs null_decspecs;
 

+ 49 - 56
lang/cem/cemcom.ansi/domacro.c

@@ -6,8 +6,10 @@
 /* PREPROCESSOR: CONTROLLINE INTERPRETER */
 
 #include <stdlib.h>
+#include <string.h>
 
 #include	"debug.h"
+#include	"specials.h"
 #include	"arith.h"
 #include	"LLlex.h"
 #include	"Lpars.h"
@@ -15,6 +17,13 @@
 #include	"input.h"
 #include	"nopp.h"
 #include	"lint.h"
+#include	"skip.h"
+#include	"domacro.h"
+#include	"error.h"
+#include	"pragma.h"
+#include	"program.h"
+#include	"main.h"
+#include	"replace_loc.h"
 
 #ifndef NOPP
 #include	"ifdepth.h"
@@ -38,16 +47,15 @@ int		IncludeLevel = 0;
 
 extern char options[];
 extern	char **inctable;	/* list of include directories		*/
-extern	char *getwdir();
 char ifstack[IFDEPTH];	/* if-stack: the content of an entry is	*/
 				/* 1 if a corresponding ELSE has been	*/
 				/* encountered.				*/
 
 int	nestlevel = -1;
+extern char *getwdir();
 
-struct idf *
-GetIdentifier(skiponerr)
-	int skiponerr;		/* skip the rest of the line on error */
+/* skiponerr -> skip the rest of the line on error */
+struct idf *GetIdentifier(int skiponerr)
 {
 	/*	returns a pointer to the descriptor of the identifier that is
 		read from the input stream. When the input doe not contain
@@ -78,7 +86,7 @@ GetIdentifier(skiponerr)
 	An error message is produced when the token is not recognized,
 	i.e. it is not one of "define" .. "undef" , integer or newline.
 */
-domacro()
+void domacro()
 {
 	struct token tk;	/* the token itself			*/
 	int toknum;
@@ -156,8 +164,7 @@ domacro()
 int lint_skip_comment;
 #endif
 
-skip_block(to_endif)
-int to_endif;
+void skip_block(int to_endif)
 {
 	/*	skip_block() skips the input from
 		1)	a false #if, #ifdef, #ifndef or #elif until the
@@ -167,8 +174,8 @@ int to_endif;
 			#ifndef or #elif until the corresponding #endif is
 			seen.
 	*/
-	register int ch;
-	register int skiplevel = nestlevel; /* current nesting level	*/
+	int ch;
+	int skiplevel = nestlevel; /* current nesting level	*/
 	struct token tk;
 	int toknum;
 
@@ -291,7 +298,7 @@ int to_endif;
 }
 
 
-ifexpr()
+int ifexpr()
 {
 	/*	ifexpr() returns whether the restricted constant
 		expression following #if or #elif evaluates to true.  This
@@ -313,7 +320,7 @@ ifexpr()
 	return (errors == err_occurred) && (ifval != (arith)0);
 }
 
-do_include()
+void do_include()
 {
 	/*	do_include() performs the inclusion of a file.
 	*/
@@ -358,7 +365,7 @@ do_include()
 	}
 }
 
-do_define()
+void do_define()
 {
 	/*	do_define() interprets a #define control line.
 	*/
@@ -397,7 +404,7 @@ do_define()
 	LineNumber++;
 }
 
-push_if()
+void push_if()
 {
 	if (nestlevel >= IFDEPTH)
 		fatal("too many nested #if/#ifdef/#ifndef");
@@ -405,7 +412,7 @@ push_if()
 		ifstack[++nestlevel] = 0;
 }
 
-do_elif()
+void do_elif()
 {
 	if (nestlevel <= nestlow) {
 		lexerror("#elif without corresponding #if");
@@ -422,7 +429,7 @@ do_elif()
 	}
 }
 
-do_else()
+void do_else()
 {
 	if (SkipToNewLine())
 		if (!options['o'])
@@ -438,7 +445,7 @@ do_else()
 	}
 }
 
-do_endif()
+void do_endif()
 {
 	if (SkipToNewLine()) {
 		if (!options['o'])
@@ -450,16 +457,16 @@ do_endif()
 	else	nestlevel--;
 }
 
-do_if()
+void do_if()
 {
 	push_if();
 	if (!ifexpr())	/* a false #if/#elif expression */
 		skip_block(0);
 }
 
-do_ifdef(how)
+void do_ifdef(how)
 {
-	register struct idf *id;
+	struct idf *id;
 
 	/*	how == 1 : ifdef; how == 0 : ifndef
 	*/
@@ -479,10 +486,9 @@ do_ifdef(how)
 }
 
 /* argidf != NULL when the undef came from a -U option */
-do_undef(argidf)
-	struct idf *argidf;
+void do_undef(struct idf *argidf)
 {
-	register struct idf *id = argidf;
+	struct idf *id = argidf;
 
 	/* Forget a macro definition.	*/
 	if (id || (id = GetIdentifier(1))) {
@@ -505,7 +511,7 @@ do_undef(argidf)
 		lexerror("illegal #undef construction");
 }
 
-do_error()
+void do_error()
 {
 	int len;
 	char *get_text();
@@ -516,10 +522,7 @@ do_error()
 	LineNumber++;
 }
 
-int
-getparams(buf, parbuf)
-	char *buf[];
-	char parbuf[];
+int getparams(char *buf[], char parbuf[])
 {
 	/*	getparams() reads the formal parameter list of a macro
 		definition.
@@ -531,10 +534,10 @@ getparams(buf, parbuf)
 		Note that the '(' has already been eaten.
 		The names of the formal parameters are stored into parbuf.
 	*/
-	register char **pbuf = &buf[0];
-	register int c;
-	register char *ptr = &parbuf[0];
-	register char **pbuf2;
+	char **pbuf = &buf[0];
+	int c;
+	char *ptr = &parbuf[0];
+	char **pbuf2;
 
 	c = GetChar();
 	c = skipspaces(c,0);
@@ -585,11 +588,9 @@ getparams(buf, parbuf)
 	/*NOTREACHED*/
 }
 
-macro_def(id, text, nformals, length, flags)
-	register struct idf *id;
-	char *text;
+void macro_def(struct idf *id, char *text, int nformals, int length, int flags)
 {
-	register struct macro *newdef = id->id_macro;
+	struct macro *newdef = id->id_macro;
 
 	/*	macro_def() puts the contents and information of a macro
 		definition into a structure and stores it into the symbol
@@ -611,15 +612,13 @@ macro_def(id, text, nformals, length, flags)
 	newdef->mc_flag = flags;	/* special flags	*/
 }
 
-int
-find_name(nm, index)
-	char *nm, *index[];
+int find_name(char *nm, char *index[])
 {
 	/*	find_name() returns the index of "nm" in the namelist
 		"index" if it can be found there. 0 is returned if it is
 		not there.
 	*/
-	register char **ip = &index[0];
+	char **ip = &index[0];
 
 	while (*ip)
 		if (strcmp(nm, *ip++) == 0)
@@ -630,10 +629,7 @@ find_name(nm, index)
 
 #define	BLANK(ch)	((ch == ' ') || (ch == '\t'))
 
-char *
-get_text(formals, length)
-	char *formals[];
-	int *length;
+char *get_text(char *formals[], int *length)
 {
 	/*	get_text() copies the replacement text of a macro
 		definition with zero, one or more parameters, thereby
@@ -657,9 +653,9 @@ get_text(formals, length)
 		4-  comment, same as for 1
 		Other tokens will not be seen as such.
 	*/
-	register int c;
+	int c;
 	struct repl repls;
-	register struct repl *repl = &repls;
+	struct repl *repl = &repls;
 	int blank = 0;
 
 	c = GetChar();
@@ -674,7 +670,7 @@ get_text(formals, length)
 		}
 
 		if (c == '\'' || c == '"') {
-			register int delim = c;
+			int delim = c;
 
 			if (blank) {
 				blank = 0;
@@ -707,7 +703,7 @@ get_text(formals, length)
 		} else if (formals
 			    && (class(c) == STIDF || class(c) == STELL)) {
 			char id_buf[IDFSIZE + 1];
-			register char *idp = id_buf;
+			char *idp = id_buf;
 			int n;
 
 			/* read identifier: it may be a formal parameter */
@@ -724,7 +720,7 @@ get_text(formals, length)
 				add2repl(repl, ' ');
 			}
 			/* construct the formal parameter mark or identifier */
-			if (n = find_name(id_buf, formals))
+			if ((n = find_name(id_buf, formals)))
 			    add2repl(repl, FORMALP | (char) n);
 			else {
 			    idp = id_buf;
@@ -773,8 +769,7 @@ get_text(formals, length)
 	as strings, without taking care of the leading and trailing
 	blanks (spaces and tabs).
 */
-macroeq(s, t)
-	register char *s, *t;
+int macroeq(char *s, char *t)
 {
 
 	/* skip leading spaces	*/
@@ -797,9 +792,8 @@ macroeq(s, t)
 }
 #else /* NOPP */
 
-struct idf *
-GetIdentifier(skiponerr)
-	int skiponerr;		/* skip the rest of the line on error */
+/* skiponerr -> skip the rest of the line on error */
+struct idf *GetIdentifier(int skiponerr)
 {
 	/*	returns a pointer to the descriptor of the identifier that is
 		read from the input stream. When the input does not contain
@@ -818,7 +812,7 @@ GetIdentifier(skiponerr)
 	return tk.tk_idf;
 }
 
-domacro()
+void domacro()
 {
 	int tok;
 	struct token tk;
@@ -842,8 +836,7 @@ domacro()
 #endif /* NOPP */
 
 
-do_line(l)
-	unsigned int l;
+void do_line(unsigned int l)
 {
 	struct token tk;
 	int t = GetToken(&tk);

+ 15 - 16
lang/cem/cemcom.ansi/domacro.h

@@ -7,25 +7,24 @@
 
 /* lang/cem/cemcom.ansi/domacro.c */
 struct idf *GetIdentifier(int skiponerr);
-int domacro(void);
-int skip_block(int to_endif);
+void domacro(void);
+void skip_block(int to_endif);
 int ifexpr(void);
-int do_include(void);
-int do_define(void);
-int push_if(void);
-int do_elif(void);
-int do_else(void);
-int do_endif(void);
-int do_if(void);
-int do_ifdef(int how);
-int do_undef(struct idf *argidf);
-int do_error(void);
+void do_include(void);
+void do_define(void);
+void push_if(void);
+void do_elif(void);
+void do_else(void);
+void do_endif(void);
+void do_if(void);
+void do_ifdef(int how);
+void do_undef(struct idf *argidf);
+void do_error(void);
 int getparams(char *buf[], char parbuf[]);
-int macro_def(register struct idf *id, char *text, int nformals, int length, int flags);
+void macro_def(struct idf *id, char *text, int nformals, int length, int flags);
 int find_name(char *nm, char *index[]);
 char *get_text(char *formals[], int *length);
-int macroeq(register char *s, register char *t);
-int do_line(unsigned int l);
+int macroeq(char *s, char *t);
+void do_line(unsigned int l);
 
 #endif /* LANG_CEM_CEMCOM_ANSI_DOMACRO_H */
-

+ 8 - 12
lang/cem/cemcom.ansi/error.c

@@ -7,6 +7,7 @@
 
 #include	"lint.h"
 #if __STDC__
+#include	<stdio.h>
 #include	<stdarg.h>
 #else
 #include	<varargs.h>
@@ -22,6 +23,7 @@
 #include	"lint.h"
 #include	"nopp.h"
 #include	"errout.h"
+#include	"print.h"
 
 #include	"tokenname.h"
 #include	<flt_arith.h>
@@ -30,11 +32,13 @@
 #include	"expr.h"
 #include	"def.h"
 #include	"LLlex.h"
+#include	"error.h"
 
 /*	This file contains the error-message and diagnostic
 	functions.  Beware, they are called with a variable number of
 	arguments!
 */
+static void _error(int class, char *fn, unsigned int ln, char *fmt, va_list ap);
 
 /* error classes */
 #define	STRICT		1
@@ -62,8 +66,6 @@ extern char loptions[];
 	expression, whereas other errors use the information in the token.
 */
 
-static _error();
-
 #if __STDC__
 /*VARARGS*/
 void error(char *fmt, ...)
@@ -526,13 +528,7 @@ fatal(va_alist)				/* fmt, args */
 }
 #endif
 
-static
-_error(class, fn, ln, fmt, ap)
-	int class;
-	char *fn;
-	unsigned int ln;
-	char *fmt;
-	va_list ap;
+static void _error(int class, char *fn, unsigned int ln, char *fmt, va_list ap)
 {
 	char *remark;
 	
@@ -619,9 +615,9 @@ _error(class, fn, ln, fmt, ap)
 #endif	/* LINT */
 	
 	if (fn)
-		fprint(ERROUT, "\"%s\", line %u: ", fn, ln);
+		fprintf(stderr, "\"%s\", line %u: ", fn, ln);
 	if (remark)
-		fprint(ERROUT, "%s ", remark);
+		fprintf(stderr, "%s ", remark);
 	doprnt(ERROUT, fmt, ap);		/* contents of error */
-	fprint(ERROUT, "\n");
+	fprintf(stderr, "\n");
 }

+ 6 - 0
lang/cem/cemcom.ansi/estack.str

@@ -5,6 +5,10 @@
 /* $Id$ */
 /* EXPRESSION STACK */
 /* Used for global initializations */
+
+#ifndef LANG_CEM_CEMCOM_ANSI_ESTACK_STR
+#define LANG_CEM_CEMCOM_ANSI_ESTACK_STR
+
 struct e_stack {
 	struct e_stack	*next;
 	arith		s_cnt1, s_cnt2;
@@ -19,3 +23,5 @@ struct e_stack {
 #define last_offset	s_cnt2
 #define elem_count	s_cnt1
 #define nelem		s_cnt2
+
+#endif /* LANG_CEM_CEMCOM_ANSI_ESTACK_STR */

+ 56 - 43
lang/cem/cemcom.ansi/eval.c

@@ -15,6 +15,8 @@
 #include	"nobitfield.h"
 #include	"dataflow.h"
 #include	<flt_arith.h>
+#include	<system.h>
+#include	"print.h"
 #include	"arith.h"
 #include	"type.h"
 #include	"idf.h"
@@ -33,12 +35,17 @@
 #include	"blocks.h"
 #include	"conversion.h"
 #include	"specials.h"
+#include	"ch3.h"
+#include	"eval.h"
+#include	"error.h"
+#include	"field_loc.h"
+#include	"struct_loc.h"
+#include	"util_loc.h"
+
+#include	<symbol2str.h>
 
 #define	CRASH()		crash("EVAL: CRASH at line %u", __LINE__)
 
-char *symbol2str();
-char *long2str();
-arith NewLocal();	/* util.c */
 #define LocalPtrVar()	NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER)
 extern int	err_occurred; /* error.c */
 
@@ -68,13 +75,10 @@ extern int	err_occurred; /* error.c */
 		labels, in case they are specified (i.e. are non-zero)
 */
 
-EVAL(expr, val, code, true_label, false_label)
-	register struct expr *expr;
-	int val, code;
-	label true_label, false_label;
+void EVAL(struct expr *expr, int val, int code, label true_label, label false_label)
 {
 	int vol = (code != TRUE && recurqual(expr->ex_type, TQ_VOLATILE));
-	register int gencode = code == TRUE;
+	int gencode = code == TRUE;
 
 	if (err_occurred) return;
 	switch (expr->ex_class) {
@@ -116,9 +120,9 @@ EVAL(expr, val, code, true_label, false_label)
 	case Oper:	/* compound expression	*/
 	{
 		int oper = expr->OP_OPER;
-		register struct expr *left = expr->OP_LEFT;
-		register struct expr *right = expr->OP_RIGHT;
-		register struct type *tp = expr->OP_TYPE;
+		struct expr *left = expr->OP_LEFT;
+		struct expr *right = expr->OP_RIGHT;
+		struct type *tp = expr->OP_TYPE;
 
 		switch (oper) {
 		case '+':
@@ -257,26 +261,44 @@ EVAL(expr, val, code, true_label, false_label)
 			operands(expr, gencode);
 			ASSERT(tp->tp_fund==INT || tp->tp_fund==LONG);
 			if (gencode)
+			{
 				if (tp->tp_unsigned)
+				{
 					C_rmu(tp->tp_size);
+				}
 				else
+				{
 					C_rmi(tp->tp_size);
+				}
+			}
 			break;
 		case LEFT:
 			operands(expr, gencode);
 			if (gencode)
+			{
 				if (tp->tp_unsigned)
+				{
 					C_slu(tp->tp_size);
+				}
 				else
+				{
 					C_sli(tp->tp_size);
+				}
+			}
 			break;
 		case RIGHT:
 			operands(expr, gencode);
 			if (gencode)
+			{
 				if (tp->tp_unsigned)
+				{
 					C_sru(tp->tp_size);
+				}
 				else
+				{
 					C_sri(tp->tp_size);
+				}
+			}
 			break;
 		case '<':
 		case LESSEQ:
@@ -474,7 +496,7 @@ EVAL(expr, val, code, true_label, false_label)
 		}
 		case '(':
 		{
-			register struct expr *ex;
+			struct expr *ex;
 			arith ParSize = (arith)0;
 			label setjmp_label = 0;
 			arith retspace = 0;
@@ -660,9 +682,7 @@ EVAL(expr, val, code, true_label, false_label)
 }
 
 /*	compare() serves as an auxiliary function of EVAL	*/
-compare(relop, lbl)
-	int relop;
-	label lbl;
+void compare(int relop, label lbl)
 {
 	switch (relop) {
 	case '<':
@@ -689,8 +709,7 @@ compare(relop, lbl)
 }
 
 /*	truthvalue() serves as an auxiliary function of EVAL	*/
-truthvalue(relop)
-	int relop;
+void truthvalue(int relop)
 {
 	switch (relop)	{
 	case '<':
@@ -718,12 +737,10 @@ truthvalue(relop)
 
 
 /*	assop() generates the opcode of an assignment operators op=	*/
-assop(type, oper)
-	register struct type *type;
-	int oper;
+void assop(struct type *type, int oper)
 {
-	register arith size;
-	register uns = type->tp_unsigned;
+	arith size;
+	int uns = type->tp_unsigned;
 
 	if ((int)(size = type->tp_size) < (int)word_size)
 		size = word_size;
@@ -823,8 +840,7 @@ assop(type, oper)
 	}
 }
 
-ptr_add(size)
-	arith size;
+void ptr_add(arith size)
 {
 	if (size != pointer_size) {
 		C_loc(size);
@@ -841,12 +857,10 @@ ptr_add(size)
 	- into a local static variable
 	- absolute addressing
 */
-store_val(vl, tp)
-	register struct value *vl;
-	register struct type *tp;
+void store_val(struct value *vl, struct type *tp)
 {
-	register int inword = 0;
-	register int indword = 0;
+	int inword = 0;
+	int indword = 0;
 	arith val = vl->vl_value;
 
 	if (vl->vl_class == Const) {	/* absolute addressing */
@@ -859,8 +873,8 @@ store_val(vl, tp)
 		else if (tp->tp_size == dword_size) indword = 1;
 	}
 	if (vl->vl_class == Name) {
-		register struct idf *id = vl->vl_data.vl_idf;
-		register struct def *df = id->id_def;
+		struct idf *id = vl->vl_data.vl_idf;
+		struct def *df = id->id_def;
 
 		/* if (df->df_level == L_GLOBAL) { // } ??? re-examine */
 		if (df->df_sc == GLOBAL
@@ -912,14 +926,15 @@ store_val(vl, tp)
 	- static variable
 	- local variable
 */
-load_val(expr, rlval)
-	register struct expr *expr; /* expression containing the value	*/
-	int rlval;		/* generate either LVAL or RVAL		*/
+/* expr		-> expression containing the value
+   rlval	-> generate either LVAL or RVAL
+ */
+void load_val(struct expr *expr, int rlval)
 {
-	register struct type *tp = expr->ex_type;
+	struct type *tp = expr->ex_type;
 	int rvalue = (rlval == RVAL && expr->ex_lvalue != 0);
-	register int inword = 0, indword = 0;
-	register arith val = expr->VL_VALUE;
+	int inword = 0, indword = 0;
+	arith val = expr->VL_VALUE;
 
 	if (expr->ex_type->tp_fund == FLOAT
 	    || expr->ex_type->tp_fund == DOUBLE
@@ -959,8 +974,8 @@ load_val(expr, rlval)
 		}
 	}
 	else {
-		register struct idf *id = expr->VL_IDF;
-		register struct def *df = id->id_def;
+		struct idf *id = expr->VL_IDF;
+		struct def *df = id->id_def;
 		int fund = df->df_type->tp_fund;
 
 		ASSERT(ISNAME(expr));
@@ -1011,8 +1026,7 @@ load_val(expr, rlval)
 	}
 }
 
-load_cst(val, siz)
-	arith val, siz;
+void load_cst(arith val, arith siz)
 {
 	if ((int)siz <= (int)word_size)
 		C_loc(val);
@@ -1029,8 +1043,7 @@ load_cst(val, siz)
 	}
 }
 
-operands(expr, gencode)
-	register struct expr *expr;
+void operands(struct expr *expr, int gencode)
 {
 	EVAL(expr->OP_LEFT, RVAL, gencode, NO_LABEL, NO_LABEL);
 	EVAL(expr->OP_RIGHT, RVAL, gencode, NO_LABEL, NO_LABEL);

+ 11 - 0
lang/cem/cemcom.ansi/eval.g.h

@@ -0,0 +1,11 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_EVAL_G_H
+#define LANG_CEM_CEMCOM_ANSI_EVAL_G_H
+
+/* lang/cem/cemcom.ansi/eval.g.c */
+
+#endif /* LANG_CEM_CEMCOM_ANSI_EVAL_G_H */
+

+ 20 - 0
lang/cem/cemcom.ansi/eval.h

@@ -0,0 +1,20 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_EVAL_H
+#define LANG_CEM_CEMCOM_ANSI_EVAL_H
+
+/* lang/cem/cemcom.ansi/eval.c */
+void EVAL(struct expr *expr, int val, int code, label true_label, label false_label);
+void compare(int relop, label lbl);
+void truthvalue(int relop);
+void assop(struct type *type, int oper);
+void ptr_add(arith size);
+void store_val(struct value *vl, struct type *tp);
+void load_val(struct expr *expr, int rlval);
+void load_cst(arith val, arith siz);
+void operands(struct expr *expr, int gencode);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_EVAL_H */
+

+ 31 - 58
lang/cem/cemcom.ansi/expr.c

@@ -27,15 +27,15 @@
 #include	"level.h"
 #include	"use_tmp.h"
 #include	"cstoper.h"
-
+#include	"idf_loc.h"
+#include	"expr_loc.h"
+#include	"error.h"
 #include	<symbol2str.h>
 
 extern char options[];
 extern int InSizeof;
 
-int
-rank_of(oper)
-	int oper;
+int rank_of(int oper)
 {
 	/*	The rank of the operator oper is returned.
 	*/
@@ -104,13 +104,12 @@ rank_of(oper)
 	/*NOTREACHED*/
 }
 
-dot2expr(expp)
-	struct expr **expp;
+void dot2expr(struct expr **expp)
 {
 	/*	The token in dot is converted into an expression, a
 		pointer to which is stored in *expp.
 	*/
-	register struct expr *ex = new_expr();
+	struct expr *ex = new_expr();
 
 	*expp = ex;
 	ex->ex_file = dot.tk_file;
@@ -131,16 +130,15 @@ dot2expr(expp)
 	}
 }
 
-idf2expr(expr)
-	register struct expr *expr;
+void idf2expr(struct expr *expr)
 {
 	/*	Dot contains an identifier which is turned into an
 		expression.
 		Note that this constitutes an applied occurrence of
 		the identifier.
 	*/
-	register struct idf *idf = dot.tk_idf;	/* != 0*/
-	register struct def *def = idf->id_def;
+	struct idf *idf = dot.tk_idf;	/* != 0*/
+	struct def *def = idf->id_def;
 	
 	if (def == 0)	{
 		if (AHEAD == '(') {
@@ -201,15 +199,12 @@ idf2expr(expr)
 	}
 }
 
-string2expr(expp, str, len)
-	register struct expr **expp;
-	int len;
-	char *str;
+void string2expr(struct expr **expp, char *str, int len)
 {
 	/*	The string in the argument is converted into an expression,
 		a pointer to which is stored in *expp.
 	*/
-	register struct expr *ex = new_expr();
+	struct expr *ex = new_expr();
 
 	*expp = ex;
 	ex->ex_file = dot.tk_file;
@@ -223,8 +218,7 @@ string2expr(expp, str, len)
 	ex->SG_LEN = len;
 }
 
-int2expr(expr)
-	struct expr *expr;
+void int2expr(struct expr *expr)
 {
 	/*	Dot contains an integer constant which is turned
 		into an expression.
@@ -232,13 +226,12 @@ int2expr(expr)
 	fill_int_expr(expr, dot.tk_ival, dot.tk_fund);
 }
 
-float2expr(expr)
-	register struct expr *expr;
+void float2expr(struct expr *expr)
 {
 	/*	Dot contains a floating point constant which is turned
 		into an expression.
 	*/
-	register int fund;
+	int fund;
 
 	fund = dot.tk_fund;
 	switch (fund) {
@@ -262,15 +255,12 @@ float2expr(expr)
 		expr_warning(expr,"internal floating point overflow");
 }
 
-struct expr*
-intexpr(ivalue, fund)
-	arith ivalue;
-	int fund;
+struct expr *intexpr(arith ivalue, int fund)
 {
 	/*	The value ivalue is turned into an integer expression of
 		the size indicated by fund.
 	*/
-	register struct expr *expr = new_expr();
+	struct expr *expr = new_expr();
 
 	expr->ex_file = dot.tk_file;
 	expr->ex_line = dot.tk_line;
@@ -278,10 +268,7 @@ intexpr(ivalue, fund)
 	return expr;
 }
 
-fill_int_expr(ex, ivalue, fund)
-	register struct expr *ex;
-	arith ivalue;
-	int fund;
+void fill_int_expr(struct expr *ex, arith ivalue, int fund)
 {
 	/*	Details derived from ivalue and fund are put into the
 		constant integer expression ex.
@@ -309,10 +296,7 @@ fill_int_expr(ex, ivalue, fund)
 	cut_size(ex);
 }
 
-struct expr *
-new_oper(tp, e1, oper, e2)
-	struct type *tp;
-	register struct expr *e1, *e2;
+struct expr *new_oper(struct type *tp, struct expr *e1, int oper, struct expr *e2)
 {
 	/*	A new expression is constructed which consists of the
 		operator oper which has e1 and e2 as operands; for a
@@ -320,11 +304,11 @@ new_oper(tp, e1, oper, e2)
 		During the construction of the right recursive initialisation
 		tree it is possible for e2 to be NILEXPR.
 	*/
-	register struct expr *expr = new_expr();
-	register struct oper *op;
+	struct expr *expr = new_expr();
+	struct oper *op;
 
 	if (e2)	{
-		register struct expr *e = e2;
+		struct expr *e = e2;
 		
 		while (e->ex_class == Oper && e->OP_LEFT)
 			e = e->OP_LEFT;
@@ -333,7 +317,7 @@ new_oper(tp, e1, oper, e2)
 	}
 	else
 	if (e1)	{
-		register struct expr *e = e1;
+		struct expr *e = e1;
 		
 		while (e->ex_class == Oper && e->OP_RIGHT)
 			e = e->OP_RIGHT;
@@ -375,8 +359,7 @@ new_oper(tp, e1, oper, e2)
 	return expr;
 }
 
-chk_cst_expr(expp)
-	struct expr **expp;
+void chk_cst_expr(struct expr **expp)
 {
 	/*	The expression expr is checked for constancy.
 	
@@ -398,7 +381,7 @@ chk_cst_expr(expp)
 		Special problems (of which there is only one, sizeof in
 		Preprocessor #if) have to be dealt with locally
 	*/
-	register struct expr *expr = *expp;
+	struct expr *expr = *expp;
 	
 #ifdef	DEBUG
 	print_expr("constant_expression", expr);
@@ -421,9 +404,7 @@ chk_cst_expr(expp)
 	erroneous2int(expp);
 }
 
-init_expression(eppp, expr)
-	register struct expr ***eppp;
-	struct expr *expr;
+void init_expression(struct expr ***eppp, struct expr *expr)
 {
 	/*	The expression expr is added to the tree designated
 		indirectly by **eppp.
@@ -441,9 +422,7 @@ init_expression(eppp, expr)
 	*eppp = &(**eppp)->OP_RIGHT;
 }
 
-int
-is_ld_cst(expr)
-	register struct expr *expr;
+int is_ld_cst(struct expr *expr)
 {
 	/*	An expression is a `load-time constant' if it is of the form
 		<idf> +/- <integral> or <integral>.
@@ -455,9 +434,7 @@ is_ld_cst(expr)
 	return expr->ex_lvalue == 0 && expr->ex_class == Value;
 }
 
-int
-is_cp_cst(expr)
-	struct expr *expr;
+int is_cp_cst(struct expr *expr)
 {
 	/*	An expression is a `compile-time constant' if it is a
 		load-time constant, and the idf is not there.
@@ -465,9 +442,7 @@ is_cp_cst(expr)
 	return is_ld_cst(expr) && expr->VL_CLASS == Const;
 }
 
-int
-is_fp_cst(expr)
-	struct expr *expr;
+int is_fp_cst(struct expr *expr)
 {
 	/*	An expression is a `floating-point constant' if it consists
 		of the float only.
@@ -475,9 +450,7 @@ is_fp_cst(expr)
 	return expr->ex_class == Float;
 }
 
-int
-is_zero_cst(expr)
-	register struct expr *expr;
+int is_zero_cst(struct expr *expr)
 {
 	flt_arith var;
 
@@ -489,10 +462,10 @@ is_zero_cst(expr)
 		return flt_cmp(&var, &(expr->FL_ARITH)) == 0;
 	}
 	/*NOTREACHED*/
+	return 0;
 }
 
-free_expression(expr)
-	register struct expr *expr;
+void free_expression(struct expr *expr)
 {
 	/*	The expression expr is freed recursively.
 	*/

+ 9 - 0
lang/cem/cemcom.ansi/expr.str

@@ -9,6 +9,14 @@
 	a union of various goodies, we define them first; so be patient.
 */
 
+#ifndef LANG_CEM_CEMCOM_ANSI_EXPR_STR
+#define LANG_CEM_CEMCOM_ANSI_EXPR_STR
+
+#include "idf.h"
+#include "arith.h"
+#include <em_label.h>
+#include <flt_arith.h>
+
 /* classes of value */
 #define Const	1
 #define Name	2
@@ -97,3 +105,4 @@ extern struct expr *intexpr(), *new_oper();
 
 /* ALLOCDEF "expr" 20 */
 
+#endif /* LANG_CEM_CEMCOM_ANSI_EXPR_STR */

+ 12 - 12
lang/cem/cemcom.ansi/expr_loc.h

@@ -7,21 +7,21 @@
 
 /* lang/cem/cemcom.ansi/expr.c */
 int rank_of(int oper);
-int dot2expr(struct expr **expp);
-int idf2expr(register struct expr *expr);
-int string2expr(register struct expr **expp, char *str, int len);
-int int2expr(struct expr *expr);
-int float2expr(register struct expr *expr);
+void dot2expr(struct expr **expp);
+void idf2expr(struct expr *expr);
+void string2expr(struct expr **expp, char *str, int len);
+void int2expr(struct expr *expr);
+void float2expr(struct expr *expr);
 struct expr *intexpr(arith ivalue, int fund);
-int fill_int_expr(register struct expr *ex, arith ivalue, int fund);
-struct expr *new_oper(struct type *tp, register struct expr *e1, int oper, register struct expr *e2);
-int chk_cst_expr(struct expr **expp);
-int init_expression(register struct expr ***eppp, struct expr *expr);
-int is_ld_cst(register struct expr *expr);
+void fill_int_expr(struct expr *ex, arith ivalue, int fund);
+struct expr *new_oper(struct type *tp, struct expr *e1, int oper, struct expr *e2);
+void chk_cst_expr(struct expr **expp);
+void init_expression(struct expr ***eppp, struct expr *expr);
+int is_ld_cst(struct expr *expr);
 int is_cp_cst(struct expr *expr);
 int is_fp_cst(struct expr *expr);
-int is_zero_cst(register struct expr *expr);
-int free_expression(register struct expr *expr);
+int is_zero_cst(struct expr *expr);
+void free_expression(struct expr *expr);
 
 #endif /* LANG_CEM_CEMCOM_ANSI_EXPR_H */
 

+ 9 - 2
lang/cem/cemcom.ansi/expression.g

@@ -14,13 +14,20 @@
 #include	"LLlex.h"
 #include	"type.h"
 #include	"idf.h"
+#include	"decspecs.h"
+#include	"declar.h"
+#include	"declarator.h"
 #include	"label.h"
 #include	"expr.h"
+#include	"expr_loc.h"
+#include	"proto_loc.h"
 #include	"code.h"
 #include	"sizes.h"
-#include "ch3.h"
+#include	"ch3.h"
 #include	"ch3bin.h"
-#include "ch3mon.h"
+#include	"ch3mon.h"
+#include	"error.h"
+
 int InSizeof = 0;	/* inside a sizeof- expression */
 int ResultKnown = 0;	/* result of the expression is already known */
 

+ 9 - 14
lang/cem/cemcom.ansi/field.c

@@ -26,9 +26,11 @@
 #include	"align.h"
 #include	"Lpars.h"
 #include	"field.h"
+#include	"field_loc.h"
+#include	"eval.h"
+#include	"util_loc.h"
 #include	"conversion.h"
 
-arith NewLocal();		/* util.c	*/
 extern arith full_mask[];	/* cstoper.c	*/
 
 /*	Eval_field() evaluates expressions involving bit fields.
@@ -43,14 +45,12 @@ extern arith full_mask[];	/* cstoper.c	*/
 	[3]	atype: the type in which the bitfield arithmetic is done;
 		and in which bitfields are stored!
 */
-eval_field(expr, code)
-	struct expr *expr;
-	int code;
+void eval_field(struct expr *expr, int code)
 {
 	int op = expr->OP_OPER;
-	register struct expr *leftop = expr->OP_LEFT;
-	register struct expr *rightop = expr->OP_RIGHT;
-	register struct field *fd = leftop->ex_type->tp_field;
+	struct expr *leftop = expr->OP_LEFT;
+	struct expr *rightop = expr->OP_RIGHT;
+	struct field *fd = leftop->ex_type->tp_field;
 	struct type *tp = leftop->ex_type->tp_up;
 	arith tmpvar = 0;
 	struct type *atype = ( tp->tp_unsigned
@@ -119,7 +119,7 @@ eval_field(expr, code)
 			retrieval) is on top of stack.
 		*/
 		if (tp->tp_unsigned == 0) {	/* sign extension */
-			register arith shift = (int)word_size * 8 - fd->fd_width;
+			arith shift = (int)word_size * 8 - fd->fd_width;
 
 			C_loc(shift);
 			C_sli(word_size);
@@ -130,12 +130,7 @@ eval_field(expr, code)
 	}
 }
 
-store_field(fd, uns, code, leftop, tmpvar)
-	register struct field *fd;
-	int uns;
-	int code;
-	register struct expr *leftop;
-	arith tmpvar;
+void store_field(struct field *fd, int uns, int code, struct expr *leftop, arith tmpvar)
 {
 	C_loc(fd->fd_mask);
 	C_and(word_size);

+ 13 - 0
lang/cem/cemcom.ansi/field_loc.h

@@ -0,0 +1,13 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_FIELD_H
+#define LANG_CEM_CEMCOM_ANSI_FIELD_H
+
+/* lang/cem/cemcom.ansi/field.c */
+void eval_field(struct expr *expr, int code);
+void store_field(struct field *fd, int uns, int code, struct expr *leftop, arith tmpvar);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_FIELD_H */
+

+ 4 - 2
lang/cem/cemcom.ansi/fltcstoper.c

@@ -19,13 +19,15 @@
 #include	"sizes.h"
 #include	"Lpars.h"
 #include	"cstoper.h"
+#include	"fltcstoper.h"
+#include	"error.h"
+#include	"expr_loc.h"
 
 #include 	<symbol2str.h>
 
 extern int ResultKnown;
 
-fltcstbin(expp, oper, expr)
-	register struct expr **expp, *expr;
+void fltcstbin(struct expr **expp, int oper, struct expr *expr)
 {
 	/*	The operation oper is performed on the constant
 		expressions *expp(ld) and expr(ct), and the result restored in

+ 1 - 1
lang/cem/cemcom.ansi/fltcstoper.h

@@ -6,7 +6,7 @@
 #define LANG_CEM_CEMCOM_ANSI_FLTCSTOPER_H
 
 /* lang/cem/cemcom.ansi/fltcstoper.c */
-int fltcstbin(register struct expr **expp, int oper, register struct expr *expr);
+void fltcstbin(register struct expr **expp, int oper, register struct expr *expr);
 
 #endif /* LANG_CEM_CEMCOM_ANSI_FLTCSTOPER_H */
 

+ 45 - 66
lang/cem/cemcom.ansi/idf.c

@@ -7,6 +7,7 @@
 
 #include	<stdlib.h>
 #include	<string.h>
+#include	"system.h"
 #include	"lint.h"
 #include	<em_reg.h>
 #include	"debug.h"
@@ -34,10 +35,18 @@
 #include 	"ch3.h"
 #include	"code_c.h"
 #include	"conversion.h"
+#include	"print.h"
+#include	"idf_loc.h"
+#include	"struct_loc.h"
+#include	"proto_loc.h"
+#include	"util_loc.h"
+#include	"error.h"
+#include	"stab.h"
+#include	"stack_loc.h"
+
+#include	<symbol2str.h>
 
 extern char options[];
-extern arith NewLocal();
-extern char *symbol2str();
 
 #ifdef DEBUG
 #define IDF_DEBUG
@@ -45,8 +54,7 @@ extern char *symbol2str();
 
 #include <idf_pkg.body>
 
-struct idf *
-gen_idf()
+struct idf *gen_idf()
 {
 	/*	A new idf is created out of nowhere, to serve as an
 		anonymous name.
@@ -60,16 +68,12 @@ gen_idf()
 	return str2idf(s, 0);
 }
 
-int
-is_anon_idf(idf)
-	struct idf *idf;
+int is_anon_idf(struct idf *idf)
 {
 	return idf->id_text[0] == '#';
 }
 
-declare_idf(ds, dc, lvl)
-	struct decspecs *ds;
-	struct declarator *dc;
+void declare_idf(struct decspecs *ds, struct declarator *dc, int lvl)
 {
 	/*	The identifier inside dc is declared on the level lvl, with
 		properties deduced from the decspecs ds and the declarator
@@ -79,14 +83,14 @@ declare_idf(ds, dc, lvl)
 		This routine implements the rich semantics of C
 		declarations.
 	*/
-	register struct idf *idf = dc->dc_idf;
-	register int sc = ds->ds_sc;
+	struct idf *idf = dc->dc_idf;
+	int sc = ds->ds_sc;
 		/*	This local copy is essential:
 				char b(), c;
 			makes b GLOBAL and c AUTO.
 		*/
-	register struct def *def = idf->id_def;		/* may be NULL */
-	register struct type *type;
+	struct def *def = idf->id_def;		/* may be NULL */
+	struct type *type;
 	struct stack_level *stl = stack_level_of(lvl);
 	char formal_array = 0;
 	
@@ -100,8 +104,8 @@ declare_idf(ds, dc, lvl)
 	else	{
 		/* combine the decspecs and the declarator into one type */
 		type = declare_type(ds->ds_type, dc);
-		if (type->tp_size <= (arith)0 &&
-		    actual_declaration(sc, type))	{
+		if ( (type->tp_size <= (arith)0) &&
+		      actual_declaration(sc, type))	{
 			if (type->tp_size == (arith) -1) {
 				/* the type is not yet known,
 				   but it has to be:
@@ -207,7 +211,7 @@ declare_idf(ds, dc, lvl)
 		def->df_line = idf->id_line;
 	}
 	else	{ /* fill in the def block */
-		register struct def *newdef = new_def();
+		struct def *newdef = new_def();
 
 		newdef->next = def;
 		newdef->df_level = lvl;
@@ -256,13 +260,11 @@ declare_idf(ds, dc, lvl)
 	}
 }
 
-actual_declaration(sc, tp)
-	int sc;
-	struct type *tp;
+int actual_declaration(int sc, struct type *tp)
 {
 	/*	An actual_declaration needs space, right here and now.
 	*/
-	register int fund = tp->tp_fund;
+	int fund = tp->tp_fund;
 	
 	if (sc == ENUM || sc == TYPEDEF) /* virtual declarations */
 		return 0;
@@ -277,9 +279,7 @@ actual_declaration(sc, tp)
 	return 1;
 }
 
-global_redecl(idf, new_sc, tp)
-	register struct idf *idf;
-	struct type *tp;
+void global_redecl(struct idf *idf, int new_sc, struct type *tp)
 {
 	/*	A global identifier may be declared several times,
 		provided the declarations do not conflict; they might
@@ -287,7 +287,7 @@ global_redecl(idf, new_sc, tp)
 		an array) or they might conflict or supplement each other
 		in storage class.
 	*/
-	register struct def *def = idf->id_def;
+	struct def *def = idf->id_def;
 
 	while (def->df_level != L_GLOBAL) def = def->next;
 	if (!equal_type(tp, def->df_type, 0, 1)) {
@@ -371,10 +371,7 @@ global_redecl(idf, new_sc, tp)
 	}
 }
 
-int
-good_formal(def, idf)
-	register struct def *def;
-	register struct idf *idf;
+int good_formal(struct def *def, struct idf *idf)
 {
 	/*	Succeeds if def is a proper L_FORMAL1 definition and
 		gives an error message otherwise.
@@ -388,12 +385,11 @@ good_formal(def, idf)
 	return 1;
 }
 
-declare_params(dc)
-	struct declarator *dc;
+void declare_params(struct declarator *dc)
 {
 	/*	Declares the formal parameters if they exist.
 	*/
-	register struct formal *fm = dc->dc_formal;
+	struct formal *fm = dc->dc_formal;
 
 	while (fm)	{
 		declare_parameter(fm->fm_idf);
@@ -401,12 +397,11 @@ declare_params(dc)
 	}
 }
 
-idf_initialized(idf)
-	register struct idf *idf;
+void idf_initialized(struct idf *idf)
 {
 	/*	The topmost definition of idf is set to initialized.
 	*/
-	register struct def *def = idf->id_def;	/* the topmost */
+	struct def *def = idf->id_def;	/* the topmost */
 	
 	while (def->df_level <= L_PROTO) def = def->next;
 	if (def->df_initialized)
@@ -418,18 +413,14 @@ idf_initialized(idf)
 	def->df_initialized = 1;
 }
 
-declare_parameter(idf)
-	struct idf *idf;
+void declare_parameter(struct idf *idf)
 {
 	/*	idf is declared as a formal.
 	*/
 	add_def(idf, FORMAL, int_type, level);
 }
 
-declare_enum(tp, idf, l)
-	struct type *tp;
-	struct idf *idf;
-	arith l;
+void declare_enum(struct type *tp, struct idf *idf, arith l)
 {
 	/*	idf is declared as an enum constant with value l.
 	*/
@@ -437,13 +428,11 @@ declare_enum(tp, idf, l)
 	idf->id_def->df_address = l;
 }
 
-check_formals(idf, dc)
-	struct idf *idf;
-	struct declarator *dc;
+void check_formals(struct idf *idf, struct declarator *dc)
 {
-	register struct formal *fm = dc->dc_formal;
-	register struct proto *pl = idf->id_def->df_type->tp_proto;
-	register struct decl_unary *du = dc->dc_decl_unary;
+	struct formal *fm = dc->dc_formal;
+	struct proto *pl = idf->id_def->df_type->tp_proto;
+	struct decl_unary *du = dc->dc_decl_unary;
 
 	if (!du) {	/* error or typdef'ed function */
 		error("illegal definition of %s", idf->id_text);
@@ -486,7 +475,7 @@ check_formals(idf, dc)
 			error("incorrect number of parameters");
 		}
 	} else {			/* make a pseudo-prototype */
-		register struct proto *lpl = new_proto();
+		struct proto *lpl = new_proto();
 
 		if (!options['o'])
 			warning("'%s' old-fashioned function definition"
@@ -515,18 +504,16 @@ check_formals(idf, dc)
 	dc->dc_formal = 0;
 }
 
-declare_formals(idf, fp)
-	struct idf *idf;
-	arith *fp;
+void declare_formals(struct idf *idf, arith *fp)
 {
 	/*	Declares those formals as int that haven't been declared
 		by the user.
 		An address is assigned to each formal parameter.
 		The total size of the formals is returned in *fp;
 	*/
-	register struct stack_entry *se = stack_level_of(L_FORMAL1)->sl_entry;
+	struct stack_entry *se = stack_level_of(L_FORMAL1)->sl_entry;
 	arith f_offset = (arith)0;
-	register int nparams = 0;
+	int nparams = 0;
 	int hasproto;
 	struct def *df = idf->id_def;
 
@@ -593,9 +580,7 @@ declare_formals(idf, fp)
 	*fp = f_offset;
 }
 
-int
-regtype(tp)
-	struct type *tp;
+int regtype(struct type *tp)
 {
 	switch(tp->tp_fund) {
 	case INT:
@@ -611,11 +596,7 @@ regtype(tp)
 	return -1;
 }
 
-add_def(idf, sc, tp, lvl)
-	struct idf *idf;
-	struct type *tp;
-	int lvl;
-	int sc;
+void add_def(struct idf *idf, int sc, struct type *tp, int lvl)
 {
 	/*	The identifier idf is declared on level lvl with storage
 		class sc and type tp, through a faked C declaration.
@@ -632,13 +613,12 @@ add_def(idf, sc, tp, lvl)
 	declare_idf(&Ds, &Dc, lvl);
 }
 
-update_ahead(idf)
-	register struct idf *idf;
+void update_ahead(struct idf *idf)
 {
 	/*	The tk_symb of the token ahead is updated in the light of new
 		information about the identifier idf.
 	*/
-	register int tk_symb = AHEAD;
+	int tk_symb = AHEAD;
 
 	if (	(tk_symb == IDENTIFIER || tk_symb == TYPE_IDENTIFIER) &&
 		ahead.tk_idf == idf
@@ -647,8 +627,7 @@ update_ahead(idf)
 				TYPE_IDENTIFIER : IDENTIFIER;
 }
 
-free_formals(fm)
-	register struct formal *fm;
+void free_formals(struct formal *fm)
 {
 	while (fm)	{
 		struct formal *tmp = fm->next;

+ 4 - 0
lang/cem/cemcom.ansi/idf.str

@@ -4,6 +4,8 @@
  */
 /* $Id$ */
 /* IDENTIFIER DESCRIPTOR */
+#ifndef LANG_CEM_CEMCOM_ANSI_IDF_STR
+#define LANG_CEM_CEMCOM_ANSI_IDF_STR
 
 #include	"nopp.h"
 
@@ -47,3 +49,5 @@ struct dependency	{
 
 extern int level;
 extern struct idf *gen_idf();
+
+#endif /* LANG_CEM_CEMCOM_ANSI_IDF_STR */

+ 12 - 12
lang/cem/cemcom.ansi/idf_loc.h

@@ -14,20 +14,20 @@ void init_idf(void);
 struct idf *str2idf(char tg[], int cpy);
 struct idf *gen_idf(void);
 int is_anon_idf(struct idf *idf);
-int declare_idf(struct decspecs *ds, struct declarator *dc, int lvl);
+void declare_idf(struct decspecs *ds, struct declarator *dc, int lvl);
 int actual_declaration(int sc, struct type *tp);
-int global_redecl(register struct idf *idf, int new_sc, struct type *tp);
-int good_formal(register struct def *def, register struct idf *idf);
-int declare_params(struct declarator *dc);
-int idf_initialized(register struct idf *idf);
-int declare_parameter(struct idf *idf);
-int declare_enum(struct type *tp, struct idf *idf, arith l);
-int check_formals(struct idf *idf, struct declarator *dc);
-int declare_formals(struct idf *idf, arith *fp);
+void global_redecl(struct idf *idf, int new_sc, struct type *tp);
+int good_formal(struct def *def, struct idf *idf);
+void declare_params(struct declarator *dc);
+void idf_initialized(struct idf *idf);
+void declare_parameter(struct idf *idf);
+void declare_enum(struct type *tp, struct idf *idf, arith l);
+void check_formals(struct idf *idf, struct declarator *dc);
+void declare_formals(struct idf *idf, arith *fp);
 int regtype(struct type *tp);
-int add_def(struct idf *idf, int sc, struct type *tp, int lvl);
-int update_ahead(register struct idf *idf);
-int free_formals(register struct formal *fm);
+void add_def(struct idf *idf, int sc, struct type *tp, int lvl);
+void update_ahead(struct idf *idf);
+void free_formals(struct formal *fm);
 
 #endif /* LANG_CEM_CEMCOM_ANSI_IDF_H */
 

+ 11 - 5
lang/cem/cemcom.ansi/init.c

@@ -13,11 +13,17 @@
 #include	<system.h>
 #include	<alloc.h>
 #include	<time.h>
+
+#include	<flt_arith.h>
+#include	<em_label.h>
 #include	"class.h"
 #include	"macro.h"
 #include	"idf.h"
-
-extern char *sprint();
+#include	"arith.h"
+#include	"print.h"
+#include	"expr.h"
+#include	"error.h"
+#include	"domacro.h"
 
 struct mkey	{
 	char *mk_reserved;
@@ -38,7 +44,7 @@ struct mkey	{
 	{0,		K_UNKNOWN}
 };
 
-init_pp()
+void init_pp()
 {
 	static char *months[12] = {
 		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
@@ -55,10 +61,10 @@ init_pp()
 		id_resmac field of the identifier.
 	*/
 	{
-		register struct mkey *mk = &mkey[0];
+		struct mkey *mk = &mkey[0];
 
 		while (mk->mk_reserved)	{
-			register struct idf *idf = str2idf(mk->mk_reserved, 0);
+			struct idf *idf = str2idf(mk->mk_reserved, 0);
 			
 			if (idf->id_resmac)
 				fatal("maximum identifier length insufficient");

+ 12 - 0
lang/cem/cemcom.ansi/init.h

@@ -0,0 +1,12 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_INIT_H
+#define LANG_CEM_CEMCOM_ANSI_INIT_H
+
+/* lang/cem/cemcom.ansi/init.c */
+void init_pp();
+
+#endif /* LANG_CEM_CEMCOM_ANSI_INIT_H */
+

+ 7 - 0
lang/cem/cemcom.ansi/input.c

@@ -7,9 +7,16 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include "idf.h"
+#include "arith.h"
+#include <em_label.h>
+#include <flt_arith.h>
+#include "expr.h"
 #include "inputtype.h"
 #include "file_info.h"
 #include "input.h"
+#include "replace_loc.h"
+#include "error.h"
 
 #define INP_PUSHBACK	3
 #define INP_TYPE	struct file_info

+ 5 - 0
lang/cem/cemcom.ansi/input.h

@@ -3,6 +3,9 @@
  * See the copyright notice in the ACK home directory, in the file "Copyright".
  */
 /* $Id$ */
+#ifndef LANG_CEM_CEMCOM_ANSI_INPUT_H
+#define LANG_CEM_CEMCOM_ANSI_INPUT_H
+
 #define INP_PUSHBACK 3
 
 #include <inp_pkg.spec>
@@ -13,3 +16,5 @@
 
 extern	int LexSave;	/* last character read by GetChar		*/
 extern 	int GetChar();	/* character input, with trigraph parsing	*/
+
+#endif /* LANG_CEM_CEMCOM_ANSI_INPUT_H */

+ 57 - 82
lang/cem/cemcom.ansi/ival.g

@@ -14,6 +14,8 @@
 #include	"l_lint.h"
 #endif	/* LINT */
 #include	"debug.h"
+#include	<stdio.h>
+#include	<stdlib.h>
 #include	<alloc.h>
 #include	<assert.h>
 #include	"nobitfield.h"
@@ -21,32 +23,36 @@
 #include	"arith.h"
 #include	"label.h"
 #include	"expr.h"
+#include	"expr_loc.h"
 #include	"type.h"
 #include	"proto.h"
 #include	"struct.h"
+#include	"struct_loc.h"
 #include	"field.h"
 #include	"assert.h"
 #include	"Lpars.h"
 #include	"sizes.h"
 #include	"align.h"
 #include	"idf.h"
+#include	"idf_loc.h"
 #include	"level.h"
 #include	"def.h"
+#include	"ch3.h"
+#include	"ival.h"
 #include	"LLlex.h"
 #include	"estack.h"
 #include	"conversion.h"
-#include "cstopen.h"
+#include	"cstoper.h"
+#include	"error.h"
 
 #define con_nullbyte()	C_con_ucon("0", (arith)1)
 #define aggregate_type(tp) ((tp)->tp_fund == ARRAY || (tp)->tp_fund == STRUCT)
 
 char *long2str();
-char *strncpy();
+
 extern char options[];
 static int gen_error;
 static int pack_level;
-struct type **gen_tphead(), **gen_tpmiddle();
-struct sdef *gen_align_to_next();
 struct e_stack *p_stack;
 }
 
@@ -54,7 +60,7 @@ struct e_stack *p_stack;
  */
 /* 3.5 */
 
-initial_value(register struct type **tpp; register struct expr **expp;) :
+initial_value(struct type **tpp; struct expr **expp;) :
 	{ if (tpp) gen_tpcheck(tpp); }
 [
 		{ if (pack_level == 0) gen_error = 0; }
@@ -124,10 +130,9 @@ initial_value_list(register struct type **tpp; struct expr **expp;)
 ;
 
 {
-gen_tpcheck(tpp)
-	struct type **tpp;
+void gen_tpcheck(struct type **tpp)
 {
-	register struct type *tp;
+	struct type *tp;
 
 	if (gen_error) return;
 	switch((tp = *tpp)->tp_fund) {
@@ -149,11 +154,9 @@ gen_tpcheck(tpp)
 	}
 }
 
-gen_simple_exp(tpp, expp)
-	struct type **tpp;
-	struct expr **expp;
+void gen_simple_exp(struct type **tpp, struct expr **expp)
 {
-	register struct type *tp;
+	struct type *tp;
 
 	if (gen_error) return;
 	tp = *tpp;
@@ -179,12 +182,9 @@ gen_simple_exp(tpp, expp)
 	}
 }
 
-struct type **
-arr_elem(tpp, p)
-	struct type **tpp;
-	struct e_stack *p;
+struct type **arr_elem(struct type **tpp, struct e_stack *p)
 {
-	register struct type *tp = *tpp;
+	struct type *tp = *tpp;
 
 	if (tp->tp_up->tp_fund == CHAR && AHEAD == STRING && p->elem_count == 1) {
 		p->nelem = 1;
@@ -195,10 +195,7 @@ arr_elem(tpp, p)
 	return gen_tphead(&(tp->tp_up), 1);
 }
 
-struct sdef *
-next_field(sd, p)
-	register struct sdef *sd;
-	register struct e_stack *p;
+struct sdef *next_field(struct sdef *sd, struct e_stack *p)
 {
 	if (sd->sd_sdef)
 		p->bytes_upto_here += zero_bytes(sd);
@@ -208,13 +205,11 @@ next_field(sd, p)
 	return sd->sd_sdef;
 }
 
-struct type **
-gen_tphead(tpp, nest)
-	struct type **tpp;
+struct type **gen_tphead(struct type **tpp, int nest)
 {
-	register struct type *tp = *tpp;
-	register struct e_stack *p;
-	register struct sdef *sd;
+	struct type *tp = *tpp;
+	struct e_stack *p;
+	struct sdef *sd;
 
 	if (tpp && *tpp == error_type) {
 		gen_error = pack_level;
@@ -285,12 +280,11 @@ gen_tphead(tpp, nest)
 	}
 }
 
-struct type **
-gen_tpmiddle()
+struct type **gen_tpmiddle()
 {
-	register struct type *tp;
-	register struct sdef *sd;
-	register struct e_stack *p = p_stack;
+	struct type *tp;
+	struct sdef *sd;
+	struct e_stack *p = p_stack;
 
 	if (gen_error) {
 		if (p) return p->s_tpp;
@@ -344,11 +338,9 @@ again:
 	}
 }
 
-struct sdef *
-gen_align_to_next(p)
-	register struct e_stack *p;
+struct sdef *gen_align_to_next(struct e_stack *p)
 {
-	register struct sdef *sd = p->s_def;
+	struct sdef *sd = p->s_def;
 
 	if (! sd) return sd;
 #ifndef NOBITFIELD
@@ -363,11 +355,11 @@ gen_align_to_next(p)
 	return sd;
 }
 
-gen_tpend()
+void gen_tpend()
 {
-	register struct e_stack *p = p_stack;
-	register struct type *tp;
-	register struct sdef *sd;
+	struct e_stack *p = p_stack;
+	struct type *tp;
+	struct sdef *sd;
 	int getout = 0;
 
 	while (!getout && p) {
@@ -419,11 +411,9 @@ gen_tpend()
 	In the latter case, only the first member is initialised and
 	the rest is zeroed.
 */
-check_and_pad(expp, tpp)
-	struct type **tpp;
-	struct expr **expp;
+void check_and_pad(struct expr **expp, struct type **tpp)
 {
-	register struct type *tp = *tpp;
+	struct type *tp = *tpp;
 
 	if (tp->tp_fund == ARRAY) {
 		check_and_pad(expp, &(tp->tp_up));	/* first member	*/
@@ -434,7 +424,7 @@ check_and_pad(expp, tpp)
 			tp = *tpp = construct_type(ARRAY, tp->tp_up,
 					0, (arith)1, NO_PROTO);
 		else {
-			register int dim = tp->tp_size / tp->tp_up->tp_size;
+			int dim = tp->tp_size / tp->tp_up->tp_size;
 			/* pad remaining members with zeroes */
 			while (--dim > 0)
 				pad(tp->tp_up);
@@ -442,13 +432,13 @@ check_and_pad(expp, tpp)
 	}
 	else
 	if (tp->tp_fund == STRUCT) {
-		register struct sdef *sd = tp->tp_sdef;
+		struct sdef *sd = tp->tp_sdef;
 
 		check_and_pad(expp, &(sd->sd_type));
 		/* next selector is aligned by adding extra zeroes */
 		if (sd->sd_sdef)
 			zero_bytes(sd);
-		while (sd = sd->sd_sdef) { /* pad remaining selectors	*/
+		while ( (sd = sd->sd_sdef) ) { /* pad remaining selectors	*/
 			pad(sd->sd_type);
 			if (sd->sd_sdef)
 				zero_bytes(sd);
@@ -456,7 +446,7 @@ check_and_pad(expp, tpp)
 	}
 	else if (tp->tp_fund == UNION) {
 		/* only the first selector can be initialized */
-		register struct sdef *sd = tp->tp_sdef;
+		struct sdef *sd = tp->tp_sdef;
 
 		check_and_pad(expp, &(sd->sd_type));
 	}
@@ -467,11 +457,10 @@ check_and_pad(expp, tpp)
 /*	pad() fills an element of type tp with zeroes.
 	If the element is an aggregate, pad() is called recursively.
 */
-pad(tpx)
-	struct type *tpx;
+void pad(struct type *tpx)
 {
-	register struct type *tp = tpx;
-	register arith sz = tp->tp_size;
+	struct type *tp = tpx;
+	arith sz = tp->tp_size;
 
 	gen_tpcheck(&tpx);
 	if (gen_error) return;
@@ -498,16 +487,14 @@ pad(tpx)
 	No further comment is needed to explain the internal structure
 	of this straightforward function.
 */
-check_ival(expp, tp)
-	register struct type *tp;
-	struct expr **expp;
+void check_ival(struct expr **expp, struct type *tp)
 {
 	/*	The philosophy here is that ch3cast puts an explicit
 		conversion node in front of the expression if the types
 		are not compatible.  In this case, the initialisation
 		expression is no longer a constant.
 	*/
-	register struct expr *expr = *expp;
+	struct expr *expr = *expp;
 	
 	switch (tp->tp_fund) {
 	case CHAR:
@@ -611,13 +598,13 @@ and also to prevent runtime coercions for compile-time constants.
 	a string constant.
 	Alignment is taken care of.
 */
-ch_array(tpp, ex)
-	struct type **tpp;	/* type tp = array of characters	*/
-	struct expr *ex;
+
+/* tpp -> type tp = array of characters	*/
+void ch_array(struct type **tpp, struct expr *ex)
 {
-	register struct type *tp = *tpp;
-	register int length = ex->SG_LEN, i;
-	register char *to, *from, *s;
+	struct type *tp = *tpp;
+	int length = ex->SG_LEN, i;
+	char *to, *from, *s;
 
 	ASSERT(ex->ex_class == String);
 	if (tp->tp_size == (arith)-1) {
@@ -653,10 +640,7 @@ ch_array(tpp, ex)
 /*	As long as some parts of the pipeline cannot handle very long string
 	constants, string constants are written out in chunks
 */
-str_cst(str, len, inrom)
-	register char *str;
-	register int len;
-	int inrom;
+void str_cst(char *str, int len, int inrom)
 {
 	int chunksize = ((127 + (int) word_size) / (int) word_size) * (int) word_size;
 
@@ -680,9 +664,7 @@ str_cst(str, len, inrom)
 	"throws" the result of "field" out if the current selector
 	is the last of this number of fields stored at the same address.
 */
-put_bf(tp, val)
-	struct type *tp;
-	arith val;
+void put_bf(struct type *tp, arith val)
 {
 	static long field = (arith)0;
 	static arith offset = (arith)-1;
@@ -710,9 +692,7 @@ put_bf(tp, val)
 }
 #endif /* NOBITFIELD */
 
-int
-zero_bytes(sd)
-	register struct sdef *sd;
+int zero_bytes(struct sdef *sd)
 {
 	/*	fills the space between a selector of a struct
 		and the next selector of that struct with zero-bytes.
@@ -726,10 +706,7 @@ zero_bytes(sd)
 	return count;
 }
 
-int
-valid_type(tp, str)
-	struct type *tp;
-	char *str;
+int valid_type(struct type *tp, char *str)
 {
 	ASSERT(tp!=(struct type *)0);
 	if (tp->tp_size < 0) {
@@ -739,10 +716,9 @@ valid_type(tp, str)
 	return 1;
 }
 
-con_int(ex)
-	register struct expr *ex;
+void con_int(struct expr *ex)
 {
-	register struct type *tp = ex->ex_type;
+	struct type *tp = ex->ex_type;
 
 	ASSERT(is_cp_cst(ex));
 	if (tp->tp_unsigned)
@@ -753,14 +729,13 @@ con_int(ex)
 		C_con_icon(long2str((long)ex->VL_VALUE, 10), tp->tp_size);
 }
 
-illegal_init_cst(ex)
-	struct expr *ex;
+void illegal_init_cst(struct expr *ex)
 {
 	expr_error(ex, "illegal initialization constant");
 	gen_error = pack_level;
 }
 
-too_many_initialisers()
+void too_many_initialisers()
 {
 	error("too many initializers");
 	gen_error = pack_level;

+ 66 - 0
lang/cem/cemcom.ansi/ival.h

@@ -0,0 +1,66 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_IVAL_H
+#define LANG_CEM_CEMCOM_ANSI_IVAL_H
+
+#include "estack.h"
+
+/* lang/cem/cemcom.ansi/ival.g */
+void gen_tpcheck(struct type **tpp);
+void gen_simple_exp(struct type **tpp, struct expr **expp);
+struct type **arr_elem(struct type **tpp, struct e_stack *p);
+struct sdef *next_field(struct sdef *sd, struct e_stack *p);
+struct type **gen_tphead(struct type **tpp, int nest);
+struct type **gen_tpmiddle();
+struct sdef *gen_align_to_next(struct e_stack *p);
+void gen_tpend();
+/*	check_and_pad() is given a simple initialisation expression
+	where the type can be either a simple or an aggregate type.
+	In the latter case, only the first member is initialised and
+	the rest is zeroed.
+*/
+void check_and_pad(struct expr **expp, struct type **tpp);
+/*	pad() fills an element of type tp with zeroes.
+	If the element is an aggregate, pad() is called recursively.
+*/
+void pad(struct type *tpx);
+/*	check_ival() checks whether the initialisation of an element
+	of a fundamental type is legal and, if so, performs the initialisation
+	by directly generating the necessary code.
+	No further comment is needed to explain the internal structure
+	of this straightforward function.
+*/
+void check_ival(struct expr **expp, struct type *tp);
+/*	ch_array() initialises an array of characters when given
+	a string constant.
+	Alignment is taken care of.
+*/
+
+/* tpp -> type tp = array of characters	*/
+void ch_array(struct type **tpp, struct expr *ex);
+/*	As long as some parts of the pipeline cannot handle very long string
+	constants, string constants are written out in chunks
+*/
+void str_cst(char *str, int len, int inrom);
+#ifndef NOBITFIELD
+/*	put_bf() takes care of the initialisation of (bit-)field
+	selectors of a struct: each time such an initialisation takes place,
+	put_bf() is called instead of the normal code generating routines.
+	Put_bf() stores the given integral value into "field" and
+	"throws" the result of "field" out if the current selector
+	is the last of this number of fields stored at the same address.
+*/
+void put_bf(struct type *tp, arith val);
+#endif /* NOBITFIELD */
+
+int zero_bytes(struct sdef *sd);
+int valid_type(struct type *tp, char *str);
+void con_int(struct expr *ex);
+void illegal_init_cst(struct expr *ex);
+void too_many_initialisers();
+
+
+#endif /* LANG_CEM_CEMCOM_ANSI_IVAL_H */
+

+ 6 - 5
lang/cem/cemcom.ansi/label.c

@@ -13,18 +13,20 @@
 #include	"def.h"
 #include	"type.h"
 #include	"stack.h"
+#include	"error.h"
+#include	"idf_loc.h"
+#include	"stack_loc.h"
 
 extern char options[];
 
-enter_label(idf, defining)
-	register struct idf *idf;
+void enter_label(struct idf *idf, int defining)
 {
 	/*	The identifier idf is entered as a label. If it is new,
 		it is entered into the idf list with the largest possible
 		scope, i.e., on the lowest possible level.
 		If defining, the label comes from a label statement.
 	*/
-	register struct def *def = idf->id_label;
+	struct def *def = idf->id_label;
 
 	if (def)	{
 		if (defining && def->df_initialized)
@@ -44,8 +46,7 @@ enter_label(idf, defining)
 		def->df_initialized = 1;
 }
 
-unstack_label(idf)
-	register struct idf *idf;
+void unstack_label(struct idf *idf)
 {
 	/*	The scope in which the label idf occurred is left.
 	*/

+ 9 - 0
lang/cem/cemcom.ansi/label.h

@@ -4,6 +4,8 @@
  */
 /* $Id$ */
 /*		L A B E L   D E F I N I T I O N				*/
+#ifndef LANG_CEM_CEMCOM_ANSI_LABEL_H
+#define LANG_CEM_CEMCOM_ANSI_LABEL_H
 
 #include <em_label.h>		/* obtain definition of "label" */
 
@@ -26,3 +28,10 @@ extern label datlab_count;
 		not be there, and if it is there, it may be from a
 		declaration or another application.
 	*/
+
+struct idf;
+
+void enter_label(struct idf *idf, int defining);
+void unstack_label(struct idf *idf);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_LABEL_H */

+ 29 - 26
lang/cem/cemcom.ansi/main.c

@@ -5,10 +5,13 @@
 /* $Id$ */
 /* MAIN PROGRAM */
 
+#include 	<string.h>
 #include	"lint.h"
 #include	<system.h>
+#include	"print.h"
 #include	"debug.h"
 #include	"nopp.h"
+#include	"label.h"
 #include	"trgt_sizes.h"
 #include	"use_tmp.h"
 #include	"inputtype.h"
@@ -31,6 +34,15 @@
 #include	"assert.h"
 #include	"code_c.h"
 #include	"cstoper.h"
+#include	"init.h"
+#include	"options.h"
+#include	"main.h"
+#include	"error.h"
+#include	"stack.h"
+#include	"stack_loc.h"
+#include	"idf_loc.h"
+#include	"program.h"
+#include	"tokenname.h"
 
 #include	<symbol2str.h>
 
@@ -86,8 +98,7 @@ arith ifval;	/* ifval will contain the result of the #if expression	*/
 
 char *prog_name;
 
-main(argc, argv)
-	char *argv[];
+int main(int argc, char *argv[])
 {
 	/* parse and interpret the command line options	*/
 	prog_name = argv[0];
@@ -142,15 +153,13 @@ main(argc, argv)
 #ifndef NOPP
 
 struct dependency    *file_head;
-extern char *strrchr();
 
-list_dependencies(source)
-char *source;
+void list_dependencies(char *source)
 {
-    register struct dependency *p = file_head;
+    struct dependency *p = file_head;
 
     if (source) {
-	register char *s = strrchr(source, '.');
+	char *s = strrchr(source, '.');
 
 	if (s && *(s+1)) {
 	    s++;
@@ -160,7 +169,7 @@ char *source;
 	     * object generated, so don't include the pathname
 	     * leading to it.
              */
-            if (s = strrchr(source, '/')) {
+            if ( (s = strrchr(source, '/')) ) {
 		source = s + 1;
 	    }
 	}
@@ -175,13 +184,12 @@ char *source;
     }
 }
 
-add_dependency(s)
-char *s;
+void add_dependency(char *s)
 {
-    register struct idf *p = str2idf(s, 1);
+    struct idf *p = str2idf(s, 1);
 
     if (! p->id_resmac) {
-	register struct dependency *q = new_dependency();
+	struct dependency *q = new_dependency();
 
 	p->id_resmac = K_FILE;
 	q->dep_idf = p;
@@ -190,8 +198,7 @@ char *s;
     }
 }
 
-dependency(s, source)
-char *s, *source;
+void dependency(char *s, char *source)
 {
     if (options['i'] && !strncmp(s, "/usr/include/", 13)) {
 	return;
@@ -210,12 +217,11 @@ char *source = 0;
 char *nmlist = 0;
 #endif /* GEN_NM_LIST */
 
-compile(argc, argv)
-	char *argv[];
+void compile(int argc, char *argv[])
 {
 	char *result;
 #ifndef	LINT
-	register char *destination = 0;
+	char *destination = 0;
 #endif	/* LINT */
 
 #ifdef DEBUG
@@ -321,7 +327,7 @@ compile(argc, argv)
 #endif	/* NOPP */
 }
 
-init()
+void init()
 {
 	init_cst();	/* initialize variables of "cstoper.c"		*/
 	reserve(tkidf);		/* mark the C reserved words as such	*/
@@ -386,8 +392,7 @@ init()
 	stack_level();
 }
 
-init_specials(si)
-	register struct sp_id *si;
+void init_specials(struct sp_id *si)
 {
 	while (si->si_identifier)	{
 		struct idf *idf = str2idf(si->si_identifier, 0);
@@ -401,7 +406,7 @@ init_specials(si)
 
 #ifdef DEBUG
 #ifndef NOPP
-preprocess()
+void preprocess()
 {
 	/*	preprocess() is the "stand-alone" preprocessor which
 		consecutively calls the lexical analyzer LLlex() to get
@@ -471,7 +476,7 @@ preprocess()
 }
 #endif /* NOPP */
 
-Info()
+void Info()
 {
 	extern int cnt_string_cst, cnt_formal,
 		    cnt_decl_unary, cnt_def, cnt_expr, cnt_field,
@@ -503,14 +508,12 @@ Info()
 }
 #endif /* DEBUG */
 
-void
-No_Mem()				/* called by alloc package */
+void No_Mem()				/* called by alloc package */
 {
 	fatal("out of memory");
 }
 
-void
-C_failed()				/* called by EM_code module */
+void C_failed()				/* called by EM_code module */
 {
 	fatal("write failed");
 }

+ 20 - 0
lang/cem/cemcom.ansi/main.h

@@ -0,0 +1,20 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_MAIN_H
+#define LANG_CEM_CEMCOM_ANSI_MAIN_H
+
+/* lang/cem/cemcom.ansi/main.c */
+int main(int argc, char *argv[]);
+void list_dependencies(char *source);
+void add_dependency(char *s);
+void dependency(char *s, char *source);
+void compile(int argc, char *argv[]);
+void init(void);
+void init_specials(struct sp_id *si);
+void No_Mem(void);
+void C_failed(void);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_MAIN_H */
+

+ 15 - 16
lang/cem/cemcom.ansi/options.c

@@ -23,6 +23,8 @@
 #include	"dataflow.h"
 #include	"dbsymtab.h"
 #include	"conversion.h"
+#include	"error.h"
+#include	"domacro.h"
 
 #ifndef NOPP
 extern char **inctable;
@@ -42,12 +44,11 @@ char loptions[128];			/* one for every char	*/
 extern int idfsize;
 extern int density;
 
-static int txt2int();
+static int txt2int(char **tp);
 
-do_option(text)
-	char *text;
+void do_option(char *text)
 {
-	register char opt;
+	char opt;
 
 next_option:			/* to allow combined one-char options */
 	switch (opt = *text++)	{
@@ -64,7 +65,7 @@ next_option:			/* to allow combined one-char options */
 		break;
 
 	case '-':
-		options[*text++] = 1;	/* flags, debug options etc.	*/
+		options[*(unsigned char *)text++] = 1;	/* flags, debug options etc.	*/
 		goto next_option;
 
 #ifndef LINT
@@ -77,7 +78,7 @@ next_option:			/* to allow combined one-char options */
                 break;
         case 'i':
         case 'm':
-             	options[opt] = 1;
+             	options[(unsigned char)opt] = 1;
             	break;
 #endif /* NOPP */
 #endif /* LINT */
@@ -98,7 +99,7 @@ next_option:			/* to allow combined one-char options */
 	case 'w':			/* no warnings will be given */
 	case 's':			/* no stricts will be given */
 	case 'o':			/* no complaints about old-style */
-		options[opt] = 1;
+		options[(unsigned char)opt] = 1;
 		goto next_option;
 	case 'a':		/* suppress all but errors diagnostics */
 		options['w'] = 1;	/* implies -a */
@@ -120,17 +121,17 @@ next_option:			/* to allow combined one-char options */
 
 #ifndef NOPP
 	case 'D' :	{	/* -Dname :	predefine name		*/
-		register char *cp = text, *name, *mactext;
+		char *cp = text, *name, *mactext;
 		unsigned maclen;
 
-		if (class(*cp) != STIDF && class(*cp) != STELL) {
+		if (class(*(unsigned char *)cp) != STIDF && class(*(unsigned char *)cp) != STELL) {
 			error("identifier missing in -D%s", text);
 			break;
 		}
 
 		name = cp;
 
-		while (*cp && in_idf(*cp)) {
+		while (*cp && in_idf(*(unsigned char *)cp)) {
 			++cp;
 		}
 
@@ -156,7 +157,7 @@ next_option:			/* to allow combined one-char options */
 	case 'I' :	/* -Ipath : insert "path" into include list	*/
 		if (*text)	{
 			int i;
-			register char *new = text;
+			char *new = text;
 			
 			if (inc_total >= inc_max) {
 				inctable = (char **)
@@ -215,10 +216,10 @@ next_option:			/* to allow combined one-char options */
 #ifndef NOCROSS
 	case 'V' :	/* set object sizes and alignment requirements	*/
 	{
-		register arith sz, algn;
+		arith sz, algn;
 		char c;
 
-		while (c = *text++)	{
+		while ( (c = *text++) )	{
 			sz = txt2int(&text);
 			algn = 0;
 			if (*text == '.')	{
@@ -303,9 +304,7 @@ next_option:			/* to allow combined one-char options */
 	}
 }
 
-static int
-txt2int(tp)
-	register char **tp;
+static int txt2int(char **tp)
 {
 	/*	the integer pointed to by *tp is read, while increasing
 		*tp; the resulting value is yielded.

+ 12 - 0
lang/cem/cemcom.ansi/options.h

@@ -0,0 +1,12 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_OPTIONS_H
+#define LANG_CEM_CEMCOM_ANSI_OPTIONS_H
+
+/* lang/cem/cemcom.ansi/options.c */
+void do_option(char *text);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_OPTIONS_H */
+

+ 5 - 5
lang/cem/cemcom.ansi/pragma.c

@@ -7,6 +7,8 @@
 
 #include	"debug.h"
 #include	"idf.h"
+#include	"skip.h"
+#include	"domacro.h"
 
 #define P_UNKNOWN	0
 #define NR_PRAGMAS	0
@@ -18,14 +20,12 @@ struct pkey {
 	{0,		P_UNKNOWN}
 };
 
-extern struct idf *GetIdentifier();
-
-do_pragma()
+void do_pragma()
 {
 #if	NR_PRAGMAS
-	register struct pkey *pkp = &pragmas[0];
+	struct pkey *pkp = &pragmas[0];
 #endif
-	register struct idf *id = GetIdentifier(1);
+	struct idf *id = GetIdentifier(1);
 
 	if (id != (struct idf *)0) {
 #if	NR_PRAGMAS

+ 12 - 0
lang/cem/cemcom.ansi/pragma.h

@@ -0,0 +1,12 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_PRAGMA_H
+#define LANG_CEM_CEMCOM_ANSI_PRAGMA_H
+
+/* lang/cem/cemcom.ansi/pragma.c */
+int do_pragma(void);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_PRAGMA_H */
+

+ 9 - 2
lang/cem/cemcom.ansi/program.g

@@ -52,14 +52,22 @@
 #include	"arith.h"
 #include	"LLlex.h"
 #include	"idf.h"
+#include	"idf_loc.h"
 #include	"label.h"
 #include	"type.h"
 #include	"declar.h"
 #include	"decspecs.h"
 #include	"code.h"
 #include	"expr.h"
+#include	"expr_loc.h"
 #include	"def.h"
-#include "code_c.h"
+#include	"code_c.h"
+#include	"error.h"
+#include	"stack.h"
+#include	"stack_loc.h"
+#include	"declarator.h"
+#include	"proto_loc.h"
+
 #ifdef	LINT
 #include	"l_lint.h"
 #endif	/* LINT */
@@ -68,7 +76,6 @@
 extern arith ifval;
 #endif /* NOPP */
 
-extern error();
 }
 
 control_if_expression

+ 16 - 0
lang/cem/cemcom.ansi/program.h

@@ -0,0 +1,16 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_PROGRAM_H
+#define LANG_CEM_CEMCOM_ANSI_PROGRAM_H
+
+/* lang/cem/cemcom.ansi/program.g */
+
+void If_expr(void);
+void C_program(void);
+
+void LL1_control_if_expression(void);
+void LL0_program(void);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_PROGRAM_H */

+ 35 - 40
lang/cem/cemcom.ansi/proto.c

@@ -17,24 +17,28 @@
 #include	"arith.h"
 #include	"align.h"
 #include	"stack.h"
+#include	"stack_loc.h"
 #include	"idf.h"
+#include	"idf_loc.h"
 #include	"def.h"
 #include	"type.h"
+#include	"ch3.h"
 #include	"struct.h"
 #include	"label.h"
 #include	"expr.h"
 #include	"declar.h"
 #include	"decspecs.h"
 #include	"proto.h"
+#include	"proto_loc.h"
 #include	"assert.h"
 #include	"conversion.h"
+#include	"error.h"
 
 extern char options[];
 
-check_for_void(pl)
-	register struct proto *pl;
+void check_for_void(struct proto *pl)
 {
-	register int errcnt = 0;
+	int errcnt = 0;
 
 	if (!pl) return;
 	if ((pl->pl_flag & PL_VOID) && !(pl->next)) return;
@@ -50,11 +54,7 @@ check_for_void(pl)
 	}
 }
 
-add_proto(pl, ds, dc, lvl)
-	struct proto *pl;
-	struct decspecs *ds;
-	struct declarator *dc;
-	int lvl;
+void add_proto(struct proto *pl, struct decspecs *ds, struct declarator *dc, int lvl)
 {
 	/*	The full typed identifier or abstract type, described
 		by the structures decspecs and declarator are turned
@@ -63,10 +63,10 @@ add_proto(pl, ds, dc, lvl)
 		later on it's decided whether they were prototypes
 		or actual declarations.
 	*/
-	register struct idf *idf = dc->dc_idf;
-	register struct def *def = idf ? idf->id_def : (struct def *)0;
-	register int sc = ds->ds_sc;
-	register struct type *type;
+	struct idf *idf = dc->dc_idf;
+	struct def *def = idf ? idf->id_def : (struct def *)0;
+	int sc = ds->ds_sc;
+	struct type *type;
 	char formal_array = 0;
 
 	ASSERT(ds->ds_type != (struct type *)0);
@@ -123,7 +123,7 @@ add_proto(pl, ds, dc, lvl)
 	} else if (idf != (struct idf *)0) {
 		/*	New definition, redefinition hides earlier one
 		*/
-		register struct def *newdef = new_def();
+		struct def *newdef = new_def();
 		
 		newdef->next = def;
 		newdef->df_level = lvl;
@@ -173,7 +173,7 @@ struct type *tp;
 struct idf **idpp;
 {
 	struct tag *tg = (struct tag *)0;
-	register int fund = tp->tp_fund;
+	int fund = tp->tp_fund;
 
         while (fund == FIELD || fund == POINTER
                 || fund == ARRAY || fund == FUNCTION) {
@@ -190,17 +190,16 @@ struct idf **idpp;
 }
 
 
-declare_protos(dc)
-	register struct declarator *dc;
+void declare_protos(struct declarator *dc)
 {
 	/*	At this points we know that the idf's in protolist are formal
 		parameters. So it's time to declare them at level L_FORMAL2.
 	*/
 	struct stack_level *stl = stack_level_of(L_FORMAL1);
-	register struct decl_unary *du;
-	register struct type *type;
-	register struct proto *pl;
-	register struct def *def;
+	struct decl_unary *du;
+	struct type *type;
+	struct proto *pl;
+	struct def *def;
 
 #ifdef	DEBUG
 	if (options['t'])
@@ -266,8 +265,7 @@ declare_protos(dc)
 }
 
 
-update_proto(tp, otp)
-	register struct type *tp, *otp;
+void update_proto(struct type *tp, struct type *otp)
 {
 	/*	This routine performs the proto type updates.
 		Consider the following code:
@@ -280,7 +278,7 @@ update_proto(tp, otp)
 		This routine will silently update all lists,
 		and removes the redundant occupied space.
 	*/
-	register struct proto *pl, *opl;
+	struct proto *pl, *opl;
 
 	if (tp == otp) return;
 	if (!tp || !otp) return;
@@ -317,12 +315,11 @@ update_proto(tp, otp)
 /* struct/union and enum tags can be declared inside prototypes
  * remove them from the symbol-table
  */
-remove_proto_tag(tp)
-struct type *tp;
+void remove_proto_tag(struct type *tp)
 {
-	register struct idf *ident;
-	register struct tag *tgp, **tgpp;
-	register int fund = tp->tp_fund;
+	struct idf *ident;
+	struct tag *tgp, **tgpp;
+	int fund = tp->tp_fund;
 
 	while (fund == FIELD || fund == POINTER
 		|| fund == ARRAY || fund == FUNCTION) {
@@ -356,13 +353,12 @@ struct type *tp;
 	free_tag(tgp);
 }
 
-remove_proto_idfs(pl)
-	register struct proto *pl;
+void remove_proto_idfs(struct proto *pl)
 {
 	/*	Remove all the identifier definitions from the
 		prototype list.
 	*/
-	register struct def *def;
+	struct def *def;
 
 	while (pl) {
 		if (pl->pl_idf) {
@@ -385,8 +381,7 @@ remove_proto_idfs(pl)
 	}
 }
 
-call_proto(expp)
-	register struct expr **expp;
+void call_proto(struct expr **expp)
 {
 	/*	If the function specified by (*expp)->OP_LEFT has a prototype,
 		the parameters are converted according the rules specified in
@@ -395,13 +390,13 @@ call_proto(expp)
 		under ellipsis clause the old parameters conversion stuff
 		applies.
 	*/
-	register struct expr *left = (*expp)->OP_LEFT;
-	register struct expr *right = (*expp)->OP_RIGHT;
-	register struct proto *pl = NO_PROTO;
+	struct expr *left = (*expp)->OP_LEFT;
+	struct expr *right = (*expp)->OP_RIGHT;
+	struct proto *pl = NO_PROTO;
 	static struct proto ellipsis = { 0, 0, 0, PL_ELLIPSIS };
 
 	if (left != NILEXPR) {		/* in case of an error */
-		register struct type *tp = left->ex_type;
+		struct type *tp = left->ex_type;
 
 		while (tp && tp->tp_fund != FUNCTION && tp != error_type)
 			tp = tp->tp_up;
@@ -410,8 +405,8 @@ call_proto(expp)
 	}
 
 	if (right != NILEXPR) {		/* function call with parameters */
-		register struct expr **ep = &((*expp)->OP_RIGHT);
-		register int ecnt = 0, pcnt = 0;
+		struct expr **ep = &((*expp)->OP_RIGHT);
+		int ecnt = 0, pcnt = 0;
 		struct expr **estack[NPARAMS];
 		struct proto *pstack[NPARAMS];
 
@@ -450,7 +445,7 @@ call_proto(expp)
 			pstack[0] = &ellipsis;
 		}
 
-		for (ecnt; ecnt >= 0; ecnt--) {
+		for (; ecnt >= 0; ecnt--) {
 			/*	Only the parameters specified in the prototype
 				are checked and converted. The parameters that
 				fall under the ellipsis clause are neither

+ 19 - 0
lang/cem/cemcom.ansi/proto_loc.h

@@ -0,0 +1,19 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_PROTO_H
+#define LANG_CEM_CEMCOM_ANSI_PROTO_H
+
+/* lang/cem/cemcom.ansi/proto.c */
+void check_for_void(register struct proto *pl);
+void add_proto(struct proto *pl, struct decspecs *ds, struct declarator *dc, int lvl);
+struct tag *gettag(struct type *tp, struct idf **idpp);
+void declare_protos(register struct declarator *dc);
+void update_proto(register struct type *tp, register struct type *otp);
+void remove_proto_tag(struct type *tp);
+void remove_proto_idfs(register struct proto *pl);
+void call_proto(register struct expr **expp);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_PROTO_H */
+

+ 67 - 89
lang/cem/cemcom.ansi/replace.c

@@ -17,26 +17,28 @@
 #include	"nparams.h"
 #include	"idfsize.h"
 #include	"numsize.h"
+#include	"arith.h"
 #include	<alloc.h>
 #include	"idf.h"
+#include	"idf_loc.h"
 #include	"input.h"
 #include	"macro.h"
-#include	"arith.h"
 #include	"LLlex.h"
 #include	"class.h"
 #include	"assert.h"
 #include	"static.h"
 #include	"macbuf.h"
 #include	"replace.h"
+#include	"replace_loc.h"
+#include	"error.h"
+#include	"skip.h"
+#include	"domacro.h"
+#include	"replace_loc.h"
 
-extern struct idf *GetIdentifier();
 extern int InputLevel;
 struct repl *ReplaceList;	/* list of currently active macros */
-//extern char *strcat(), *strcpy();
 
-int
-replace(idf)
-	register struct idf *idf;
+int replace(struct idf *idf)
 {
 	/*	replace is called by the lexical analyzer to perform
 		macro replacement. The routine actualy functions as a
@@ -62,15 +64,14 @@ replace(idf)
 	return 1;
 }
 
-unstackrepl()
+void unstackrepl()
 {
 	Unstacked++;
 }
 
-freeargs(args)
-	struct args *args;
+void freeargs(struct args *args)
 {
-	register int i;
+	int i;
 
 	/* We must don't know how many parameters were specified, so be
 	 * prepared to free all NPARAMS parameters.
@@ -86,9 +87,9 @@ freeargs(args)
 	free_args(args);
 }
 
-EnableMacros()
+void EnableMacros()
 {
-	register struct repl *r = ReplaceList, *prev = 0;
+	struct repl *r = ReplaceList, *prev = 0;
 
 	ASSERT(Unstacked > 0);
 	while(r) {
@@ -108,9 +109,7 @@ EnableMacros()
 	Unstacked = 0;
 }
 
-expand_macro(repl, idf)
-	register struct repl *repl;
-	register struct idf *idf;
+int expand_macro(struct repl *repl, struct idf *idf)
 {
 	/*	expand_macro() does the actual macro replacement.
 		"idf" is a description of the identifier which
@@ -129,9 +128,9 @@ expand_macro(repl, idf)
 		on a single, unexpanded identifier, which may be surrounded
 		by parenthesis. The function expand_defined() handles this.
 	*/
-	register struct macro *mac = idf->id_macro;
+	struct macro *mac = idf->id_macro;
 	struct args *args = repl->r_args;
-	register int ch;
+	int ch;
 
 	if (mac->mc_nps != -1) {	/* with parameter list	*/
 		if (mac->mc_flag & FUNC) {
@@ -180,10 +179,9 @@ expand_macro(repl, idf)
 	return 1;
 }
 
-expand_defined(repl)
-	register struct repl *repl;
+void expand_defined(struct repl *repl)
 {
-	register int ch = GetChar();
+	int ch = GetChar();
 	struct idf *id;
 	int parens = 0;
 
@@ -212,25 +210,22 @@ expand_defined(repl)
 	add2repl(repl, ' ');
 }
 
-newarg(args)
-	struct args *args;
+void newarg(struct args *args)
 {
 	args->a_expptr = args->a_expbuf = Malloc(args->a_expsize = ARGBUF);
 	args->a_rawptr = args->a_rawbuf = Malloc(args->a_rawsize = ARGBUF);
 }
 
-getactuals(repl, idf)
-	struct repl *repl;
-	register struct idf *idf;
+void getactuals(struct repl *repl, struct idf *idf)
 {
 	/*	Get the actual parameters from the input stream.
 		The hard part is done by actual(), only comma's and
 		other syntactic trivialities are checked here.
 	*/
-	register struct args *args = repl->r_args;
-	register int nps = idf->id_macro->mc_nps;
-	register int argcnt;
-	register int ch;
+	struct args *args = repl->r_args;
+	int nps = idf->id_macro->mc_nps;
+	int argcnt;
+	int ch;
 
 	argcnt = 0;
 	newarg(args);
@@ -262,12 +257,11 @@ getactuals(repl, idf)
 		lexerror("too many macro arguments");
 }
 
-saveraw(repl)
-struct repl *repl;
+void saveraw(struct repl *repl)
 {
-	register struct repl *nrepl = ReplaceList;
-	register struct args *ap = nrepl->r_args;
-	register char *p;
+	struct repl *nrepl = ReplaceList;
+	struct args *ap = nrepl->r_args;
+	char *p;
 
 	/* stash identifier name */
 	for (p = nrepl->r_idf->id_text; *p != '\0'; p++)
@@ -288,7 +282,7 @@ struct repl *repl;
 	*/
 	if (ap->a_rawvec[0]) {
 		/* stash arguments */
-		register int i;
+		int i;
 
 		for (i = 0; ap->a_rawvec[i] != (char *)0; i++) {
 			if (i == 0) stash(repl, '(', -1);
@@ -300,16 +294,14 @@ struct repl *repl;
 	}
 }
 
-int
-actual(repl)
-	struct repl *repl;
+int actual(struct repl *repl)
 {
 	/*	This routine deals with the scanning of an actual parameter.
 		It keeps in account the opening and closing brackets,
 		preprocessor numbers, strings and character constants.
 	*/
-	register int ch = 0;
-	register int level = 0, nostashraw = 0;
+	int ch = 0;
+	int level = 0, nostashraw = 0;
 	int lastch;
 	static int Unstacked_missed;
 
@@ -335,9 +327,9 @@ actual(repl)
 				token is a macro, it is expanded first.
 			*/
 			char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 1];
-			register char *p = buf;
-			register struct idf *idef;
-			register int pos = -1;
+			char *p = buf;
+			struct idf *idef;
+			int pos = -1;
 			extern int idfsize;
 			int NoExpandMacro;
 
@@ -478,7 +470,7 @@ a_new_line:		ch = GetChar();
 			/*	Strings are considered as ONE token, thus no
 				replacement within strings.
 			*/
-			register int match = ch;
+			int match = ch;
 
 			stash(repl, ch, !nostashraw);
 			while ((ch = GetChar()) != EOI) {
@@ -507,15 +499,14 @@ a_new_line:		ch = GetChar();
 	}
 }
 
-macro_func(idef)
-	register struct idf *idef;
+void macro_func(struct idf *idef)
 {
 	/*	macro_func() performs the special actions needed with some
 		macros. These macros are __FILE__ and __LINE__ which
 		replacement texts must be evaluated at the time they are
 		used.
 	*/
-	register struct macro *mac = idef->id_macro;
+	struct macro *mac = idef->id_macro;
 	static char FilNamBuf[PATHLENGTH];
 	char *long2str();
 
@@ -537,10 +528,7 @@ macro_func(idef)
 	}
 }
 
-macro2buffer(repl, idf, args)
-	register struct repl *repl;
-	register struct idf *idf;
-	register struct args *args;
+void macro2buffer(struct repl *repl, struct idf *idf, struct args *args)
 {
 	/*	macro2buffer expands the replacement list and places the
 		result onto the replacement buffer. It deals with the #
@@ -568,15 +556,14 @@ macro2buffer(repl, idf, args)
 		linear fashion. This is VERY expensive, something
 		smarter should be done (but even a DFA is O(|s|)).
 	*/
-	register char *ptr = idf->id_macro->mc_text;
+	char *ptr = idf->id_macro->mc_text;
 	int err = 0;
 	int func = idf->id_macro->mc_nps != -1;
-	char *stringify();
 
 	ASSERT(ptr[idf->id_macro->mc_length] == '\0');
 	while (*ptr) {
 	    if (*ptr == '\'' || *ptr == '"') {
-		register int delim = *ptr;
+		int delim = *ptr;
 
 		do {
 		    add2repl(repl, *ptr);
@@ -591,14 +578,14 @@ macro2buffer(repl, idf, args)
 		add2repl(repl, *ptr++);
 	    } else if (*ptr == '#' && (func || *(ptr+1) == '#')) {
 		if (*++ptr == '#') {
-		    register int tmpindex;
+		    int tmpindex;
 			/* ## - paste operator */
 		    ptr++;
 
 			/* trim the actual replacement list */
 		    --repl->r_ptr;
 		    while (repl->r_ptr >= repl->r_text
-			    && is_wsp(*repl->r_ptr))
+			    && is_wsp(*(unsigned char *)repl->r_ptr))
 			--repl->r_ptr;
 
 		    /*	## occurred at the beginning of the replacement list.
@@ -617,25 +604,25 @@ macro2buffer(repl, idf, args)
 		    /* tmpindex can be 0 */
 
 		    /* skip space in macro replacement list */
-		    while ((*ptr & FORMALP) == 0 && is_wsp(*ptr))
+		    while ((*ptr & FORMALP) == 0 && is_wsp(*(unsigned char *)ptr))
 			    ptr++;
 
 		    /*	## occurred at the end of the replacement list.
 		     */
 		    if (*ptr & FORMALP) {
-			register int n = *ptr++ & 0177;
-			register char *p;
+			int n = *ptr++ & 0177;
+			char *p;
 
 			ASSERT(n > 0);
 			p = args->a_rawvec[n-1];
 			if (p) {	/* else macro argument missing */
-			    while (is_wsp(*p)) p++;
+			    while (is_wsp(*(unsigned char *)p)) p++;
 			    if (*p == NOEXPM) p++;
 			    while (*p)
 				add2repl(repl, *p++);
 			}
 			while (tmpindex > 0
-				&& in_idf(repl->r_text[tmpindex]))
+				&& in_idf((unsigned char)repl->r_text[tmpindex]))
 			    tmpindex--;
 			if (tmpindex >= 0
 			    && repl->r_text[tmpindex] == NOEXPM)
@@ -644,10 +631,10 @@ macro2buffer(repl, idf, args)
 			    err = 1;
 			    break;
 		    } else {
-			    if (in_idf(*ptr)) {
+			    if (in_idf(*(unsigned char *)ptr)) {
 				tmpindex--;
 				while (tmpindex > 0
-					&& in_idf(repl->r_text[tmpindex]))
+					&& in_idf((unsigned char)repl->r_text[tmpindex]))
 				    tmpindex--;
 				if (tmpindex >= 0
 				    && repl->r_text[tmpindex] == NOEXPM)
@@ -659,8 +646,8 @@ macro2buffer(repl, idf, args)
 		}
 	    } else if (*ptr & FORMALP) {
 		/* insert actual parameter */
-		register int n = *ptr++ & 0177;
-		register char *p, *q;
+		int n = *ptr++ & 0177;
+		char *p, *q;
 
 		ASSERT(n > 0);
 
@@ -669,7 +656,7 @@ macro2buffer(repl, idf, args)
 			argument buffer instead of the expanded
 			one.
 		*/
-		for (p = ptr; (*p & FORMALP) == 0 && is_wsp(*p); p++)
+		for (p = ptr; (*p & FORMALP) == 0 && is_wsp(*(unsigned char *)p); p++)
 			/* EMPTY */;
 		if (*p == '#' && p[1] == '#')
 			q = args->a_rawvec[n-1];
@@ -690,11 +677,7 @@ macro2buffer(repl, idf, args)
 		lexerror("illegal use of the ## operator");
 }
 
-char *
-stringify(repl, ptr, args)
-	register struct repl *repl;
-	register char *ptr;
-	register struct args *args;
+char *stringify(struct repl *repl, char *ptr, struct args *args)
 {
 	/*	If a parameter is immediately preceded by a # token
 		both are replaced by a single string literal that
@@ -708,23 +691,23 @@ stringify(repl, ptr, args)
 		as appropriate. We only escape backslashes if they
 		occure within string tokens.
 	*/
-	register int space = 1;		/* skip leading spaces */
-	register int delim = 0;		/* string or character constant delim */
-	register int backslash = 0;	/* last character was a \ */
+	int space = 1;		/* skip leading spaces */
+	int delim = 0;		/* string or character constant delim */
+	int backslash = 0;	/* last character was a \ */
 
 	/* skip spaces macro replacement list */
-	while ((*ptr & FORMALP) == 0 && is_wsp(*ptr))
+	while ((*ptr & FORMALP) == 0 && is_wsp(*(unsigned char *)ptr))
 		ptr++;
 
 	if (*ptr & FORMALP) {
-		register int n = *ptr++ & 0177;
-		register char *p;
+		int n = *ptr++ & 0177;
+		char *p;
 
 		ASSERT(n != 0);
 		p = args->a_rawvec[n-1];
 		add2repl(repl, '"');
 		while (*p) {
-			if (is_wsp(*p)) {
+			if (is_wsp(*(unsigned char *)p)) {
 				if (!space) {
 					space = 1;
 					add2repl(repl, ' ');
@@ -746,7 +729,7 @@ stringify(repl, ptr, args)
 		}
 
 		/* trim spaces in the replacement list */
-		for (--repl->r_ptr; is_wsp(*repl->r_ptr); repl->r_ptr--)
+		for (--repl->r_ptr; is_wsp(*(unsigned char *)repl->r_ptr); repl->r_ptr--)
 			/* EMPTY */;
 		++repl->r_ptr;		/* oops, one to far */
 		add2repl(repl, '"');
@@ -757,11 +740,9 @@ stringify(repl, ptr, args)
 
 /* The following routine is also called from domacro.c.
  */
-add2repl(repl, ch)
-	register struct repl *repl;
-	int ch;
+void add2repl(struct repl *repl, int ch)
 {
-	register int index = repl->r_ptr - repl->r_text;
+	int index = repl->r_ptr - repl->r_text;
 
 	ASSERT(index < repl->r_size);
 	if (index + 2 >= repl->r_size) {
@@ -776,15 +757,12 @@ add2repl(repl, ch)
  * buffer. If the variable is zero, we must only stash into the expanded
  * buffer. Otherwise, we must use both buffers.
  */
-stash(repl, ch, stashraw)
-	struct repl *repl;
-	register int ch;
-	int stashraw;
+void stash(struct repl *repl ,int ch, int stashraw)
 {
 	/*	Stash characters into the macro expansion buffer.
 	*/
-	register struct args *args = repl->r_args;
-	register int index = args->a_expptr - args->a_expbuf;
+	struct args *args = repl->r_args;
+	int index = args->a_expptr - args->a_expbuf;
 
 	if (stashraw >= 0) {
 		ASSERT(index < args->a_expsize);

+ 11 - 11
lang/cem/cemcom.ansi/replace.h → lang/cem/cemcom.ansi/replace_loc.h

@@ -10,20 +10,20 @@ struct repl;
 
 /* lang/cem/cemcom.ansi/replace.c */
 int replace(register struct idf *idf);
-int unstackrepl(void);
-int freeargs(struct args *args);
-int EnableMacros(void);
+void unstackrepl(void);
+void freeargs(struct args *args);
+void EnableMacros(void);
 int expand_macro(register struct repl *repl, register struct idf *idf);
-int expand_defined(register struct repl *repl);
-int newarg(struct args *args);
-int getactuals(struct repl *repl, register struct idf *idf);
-int saveraw(struct repl *repl);
+void expand_defined(register struct repl *repl);
+void newarg(struct args *args);
+void getactuals(struct repl *repl, register struct idf *idf);
+void saveraw(struct repl *repl);
 int actual(struct repl *repl);
-int macro_func(register struct idf *idef);
-int macro2buffer(register struct repl *repl, register struct idf *idf, register struct args *args);
+void macro_func(register struct idf *idef);
+void macro2buffer(register struct repl *repl, register struct idf *idf, register struct args *args);
 char *stringify(register struct repl *repl, register char *ptr, register struct args *args);
-int add2repl(register struct repl *repl, int ch);
-int stash(struct repl *repl, register int ch, int stashraw);
+void add2repl(register struct repl *repl, int ch);
+void stash(struct repl *repl, register int ch, int stashraw);
 
 #endif /* LANG_CEM_CEMCOM_ANSI_REPLACE_H */
 

+ 8 - 8
lang/cem/cemcom.ansi/skip.c

@@ -10,18 +10,18 @@
 #include	"LLlex.h"
 #include	"class.h"
 #include	"input.h"
+#include	"domacro.h"
+#include	"error.h"
 
 #ifndef NOPP
 extern int InputLevel;
 
-int
-skipspaces(ch, skipnl)
-	register int ch;
+int skipspaces(int ch, int skipnl)
 {
 	/*	skipspaces() skips any white space and returns the first
 		non-space character.
 	*/
-	register int nlseen = 0;
+	int nlseen = 0;
 
 	for (;;) {
 		while (class(ch) == STSKIP)
@@ -59,12 +59,12 @@ skipspaces(ch, skipnl)
 }
 #endif /* NOPP */
 
-SkipToNewLine()
+int SkipToNewLine()
 {
-	register int ch;
-	register int garbage = 0;
+	int ch;
+	int garbage = 0;
 #ifndef	NOPP
-	register int delim = 0;
+	int delim = 0;
 #endif
 
 	while ((ch = GetChar()) != '\n') {

+ 13 - 0
lang/cem/cemcom.ansi/skip.h

@@ -0,0 +1,13 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_SKIP_H
+#define LANG_CEM_CEMCOM_ANSI_SKIP_H
+
+/* lang/cem/cemcom.ansi/skip.c */
+int skipspaces(register int ch, int skipnl);
+int SkipToNewLine(void);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_SKIP_H */
+

+ 11 - 24
lang/cem/cemcom.ansi/stab.c

@@ -41,8 +41,7 @@ static struct db_str {
 	char		*currpos;
 } db_str;
 
-static
-create_db_str()
+static void create_db_str()
 {
 	if (! db_str.base) {
 		db_str.base = Malloc(INCR_SIZE);
@@ -51,9 +50,7 @@ create_db_str()
 	db_str.currpos = db_str.base;
 }
 
-static
-addc_db_str(c)
-	int	c;
+static void addc_db_str(int c)
 {
 	int df = db_str.currpos - db_str.base;
 	if (df >= db_str.sz-1) {
@@ -65,16 +62,12 @@ addc_db_str(c)
 	*db_str.currpos = '\0';
 }
 
-static
-adds_db_str(s)
-	char	*s;
+static void adds_db_str(char *s)
 {
 	while (*s) addc_db_str(*s++);
 }
 
-static
-stb_type(tp)
-	register struct type	*tp;
+static void stb_type(struct type *tp)
 {
 	char		buf[128];
 	static int	stb_count;
@@ -149,10 +142,10 @@ stb_type(tp)
 		}
 		addc_db_str('e');
 		{
-			register struct stack_entry *se = local_level->sl_entry;
+			struct stack_entry *se = local_level->sl_entry;
 
 			while (se) {
-				register struct def	*edef = se->se_idf->id_def;
+				struct def	*edef = se->se_idf->id_def;
 				while (edef) {
 					if (edef->df_type == tp &&
 					    edef->df_sc == ENUM) {
@@ -183,7 +176,7 @@ stb_type(tp)
 				   tp->tp_fund == STRUCT ? 's' : 'u',
 				   tp->tp_size));
 		{
-			register struct sdef	*sdef = tp->tp_sdef;
+			struct sdef	*sdef = tp->tp_sdef;
 
 			while (sdef) {
 				adds_db_str(sdef->sd_idf->id_text);
@@ -213,9 +206,7 @@ stb_type(tp)
 	}
 }
 
-stb_tag(tg, str)
-	register struct tag	*tg;
-	char			*str;
+void stb_tag(struct tag *tg, char *str)
 {
 	create_db_str();
 	adds_db_str(str);
@@ -230,9 +221,7 @@ stb_tag(tg, str)
 		     (arith) 0);
 }
 
-stb_typedef(tp, str)
-	register struct type	*tp;
-	char			*str;
+void stb_typedef(struct type *tp, char *str)
 {
 	create_db_str();
 	adds_db_str(str);
@@ -247,11 +236,9 @@ stb_typedef(tp, str)
 		     (arith) 0);
 }
 
-stb_string(df, kind, str)
-	register struct def	*df;
-	char			*str;
+void stb_string(struct def *df, int kind, char *str)
 {
-	register struct type	*tp = df->df_type;
+	struct type	*tp = df->df_type;
 
 	create_db_str();
 	adds_db_str(str);

+ 14 - 0
lang/cem/cemcom.ansi/stab.h

@@ -0,0 +1,14 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_STAB_H
+#define LANG_CEM_CEMCOM_ANSI_STAB_H
+
+/* lang/cem/cemcom.ansi/stab.c */
+void stb_tag(register struct tag *tg, char *str);
+void stb_typedef(register struct type *tp, char *str);
+void stb_string(register struct def *df, int kind, char *str);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_STAB_H */
+

+ 26 - 23
lang/cem/cemcom.ansi/stack.c

@@ -18,13 +18,19 @@
 #include	"Lpars.h"
 #include	"arith.h"
 #include	"stack.h"
+#include	"stack_loc.h"
 #include	"type.h"
 #include	"idf.h"
+#include	"idf_loc.h"
 #include	"def.h"
 #include	"struct.h"
 #include	"level.h"
 #include	"mes.h"
 #include	"code_c.h"
+#include	"error.h"
+#include	"label.h"
+#include	"util_loc.h"
+
 /* #include	<em_reg.h> */
 
 extern char options[];
@@ -43,11 +49,12 @@ struct stack_level *local_level = &UniversalLevel;
 
 int level;	/* Always equal to local_level->sl_level. */
 
-stack_level()	{
+void stack_level()
+{
 	/*	A new level is added on top of the identifier stack.
 	*/
-	register struct stack_level *stl = new_stack_level();
-	register struct stack_level *loclev = local_level;
+	struct stack_level *stl = new_stack_level();
+	struct stack_level *loclev = local_level;
 	
 	loclev->sl_next = stl;
 	stl->sl_previous = loclev;
@@ -59,14 +66,12 @@ stack_level()	{
 #endif	/* LINT */
 }
 
-stack_idf(idf, stl)
-	struct idf *idf;
-	register struct stack_level *stl;
+void stack_idf(struct idf *idf, struct stack_level *stl)
 {
 	/*	The identifier idf is inserted in the stack on level stl,
 		but only if it is not already present at this level.
 	*/
-	register struct stack_entry *se;
+	struct stack_entry *se;
 	
 	se = stl->sl_entry;
 	while (se) {
@@ -82,14 +87,13 @@ stack_idf(idf, stl)
 	stl->sl_entry = se;
 }
 
-struct stack_level *
-stack_level_of(lvl)
+struct stack_level *stack_level_of(int lvl)
 {
 	/*	The stack_level corresponding to level lvl is returned.
 		The stack should probably be an array, to be extended with
 		realloc where needed.
 	*/
-	register struct stack_level *stl;
+	struct stack_level *stl;
 
 	if (lvl == level)
 		return local_level;
@@ -101,7 +105,7 @@ stack_level_of(lvl)
 	return stl;
 }
 
-unstack_level()
+void unstack_level()
 {
 	/*	The top level of the identifier stack is removed.
 	*/
@@ -120,11 +124,11 @@ unstack_level()
 		necessary. Optimists may optimize it afterwards.
 	*/
 	while (local_level->sl_entry)	{
-		register struct stack_entry *se = local_level->sl_entry;
-		register struct idf *idf = se->se_idf;
-		register struct def *def;
-		register struct sdef *sdef;
-		register struct tag *tag;
+		struct stack_entry *se = local_level->sl_entry;
+		struct idf *idf = se->se_idf;
+		struct def *def;
+		struct sdef *sdef;
+		struct tag *tag;
 
 		/* unlink it from the local stack level */
 		local_level->sl_entry = se->next;
@@ -175,7 +179,7 @@ unstack_level()
 #endif	/* DEBUG */
 }
 
-unstack_world()
+void unstack_world()
 {
 	/*	The global level of identifiers is scanned, and final
 		decisions are taken about such issues as
@@ -184,7 +188,7 @@ unstack_world()
 		have already been encoded while the uninitialised ones
 		are not and have to be encoded at this moment.
 	*/
-	register struct stack_entry *se = local_level->sl_entry;
+	struct stack_entry *se = local_level->sl_entry;
 
 #ifdef	LINT
 	lint_end_global(local_level);
@@ -195,8 +199,8 @@ unstack_world()
 #endif /* GEN_NM_LIST */
 
 	while (se)	{
-		register struct idf *idf = se->se_idf;
-		register struct def *def = idf->id_def;
+		struct idf *idf = se->se_idf;
+		struct def *def = idf->id_def;
 		
 		if (!def)	{
 			/* global selectors, etc. */
@@ -264,14 +268,13 @@ unstack_world()
 extern char *nmlist;	/* BAH! -- main.c	*/
 static File *nfp = 0;
 
-open_name_list()
+void open_name_list()
 {
 	if (nmlist && sys_open(nmlist, OP_WRITE, &nfp) == 0)
 		fatal("cannot create namelist %s", nmlist);
 }
 
-namelist(nm)
-	char *nm;
+void namelist(char *nm)
 {
 	if (nmlist)	{
 		sys_write(nfp, nm, strlen(nm));

+ 4 - 0
lang/cem/cemcom.ansi/stack.str

@@ -4,6 +4,8 @@
  */
 /* $Id$ */
 /* IDENTIFIER STACK DEFINITIONS */
+#ifndef LANG_CEM_CEMCOM_ANSI_STACK_STR
+#define LANG_CEM_CEMCOM_ANSI_STACK_STR
 
 /*	The identifier stack is implemented as a stack of sets.
 	The stack is implemented by a doubly linked list,
@@ -32,3 +34,5 @@ struct stack_entry	{
 extern struct stack_level *local_level;
 extern struct stack_level *stack_level_of();
 extern int level;
+
+#endif /* LANG_CEM_CEMCOM_ANSI_STACK_STR */

+ 16 - 0
lang/cem/cemcom.ansi/stack_loc.h

@@ -0,0 +1,16 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_STACK_H
+#define LANG_CEM_CEMCOM_ANSI_STACK_H
+
+/* lang/cem/cemcom.ansi/stack.c */
+void stack_level(void);
+void stack_idf(struct idf *idf, struct stack_level *stl);
+struct stack_level *stack_level_of(int lvl);
+void unstack_level(void);
+void unstack_world(void);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_STACK_H */
+

+ 7 - 1
lang/cem/cemcom.ansi/statement.g

@@ -22,13 +22,19 @@
 #include	"arith.h"
 #include	"LLlex.h"
 #include	"type.h"
+#include	"type_loc.h"
 #include	"idf.h"
+#include	"idf_loc.h"
 #include	"label.h"
 #include	"expr.h"
+#include	"expr_loc.h"
 #include	"code.h"
 #include	"stack.h"
+#include	"stack_loc.h"
 #include	"def.h"
-#include "code_c.h"
+#include	"code_c.h"
+#include	"switch_loc.h"
+
 #ifdef DBSYMTAB
 #include	<stb.h>
 #endif /* DBSYMTAB */

+ 44 - 52
lang/cem/cemcom.ansi/struct.c

@@ -11,11 +11,14 @@
 #include	<alloc.h>
 #include	"arith.h"
 #include	"stack.h"
+#include	"stack_loc.h"
 #include	"idf.h"
+#include	"idf_loc.h"
 #include	"def.h"
 #include	"type.h"
 #include	"proto.h"
 #include	"struct.h"
+#include	"struct_loc.h"
 #include	"field.h"
 #include	"LLlex.h"
 #include	"Lpars.h"
@@ -23,6 +26,10 @@
 #include	"level.h"
 #include	"assert.h"
 #include	"sizes.h"
+#include	"error.h"
+#include	"ch3.h"
+
+#include	<symbol2str.h>
 
 /*	Type of previous selector declared with a field width specified,
 	if any.  If a selector is declared with no field with it is set to 0.
@@ -30,8 +37,6 @@
 static field_busy = 0;
 
 extern char options[];
-char *symbol2str();
-int lcm();
 
 /*	The semantics of the identification of structure/union tags is
 	obscure.  Some highly regarded compilers are found out to accept,
@@ -53,14 +58,16 @@ int lcm();
 	If below struct is mentioned, union is implied (and sometimes enum
 	as well).
 */
-
-add_sel(stp, tp, idf, sdefpp, szp, fd)	/* this is horrible */
-	register struct type *stp;	/* type of the structure */
-	struct type *tp;		/* type of the selector */
-	register struct idf *idf;	/* idf of the selector */
-	struct sdef ***sdefpp;	/* address of hook to selector definition */
-	arith *szp;		/* pointer to struct size upto here */
+/*
+	struct type *stp;			 type of the structure
+	struct type *tp;			 type of the selector
+	struct idf *idf;			 idf of the selector
+	struct sdef ***sdefpp;		 address of hook to selector definition
+	arith *szp;					 pointer to struct size upto here
 	struct field *fd;
+ */
+void add_sel(struct type *stp, struct type *tp, struct idf *idf,
+			 struct sdef ***sdefpp, arith *szp, struct field *fd) /* this is horrible */
 {
 	/*	The selector idf with type tp is added to two chains: the
 		selector identification chain starting at idf->id_sdef,
@@ -75,7 +82,7 @@ add_sel(stp, tp, idf, sdefpp, szp, fd)	/* this is horrible */
 
 	struct tag *tg = stp->tp_idf->id_tag;	/* or union */
 	struct sdef *sdef = idf->id_sdef;
-	register struct sdef *newsdef;
+	struct sdef *newsdef;
 	int lvl = tg->tg_level;
 	
 	if (stp->tp_fund == STRUCT)	{
@@ -149,15 +156,13 @@ add_sel(stp, tp, idf, sdefpp, szp, fd)	/* this is horrible */
 		stp->tp_align = lcm(stp->tp_align, tp->tp_align);
 	}
 }
-
-check_selector(idf, stp)
-	register struct idf *idf;
-	struct type *stp;	/* the type of the struct */
+/* stp: the type of the struct */
+void check_selector(struct idf *idf, struct type *stp)
 {
 	/*	checks if idf occurs already as a selector in
 		struct or union *stp.
 	*/
-	register struct sdef *sdef = stp->tp_sdef;
+	struct sdef *sdef = stp->tp_sdef;
 	
 	while (sdef)	{
 		if (sdef->sd_idf == idf)
@@ -166,9 +171,7 @@ check_selector(idf, stp)
 	}
 }
 
-declare_struct(fund, idf, tpp)
-	register struct idf *idf;
-	struct type **tpp;
+void declare_struct(int fund, struct idf *idf, struct type **tpp)
 {
 	/*	A struct, union or enum (depending on fund) with tag (!)
 		idf is declared, and its type (incomplete as it may be) is
@@ -176,8 +179,8 @@ declare_struct(fund, idf, tpp)
 		The idf may be missing (i.e. idf == 0), in which case an
 		anonymous struct etc. is defined.
 	*/
-	register struct tag **tgp;
-	register struct tag *tg;
+	struct tag **tgp;
+	struct tag *tg;
 
 
 	if (*tpp) error("multiple types in declaration");
@@ -235,16 +238,14 @@ declare_struct(fund, idf, tpp)
 	}
 }
 
-apply_struct(fund, idf, tpp)
-	register struct idf *idf;
-	struct type **tpp;
+void apply_struct(int fund, struct idf *idf, struct type **tpp)
 {
 	/*	The occurrence of a struct, union or enum (depending on
 		fund) with tag idf is noted. It may or may not have been
 		declared before. Its type (complete or incomplete) is
 		returned in *tpp.
 	*/
-	register struct tag **tgp;
+	struct tag **tgp;
 
 	tgp = &idf->id_tag;
 
@@ -261,10 +262,7 @@ apply_struct(fund, idf, tpp)
 		declare_struct(fund, idf, tpp);
 }
 
-struct sdef *
-idf2sdef(idf, tp)
-	register struct idf *idf;
-	struct type *tp;
+struct sdef *idf2sdef(struct idf *idf, struct type *tp)
 {
 	/*	The identifier idf is identified as a selector
 		in the struct tp.
@@ -273,17 +271,17 @@ idf2sdef(idf, tp)
 		If this fails too, a selector of type error_type is
 		created.
 	*/
-	register struct sdef **sdefp = &idf->id_sdef, *sdef;
+	struct sdef **sdefp = &idf->id_sdef, *sdef;
 	
 	/* Follow chain from idf, to meet tp. */
-	while ((sdef = *sdefp))	{
+	while ( (sdef = *sdefp) )	{
 		if (equal_type(sdef->sd_stype, tp, -999, 0))	/* ??? hack */
 			return sdef;
 		sdefp = &(*sdefp)->next;
 	}
 	
 	/* Tp not met; take an identification. */
-	if (sdef = idf->id_sdef)	{
+	if ( (sdef = idf->id_sdef) )	{
 		/* There is an identification */
 		error("illegal use of selector %s", idf->id_text);
 		return sdef;
@@ -299,9 +297,7 @@ idf2sdef(idf, tp)
 }
 
 #if	0
-int
-uniq_selector(idf_sdef)
-	register struct sdef *idf_sdef;
+int uniq_selector(struct sdef *idf_sdef)
 {
 	/*	Returns true if idf_sdef (which is guaranteed to exist)
 		is unique for this level, i.e there is no other selector
@@ -311,7 +307,7 @@ uniq_selector(idf_sdef)
 		case!
 	*/
 	
-	register struct sdef *sdef = idf_sdef->next;
+	struct sdef *sdef = idf_sdef->next;
 	
 	while (sdef && sdef->sd_level == idf_sdef->sd_level)	{
 		if (	sdef->sd_type != idf_sdef->sd_type
@@ -326,13 +322,15 @@ uniq_selector(idf_sdef)
 #endif
 
 #ifndef NOBITFIELD
-arith
-add_field(szp, fd, fdtpp, idf, stp)
-	arith *szp;			/* size of struct upto here	*/
-	register struct field *fd;	/* bitfield, containing width	*/
-	register struct type **fdtpp;	/* type of selector		*/
-	struct idf *idf;		/* name of selector		*/
-	register struct type *stp;	/* current struct descriptor	*/
+
+/*
+	arith *szp;				 size of struct upto here
+	struct field *fd;		 bitfield, containing width
+	struct type **fdtpp;	 type of selector
+	struct idf *idf;		 name of selector
+	struct type *stp;		 current struct descripton
+ */
+arith add_field(arith *szp, struct field *fd, struct type **fdtpp, struct idf *idf, struct type *stp)
 {
 	/*	The address where this selector is put is returned. If the
 		selector with specified width does not fit in the word, or
@@ -441,20 +439,16 @@ add_field(szp, fd, fdtpp, idf, stp)
 #endif /* NOBITFIELD */
 
 /* some utilities */
-int
-is_struct_or_union(fund)
-	register int fund;
+int is_struct_or_union(int fund)
 {
 	return fund == STRUCT || fund == UNION;
 }
 
 /*	Greatest Common Divisor
  */
-int
-gcd(m, n)
-	register int m, n;
+int gcd(int m, int n)
 {
-	register int r;
+	int r;
 
 	while (n)	{
 		r = m % n;
@@ -466,9 +460,7 @@ gcd(m, n)
 
 /*	Least Common Multiple
  */
-int
-lcm(m, n)
-	register int m, n;
+int lcm(int m, int n)
 {
 	return m * (n / gcd(m, n));
 }

+ 6 - 6
lang/cem/cemcom.ansi/struct_loc.h

@@ -6,12 +6,12 @@
 #define LANG_CEM_CEMCOM_ANSI_STRUCT_H
 
 /* lang/cem/cemcom.ansi/struct.c */
-int add_sel(register struct type *stp, struct type *tp, register struct idf *idf, struct sdef ***sdefpp, arith *szp, struct field *fd);
-int check_selector(register struct idf *idf, struct type *stp);
-int declare_struct(int fund, register struct idf *idf, struct type **tpp);
-int apply_struct(int fund, register struct idf *idf, struct type **tpp);
-struct sdef *idf2sdef(register struct idf *idf, struct type *tp);
-arith add_field(arith *szp, register struct field *fd, register struct type **fdtpp, struct idf *idf, register struct type *stp);
+void add_sel(struct type *stp, struct type *tp, struct idf *idf, struct sdef ***sdefpp, arith *szp, struct field *fd);
+void check_selector(struct idf *idf, struct type *stp);
+void declare_struct(int fund, struct idf *idf, struct type **tpp);
+void apply_struct(int fund, struct idf *idf, struct type **tpp);
+struct sdef *idf2sdef(struct idf *idf, struct type *tp);
+arith add_field(arith *szp, struct field *fd, struct type **fdtpp, struct idf *idf, struct type *stp);
 int is_struct_or_union(register int fund);
 int gcd(register int m, register int n);
 int lcm(register int m, register int n);

+ 22 - 23
lang/cem/cemcom.ansi/switch.c

@@ -27,13 +27,16 @@
 #include	"type.h"
 #include	"sizes.h"
 #include	"code_c.h"
+#include	"eval.h"
+#include	"ch3.h"
+#include	<system.h>
+#include	"print.h"
 
 extern char options[];
 
 int	density = DENSITY;
 
-compact(nr, low, up)
-	arith low, up;
+int compact(int nr, arith low, arith up)
 {
 	/*	Careful! up - low might not fit in an arith. And then,
 		the test "up-low < 0" might also not work to detect this
@@ -53,15 +56,14 @@ static struct switch_hdr *switch_stack = 0;
 	For simplicity, we suppose int_size == word_size.
 */
 
-code_startswitch(expp)
-	struct expr **expp;
+void code_startswitch(struct expr **expp)
 {
 	/*	Check the expression, stack a new case header and
 		fill in the necessary fields.
 	*/
-	register label l_table = text_label();
-	register label l_break = text_label();
-	register struct switch_hdr *sh = new_switch_hdr();
+	label l_table = text_label();
+	label l_break = text_label();
+	struct switch_hdr *sh = new_switch_hdr();
 	int fund = any2arith(expp, SWITCH);
 				    /* INT, LONG, FLOAT, DOUBLE or LNGDBL */
 	
@@ -89,13 +91,11 @@ code_startswitch(expp)
 	C_bra(l_table);			/* goto start of switch_table	*/
 }
 
-extern char *long2str();
-
-code_endswitch()
+void code_endswitch()
 {
-	register struct switch_hdr *sh = switch_stack;
-	register label tablabel;
-	register struct case_entry *ce;
+	struct switch_hdr *sh = switch_stack;
+	label tablabel;
+	struct case_entry *ce;
 	arith size = sh->sh_type->tp_size;
 
 	if (sh->sh_default == 0)	/* no default occurred yet */
@@ -121,7 +121,7 @@ code_endswitch()
 	    C_rom_ilb(sh->sh_default);
 	    if (compact(sh->sh_nrofentries, sh->sh_lowerbd, sh->sh_upperbd)) {
 		/* CSA */
-		register arith val;
+		arith val;
 
 		C_rom_icon(long2str((long)sh->sh_lowerbd,10), size);
 		C_rom_icon(long2str((long)(sh->sh_upperbd - sh->sh_lowerbd),10),
@@ -155,7 +155,7 @@ code_endswitch()
 
 	switch_stack = sh->next;	/* unstack the switch descriptor */
 	for (ce = sh->sh_entries; ce;) { /* free allocated switch structure */
-		register struct case_entry *tmp = ce->next;
+		struct case_entry *tmp = ce->next;
 
 		free_case_entry(ce);
 		ce = tmp;
@@ -164,12 +164,11 @@ code_endswitch()
 	unstack_stmt();
 }
 
-code_case(expr)
-	struct expr *expr;
+void code_case(struct expr *expr)
 {
-	register arith val;
-	register struct case_entry *ce;
-	register struct switch_hdr *sh = switch_stack;
+	arith val;
+	struct case_entry *ce;
+	struct switch_hdr *sh = switch_stack;
 	
 	ASSERT(is_cp_cst(expr));
 	if (sh == 0) {
@@ -189,7 +188,7 @@ code_case(expr)
 		sh->sh_nrofentries = 1;
 	}
 	else { /* second etc. case entry; put ce into proper place */
-		register struct case_entry *c1 = sh->sh_entries, *c2 = 0;
+		struct case_entry *c1 = sh->sh_entries, *c2 = 0;
 		
 		if (val < sh->sh_lowerbd)
 			sh->sh_lowerbd = val;
@@ -232,9 +231,9 @@ code_case(expr)
 	}
 }
 
-code_default()
+void code_default()
 {
-	register struct switch_hdr *sh = switch_stack;
+	struct switch_hdr *sh = switch_stack;
 
 	if (sh == 0) {
 		error("default statement not in switch");

+ 16 - 0
lang/cem/cemcom.ansi/switch_loc.h

@@ -0,0 +1,16 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_SWITCH_H
+#define LANG_CEM_CEMCOM_ANSI_SWITCH_H
+
+/* lang/cem/cemcom.ansi/switch.c */
+int compact(int nr, arith low, arith up);
+void code_startswitch(struct expr **expp);
+void code_endswitch(void);
+void code_case(struct expr *expr);
+void code_default(void);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_SWITCH_H */
+

+ 2 - 2
lang/cem/cemcom.ansi/tokenname.c

@@ -10,6 +10,7 @@
 #include	"LLlex.h"
 #include	"tokenname.h"
 #include	"Lpars.h"
+#include	"error.h"
 
 /*	To centralize the declaration of %tokens, their presence in this
 	file is taken as their declaration. The Makefile will produce
@@ -131,8 +132,7 @@ struct tokenname tkfunny[] =	{	/* internal keywords */
 };
 #endif	/* ____ */
 
-reserve(resv)
-	register struct tokenname resv[];
+void reserve(struct tokenname resv[])
 {
 	/*	The names of the tokens described in resv are entered
 		as reserved words.

+ 6 - 0
lang/cem/cemcom.ansi/tokenname.h

@@ -4,6 +4,8 @@
  */
 /* $Id$ */
 /* TOKENNAME DEFINITION */
+#ifndef LANG_CEM_CEMCOM_ANSI_TOCKENNAME_H
+#define LANG_CEM_CEMCOM_ANSI_TOCKENNAME_H
 
 struct tokenname	{	/*	Used for defining the name of a
 					token as identified by its symbol
@@ -11,3 +13,7 @@ struct tokenname	{	/*	Used for defining the name of a
 	int tn_symbol;
 	char *tn_name;
 };
+
+void reserve(struct tokenname resv[]);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_TOCKENNAME_H */

+ 42 - 67
lang/cem/cemcom.ansi/type.c

@@ -9,6 +9,8 @@
 #include	"debug.h"
 #include	"botch_free.h"
 #include	<alloc.h>
+#include	"arith.h"
+#include	"util.h"
 #include	"Lpars.h"
 #include	"arith.h"
 #include	"type.h"
@@ -18,11 +20,7 @@
 #include	"sizes.h"
 #include	"align.h"
 #include	"decspecs.h"
-
-extern struct type *function_of(), *array_of();
-#ifndef NOBITFIELD
-extern struct type *field_of();
-#endif /* NOBITFIELD */
+#include	"error.h"
 
 /*	To be created dynamically in main() from defaults or from command
 	line parameters.
@@ -39,14 +37,12 @@ struct type
 
 struct type *pa_type;	/* Pointer-Arithmetic type	*/
 
-struct type *
-create_type(fund)
-	int fund;
+struct type *create_type(int fund)
 {
 	/*	A brand new struct type is created, and its tp_fund set
 		to fund.
 	*/
-	register struct type *ntp = new_type();
+	struct type *ntp = new_type();
 
 	ntp->tp_fund = fund;
 	ntp->tp_size = (arith)-1;
@@ -54,30 +50,34 @@ create_type(fund)
 	return ntp;
 }
 
-struct type *
-promoted_type(tp)
-struct type *tp;
+struct type *promoted_type(struct type *tp)
 {
-	if (tp->tp_fund == CHAR || tp->tp_fund == SHORT) {
+	if (tp->tp_fund == CHAR || tp->tp_fund == SHORT)
+	{
 		if (tp->tp_unsigned && (int) tp->tp_size == (int) int_size)
+		{
 			return uint_type;
-		else return int_type;
-	} else if (tp->tp_fund == FLOAT)
+		}
+		else
+		{
+			return int_type;
+		}
+	}
+	else if (tp->tp_fund == FLOAT)
+	{
 		return double_type;
-	else return tp;
+	}
+	return tp;
 }
 
-struct type *
-construct_type(fund, tp, qual, count, pl)
-	register struct type *tp;
-	register struct proto *pl;
-	arith count; /* for fund == ARRAY only */
-	int qual;
+
+/* count: for fund == ARRAY only */
+struct type *construct_type(int fund, struct type *tp, int qual, arith count, struct proto *pl)
 {
 	/*	fund must be a type constructor: FIELD, FUNCTION, POINTER or
 		ARRAY. The pointer to the constructed type is returned.
 	*/
-	register struct type *dtp;
+	struct type *dtp;
 
 	switch (fund)	{
 #ifndef NOBITFIELD
@@ -115,17 +115,13 @@ construct_type(fund, tp, qual, count, pl)
 	return dtp;
 }
 
-struct type *
-function_of(tp, pl, qual)
-	register struct type *tp;
-	struct proto *pl;
-	int qual;
+struct type *function_of(struct type *tp, struct proto *pl, int qual)
 {
 #if 0
 /* See comment below */
-	register struct type *dtp = tp->tp_function;
+	struct type *dtp = tp->tp_function;
 #else
-	register struct type *dtp;
+	struct type *dtp;
 #endif
 
 	/* look for a type with the right qualifier */
@@ -161,12 +157,9 @@ function_of(tp, pl, qual)
 	return dtp;
 }
 
-struct type *
-pointer_to(tp, qual)
-	register struct type *tp;
-	int qual;
+struct type *pointer_to(struct type *tp, int qual)
 {
-	register struct type *dtp = tp->tp_pointer;
+	struct type *dtp = tp->tp_pointer;
 
 	/* look for a type with the right qualifier */
 	while (dtp && dtp->tp_typequal != qual)
@@ -185,13 +178,9 @@ pointer_to(tp, qual)
 	return dtp;
 }
 
-struct type *
-array_of(tp, count, qual)
-	register struct type *tp;
-	arith count;
-	int qual;
+struct type *array_of(struct type *tp, arith count, int qual)
 {
-	register struct type *dtp = tp->tp_array;
+	struct type *dtp = tp->tp_array;
 
 	/* look for a type with the right size */
 	while (dtp && (dtp->tp_nel != count || dtp->tp_typequal != qual))
@@ -214,12 +203,9 @@ array_of(tp, count, qual)
 }
 
 #ifndef NOBITFIELD
-struct type *
-field_of(tp, qual)
-	register struct type *tp;
-	int qual;
+struct type *field_of(struct type *tp, int qual)
 {
-	register struct type *dtp = create_type(FIELD);
+	struct type *dtp = create_type(FIELD);
 
 	dtp->tp_up = tp;
 	dtp->tp_align = tp->tp_align;
@@ -229,10 +215,7 @@ field_of(tp, qual)
 }
 #endif /* NOBITFIELD */
 
-arith
-size_of_type(tp, nm)
-	struct type *tp;
-	char nm[];
+arith size_of_type(struct type *tp, char nm[])
 {
 	arith sz = tp->tp_size;
 
@@ -243,16 +226,14 @@ size_of_type(tp, nm)
 	return sz;
 }
 
-idf2type(idf, tpp)
-	struct idf *idf;
-	struct type **tpp;
+void idf2type(struct idf *idf, struct type **tpp)
 {
 	/*	Decoding  a typedef-ed identifier or basic type: if the
 		size is yet unknown we have to make copy of the type
 		descriptor to prevent garbage at the initialisation of
 		arrays with unknown size.
 	*/
-	register struct type *tp = idf->id_def->df_type;
+	struct type *tp = idf->id_def->df_type;
 
 	if (*tpp) error("multiple types in declaration");
 	if (	tp->tp_size < (arith)0 && tp->tp_fund == ARRAY)	{
@@ -265,19 +246,14 @@ idf2type(idf, tpp)
 	}
 }
 
-arith
-align(pos, al)
-	arith pos;
-	int al;
+arith align(arith pos, int al)
 {
 	return ((pos + al - 1) / al) * al;
 }
 
-struct type *
-standard_type(fund, sgn, algn, sz)
-	int algn; arith sz;
+struct type *standard_type(int fund, int sgn, int algn, arith sz)
 {
-	register struct type *tp = create_type(fund);
+	struct type *tp = create_type(fund);
 
 	tp->tp_unsigned = sgn != 0;
 	tp->tp_align = algn;
@@ -286,17 +262,16 @@ standard_type(fund, sgn, algn, sz)
 	return tp;
 }
 
-completed(tp)
-	struct type *tp;
+void completed(struct type *tp)
 {
-	register struct type *atp = tp->tp_array;
-	register struct type *etp = tp;
+	struct type *atp = tp->tp_array;
+	struct type *etp = tp;
 
 	switch(etp->tp_fund) {
 	case STRUCT:
 	case UNION:
 	case ENUM:
-		while (etp = etp->next) {
+		while ( (etp = etp->next) ) {
 			if (! etp->tp_sdef) etp->tp_sdef = tp->tp_sdef;
 			etp->tp_size = tp->tp_size;
 			etp->tp_align = tp->tp_align;

+ 23 - 0
lang/cem/cemcom.ansi/type_loc.h

@@ -0,0 +1,23 @@
+/*
+ * The Amsterdam Compiler Kit
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef LANG_CEM_CEMCOM_ANSI_TYPE_H
+#define LANG_CEM_CEMCOM_ANSI_TYPE_H
+
+/* lang/cem/cemcom.ansi/type.c */
+struct type *create_type(int fund);
+struct type *promoted_type(struct type *tp);
+struct type *construct_type(int fund, struct type *tp, int qual, arith count, struct proto *pl);
+struct type *function_of(struct type *tp, struct proto *pl, int qual);
+struct type *pointer_to(struct type *tp, int qual);
+struct type *array_of(struct type *tp, arith count, int qual);
+struct type *field_of(struct type *tp, int qual);
+arith size_of_type(struct type *tp, char nm[]);
+void idf2type(struct idf *idf, struct type **tpp);
+arith align(arith pos, int al);
+struct type *standard_type(int fund, int sgn, int algn, arith sz);
+void completed(struct type *tp);
+
+#endif /* LANG_CEM_CEMCOM_ANSI_TYPE_H */
+

+ 21 - 31
lang/cem/cemcom.ansi/util.c

@@ -24,6 +24,7 @@
 
 #include	"debug.h"
 #include	"util.h"
+#include	"util_loc.h"
 #include	"use_tmp.h"
 #include	"regcount.h"
 #include	"sizes.h"
@@ -44,18 +45,16 @@ static int	loc_id;
 
 extern char options[];
 
-LocalInit()
+void LocalInit()
 {
 #ifdef USE_TMP
 	C_insertpart(loc_id = C_getid());
 #endif /* USE_TMP */
 }
 
-arith
-LocalSpace(sz, al)
-	arith sz;
+arith LocalSpace(arith sz, int al)
 {
-	register struct stack_level *stl = local_level;
+	struct stack_level *stl = local_level;
 
 	stl->sl_max_block = - align(sz - stl->sl_max_block, al);
 	return stl->sl_max_block;
@@ -64,11 +63,9 @@ LocalSpace(sz, al)
 #define TABSIZ 32
 static struct localvar *regs[TABSIZ];
 
-arith
-NewLocal(sz, al, regtype, sc)
-	arith sz;
+arith NewLocal(arith sz, int al, int regtype, int sc)
 {
-	register struct localvar *tmp = FreeTmps;
+	struct localvar *tmp = FreeTmps;
 	struct localvar *prev = 0;
 	int index;
 
@@ -101,11 +98,10 @@ NewLocal(sz, al, regtype, sc)
 	return tmp->t_offset;
 }
 
-FreeLocal(off)
-	arith off;
+void FreeLocal(arith off)
 {
 	int index = (int) (off >> 2) & (TABSIZ - 1);
-	register struct localvar *tmp = regs[index];
+	struct localvar *tmp = regs[index];
 	struct localvar *prev = 0;
 
 	while (tmp && tmp->t_offset != off) {
@@ -120,10 +116,10 @@ FreeLocal(off)
 	}
 }
 
-LocalFinish()
+void LocalFinish()
 {
-	register struct localvar *tmp, *tmp1;
-	register int i;
+	struct localvar *tmp, *tmp1;
+	int i;
 
 #ifdef USE_TMP
 	C_beginpart(loc_id);
@@ -166,10 +162,9 @@ LocalFinish()
 #endif
 }
 
-RegisterAccount(offset, size, regtype, sc)
-	arith offset, size;
+void RegisterAccount(arith offset, arith size, int regtype, int sc)
 {
-	register struct localvar *p;
+	struct localvar *p;
 	int index;
 
 	if (regtype < 0) return;
@@ -185,20 +180,17 @@ RegisterAccount(offset, size, regtype, sc)
 	regs[index] = p;
 }
 
-static struct localvar *
-find_reg(off)
-	arith off;
+static struct localvar *find_reg(arith off)
 {
-	register struct localvar *p = regs[(int)(off >> 2) & (TABSIZ - 1)];
+	struct localvar *p = regs[(int)(off >> 2) & (TABSIZ - 1)];
 
 	while (p && p->t_offset != off) p = p->next;
 	return p;
 }
 
-LoadLocal(off, sz)
-	arith off, sz;
+void LoadLocal(arith off, arith sz)
 {
-	register struct localvar *p = find_reg(off);
+	struct localvar *p = find_reg(off);
 
 #ifdef USE_TMP
 #ifdef REGCOUNT
@@ -215,10 +207,9 @@ LoadLocal(off, sz)
 	}
 }
 
-StoreLocal(off, sz)
-	arith off, sz;
+void StoreLocal(arith off, arith sz)
 {
-	register struct localvar *p = find_reg(off);
+	struct localvar *p = find_reg(off);
 
 #ifdef USE_TMP
 #ifdef REGCOUNT
@@ -236,10 +227,9 @@ StoreLocal(off, sz)
 }
 
 #ifndef	LINT
-AddrLocal(off)
-	arith off;
+void AddrLocal(arith off)
 {
-	register struct localvar *p = find_reg(off);
+	struct localvar *p = find_reg(off);
 
 	if (p) p->t_regtype = -1;
 	C_lal(off);

+ 7 - 7
lang/cem/cemcom.ansi/util.h → lang/cem/cemcom.ansi/util_loc.h

@@ -6,15 +6,15 @@
 #define LANG_CEM_CEMCOM_ANSI_UTIL_H
 
 /* lang/cem/cemcom.ansi/util.c */
-int LocalInit(void);
+void LocalInit(void);
 arith LocalSpace(arith sz, int al);
 arith NewLocal(arith sz, int al, int regtype, int sc);
-int FreeLocal(arith off);
-int LocalFinish(void);
-int RegisterAccount(arith offset, arith size, int regtype, int sc);
-int LoadLocal(arith off, arith sz);
-int StoreLocal(arith off, arith sz);
-int AddrLocal(arith off);
+void FreeLocal(arith off);
+void LocalFinish(void);
+void RegisterAccount(arith offset, arith size, int regtype, int sc);
+void LoadLocal(arith off, arith sz);
+void StoreLocal(arith off, arith sz);
+void AddrLocal(arith off);
 
 #endif /* LANG_CEM_CEMCOM_ANSI_UTIL_H */
 

+ 37 - 36
lang/cem/cpp.ansi/replace.c

@@ -11,6 +11,7 @@
 
 #include	"pathlength.h"
 #include	"strsize.h"
+#include	<system.h>
 #include	"nparams.h"
 #include	"idfsize.h"
 #include	"numsize.h"
@@ -25,6 +26,7 @@
 #include	"assert.h"
 #include	"macbuf.h"
 #include	"replace.h"
+#include	"print.h"
 
 extern int InputLevel;
 struct repl *ReplaceList;	/* list of currently active macros */
@@ -70,7 +72,7 @@ void unstackrepl()
 
 void freeargs(struct args *args)
 {
-	register int i;
+	int i;
 
 	/* We must don't know how many parameters were specified, so be
 	 * prepared to free all NPARAMS parameters.
@@ -88,7 +90,7 @@ void freeargs(struct args *args)
 
 void EnableMacros()
 {
-	register struct repl *r = ReplaceList, *prev = 0;
+	struct repl *r = ReplaceList, *prev = 0;
 
 	assert(Unstacked > 0);
 	while(r) {
@@ -127,9 +129,9 @@ int expand_macro(struct repl *repl, struct idf *idf)
 		on a single, unexpanded identifier, which may be surrounded
 		by parenthesis. The function expand_defined() handles this.
 	*/
-	register struct macro *mac = idf->id_macro;
+	struct macro *mac = idf->id_macro;
 	struct args *args = repl->r_args;
-	register int ch;
+	int ch;
 
 	if (mac->mc_nps != -1) {	/* with parameter list	*/
 		if (mac->mc_flag & FUNC) {
@@ -173,7 +175,7 @@ int expand_macro(struct repl *repl, struct idf *idf)
 
 void expand_defined(struct repl *repl)
 {
-	register int ch = GetChar();
+	int ch = GetChar();
 	struct idf *id;
 	char *str;
 	int parens = 0;
@@ -218,10 +220,10 @@ void getactuals(struct repl *repl, struct idf *idf)
 		The hard part is done by actual(), only comma's and
 		other syntactic trivialities are checked here.
 	*/
-	register struct args *args = repl->r_args;
-	register int nps = idf->id_macro->mc_nps;
-	register int argcnt;
-	register int ch;
+	struct args *args = repl->r_args;
+	int nps = idf->id_macro->mc_nps;
+	int argcnt;
+	int ch;
 
 	argcnt = 0;
 	newarg(args);
@@ -255,9 +257,9 @@ void getactuals(struct repl *repl, struct idf *idf)
 
 void saveraw(struct repl *repl)
 {
-	register struct repl *nrepl = ReplaceList;
-	register struct args *ap = nrepl->r_args;
-	register char *p;
+	struct repl *nrepl = ReplaceList;
+	struct args *ap = nrepl->r_args;
+	char *p;
 
 	/* stash identifier name */
 	for (p = nrepl->r_idf->id_text; *p != '\0'; p++)
@@ -278,7 +280,7 @@ void saveraw(struct repl *repl)
 	*/
 	if (ap->a_rawvec[0]) {
 		/* stash arguments */
-		register int i;
+		int i;
 
 		for (i = 0; ap->a_rawvec[i] != (char *)0; i++) {
 			if (i == 0) stash(repl, '(', -1);
@@ -296,8 +298,8 @@ int actual(struct repl *repl)
 		It keeps in account the opening and closing brackets,
 		preprocessor numbers, strings and character constants.
 	*/
-	register int ch = 0;
-	register int level = 0, nostashraw = 0;
+	int ch = 0;
+	int level = 0, nostashraw = 0;
 	int lastch;
 	static int Unstacked_missed;
 
@@ -323,9 +325,9 @@ int actual(struct repl *repl)
 				token is a macro, it is expanded first.
 			*/
 			char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 1];
-			register char *p = buf;
-			register struct idf *idef;
-			register int pos = -1;
+			char *p = buf;
+			struct idf *idef;
+			int pos = -1;
 			extern int idfsize;
 			int NoExpandMacro;
 
@@ -462,7 +464,7 @@ a_new_line:		ch = GetChar();
 			/*	Strings are considered as ONE token, thus no
 				replacement within strings.
 			*/
-			register int match = ch;
+			int match = ch;
 
 			stash(repl, ch, !nostashraw);
 			while ((ch = GetChar()) != EOI) {
@@ -498,9 +500,8 @@ void macro_func(struct idf *idef)
 		replacement texts must be evaluated at the time they are
 		used.
 	*/
-	register struct macro *mac = idef->id_macro;
+	struct macro *mac = idef->id_macro;
 	static char FilNamBuf[PATHLENGTH];
-	char *long2str();
 
 	switch (idef->id_text[2]) {
 	case 'F':			/* __FILE__	*/
@@ -548,7 +549,7 @@ void macro2buffer(struct repl *repl, struct idf *idf, struct args *args)
 		linear fashion. This is VERY expensive, something
 		smarter should be done (but even a DFA is O(|s|)).
 	*/
-	register char *ptr = idf->id_macro->mc_text;
+	char *ptr = idf->id_macro->mc_text;
 	int err = 0;
 	int func = idf->id_macro->mc_nps != -1;
 	char *stringify();
@@ -556,7 +557,7 @@ void macro2buffer(struct repl *repl, struct idf *idf, struct args *args)
 	assert(ptr[idf->id_macro->mc_length] == '\0');
 	while (*ptr) {
 	    if (*ptr == '\'' || *ptr == '"') {
-		register int delim = *ptr;
+		int delim = *ptr;
 
 		do {
 		    add2repl(repl, *ptr);
@@ -571,7 +572,7 @@ void macro2buffer(struct repl *repl, struct idf *idf, struct args *args)
 		add2repl(repl, *ptr++);
 	    } else if (*ptr == '#' && (func || *(ptr+1) == '#')) {
 		if (*++ptr == '#') {
-		    register int tmpindex;
+		    int tmpindex;
 			/* ## - paste operator */
 		    ptr++;
 
@@ -603,8 +604,8 @@ void macro2buffer(struct repl *repl, struct idf *idf, struct args *args)
 		    /*	## occurred at the end of the replacement list.
 		    */
 		    if (*ptr & FORMALP) {
-			register int n = *ptr++ & 0177;
-			register char *p;
+			int n = *ptr++ & 0177;
+			char *p;
 
 			assert(n > 0);
 			p = args->a_rawvec[n-1];
@@ -639,8 +640,8 @@ void macro2buffer(struct repl *repl, struct idf *idf, struct args *args)
 		}
 	    } else if (*ptr & FORMALP) {
 		/* insert actual parameter */
-		register int n = *ptr++ & 0177;
-		register char *p, *q;
+		int n = *ptr++ & 0177;
+		char *p, *q;
 
 		assert(n > 0);
 
@@ -684,17 +685,17 @@ char *stringify(struct repl *repl, char *ptr, struct args *args)
 		as appropriate. We only escape backslashes if they
 		occure within string tokens.
 	*/
-	register int space = 1;		/* skip leading spaces */
-	register int delim = 0;		/* string or character constant delim */
-	register int backslash = 0;	/* last character was a \ */
+	int space = 1;		/* skip leading spaces */
+	int delim = 0;		/* string or character constant delim */
+	int backslash = 0;	/* last character was a \ */
 
 	/* skip spaces macro replacement list */
 	while ((*ptr & FORMALP) == 0 && is_wsp(*(unsigned char *)ptr))
 		ptr++;
 
 	if (*ptr & FORMALP) {
-		register int n = *ptr++ & 0177;
-		register char *p;
+		int n = *ptr++ & 0177;
+		char *p;
 
 		assert(n != 0);
 		p = args->a_rawvec[n-1];
@@ -735,7 +736,7 @@ char *stringify(struct repl *repl, char *ptr, struct args *args)
  */
 void add2repl(struct repl *repl, int ch)
 {
-	register int index = repl->r_ptr - repl->r_text;
+	int index = repl->r_ptr - repl->r_text;
  
 	assert(index < repl->r_size);
 	if (index + 2 >= repl->r_size) {
@@ -754,8 +755,8 @@ void stash(struct repl *repl, int ch, int stashraw)
 {
 	/* Stash characters into the macro expansion buffer.
 	 */
-	register struct args *args = repl->r_args;
-	register int index = args->a_expptr - args->a_expbuf;
+	struct args *args = repl->r_args;
+	int index = args->a_expptr - args->a_expbuf;
  
 	if (stashraw >= 0) {
 		assert(index < args->a_expsize);