Merge pull request #108 from davidgiven/dtrg-warnings

Warning-fix and protoise the basic library.
This commit is contained in:
David Given 2018-06-24 01:00:30 +02:00 committed by GitHub
commit 47bdd9cc49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 133 additions and 123 deletions

View file

@ -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

View file

@ -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)
{

View file

@ -1,6 +1,4 @@
#include "bc_string.h"
/* $Id$ */
#include "lib.h"
int _asc(String* str)
{

View file

@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "lib.h"
void asrt(int b)
{

View file

@ -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 <math.h>
#include "lib.h"
double _atn(double x) { return atan(x); }

View file

@ -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 <stdio.h>
/* $Id$ */
/* BASIC file io definitions */
extern FILE *_chanrd;

View file

@ -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 }
}

View file

@ -1,6 +1,4 @@
#include "bc_string.h"
/* $Id$ */
#include "lib.h"
String* _chr(int i)
{

View file

@ -1,4 +1,4 @@
/* $Id$ */
#include "lib.h"
int _cint(double f)
{

View file

@ -1,5 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
#include "lib.h"
int _errsym;
int _erlsym;

View file

@ -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 <math.h>
#include "lib.h"
double _exp(double x)
{

View file

@ -1,8 +1,6 @@
#
mes 2,EM_WSIZE,EM_PSIZE
; $Id$
#define FARG 0
#define ERES EM_DSIZE

View file

@ -1,8 +1,6 @@
#
mes 2,EM_WSIZE,EM_PSIZE
; $Id$
#define ARG1 0
#define ARG2 EM_DSIZE
#define IRES 2*EM_DSIZE

View file

@ -1,8 +1,6 @@
#include "bc_string.h"
#include <stdio.h>
#include "bc_io.h"
/* $Id$ */
#include "lib.h"
Filedesc _fdtable[16];
/* BASIC file descriptor table */

View file

@ -1,4 +1,5 @@
#include <stdlib.h>
#include "lib.h"
void _hlt(int nr)
{

View file

@ -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

View file

@ -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

View file

@ -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 <math.h>
#include "lib.h"
double _log(double x)
{

View file

@ -1,6 +1,4 @@
#include "bc_string.h"
/* $Id$ */
#include "lib.h"
String* _mki(long i)
{

View file

@ -1,8 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
#include "bc_string.h"
/* $Id$ */
#include "lib.h"
String* _oct(int i)
{

View file

@ -1,4 +1,4 @@
/* $Id$ */
#include "lib.h"
int peek(int addr)
{

View file

@ -1,3 +1,4 @@
#include <math.h>
#include "lib.h"
double _power(double x, double y) { return pow(x, y); }

View file

@ -1,9 +1,8 @@
#include <stdlib.h>
#include <stdio.h>
#include "bc_string.h"
#include <string.h>
#include "bc_io.h"
/* $Id$ */
#include "lib.h"
/* Here all routine to generate terminal oriented output is located */

View file

@ -1,5 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
#include "lib.h"
#if !defined(EM_WSIZE)
#define EM_WSIZE _EM_WSIZE

View file

@ -1,8 +1,6 @@
#include "bc_string.h"
#include "bc_io.h"
#include <ctype.h>
/* $Id$ */
#include "lib.h"
void _readln(void)
{

View file

@ -1,4 +1,4 @@
/* $Id$ */
#include "lib.h"
#define MAXNESTING 1000

View file

@ -1,4 +1,5 @@
#include <stdlib.h>
#include "lib.h"
char* salloc(unsigned length)
{

View file

@ -1,6 +1,5 @@
#
mes 2,EM_WSIZE,EM_PSIZE
; $Id$
; Save the line where the error occurred
exp $_setline
pro $_setline,0

View file

@ -1,4 +1,4 @@
/* $Id$ */
#include "lib.h"
int _sgn(double v)
{

View file

@ -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 <math.h>
#include "lib.h"
double _sin(double x) { return sin(x); }
double _cos(double x) { return cos(x); }

View file

@ -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 <math.h>
#include "lib.h"
double _sqt(double x) { return sqrt(x); }

View file

@ -1,5 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
#include "lib.h"
_stop()
{

View file

@ -1,10 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include "bc_string.h"
#include "lib.h"
/* $Id$ */
#define ok(X) \
if (X == 0) \
return;

View file

@ -1,6 +1,4 @@
#include "bc_string.h"
/* $Id$ */
#include "lib.h"
void _intswap(int* i1, int* i2)
{

View file

@ -1,4 +1,5 @@
/* $Id$ */
#include <stdio.h>
#include "lib.h"
void _trace(int i)
{

View file

@ -2,13 +2,12 @@
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include "lib.h"
#ifndef NSIG
#define NSIG _NSIG
#endif
/* $Id$ */
/* Trap handling */
int _trpline; /* BASIC return label */
jmp_buf trpbuf;

View file

@ -1,7 +1,5 @@
#include "bc_string.h"
#include "bc_io.h"
/* $Id$ */
#include "lib.h"
/* assume that the channel has been set */