/* $Header$ */
#include <system.h>
-#include <varargs.h>
+#include "print.h"
#include "param.h"
/*FORMAT1 $
%[uxbo] = unsigned int
%d = int
$ */
-/*VARARGS2*/
+void
doprnt(fp, fmt, argp)
File *fp;
char *fmt;
*/
/* $Header$ */
-#include <varargs.h>
+#include <system.h>
+#include "print.h"
extern char *long2str();
%[uxbo] = unsigned int
%d = int
$ */
-/*VARARGS2*/
int
_format(buf, fmt, argp)
char *buf, *fmt;
*/
/* $Header$ */
-#include <varargs.h>
#include <system.h>
+#include "print.h"
#include "param.h"
/*FORMAT1v $
%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);
}
.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;
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
*/
/* $Header$ */
-#include <varargs.h>
#include <system.h>
+#include "print.h"
#include "param.h"
/*FORMAT0v $
%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);
}
*/
/* $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__ */
$(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)
*/
/* $Header$ */
-#include <varargs.h>
#include <system.h>
+#include "print.h"
#include "param.h"
/*FORMAT1v $
$ */
/*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;
#ifndef __EMCOMP_INCLUDED__
#define __EMCOMP_INCLUDED__
+#include <ansi.h>
+
struct e_arg {
int ema_argtype; /* type of this argument */
union e_simple_arg {
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
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;
{
/* EM_doinstr: An EM instruction
*/
-PRIVATE
+PRIVATE void
EM_doinstr(p)
register struct e_instr *p;
{
#include "C_mnem"
}
-PRIVATE
+PRIVATE void
EM_dopseudo(p)
register struct e_instr *p;
{
}
}
-PRIVATE
+PRIVATE void
EM_docon(p)
register struct e_instr *p;
{
}
}
-PRIVATE
+PRIVATE void
EM_dostartmes(p)
register struct e_instr *p;
{
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) \
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)
-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)
.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
/* Error handling
*/
-PRIVATE
+PRIVATE void
xerror(s)
char *s;
{
}
#ifdef COMPACT
-PRIVATE
+PRIVATE void
xfatal(s)
char *s;
{
/* EM_close: Close input file
*/
-EXPORT
+EXPORT void
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;
{
return h;
}
-PRIVATE
+PRIVATE void
pre_hash(i, s)
char *s;
{
extern char em_mnem[][4];
extern char em_pseu[][4];
-PRIVATE
+PRIVATE void
inithash()
{
register int i;
/* syntax: Put an error message in EM_error and skip to the end of the line
*/
-PRIVATE
+PRIVATE void
syntax(s)
char *s;
{
/* checkeol: check that we have a complete line (except maybe for spaces)
*/
-PRIVATE
+PRIVATE void
checkeol()
{
return s;
}
-PRIVATE gettyp();
+PRIVATE void gettyp();
PRIVATE int
offsetted(argtyp, ap)
return (int) (dummy.ema_cst);
}
-PRIVATE
+PRIVATE void
gettyp(typset, ap)
register struct e_arg *ap;
{
if (argtyp == sp_cend) {
ap->ema_argtype = 0;
}
- return;
}
-PRIVATE
+PRIVATE void
getarg(typset, ap)
struct e_arg *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;
{
}
}
-PRIVATE
+PRIVATE void
line_line()
{
static char filebuf[256 + 1];
EM_filename = filebuf;
}
-PRIVATE
+PRIVATE void
getlabel(c, p)
register struct e_instr *p;
{
checkeol();
}
-PRIVATE
+PRIVATE void
gethead(p)
register struct e_instr *p;
{
/* 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;
{
/* gethead: read the start of an EM-line
*/
-PRIVATE
+PRIVATE void
gethead(p)
register struct e_instr *p;
{
strncpy.c
strrindex.c
strzero.c
+ack_string.h
--- /dev/null
+/*
+ * (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__ */
86/03/17 EHB
*/
+#include "ack_string.h"
+
#define is_print(c) ((unsigned)((c) - ' ') <= '~' - ' ')
char *
/* btscat()
*/
+#include "ack_string.h"
+
char *
btscat(b1, n1, b2, n2)
char *b1;
/* btscmp()
*/
+#include "ack_string.h"
+
int
btscmp(b1, n1, b2, n2)
register char *b1, *b2;
/* btscpy()
*/
+#include "ack_string.h"
+
char *
btscpy(b1, b2, n)
register char *b1, *b2;
/* btszero()
*/
+#include "ack_string.h"
+
char *
btszero(b, n)
char *b;
(1985, EHB)
*/
+#include "ack_string.h"
+
#define MAXWIDTH 32
char *
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)
$(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)
*/
/* str2bts -- (1985, EHB)
*/
+
+#include "ack_string.h"
+
static
is_oct(c)
char c;
/* str2long()
*/
+#include "ack_string.h"
+
value(c, b)
char c;
int b;
*/
/* 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;
/* 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')
*/
/* 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;
/* 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)
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
*/
/* 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++)
;
*/
/* 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;
/* 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++) {
*/
/* 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;
* (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;
/* strzero()
*/
+#include "ack_string.h"
+
char *
strzero(s)
char *s;