decspecs.str
def.str
domacro.c
+doprnt.c
dumpidf.c
error.c
eval.c
stb.c
storage.c
storage.h
-string.c
-string.h
struct.c
struct.str
switch.c
# Libraries
SYSLIB = /user1/erikb/em/lib/libsystem.a
EMLIB = /user1/erikb/em/lib/libemk.a
+STRLIB = /user1/erikb/em/lib/libstr.a
EMMESLIB = /user1/erikb/em/lib/libem_mes.a
-LIBS = $(EMMESLIB) $(EMLIB) $(SYSLIB)
+LIBS = $(EMMESLIB) $(EMLIB) $(STRLIB) $(SYSLIB)
LIB_INCLUDES = /user1/erikb/em/h
# Where to install the compiler and its driver
input.o domacro.o replace.o init.o options.o \
scan.o skip.o stack.o type.o ch7mon.o label.o eval.o \
switch.o storage.o ival.o conversion.o \
- blocks.o dataflow.o string.o
+ blocks.o dataflow.o doprnt.o
# Objects of other generated C files
GOBJ = char.o symbol2str.o next.o
maxincl.h myalloc.h nobitfield.h nopp.h \
nparams.h numsize.h parbufsize.h pathlength.h predefine.h \
strsize.h target_sizes.h textsize.h use_tmp.h \
- str_params.h spec_arith.h
+ ssize.h spec_arith.h
# Other generated files, for 'make clean' only
GENERATED = tab tokenfile.g Lpars.h LLfiles LL.output lint.out \
make LLfiles
make main
-cem: cem.c string.o
- $(CC) -O cem.c string.o $(SYSLIB) -o cem
+cem: cem.c
+ $(CC) -O cem.c $(SYSLIB) -o cem
-lint.cem: cem.c string.c
+lint.cem: cem.c
lint -abx cem.c
hfiles: Parameters
alloc.o: alloc.h assert.h debug.h myalloc.h
code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h type.h use_tmp.h
dumpidf.o: Lpars.h arith.h debug.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h struct.h type.h
-error.o: LLlex.h arith.h debug.h errout.h expr.h label.h nopp.h spec_arith.h string.h tokenname.h use_tmp.h
+error.o: LLlex.h arith.h debug.h errout.h expr.h label.h nopp.h spec_arith.h tokenname.h use_tmp.h
field.o: Lpars.h arith.h assert.h code.h debug.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h type.h
tokenname.o: LLlex.h Lpars.h arith.h idf.h nopp.h spec_arith.h tokenname.h
LLlex.o: LLlex.h Lpars.h alloc.h arith.h assert.h class.h debug.h def.h idf.h idfsize.h input.h nopp.h numsize.h sizes.h spec_arith.h strsize.h
LLmessage.o: LLlex.h Lpars.h alloc.h arith.h idf.h nopp.h spec_arith.h
input.o: LLlex.h alloc.h arith.h assert.h debug.h idepth.h input.h inputtype.h interface.h nopp.h pathlength.h spec_arith.h
domacro.o: LLlex.h Lpars.h alloc.h arith.h assert.h botch_free.h class.h debug.h idf.h idfsize.h ifdepth.h input.h interface.h macro.h nopp.h nparams.h parbufsize.h spec_arith.h storage.h textsize.h
-replace.o: LLlex.h alloc.h arith.h assert.h class.h debug.h idf.h input.h interface.h macro.h nopp.h pathlength.h spec_arith.h string.h strsize.h
-init.o: alloc.h class.h idf.h interface.h macro.h nopp.h predefine.h string.h
+replace.o: LLlex.h alloc.h arith.h assert.h class.h debug.h idf.h input.h interface.h macro.h nopp.h pathlength.h spec_arith.h strsize.h
+init.o: alloc.h class.h idf.h interface.h macro.h nopp.h predefine.h
options.o: align.h arith.h class.h idf.h idfsize.h macro.h maxincl.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h
scan.o: class.h idf.h input.h interface.h lapbuf.h macro.h nopp.h nparams.h
skip.o: LLlex.h arith.h class.h input.h interface.h nopp.h spec_arith.h
type.o: Lpars.h align.h alloc.h arith.h def.h idf.h nobitfield.h nopp.h sizes.h spec_arith.h type.h
ch7mon.o: Lpars.h arith.h botch_free.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h type.h
label.o: Lpars.h arith.h def.h idf.h label.h level.h nobitfield.h nopp.h spec_arith.h type.h
-eval.o: Lpars.h align.h arith.h assert.h atw.h code.h dataflow.h debug.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h stack.h string.h type.h
+eval.o: Lpars.h align.h arith.h assert.h atw.h code.h dataflow.h debug.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h stack.h type.h
switch.o: Lpars.h arith.h assert.h botch_free.h code.h debug.h density.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h switch.h type.h
storage.o: alloc.h assert.h botch_free.h debug.h storage.h
-ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h expr.h field.h idf.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h string.h struct.h type.h
+ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h expr.h field.h idf.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h struct.h type.h
conversion.o: Lpars.h arith.h nobitfield.h sizes.h spec_arith.h type.h
blocks.o: arith.h atw.h sizes.h spec_arith.h
dataflow.o: dataflow.h
-string.o: arith.h nopp.h spec_arith.h str_params.h string.h
+doprnt.o: ssize.h
tokenfile.o: Lpars.h
declar.o: LLlex.h Lpars.h arith.h debug.h declar.h decspecs.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h struct.h type.h
statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h storage.h type.h
#undef NOBITFIELD 1 /* implement bitfields */
-!File: str_params.h
-/* maximum number of characters in string representation of (unsigned) long
-*/
-#define MAXWIDTH 32
-
+!File: ssize.h
#define SSIZE 1024 /* string-buffer size for print routines */
Author: Erik Baalbergen
*/
-#include "string.h"
+#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
--- /dev/null
+/* $Header$ */
+/* STRING MANIPULATION AND PRINT ROUTINES */
+
+#include <system.h>
+#include "ssize.h"
+
+char *long2str();
+
+static
+integral(c)
+{
+ switch (c) {
+ case 'b':
+ return -2;
+ case 'd':
+ return 10;
+ case 'o':
+ return -8;
+ case 'u':
+ return -10;
+ case 'x':
+ return -16;
+ }
+ return 0;
+}
+
+static int
+format(buf, fmt, argp)
+ char *buf, *fmt;
+ char *argp;
+{
+ register char *pf = fmt, *pa = argp;
+ register char *pb = buf;
+
+ while (*pf) {
+ if (*pf == '%') {
+ register width, base, pad, npad;
+ char *arg;
+ char cbuf[2];
+ char *badformat = "<bad format>";
+
+ /* get padder */
+ if (*++pf == '0') {
+ pad = '0';
+ ++pf;
+ }
+ else
+ pad = ' ';
+
+ /* get width */
+ width = 0;
+ while (*pf >= '0' && *pf <= '9')
+ width = 10 * width + *pf++ - '0';
+
+ /* get text and move pa */
+ if (*pf == 's') {
+ arg = *(char **)pa;
+ pa += sizeof(char *);
+ }
+ else
+ if (*pf == 'c') {
+ cbuf[0] = * (char *) pa;
+ cbuf[1] = '\0';
+ pa += sizeof(int);
+ arg = &cbuf[0];
+ }
+ else
+ if (*pf == 'l') {
+ /* alignment ??? */
+ if (base = integral(*++pf)) {
+ arg = long2str(*(long *)pa, base);
+ pa += sizeof(long);
+ }
+ else {
+ pf--;
+ arg = badformat;
+ }
+ }
+ else
+ if (base = integral(*pf)) {
+ arg = long2str((long)*(int *)pa, base);
+ pa += sizeof(int);
+ }
+ else
+ if (*pf == '%')
+ arg = "%";
+ else
+ arg = badformat;
+
+ npad = width - strlen(arg);
+
+ while (npad-- > 0)
+ *pb++ = pad;
+
+ while (*pb++ = *arg++);
+ pb--;
+ pf++;
+ }
+ else
+ *pb++ = *pf++;
+ }
+ return pb - buf;
+}
+
+doprnt(fp, fmt, argp)
+ File *fp;
+ char *fmt;
+ int argp[];
+{
+ char buf[SSIZE];
+
+ sys_write(fp, buf, format(buf, fmt, (char *)argp));
+}
+
+/*VARARGS1*/
+printf(fmt, args)
+ char *fmt;
+ char args;
+{
+ char buf[SSIZE];
+
+ sys_write(STDOUT, buf, format(buf, fmt, &args));
+}
+
+/*VARARGS1*/
+fprintf(fp, fmt, args)
+ File *fp;
+ char *fmt;
+ char args;
+{
+ char buf[SSIZE];
+
+ sys_write(fp, buf, format(buf, fmt, &args));
+}
+
+/*VARARGS1*/
+char *
+sprintf(buf, fmt, args)
+ char *buf, *fmt;
+ char args;
+{
+ buf[format(buf, fmt, &args)] = '\0';
+ return buf;
+}
#include "use_tmp.h"
#include "errout.h"
#include "debug.h"
-#include "string.h"
#include "tokenname.h"
#include "arith.h"
#include "debug.h"
#include "nobitfield.h"
-#include "string.h"
#include "dataflow.h"
#include "arith.h"
#include "type.h"
#define roundup(n) ((n) < word_size ? word_size : (n))
char *symbol2str();
+char *long2str();
arith tmp_pointer_var();
/* EVAL() serves as the main expression tree evaluator, which turns
label datlab;
C_df_dlb(datlab = data_label());
- C_rom_icon(itos(val), siz);
+ C_rom_icon(long2str((long)val, 10), siz);
C_lae_dlb(datlab, (arith)0);
C_loi(siz);
}
#include "macro.h"
#include "idf.h"
#include "interface.h"
-#include "string.h"
PRIVATE struct mkey {
char *mk_reserved;
{0, K_UNKNOWN}
};
+char *strcpy();
+
EXPORT
init_pp()
{
char *fn, **wdir;
{
register char *p;
- char *rindex();
+ char *strrindex();
- p = rindex(fn, '/');
+ p = strrindex(fn, '/');
while (p && *(p + 1) == '\0') { /* remove trailing /'s */
*p = '\0';
- p = rindex(fn, '/');
+ p = strrindex(fn, '/');
}
if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
#include "debug.h"
#include "nobitfield.h"
-#include "string.h"
#include "arith.h"
#include "align.h"
#include "label.h"
#include "level.h"
#include "def.h"
-extern char *symbol2str();
+#define con_nullbyte() C_con_ucon("0", (arith)1)
-#define con_byte(c) C_con_ucon(itos((long)(c) & 0xFF), (arith)1)
+char *symbol2str();
+char *long2str();
struct expr *do_array(), *do_struct(), *IVAL();
struct expr *strings = 0; /* list of string constants within initialiser */
}
/* keep on aligning... */
while (bytes_upto_here++ < tp->tp_size)
- con_byte(0);
+ con_nullbyte();
return expr;
}
illegal_init_cst(expr);
break;
}
- C_con_fcon(itos(expr->VL_VALUE), type->tp_size);
+ C_con_fcon(
+ long2str((long)expr->VL_VALUE, 10),
+ type->tp_size
+ );
}
else
illegal_init_cst(expr);
}
/* throw out the characters of the already prepared string */
do
- con_byte(*s++);
+ C_con_ucon(long2str((long)*s++ & 0xFF, 10), (arith)1);
while (--length > 0);
/* pad the allocated memory (the alignment has been calculated) */
while (ntopad-- > 0)
- con_byte(0);
+ con_nullbyte();
}
#ifndef NOBITFIELD
register count = n;
while (n-- > 0)
- con_byte((arith)0);
+ con_nullbyte();
return count;
}
register struct type *tp = expr->ex_type;
if (tp->tp_unsigned)
- C_con_ucon(itos(expr->VL_VALUE), tp->tp_size);
+ C_con_ucon(long2str((long)expr->VL_VALUE, -10), tp->tp_size);
else
- C_con_icon(itos(expr->VL_VALUE), tp->tp_size);
+ C_con_icon(long2str((long)expr->VL_VALUE, 10), tp->tp_size);
}
illegal_init_cst(expr)
#include "pathlength.h" /* UF */
#include "strsize.h" /* UF */
-#include "string.h"
#include "alloc.h"
#include "idf.h"
#include "input.h"
#include "assert.h"
#include "interface.h"
+char *strcpy(), *strcat();
+char *long2str();
+
EXPORT int
replace(idef)
struct idf *idef;
break;
case 'L' : /* __LINE__ */
- idef->id_macro->mc_text = itos(LineNumber);
+ idef->id_macro->mc_text = long2str((long)LineNumber, 10);
idef->id_macro->mc_length = 1;
break;