Added prototyping stuff

This commit is contained in:
ceriel 1993-11-10 12:09:49 +00:00
parent 62f978c40f
commit 103cbb4319
37 changed files with 205 additions and 94 deletions

View file

@ -5,7 +5,7 @@
/* $Header$ */
#include <system.h>
#include <varargs.h>
#include "print.h"
#include "param.h"
/*FORMAT1 $
@ -15,7 +15,7 @@
%[uxbo] = unsigned int
%d = int
$ */
/*VARARGS2*/
void
doprnt(fp, fmt, argp)
File *fp;
char *fmt;

View file

@ -4,7 +4,8 @@
*/
/* $Header$ */
#include <varargs.h>
#include <system.h>
#include "print.h"
extern char *long2str();
@ -33,7 +34,6 @@ integral(c)
%[uxbo] = unsigned int
%d = int
$ */
/*VARARGS2*/
int
_format(buf, fmt, argp)
char *buf, *fmt;

View file

@ -4,8 +4,8 @@
*/
/* $Header$ */
#include <varargs.h>
#include <system.h>
#include "print.h"
#include "param.h"
/*FORMAT1v $
@ -16,18 +16,28 @@
%d = int
$ */
/*VARARGS*/
fprint(va_alist)
void
fprint
#if __STDC__
(File *fp, char *fmt, ...)
{
#else
(va_alist)
va_dcl
{
File *fp;
char *fmt;
#endif
va_list args;
char buf[SSIZE];
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
fp = va_arg(args, File *);
fmt = va_arg(args, char *);
#endif
sys_write(fp, buf, _format(buf, fmt, args));
va_end(args);
}

View file

@ -5,19 +5,19 @@ print, fprint, sprint, doprnt -- very simple formatted-output routines
.SH SYNOPSIS
.nf
.B #include <system.h>
.B #include <varargs.h>
.B #include <print.h>
.PP
.B print(format [, arg] ... )
.B void print(format [, arg] ... )
.B char *format;
.PP
.B fprint(filep, format [, arg] ... )
.B void fprint(filep, format [, arg] ... )
.B File *filep;
.B char *format;
.PP
.B char *sprint(s, format [, arg] ... )
.B char *s, *format;
.PP
.B doprnt(filep, format, args)
.B void doprnt(filep, format, args)
.B File *filep;
.B char *format;
.B va_list args;
@ -106,29 +106,6 @@ length of the string.
takes
.I args
as the address of the arguments of the format string.
This allows routines, e.g.
.IR print ,
to be defined as follows:
.br
.RS
.nf
#include <varargs.h>
#include <system.h>
/*VARARGS*/
print(va_alist)
va_dcl
{
char *fmt;
va_list args;
va_start(args);
fmt = va_arg(args, char *);
doprnt(STDOUT, fmt, args);
va_end(args);
}
.fi
.RE
.SH FILES
.nf
~em/modules/lib/libprint.a

View file

@ -4,8 +4,8 @@
*/
/* $Header$ */
#include <varargs.h>
#include <system.h>
#include "print.h"
#include "param.h"
/*FORMAT0v $
@ -16,15 +16,26 @@
%d = int
$ */
/*VARARGS*/
print(va_alist)
void
print
#if __STDC__
(char *fmt, ...)
{
#else
(va_alist)
va_dcl
{
char *fmt;
#endif
va_list args;
char buf[SSIZE];
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
fmt = va_arg(args, char *);
#endif
sys_write(STDOUT, buf, _format(buf, fmt, args));
va_end(args);
}

View file

@ -4,12 +4,20 @@
*/
/* $Header$ */
#define stdin STDIN
#define stdout STDOUT
#define stderr STDERR
#ifndef __PRINT_INCLUDED__
#define __PRINT_INCLUDED__
#define printf print
#define sprintf sprint
#define fprintf fprint
#include <ansi.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#define FILE File
_PROTOTYPE(void print, (char *fmt, ...));
_PROTOTYPE(void fprint, (File *f, char *fmt, ...));
_PROTOTYPE(void doprnt, (File *f, char *fmt, va_list ap));
_PROTOTYPE(int _format, (char *buf, char *fmt, va_list ap));
_PROTOTYPE(char *sprint, (char *buf, char *fmt, ...));
#endif /* __PRINT_INCLUDED__ */

View file

@ -21,16 +21,18 @@ $(LIBPRINT): $(OBJ)
$(RANLIB) $(LIBPRINT)
install: all
-mkdir $(MOD_DIR)/lib
-mkdir $(MOD_DIR)/h
cp $(LIBPRINT) $(MOD_DIR)/lib/$(LIBPRINT)
$(RANLIB) $(MOD_DIR)/lib/$(LIBPRINT)
cp $(SRC_DIR)/print.3 $(MOD_DIR)/man/print.3
cp $(SRC_DIR)/print.h $(MOD_DIR)/h/print.h
if [ $(DO_MACHINE_INDEP) = y ] ; \
then mk_manpage $(SRC_DIR)/print.3 $(TARGET_HOME) ; \
fi
cmp: all
-cmp $(LIBPRINT) $(MOD_DIR)/lib/$(LIBPRINT)
-cmp $(SRC_DIR)/print.3 $(MOD_DIR)/man/print.3
-cmp $(SRC_DIR)/print.h $(MOD_DIR)/h/print.h
pr:
@pr $(SRC_DIR)/proto.make $(SRC)

View file

@ -4,8 +4,8 @@
*/
/* $Header$ */
#include <varargs.h>
#include <system.h>
#include "print.h"
#include "param.h"
/*FORMAT1v $
@ -17,15 +17,25 @@
$ */
/*VARARGS*/
char *
sprint(va_alist)
sprint
#if __STDC__
(char *buf, char *fmt, ...)
{
#else
(va_alist)
va_dcl
{
char *buf, *fmt;
#endif
va_list args;
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
buf = va_arg(args, char *);
fmt = va_arg(args, char *);
#endif
buf[_format(buf, fmt, args)] = '\0';
va_end(args);
return buf;

View file

@ -6,6 +6,8 @@
#ifndef __EMCOMP_INCLUDED__
#define __EMCOMP_INCLUDED__
#include <ansi.h>
struct e_arg {
int ema_argtype; /* type of this argument */
union e_simple_arg {
@ -44,6 +46,11 @@ struct e_instr {
struct e_arg em_arg;
};
_PROTOTYPE(int EM_open, (char *));
_PROTOTYPE(void EM_close, (void));
_PROTOTYPE(int EM_getinstr, (struct e_instr *));
_PROTOTYPE(int EM_mkcalls, (struct e_instr *));
extern arith
EM_holsize;
#define EM_bsssize EM_holsize

View file

@ -31,7 +31,7 @@ static int listtype = 0; /* indicates pseudo when generating code for
The argument must be of a type allowed by "typset".
Return a pointer to the next argument.
*/
PRIVATE
PRIVATE int
checkarg(arg, typset)
register struct e_arg *arg;
{
@ -58,7 +58,7 @@ checkarg(arg, typset)
/* EM_doinstr: An EM instruction
*/
PRIVATE
PRIVATE void
EM_doinstr(p)
register struct e_instr *p;
{
@ -94,7 +94,7 @@ EM_doinstr(p)
#include "C_mnem"
}
PRIVATE
PRIVATE void
EM_dopseudo(p)
register struct e_instr *p;
{
@ -326,7 +326,7 @@ EM_dopseudo(p)
}
}
PRIVATE
PRIVATE void
EM_docon(p)
register struct e_instr *p;
{
@ -365,7 +365,7 @@ EM_docon(p)
}
}
PRIVATE
PRIVATE void
EM_dostartmes(p)
register struct e_instr *p;
{

View file

@ -6,7 +6,7 @@ SRC_DIR = $(SRC_HOME)/modules/src/read_em
MOD_DIR = $(TARGET_HOME)/modules
EM_TABLE = $(SRC_HOME)/etc/em_table
INCLUDES = -I$(TARGET_HOME)/h -I$(MOD_DIR)/h -I$(SRC_DIR) -I.
DEFINES = -DPRIVATE=static -DEXPORT=
DEFINES = -DPRIVATE=static -DEXPORT= -DNDEBUG
CFLAGS = $(INCLUDES) $(DEFINES) $(COPTIONS)
TARGETS = libread_emk.$(LIBSUF) \
@ -35,8 +35,9 @@ K_OFILES = read_emk.$(SUF) makecalls.$(SUF) EM_vars.$(SUF)
all: $(TARGETS)
install: all
-mkdir $(MOD_DIR)/lib
-mkdir $(MOD_DIR)/h
cp $(SRC_DIR)/em_comp.h $(MOD_DIR)/h/em_comp.h
cp $(SRC_DIR)/read_em.3 $(MOD_DIR)/man/read_em.3
cp libread_emk.$(LIBSUF) $(MOD_DIR)/lib/libread_emk.$(LIBSUF)
$(RANLIB) $(MOD_DIR)/lib/libread_emk.$(LIBSUF)
cp libread_emkV.$(LIBSUF) $(MOD_DIR)/lib/libread_emkV.$(LIBSUF)
@ -52,7 +53,6 @@ cmp: all
-cmp libread_emk.$(LIBSUF) $(MOD_DIR)/lib/libread_emk.$(LIBSUF)
-cmp libread_emkV.$(LIBSUF) $(MOD_DIR)/lib/libread_emkV.$(LIBSUF)
-cmp libread_emeV.$(LIBSUF) $(MOD_DIR)/lib/libread_emeV.$(LIBSUF)
-cmp $(SRC_DIR)/read_em.3 $(MOD_DIR)/man/read_em.3
pr:
@pr $(SRC_DIR)/proto.make $(SRC_DIR)/m_C_mnem $(SRC_DIR)/m_C_mnem_na $(SRC_DIR)/argtype $(SRCFILES)

View file

@ -20,10 +20,10 @@ EM_mkcalls\ \-\ a module to read EM assembly code
.PP
.B int EM_open(filename)
.br
.B EM_close()
.br
.B char *filename;
.PP
.B void EM_close()
.PP
.B int EM_getinstr(instr)
.B struct e_instr *instr;
.PP

View file

@ -99,7 +99,7 @@ static char *argrange = "Argument range error";
/* Error handling
*/
PRIVATE
PRIVATE void
xerror(s)
char *s;
{
@ -108,7 +108,7 @@ xerror(s)
}
#ifdef COMPACT
PRIVATE
PRIVATE void
xfatal(s)
char *s;
{
@ -157,7 +157,7 @@ EM_open(filename)
/* EM_close: Close input file
*/
EXPORT
EXPORT void
EM_close()
{
@ -175,7 +175,7 @@ EM_close()
again, but also to deliver the arguments on next calls to EM_getinstr.
This is indicated by the variable "argp".
*/
PRIVATE
PRIVATE void
startmes(p)
register struct e_instr *p;
{

View file

@ -43,7 +43,7 @@ hash(s)
return h;
}
PRIVATE
PRIVATE void
pre_hash(i, s)
char *s;
{
@ -66,7 +66,7 @@ pre_hash(i, s)
extern char em_mnem[][4];
extern char em_pseu[][4];
PRIVATE
PRIVATE void
inithash()
{
register int i;
@ -103,7 +103,7 @@ nospace()
/* syntax: Put an error message in EM_error and skip to the end of the line
*/
PRIVATE
PRIVATE void
syntax(s)
char *s;
{
@ -117,7 +117,7 @@ syntax(s)
/* checkeol: check that we have a complete line (except maybe for spaces)
*/
PRIVATE
PRIVATE void
checkeol()
{
@ -251,7 +251,7 @@ getstring()
return s;
}
PRIVATE gettyp();
PRIVATE void gettyp();
PRIVATE int
offsetted(argtyp, ap)
@ -446,7 +446,7 @@ get15u()
return (int) (dummy.ema_cst);
}
PRIVATE
PRIVATE void
gettyp(typset, ap)
register struct e_arg *ap;
{
@ -520,10 +520,9 @@ gettyp(typset, ap)
if (argtyp == sp_cend) {
ap->ema_argtype = 0;
}
return;
}
PRIVATE
PRIVATE void
getarg(typset, ap)
struct e_arg *ap;
{
@ -533,19 +532,19 @@ getarg(typset, ap)
if ((c = nospace()) != ',') {
if (c != '\n') {
syntax("comma expected");
return 0;
return;
}
ungetbyte(c);
}
}
argnum++;
return gettyp(typset, ap);
gettyp(typset, ap);
}
/* getmnem: We found the start of either an instruction or a pseudo.
get the rest of it
*/
PRIVATE
PRIVATE void
getmnem(c, p)
register struct e_instr *p;
{
@ -587,7 +586,7 @@ getmnem(c, p)
}
}
PRIVATE
PRIVATE void
line_line()
{
static char filebuf[256 + 1];
@ -601,7 +600,7 @@ line_line()
EM_filename = filebuf;
}
PRIVATE
PRIVATE void
getlabel(c, p)
register struct e_instr *p;
{
@ -624,7 +623,7 @@ getlabel(c, p)
checkeol();
}
PRIVATE
PRIVATE void
gethead(p)
register struct e_instr *p;
{

View file

@ -41,7 +41,7 @@ PRIVATE struct string *getstring();
/* getarg : read an argument of any type, and check it against "typset"
if neccesary. Put result in "ap".
*/
PRIVATE
PRIVATE void
getarg(typset, ap)
register struct e_arg *ap;
{
@ -259,7 +259,7 @@ getstring(isident)
/* gethead: read the start of an EM-line
*/
PRIVATE
PRIVATE void
gethead(p)
register struct e_instr *p;
{

View file

@ -18,3 +18,4 @@ strncmp.c
strncpy.c
strrindex.c
strzero.c
ack_string.h

View file

@ -0,0 +1,31 @@
/*
* (c) copyright 1993 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* RCS: $Header: */
#ifndef __ACK_STRING_INCLUDED__
#define __ACK_STRING_INCLUDED__
#include <ansi.h>
_PROTOTYPE(char *strcpy, (char *s1, const char *s2));
_PROTOTYPE(char *strncpy, (char *s1, const char *s2, size_t n));
_PROTOTYPE(char *strcat, (char *s1, const char *s2));
_PROTOTYPE(char *strncat, (char *s1, const char *s2, size_t n));
_PROTOTYPE(int strcmp, (const char *s1, const char *s2));
_PROTOTYPE(int strncmp, (const char *s1, const char *s2, size_t n));
_PROTOTYPE(_SIZET strlen, (const char *s));
_PROTOTYPE(char *strindex, (char *s, int c));
_PROTOTYPE(char *strrindex, (char *s, int c));
_PROTOTYPE(char *strzero, (char *s));
_PROTOTYPE(char *str2bts, (char *s, char *b, int *n));
_PROTOTYPE(char *long2str, (long l, int b));
_PROTOTYPE(long str2long, (char *s, int b));
_PROTOTYPE(char *btscpy, (char *s1, char *s2, int n));
_PROTOTYPE(char *btscat, (char *s1, int n1, char *s2, int n2));
_PROTOTYPE(int btscmp, (char *s1, int n1, char *s2, int n2));
_PROTOTYPE(char *btszero, (char *b, int n));
_PROTOTYPE(char *bts2str, (char *b, int n, char *s));
#endif /* __ACK_STRING_INCLUDED__ */

View file

@ -8,6 +8,8 @@
86/03/17 EHB
*/
#include "ack_string.h"
#define is_print(c) ((unsigned)((c) - ' ') <= '~' - ' ')
char *

View file

@ -6,6 +6,8 @@
/* btscat()
*/
#include "ack_string.h"
char *
btscat(b1, n1, b2, n2)
char *b1;

View file

@ -6,6 +6,8 @@
/* btscmp()
*/
#include "ack_string.h"
int
btscmp(b1, n1, b2, n2)
register char *b1, *b2;

View file

@ -6,6 +6,8 @@
/* btscpy()
*/
#include "ack_string.h"
char *
btscpy(b1, b2, n)
register char *b1, *b2;

View file

@ -6,6 +6,8 @@
/* btszero()
*/
#include "ack_string.h"
char *
btszero(b, n)
char *b;

View file

@ -10,6 +10,8 @@
(1985, EHB)
*/
#include "ack_string.h"
#define MAXWIDTH 32
char *

View file

@ -18,7 +18,7 @@ OBJ = bts2str.$(SUF) btscat.$(SUF) btscmp.$(SUF) btscpy.$(SUF) \
strlen.$(SUF) strncat.$(SUF) strncmp.$(SUF) strncpy.$(SUF) \
strrindex.$(SUF) strzero.$(SUF)
INCLUDES = -I$(SRC_DIR)
INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h
CFLAGS = $(COPTIONS) $(INCLUDES)
LIBSTRING = libstring.$(LIBSUF)
@ -30,16 +30,18 @@ $(LIBSTRING): $(OBJ)
$(RANLIB) $(LIBSTRING)
install: all
-mkdir $(MOD_DIR)/lib
-mkdir $(MOD_DIR)/h
cp $(LIBSTRING) $(MOD_DIR)/lib/$(LIBSTRING)
$(RANLIB) $(MOD_DIR)/lib/$(LIBSTRING)
cp $(SRC_DIR)/string.3 $(MOD_DIR)/man/string.3
cp $(SRC_DIR)/ack_string.h $(MOD_DIR)/h/ack_string.h
if [ $(DO_MACHINE_INDEP) = y ] ; \
then mk_manpage $(SRC_DIR)/string.3 $(TARGET_HOME) ; \
fi
cmp: all
-cmp $(LIBSTRING) $(MOD_DIR)/lib/$(LIBSTRING)
-cmp $(SRC_DIR)/string.3 $(MOD_DIR)/man/string.3
-cmp $(SRC_DIR)/ack_string.h $(MOD_DIR)/h/ack_string.h
pr:
@pr $(SRC_DIR)/proto.make $(SRC)

View file

@ -5,6 +5,9 @@
*/
/* str2bts -- (1985, EHB)
*/
#include "ack_string.h"
static
is_oct(c)
char c;

View file

@ -6,6 +6,8 @@
/* str2long()
*/
#include "ack_string.h"
value(c, b)
char c;
int b;

View file

@ -5,9 +5,13 @@
*/
/* append t to s
*/
#include "ack_string.h"
char *
strcat(s, t)
register char *s, *t;
register char *s;
register _CONST char *t;
{
register char *b = s;

View file

@ -6,9 +6,12 @@
/* return negative, zero or positive value if
resp. s < t, s == t or s > t
*/
#include "ack_string.h"
int
strcmp(s, t)
register char *s, *t;
register _CONST char *s, *t;
{
while (*s == *t++)
if (*s++ == '\0')

View file

@ -5,9 +5,13 @@
*/
/* Copy t into s
*/
#include "ack_string.h"
char *
strcpy(s, t)
register char *s, *t;
register char *s;
register _CONST char *t;
{
register char *b = s;

View file

@ -6,9 +6,12 @@
/* strindex() -- (86/03/18 EHB)
*/
#include "ack_string.h"
char *
strindex(s, c)
register char *s, c;
register char *s;
int c;
{
while (*s)
if (*s++ == c)

View file

@ -8,6 +8,8 @@ btscpy, btscat, btscmp, btszero, bts2str \- operations on and
conversions between strings and row of bytes
.SH SYNOPSIS
.nf
.B #include <ack_string.h>
.PP
.B char *strcpy(s1, s2)
.B char *s1, *s2;
.PP

View file

@ -5,11 +5,14 @@
*/
/* return length of s
*/
int
#include "ack_string.h"
_SIZET
strlen(s)
char *s;
_CONST char *s;
{
register char *b = s;
register _CONST char *b = s;
while (*b++)
;

View file

@ -5,10 +5,14 @@
*/
/* append t to s, upto n characters
*/
#include "ack_string.h"
char *
strncat(s, t, n)
register char *s, *t;
register int n;
register char *s;
register _CONST char *t;
register _SIZET n;
{
register char *b = s;

View file

@ -6,10 +6,13 @@
/* return negative, zero or positive value if
resp. s < t, s == t or s > t; compare at most n characters
*/
#include "ack_string.h"
int
strncmp(s, t, n)
register char *s, *t;
register int n;
register _CONST char *s, *t;
register _SIZET n;
{
while (n-- > 0) {
if (*s == *t++) {

View file

@ -5,10 +5,14 @@
*/
/* Copy t into s, upto n characters
*/
#include "ack_string.h"
char *
strncpy(s, t, n)
register char *s, *t;
register int n;
register char *s;
register _CONST char *t;
register _SIZET n;
{
register char *b = s;

View file

@ -3,9 +3,13 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include "ack_string.h"
char *
strrindex(str, chr)
register char *str, chr;
register char *str;
int chr;
{
register char *retptr = 0;

View file

@ -6,6 +6,8 @@
/* strzero()
*/
#include "ack_string.h"
char *
strzero(s)
char *s;