From 1702d873ea1e60f6b223d467c189f5e97da3d398 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 24 Jun 2018 00:35:51 +0200 Subject: [PATCH] Warning-fix and protoise the basic library. --- h/bc_string.h | 21 ------- lang/basic/lib/abs.c | 7 +-- lang/basic/lib/asc.c | 4 +- lang/basic/lib/asrt.c | 1 + lang/basic/lib/atn.c | 10 +--- {h => lang/basic/lib}/bc_io.h | 6 -- lang/basic/lib/build.lua | 1 + lang/basic/lib/chr.c | 4 +- lang/basic/lib/conversion.c | 2 +- lang/basic/lib/error.c | 1 + lang/basic/lib/exp.c | 10 +--- lang/basic/lib/fef.e | 2 - lang/basic/lib/fif.e | 2 - lang/basic/lib/file.c | 4 +- lang/basic/lib/hlt.c | 1 + lang/basic/lib/io.c | 1 + lang/basic/lib/lib.h | 104 +++++++++++++++++++++++++++++++++- lang/basic/lib/log.c | 10 +--- lang/basic/lib/mki.c | 4 +- lang/basic/lib/oct.c | 4 +- lang/basic/lib/peek.c | 2 +- lang/basic/lib/power.c | 1 + lang/basic/lib/print.c | 5 +- lang/basic/lib/random.c | 1 + lang/basic/lib/read.c | 4 +- lang/basic/lib/return.c | 2 +- lang/basic/lib/salloc.c | 1 + lang/basic/lib/setline.e | 1 - lang/basic/lib/sgn.c | 2 +- lang/basic/lib/sin.c | 10 +--- lang/basic/lib/sqt.c | 10 +--- lang/basic/lib/stop.c | 1 + lang/basic/lib/string.c | 3 - lang/basic/lib/swap.c | 4 +- lang/basic/lib/trace.c | 3 +- lang/basic/lib/trap.c | 3 +- lang/basic/lib/write.c | 4 +- 37 files changed, 133 insertions(+), 123 deletions(-) delete mode 100644 h/bc_string.h rename {h => lang/basic/lib}/bc_io.h (70%) diff --git a/h/bc_string.h b/h/bc_string.h deleted file mode 100644 index 6b5a4cdbc..000000000 --- a/h/bc_string.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -# - -/* $Id$ */ - -/* Strings are allocated in a fixed string descriptor table -** This mechanism is used to avoid string copying as much as possible -*/ - -typedef struct{ - char *strval; - int strcount; - int strlength; - } String; - -extern String *_newstr(char* str); - -#define MAXSTRING 1024 diff --git a/lang/basic/lib/abs.c b/lang/basic/lib/abs.c index 46d6fd39c..5ab28ba59 100644 --- a/lang/basic/lib/abs.c +++ b/lang/basic/lib/abs.c @@ -1,9 +1,4 @@ -/* $Id$ */ - -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ +#include "lib.h" long _abl(long i) { diff --git a/lang/basic/lib/asc.c b/lang/basic/lib/asc.c index 1e7ed8cd0..b1421d6d5 100644 --- a/lang/basic/lib/asc.c +++ b/lang/basic/lib/asc.c @@ -1,6 +1,4 @@ -#include "bc_string.h" - -/* $Id$ */ +#include "lib.h" int _asc(String* str) { diff --git a/lang/basic/lib/asrt.c b/lang/basic/lib/asrt.c index 1517eb580..cbe41b4b8 100644 --- a/lang/basic/lib/asrt.c +++ b/lang/basic/lib/asrt.c @@ -1,5 +1,6 @@ #include #include +#include "lib.h" void asrt(int b) { diff --git a/lang/basic/lib/atn.c b/lang/basic/lib/atn.c index 4b3247d68..57b3311c9 100644 --- a/lang/basic/lib/atn.c +++ b/lang/basic/lib/atn.c @@ -1,12 +1,4 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Ceriel J.H. Jacobs - */ - -/* $Id$ */ - #include +#include "lib.h" double _atn(double x) { return atan(x); } diff --git a/h/bc_io.h b/lang/basic/lib/bc_io.h similarity index 70% rename from h/bc_io.h rename to lang/basic/lib/bc_io.h index 319afc750..df58a0284 100644 --- a/h/bc_io.h +++ b/lang/basic/lib/bc_io.h @@ -1,11 +1,5 @@ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ #include -/* $Id$ */ - /* BASIC file io definitions */ extern FILE *_chanrd; diff --git a/lang/basic/lib/build.lua b/lang/basic/lib/build.lua index cff3b57ca..f99ebfed3 100644 --- a/lang/basic/lib/build.lua +++ b/lang/basic/lib/build.lua @@ -12,6 +12,7 @@ for _, plat in ipairs(vars.plats) do "h+emheaders", "lang/cem/libcc.ansi/headers+pkg", "plat/"..plat.."/include+pkg", + "./*.h", }, vars = { plat = plat } } diff --git a/lang/basic/lib/chr.c b/lang/basic/lib/chr.c index 527f1537b..a5af68eda 100644 --- a/lang/basic/lib/chr.c +++ b/lang/basic/lib/chr.c @@ -1,6 +1,4 @@ -#include "bc_string.h" - -/* $Id$ */ +#include "lib.h" String* _chr(int i) { diff --git a/lang/basic/lib/conversion.c b/lang/basic/lib/conversion.c index 4667b1ce9..e407be8d9 100644 --- a/lang/basic/lib/conversion.c +++ b/lang/basic/lib/conversion.c @@ -1,4 +1,4 @@ -/* $Id$ */ +#include "lib.h" int _cint(double f) { diff --git a/lang/basic/lib/error.c b/lang/basic/lib/error.c index b526377c2..1271fd118 100644 --- a/lang/basic/lib/error.c +++ b/lang/basic/lib/error.c @@ -1,5 +1,6 @@ #include #include +#include "lib.h" int _errsym; int _erlsym; diff --git a/lang/basic/lib/exp.c b/lang/basic/lib/exp.c index c16344e56..ab37e852d 100644 --- a/lang/basic/lib/exp.c +++ b/lang/basic/lib/exp.c @@ -1,14 +1,6 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Ceriel J.H. Jacobs - */ - -/* $Id$ */ - #define __NO_DEFS #include +#include "lib.h" double _exp(double x) { diff --git a/lang/basic/lib/fef.e b/lang/basic/lib/fef.e index a7e52fc8e..3bceb28ec 100644 --- a/lang/basic/lib/fef.e +++ b/lang/basic/lib/fef.e @@ -1,8 +1,6 @@ # mes 2,EM_WSIZE,EM_PSIZE -; $Id$ - #define FARG 0 #define ERES EM_DSIZE diff --git a/lang/basic/lib/fif.e b/lang/basic/lib/fif.e index 4b1960045..40d54d1d7 100644 --- a/lang/basic/lib/fif.e +++ b/lang/basic/lib/fif.e @@ -1,8 +1,6 @@ # mes 2,EM_WSIZE,EM_PSIZE -; $Id$ - #define ARG1 0 #define ARG2 EM_DSIZE #define IRES 2*EM_DSIZE diff --git a/lang/basic/lib/file.c b/lang/basic/lib/file.c index 4e28af0b1..cba32c439 100644 --- a/lang/basic/lib/file.c +++ b/lang/basic/lib/file.c @@ -1,8 +1,6 @@ -#include "bc_string.h" #include #include "bc_io.h" - -/* $Id$ */ +#include "lib.h" Filedesc _fdtable[16]; /* BASIC file descriptor table */ diff --git a/lang/basic/lib/hlt.c b/lang/basic/lib/hlt.c index c0d7f7511..5e4485f10 100644 --- a/lang/basic/lib/hlt.c +++ b/lang/basic/lib/hlt.c @@ -1,4 +1,5 @@ #include +#include "lib.h" void _hlt(int nr) { diff --git a/lang/basic/lib/io.c b/lang/basic/lib/io.c index dd1f6cf2a..74b6a84ac 100644 --- a/lang/basic/lib/io.c +++ b/lang/basic/lib/io.c @@ -1,4 +1,5 @@ #include "bc_io.h" +#include "lib.h" /* dtrg --- this originally used sgtty.h to do clever tty manipulation. * Strictly this should be converted to use termios, but for simplicity diff --git a/lang/basic/lib/lib.h b/lang/basic/lib/lib.h index 8dc371c91..23d6960e7 100644 --- a/lang/basic/lib/lib.h +++ b/lang/basic/lib/lib.h @@ -1,9 +1,107 @@ #ifndef LIB_H #define LIB_H +typedef struct{ + char *strval; + int strcount; + int strlength; + } String; + +#define MAXSTRING 1024 + +extern String *_chr(int i); +extern String *_concat(String *s1, String *s2); +extern String *_hex(int i); +extern String *_left(int size, String *s); +extern String *_mid(int i1, int i2, String *s); +extern String *_mkd(double d); +extern String *_mki(long i); +extern String *_newstr(char *str); +extern String *_nstr(double f); +extern String *_oct(int i); +extern String *_right(int length, String *str); +extern String *_space(int d); +extern String *_strascii(void); +extern String *_string(double f, double d); +extern char *salloc(unsigned length); +extern double _abr(double f); +extern double _atn(double x); +extern double _cos(double x); +extern double _cvd(String *s); +extern double _exp(double x); +extern double _fcint(double f); +extern double _log(double x); +extern double _power(double x, double y); +extern double _rnd(double d); +extern double _sin(double x); +extern double _sqt(double x); +extern double _tan(double x); +extern double _trunc(double f); +extern int _asc(String *str); +extern int _cint(double f); +extern int _fix(double f); +extern int _forsgn(double v); +extern int _ioeof(int channel); +extern int _length(String *str); +extern int _retstmt(void); +extern int _sgn(double v); +extern int _stop(void); +extern int _strcomp(String *s1, String *s2); +extern int peek(int addr); +extern long _abl(long i); +extern long _cvi(String *s); +extern void _asschn(void); +extern void _clochn(int nr); +extern void _closeall(void); +extern void _decstr(String *str); +extern void _delstr(String *src); +extern void _fltswap(double *i1, double *i2); +extern void _gosub(int x); +extern void _goto_err(void); +extern void _hlt(int nr); +extern void _in(char *buf); +extern void _incstr(String *src); +extern void _ini_trp(void); +extern void _intswap(int *i1, int *i2); +extern void _midstmt(String *s2, int i1, int i2, String *s); +extern void _nl(void); +extern void _opnchn(int reclen, String *fname, String *mode); +extern void _out(char *str); +extern void _outnl(void); +extern void _poke(int i, int j); +extern void _prfnum(double f); +extern void _prinum(int i); +extern void _prstr(String *str); +extern void _qstmark(void); +extern void _randomi(void); +extern void _rdline(String **s); +extern void _readflt(double *addr); +extern void _readint(int *addr); +extern void _readln(void); +extern void _readstr(String **s); +extern void _restore(int line); +extern void _setchan(int index); +extern void _setline(void); +extern void _setrand(int i); +extern void _settrap(int nr); +extern void _spc(int x); +extern void _str(double f, char *buffer); +extern void _strcpy(String *dst, String *src); +extern void _strswap(String **s1, String **s2); +extern void _tab(int x); +extern void _trace(int i); +extern void _trap(void); +extern void _trpfatal(int i); +extern void _trpset(int nr); +extern void _wrcomma(void); +extern void _wrflt(double f); +extern void _wrint(int i); +extern void _wrnl(void); +extern void _wrstr(String *s); +extern void _zone(void); +extern void asrt(int b); extern void error(int index); -extern char* salloc(unsigned length); -extern void sfree(char* c); +extern void readskip(void); +extern void sfree(char *c); #endif - diff --git a/lang/basic/lib/log.c b/lang/basic/lib/log.c index e194f51d7..dd479bad1 100644 --- a/lang/basic/lib/log.c +++ b/lang/basic/lib/log.c @@ -1,14 +1,6 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Ceriel J.H. Jacobs - */ - -/* $Id$ */ - #define __NO_DEFS #include +#include "lib.h" double _log(double x) { diff --git a/lang/basic/lib/mki.c b/lang/basic/lib/mki.c index f14d18da5..6facc31df 100644 --- a/lang/basic/lib/mki.c +++ b/lang/basic/lib/mki.c @@ -1,6 +1,4 @@ -#include "bc_string.h" - -/* $Id$ */ +#include "lib.h" String* _mki(long i) { diff --git a/lang/basic/lib/oct.c b/lang/basic/lib/oct.c index fb7eb419f..d9b250c6f 100644 --- a/lang/basic/lib/oct.c +++ b/lang/basic/lib/oct.c @@ -1,8 +1,6 @@ #include #include -#include "bc_string.h" - -/* $Id$ */ +#include "lib.h" String* _oct(int i) { diff --git a/lang/basic/lib/peek.c b/lang/basic/lib/peek.c index a3383f761..1b5d0c7fa 100644 --- a/lang/basic/lib/peek.c +++ b/lang/basic/lib/peek.c @@ -1,4 +1,4 @@ -/* $Id$ */ +#include "lib.h" int peek(int addr) { diff --git a/lang/basic/lib/power.c b/lang/basic/lib/power.c index a22d8e5a5..1913b40a2 100644 --- a/lang/basic/lib/power.c +++ b/lang/basic/lib/power.c @@ -1,3 +1,4 @@ #include +#include "lib.h" double _power(double x, double y) { return pow(x, y); } diff --git a/lang/basic/lib/print.c b/lang/basic/lib/print.c index c2078058f..329a1992a 100644 --- a/lang/basic/lib/print.c +++ b/lang/basic/lib/print.c @@ -1,9 +1,8 @@ #include #include -#include "bc_string.h" +#include #include "bc_io.h" - -/* $Id$ */ +#include "lib.h" /* Here all routine to generate terminal oriented output is located */ diff --git a/lang/basic/lib/random.c b/lang/basic/lib/random.c index 511c877b0..b5e1a714c 100644 --- a/lang/basic/lib/random.c +++ b/lang/basic/lib/random.c @@ -1,5 +1,6 @@ #include #include +#include "lib.h" #if !defined(EM_WSIZE) #define EM_WSIZE _EM_WSIZE diff --git a/lang/basic/lib/read.c b/lang/basic/lib/read.c index 63061fc8e..33a119a96 100644 --- a/lang/basic/lib/read.c +++ b/lang/basic/lib/read.c @@ -1,8 +1,6 @@ -#include "bc_string.h" #include "bc_io.h" #include - -/* $Id$ */ +#include "lib.h" void _readln(void) { diff --git a/lang/basic/lib/return.c b/lang/basic/lib/return.c index d6b122e01..85f0be74b 100644 --- a/lang/basic/lib/return.c +++ b/lang/basic/lib/return.c @@ -1,4 +1,4 @@ -/* $Id$ */ +#include "lib.h" #define MAXNESTING 1000 diff --git a/lang/basic/lib/salloc.c b/lang/basic/lib/salloc.c index 0970df509..4d6b16e5b 100644 --- a/lang/basic/lib/salloc.c +++ b/lang/basic/lib/salloc.c @@ -1,4 +1,5 @@ #include +#include "lib.h" char* salloc(unsigned length) { diff --git a/lang/basic/lib/setline.e b/lang/basic/lib/setline.e index 0033c48e1..8cc5b1699 100644 --- a/lang/basic/lib/setline.e +++ b/lang/basic/lib/setline.e @@ -1,6 +1,5 @@ # mes 2,EM_WSIZE,EM_PSIZE -; $Id$ ; Save the line where the error occurred exp $_setline pro $_setline,0 diff --git a/lang/basic/lib/sgn.c b/lang/basic/lib/sgn.c index a785061b3..f8e053794 100644 --- a/lang/basic/lib/sgn.c +++ b/lang/basic/lib/sgn.c @@ -1,4 +1,4 @@ -/* $Id$ */ +#include "lib.h" int _sgn(double v) { diff --git a/lang/basic/lib/sin.c b/lang/basic/lib/sin.c index 559736c54..12cb76432 100644 --- a/lang/basic/lib/sin.c +++ b/lang/basic/lib/sin.c @@ -1,14 +1,6 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Ceriel J.H. Jacobs - */ - -/* $Id$ */ - #define __NO_DEFS #include +#include "lib.h" double _sin(double x) { return sin(x); } double _cos(double x) { return cos(x); } diff --git a/lang/basic/lib/sqt.c b/lang/basic/lib/sqt.c index d0fe07f18..2cb12c5aa 100644 --- a/lang/basic/lib/sqt.c +++ b/lang/basic/lib/sqt.c @@ -1,13 +1,5 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Ceriel J.H. Jacobs - */ - -/* $Id$ */ - #define __NO_DEFS #include +#include "lib.h" double _sqt(double x) { return sqrt(x); } diff --git a/lang/basic/lib/stop.c b/lang/basic/lib/stop.c index 8ef27cabf..8cbba96fd 100644 --- a/lang/basic/lib/stop.c +++ b/lang/basic/lib/stop.c @@ -1,5 +1,6 @@ #include #include +#include "lib.h" _stop() { diff --git a/lang/basic/lib/string.c b/lang/basic/lib/string.c index c4cdbe117..b99440673 100644 --- a/lang/basic/lib/string.c +++ b/lang/basic/lib/string.c @@ -1,10 +1,7 @@ #include #include -#include "bc_string.h" #include "lib.h" -/* $Id$ */ - #define ok(X) \ if (X == 0) \ return; diff --git a/lang/basic/lib/swap.c b/lang/basic/lib/swap.c index af74894cb..67b2c28d4 100644 --- a/lang/basic/lib/swap.c +++ b/lang/basic/lib/swap.c @@ -1,6 +1,4 @@ -#include "bc_string.h" - -/* $Id$ */ +#include "lib.h" void _intswap(int* i1, int* i2) { diff --git a/lang/basic/lib/trace.c b/lang/basic/lib/trace.c index a84c14129..c65fdca14 100644 --- a/lang/basic/lib/trace.c +++ b/lang/basic/lib/trace.c @@ -1,4 +1,5 @@ -/* $Id$ */ +#include +#include "lib.h" void _trace(int i) { diff --git a/lang/basic/lib/trap.c b/lang/basic/lib/trap.c index 9d4085a69..372a665bb 100644 --- a/lang/basic/lib/trap.c +++ b/lang/basic/lib/trap.c @@ -2,13 +2,12 @@ #include #include #include +#include "lib.h" #ifndef NSIG #define NSIG _NSIG #endif -/* $Id$ */ - /* Trap handling */ int _trpline; /* BASIC return label */ jmp_buf trpbuf; diff --git a/lang/basic/lib/write.c b/lang/basic/lib/write.c index db90a7417..d8b22717f 100644 --- a/lang/basic/lib/write.c +++ b/lang/basic/lib/write.c @@ -1,7 +1,5 @@ -#include "bc_string.h" #include "bc_io.h" - -/* $Id$ */ +#include "lib.h" /* assume that the channel has been set */