Commit c006b46c authored by kollo's avatar kollo

version 1.20

parent 65bc30b1
This diff is collapsed.
......@@ -18,7 +18,7 @@ INCDIR=@prefix@/include/x11basic
LIBNO=@version@
# Register variables (-ffixed-reg) -Wall
REGS= @regs@
REGS= @regs@ -g -Wall
# Optimization and debugging options
OPT=@copt@
......@@ -34,7 +34,7 @@ DEF= @def@
# Compiler
#CC=@CC@ @static@ $(REGS)
CC=@CC@ $(REGS) -g
CC=@CC@ $(REGS)
# Cross-Compiler fuer Windows-Excecutable
......@@ -51,14 +51,16 @@ CPP=@CPP@
CFLAGS= $(INC) $(DEF) $(OPT) $(SFLAGS)
OBJS= xbasic.o file.o ccs.o io.o parser.o variablen.o array.o parameter.o \
OBJS= xbasic.o file.o ccs.o io.o parser.o variablen.o svariablen.o \
array.o parameter.o \
runtime.o wort_sep.o ltext.o functions.o sfunctions.o afunctions.o \
kommandos.o gkommandos.o bitmap.o do_gets.o errortxt.o window.o\
sysVstuff.o aes.o graphics.o sound.o number.o decode.o virtual-machine.o
sysVstuff.o aes.o graphics.o sound.o number.o decode.o \
virtual-machine.o
# Object group for framebuffer variant
OBJS1= xbasic.o file.o ccs.o io.o parser.o variablen.o array.o parameter.o\
OBJS1= xbasic.o file.o ccs.o io.o parser.o variablen.o svariablen.o array.o parameter.o\
runtime.o wort_sep.o ltext.o functions.o sfunctions.o afunctions.o \
kommandos.o do_gets.o errortxt.o number.o decode.o \
sysVstuff.o aes.o sound.o virtual-machine.o
......@@ -85,7 +87,7 @@ DEPSRC= $(CSRC)
HSRC= aes.h android.h array.h bitmap.h defs.h file.h functions.h gkommandos.h kommandos.h \
options.h xbasic.h window.h bytecode.h number.h parameter.h \
framebuffer.h parser.h io.h afunctions.h sfunctions.h graphics.h \
sound.h wort_sep.h variablen.h mathematics.h sysVstuff.h x11basic.h \
sound.h wort_sep.h variablen.h svariablen.h mathematics.h sysVstuff.h x11basic.h \
decode.h xb2csol.h virtual-machine.h terminal.h
EXAMPLES=examples2/calculation/randomminmax.bas \
......@@ -144,7 +146,8 @@ DIST= README INSTALL COPYING doc/man-pages/*.1 doc/ACKNOWLEGEMENTS \
BINDIST=README INSTALL COPYING doc/man-pages/*.1 doc/ACKNOWLEGEMENTS \
AUTHORS doc/HISTORY RELEASE_NOTES doc/X11-Basic-manual.txt \
doc/editors/* xbasic xbc bas2x11basic xbvm x11basic.h \
doc/editors/* xbasic xbc bas2x11basic xbbc xbvm x11basic.h xb2csol.h \
x11basic.a libx11basic.so \
examples/compiler/xbc.bas.in \
examples/compiler/inline.bas \
examples/compiler/bas2x11basic.bas \
......@@ -179,7 +182,7 @@ DOOCSDIST=$(DIST) src/doocs-wrapper.cc doc/doocs-xbasic.html \
LINKFLAGS =
WINLINKFLAGS = -L./Windows.extension/lib
LIBS = @libs@ @xtra@
LIBS = @libs@ @xtra@ -lutil
LIBS1 = @libs@
LIBS2 = -L. -ldl -lm -lncurses TomTom.extension/contrib/readline-5.2/libreadline.a
......@@ -232,25 +235,25 @@ xbasic : libx11basic.so main.o
# Make th X11-Xasic psydocompiler
xbc : xbasic libx11basic.so
LD_LIBRARY_PATH=. ./xbasic examples/compiler/xbc.bas --dynamic -o $@
LD_LIBRARY_PATH=. ./xbasic examples/compiler/xbc.bas --dynamic -o $@ -L .
strip $@
# Make the bytecode compiler xbbc
xbbc : bytecode.h bytecode.o xbbc.c
gcc -o $@ xbbc.c bytecode.o -L . $(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
$(CC) -o $@ xbbc.c bytecode.o -L . $(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
strip $@
xbbcstatic : xbbc.c bytecode.h bytecode.o x11basic.a
gcc -o xbbc xbbc.c bytecode.o x11basic.a -lm -L /usr/X11/lib/ -lX11 $(LIBS)
$(CC) -o xbbc xbbc.c bytecode.o x11basic.a -lm -L /usr/X11/lib/ -lX11 $(LIBS)
# Make the virtual machine for interpreting the bytecode
xbvm : bytecode.h xbvm.c
gcc -o $@ xbvm.c -L . $(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
$(CC) -o $@ xbvm.c -L . $(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
strip $@
xbvmstatic : bytecode.h xbvm.c bytecode.h x11basic.a
gcc -o xbvm xbvm.c x11basic.a -lm -L /usr/X11/lib/ $(LIBS) -lX11
$(CC) -o xbvm xbvm.c x11basic.a -lm -L /usr/X11/lib/ $(LIBS) -lX11
###################################################
#### Fundamentals for X11-Basic (MS WINDOWS) ######
......@@ -325,9 +328,20 @@ xbasic.framebuffer : main.c $(LIBCSRCFB)
# therefor can be used without the .so file
xbasic.static : x11basic.a main.o
$(CC) $(OPT) $(LINKFLAGS) -o xbasic main.o x11basic.a $(LIBS) $(XLIBS)
static : xbasic.static xbbcstatic xbvmstatic xb2cstatic
strip : xbasic xbbc xbvm xb2c
strip xbasic
strip xbbc
strip xbvm
strip xb2c
static : xbasic.static
debugtest : x11basic.a main.o
$(CC) $(OPT) $(LINKFLAGS) -o xbasic main.o x11basic.a $(LIBS) $(XLIBS)
valgrind --leak-check=full --track-origins=yes --partial-loads-ok=yes ./xbasic ../examples2/calculation/diffglei.bas
# Make a version of X11-basic which uses the SDL library for graphics
......@@ -481,21 +495,21 @@ tinex11basic.a : $(LIBOBJS)
# Make the ANSI-Basic to X11-Basic translator
bas2x11basic : xbc
LD_LIBRARY_PATH=. ./xbc examples/compiler/bas2x11basic.bas --dynamic -o $@
LD_LIBRARY_PATH=. ./xbc examples/compiler/bas2x11basic.bas --dynamic -o $@ -L .
strip $@
myzip : xbc
LD_LIBRARY_PATH=. ./xbc ../examples2/utils/myzip.bas --dynamic -o myzip
LD_LIBRARY_PATH=. ./xbc ../examples2/utils/myunzip.bas --dynamic -o myunzip
LD_LIBRARY_PATH=. ./xbc ../examples2/utils/myzip.bas --dynamic -o myzip -L .
LD_LIBRARY_PATH=. ./xbc ../examples2/utils/myunzip.bas --dynamic -o myunzip -L .
strip myzip
strip myunzip
# make the X11-Basic to C translator
xb2c : xb2c.c
gcc -o $@ xb2c.c -L . $(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
$(CC) -o $@ xb2c.c -L . $(LIBS) -lx11basic -L /usr/X11/lib/ -lX11
strip $@
xb2cstatic : xb2c.c x11basic.a
gcc -o xb2c xb2c.c x11basic.a -lm -L /usr/X11/lib/ -lX11 $(LIBS)
$(CC) -o xb2c xb2c.c x11basic.a -lm -L /usr/X11/lib/ -lX11 $(LIBS)
x11basic.tga: x11basic.pov
povray +I$< +O$@ +FT +W160 +H200 +V -D +X
......@@ -506,6 +520,8 @@ install : xbasic libx11basic.so x11basic.h xb2csol.h x11basic.a xbvm xbbc xbc xb
ln -s -f $(LIBDIR)/libx11basic.so.$(LIBNO) $(LIBDIR)/libx11basic.so.1
ln -s -f $(LIBDIR)/libx11basic.so.1 $(LIBDIR)/libx11basic.so
install -m 644 x11basic.a $(LIBDIR)/
install -d $(MANDIR)
install -d $(MANDIR)/man1
install -m 644 doc/man-pages/x11basic.1 $(MANDIR)/man1/x11basic.1
install -m 644 doc/man-pages/x11basic.1 $(MANDIR)/man1/xbasic.1
install -s -m 755 xbc $(BINDIR)/
......
......@@ -10,13 +10,13 @@
VERSION 1.19
VERSION 1.20
(C) 1997-2012 by Markus Hoffmann
(C) 1997-2013 by Markus Hoffmann
(kollo@users.sourceforge.net)
Name : X11Basic
Version : 1.19 Vendor: Markus Hoffmann
Version : 1.20 Vendor: Markus Hoffmann
Group : Development/Languages License: GPL
Packager : Markus Hoffmann <kollo@users.sourceforge.net>
URL : http://x11-basic.sourceforge.net/
......@@ -30,46 +30,123 @@ Description :
The structure of the language is similar to the ATARI-ST GFA-BASIC.
GFA-Basic programs should run with only few changes.
On UNIX and linux systems, the X11 graphics engine can be used as well as the
SDL library, the framebuffer devices or no graphics at all. The MS WINDOWS
version supports only SDL (or no graphics at all).
This package includes the basic interpreter named xbasic and a set of different
compilers. The interpreter can be used as a shell, and can so run basic-scripts.
You can make excecutable scripts p.ex. *.cgi-Scripts for handling web-input.
This package includes the basic interpreter named xbasic and a set of
different compilers. The interpreter can be used as a shell, and can so run
basic-scripts. You can make excecutable scripts p.ex. *.cgi-Scripts for
handling web-input.
A compiler (xbc) is included which makes stand alone binaries out of the
scripts, which run more than 10 times faster than the interpreted code. The
compiler can either pseudo-compile the X11-Basic sources by attaching the
source to a run-only interpreter (in which case the program will not run faster
than is the interpreter is used, but you have everything in one excecutable
file), or the compiler can do a real compilation of the BASIC source into
bytecode, then c, and finally machine language. This way the code excecutes
about 10 times faster. (** This is a relatively new feature, so be prepared to
catch errors here. Please report them. **)
A compiler (xbc) is included which makes stand alone binaries out of the
scripts, which run more than 10 times faster than the interpreted code. The
compiler can either pseudo-compile the X11-Basic sources by attaching the
source to a run-only interpreter (in which case the program will not run
faster than is the interpreter is used, but you have everything in one
excecutable file), or the compiler can do a real compilation of the BASIC
source into bytecode, then C, and finally machine language. This way the code
excecutes about 10 times faster.
X11-Basic programs can also be compiled into a bytecode (see xbbc). This bytecode
can be interpreted by a virtual machine (see xbvm). Finally, the bytecode can be
converted to c sourcefiles (see xb2c) which can be compiles with the gnu C
compiler (or the tiny c compiler) to native excecutables.
X11-Basic programs can also be compiled into a bytecode (see xbbc). This
bytecode can be interpreted by a virtual machine (see xbvm). Finally, the
bytecode can be converted to C sourcefiles (see xb2c) which can be compiled
with the gnu C compiler (or the tiny c compiler) to native excecutables.
Ancient ANSI-Basic programs (with line numbers) can be converted to X11-Basic
with the bas2x11basic program (see the man page bas2x11basic(1) ).
Ancient ANSI-Basic programs (with line numbers) can be converted to X11-Basic
with the bas2x11basic program (see the man page bas2x11basic(1) ).
You will find the compiler sourcecode and some other sample programs in
/usr/share/doc/packages/X11Basic/examples. A variety of other sample programs
can be found in X11-Basic-examples-1.19.zip, which you can download from the
homepage (http://x11-basic.sourceforge.net/). Also an up-to-date pdf-version
of the manual can be found there.
You will find the compiler sourcecode and some other sample programs in
/usr/share/doc/packages/X11Basic/examples. A variety of other sample programs
can be found in X11-Basic-examples-1.20.zip, which you can download from the
homepage (http://x11-basic.sourceforge.net/). Also an up-to-date pdf-version
of the manual can be found there.
Please read the file ./doc/X11-Basic-manual.txt for further information.
Please read the file ./doc/X11-Basic-manual.txt for further information.
X11BASIC is free software and comes with NO WARRANTY - read the file
COPYING for details
(Basically that means, free, open source, use and modify as you like, don't
incorporate it into non-free software, no warranty of any sort, don't blame me
if it doesn't work.)
(Basically that means, free, open source, use and modify as you like, don't
incorporate it into non-free software, no warranty of any sort, don't blame me
if it doesn't work.)
Please read the file INSTALL for compiling instructions.
ADDITIONAL CONFIGURATION OPTIONS
================================
After generating the Makefile, look at the file `options.h' (sparsely
commented) and see if there is anything you want to change. The only option
that you might need to change is GERMAN, which should be defined if you
like to have a german version of X11-Basic. The default language is english.
COMPILING a standalone excecutable
==================================
To compile the X11-Basic interpreter (called xbasic), simply type
make static
at the shell prompt. The produced file is independant of the x11basic
library and does not need the x11basic framework to be installed.
After X11Basic has been compiled and linked successfully, you can start it
by typing
./xbasic
The command-line options can be listed with the `-h' option (`./xbasic -h').
INSTALLING the standalone excecutable
=====================================
Put the executable wherever you like. I have mine in ${HOME}/bin/.
A system wide installation can be done with
sudo make install
remove the installation with
sudo make uninstall
make the pseudo-compiler work, libraries:
=========================================
If you want to use the compilers included in this package, you have to
make both the static and dynamic libraries.
cd ./src
If you do not have the file mathematics.c please do
cp mathemat_dummy.c mathematics.c
then:
make lib will generate libx11basic.so
make x11basic.a will generate x11basic.a
-- now you have to be root --
mv libx11basic.so /usr/lib/
mv x11basic.a /usr/lib/
-- please also check the permissions of the files:
chmod 755 /usr/lib/x11basic.a
chmod 755 /usr/lib/libx11basic.so
rehash
make installroot
will generate a dynamic linked binary of the interpreter,
copy it to /bin/, install the libraries in /usr/local/lib/,
install the man-page
-----------------------------
make xbc
will make the X11-basic compiler
You can then (beeing root) do a
make xbcinstall
to install the compiler in /usr/local/bin/ and the compiler
man-page
After doing all this, you will also find a xbasic.dyn executabe. This is the
interpreter, dynamically linked and much shorter.
regards and have fun
Markus Hoffmann
Release notes for Version 1.19 (Mai 2012)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Android version
- virtual machine now included in library
- new GPS and SENSOR commands (for Android version)
- new SPEAK kommand (for Android version)
- improved framebuffer graphics routines
- new command: PLAYSOUNDFILE (for Android version)
- new command: GET_LOCATION
- BUGFIX: SOUND, WAVE, AND(), OR(), XOR(), NOT()
- BUGFIX: FOR with integer variable
- BUGFIX: SELECT CASE ENDSELECT
- NEW: "!" is now allowed at the beginning of a line
- BUGFIX: SELECT/CONTINUE
- some minor changes for 64bit version
Release notes for Version 1.20 (Dez 2012-Mar 2013)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- New command: SHELL (also for Android)
- bugfix: strcpy().
- Improved: Editor excecution in Android version
- Fixed bug with desktop shortcuts under Android
- Bugfix in virtual machine (AND)
- included va_copy patch for 64 bit version by Matthias Vogl
- fixed bugs in compiler (ARRAY constants)
- fixed bugs in VARPTR() and ARRPTR()
- fixed bug in local variable handling
- fixed memory leak LOCAL/RETURN
- fixed bug/crash with MERGE
- new function: call android intents with EXEC
- fixed bug/crash in LIST command
- fixed bug in SWAP command
- fixed bug/crash in CALL command
- new commands: MKDIR, RMDIR, KILL, HIDEM, SHOWM
- new functions: LEFTOF$(), RIGHTOF$(), ENCLOSE$(), DECLOSE$(), TALLY()
- new functions: COLOR_RGB(), BYTE(), CARD(), WORD(), SWAP(), CINT(), VARIAT()
- new Commands: RENAME, CHMOD, TOUCH
......@@ -101,6 +101,7 @@ void gem_init() {
printf("sbox=(%d,%d,%d,%d)\n",sbox.x,sbox.y,sbox.w,sbox.h);
#endif
#ifdef FRAMEBUFFER
/*Das Ziel ist hier, dass ungefaehrr 60 bis 80 Zeichen in eine Zeile passen*/
if(font_behaviour==0) { /* Auto */
if(sbox.w>=1200) load_GEMFONT(FONT_LARGE);
else if(sbox.w>=640) load_GEMFONT(FONT_BIG);
......@@ -119,7 +120,7 @@ void gem_init() {
load_GEMFONT(FONT_DEFAULT);
#endif
for(i=0;i<16;i++)
gem_colors[i]=get_color(gem_colordefs[i].r,gem_colordefs[i].g,gem_colordefs[i].b);
gem_colors[i]=get_color(gem_colordefs[i].r,gem_colordefs[i].g,gem_colordefs[i].b,65535);
}
......@@ -724,12 +725,14 @@ if (drawbg) {
case G_STRING:
case G_TITLE:
text=(char *)((long)tree[idx].ob_spec);
// printf("Title: <%s> y=%d baseline=%d\n",text,oby,baseline);
DrawString(obx,oby+baseline,text,strlen(text));
case G_BOX:
case G_IBOX:
break;
case G_BUTTON:
text=(char *)((long)tree[idx].ob_spec);
// printf("Title: <%s> y=%d baseline=%d h=%d\n",text,oby,baseline+(obh-chh)/2,obh);
DrawString(obx+(obw-chw*strlen(text))/2,oby+baseline+(obh-chh)/2,text,strlen(text));
break;
case G_BOXCHAR:
......@@ -773,7 +776,7 @@ if (drawbg) {
else flen-=ted->te_junk2;
} else ted->te_junk2=0;
y=oby+(obh+fontheight(ted->te_font))/2+fontbaseline(ted->te_font)-fontheight(ted->te_font);
y=oby+(obh-fontheight(ted->te_font))/2+fontbaseline(ted->te_font);
if(ted->te_just==TE_LEFT) x=obx;
else if(ted->te_just==TE_RIGHT) {
......
......@@ -15,11 +15,13 @@
#include "x11basic.h"
#include "variablen.h"
#include "xbasic.h"
#include "parameter.h"
#include "array.h"
#include "afunctions.h"
#include "mathematics.h"
#include "functions.h"
ARRAY f_smula(PARAMETER *plist, int e) {
static ARRAY f_smula(PARAMETER *plist, int e) {
ARRAY ergeb;
ergeb.typ=plist->typ;
ergeb.dimension=plist->integer;
......@@ -28,18 +30,18 @@ ARRAY f_smula(PARAMETER *plist, int e) {
array_smul(ergeb,plist[1].real);
return(ergeb);
}
ARRAY f_nullmat(PARAMETER *plist, int e) {
static ARRAY f_nullmat(PARAMETER *plist, int e) {
int dimlist[2]={plist[0].integer,plist[1].integer};
return(nullmatrix(FLOATTYP,e,dimlist));
}
ARRAY f_einsmat(PARAMETER *plist, int e) {
static ARRAY f_einsmat(PARAMETER *plist, int e) {
int dimlist[2]={plist[0].integer,plist[0].integer};
return(einheitsmatrix(FLOATTYP,2,dimlist));
}
/* Gleichungssystem loesen d=Mx x()=SOLVE(m(),d())*/
ARRAY f_solvea(PARAMETER *plist, int e) {
static ARRAY f_solvea(PARAMETER *plist, int e) {
ARRAY ergeb;
int anzzeilen,anzspalten;
ergeb.typ=plist[0].typ;
......@@ -57,7 +59,7 @@ ARRAY f_solvea(PARAMETER *plist, int e) {
return(ergeb);
}
#ifdef CONTROL
ARRAY f_csvgeta(char *pos) {
static ARRAY f_csvgeta(char *pos) {
int o=0,nn=0;
if(e>1) nn=plist[1].integer;
if(e>2) o=plist[2].integer;
......@@ -65,25 +67,57 @@ ARRAY f_csvgeta(char *pos) {
}
#endif
#ifdef TINE
ARRAY f_tinegeta(PARAMETER *plist, int e) {
static ARRAY f_tinegeta(PARAMETER *plist, int e) {
int o=0,nn=0;
if(e>1) nn=plist[1].integer;
if(e>2) o=plist[2].integer;
return(tinevget(plist[0].pointer,nn,o));
}
ARRAY f_tinehistorya(PARAMETER *plist, int e) {
static ARRAY f_tinehistorya(PARAMETER *plist, int e) {
return(tinehistory(plist[0].pointer,plist[1].integer,plist[2].integer));
}
#endif
#ifdef DOOCS
ARRAY doocsnames(char *n);
ARRAY f_doocsgeta(PARAMETER *plist, int e) {
static ARRAY f_doocsgeta(PARAMETER *plist, int e) {
int o=0,nn=0;
if(e>1) nn=plist[1].integer;
if(e>2) o=plist[2].integer;
return(doocsvget(plist[0].pointer,nn,o));
}
ARRAY f_doocsnames(PARAMETER *plist, int e) {
static ARRAY f_doocsnames(PARAMETER *plist, int e) {
return(doocsnames(plist[0].pointer));
}
#endif
/* Array funktionen */
const AFUNCTION pafuncs[]= { /* alphabetisch !!! */
{ F_CONST|F_ARGUMENT, "!nulldummy", (afunc) f_nop ,0,0 ,{0}},
{ F_CONST|F_PLISTE, "0" , f_nullmat ,2,2 ,{PL_INT,PL_INT}},
{ F_CONST|F_PLISTE, "1" , f_einsmat ,1,1 ,{PL_INT}},
#ifdef CONTROL
{ F_PLISTE, "CSGET" , f_csvgeta ,1,3 ,{PL_STRING,PL_INT,PL_INT}},
{ F_PLISTE, "CSVGET" , f_csvgeta ,1,3 ,{PL_STRING,PL_INT,PL_INT}},
#endif
{ F_CONST|F_SQUICK, "CVA" , string_to_array ,1,1 ,{PL_STRING}},
#ifdef DOOCS
{ F_PLISTE, "DOOCSGET" , f_doocsgeta ,1,3 ,{PL_STRING,PL_INT,PL_INT}},
{ F_PLISTE, "DOOCSNAMES" , f_doocsnames ,1,1 ,{PL_STRING}},
{ F_PLISTE, "DOOCSVGET" , f_doocsgeta ,1,3 ,{PL_STRING,PL_INT,PL_INT}},
#endif
{ F_CONST|F_AQUICK, "INV" , inv_array ,1,1 ,{PL_NARRAY}},
{ F_CONST|F_PLISTE, "SMUL" , f_smula ,2,2 ,{PL_ARRAY,PL_FLOAT}},
{ F_CONST|F_PLISTE, "SOLVE" , f_solvea ,2,2 ,{PL_ARRAY,PL_ARRAY}},
#ifdef TINE
{ F_PLISTE, "TINEGET" , f_tinegeta ,1,3 ,{PL_STRING,PL_INT,PL_INT}},
{ F_PLISTE, "TINEVGET" , f_tinegeta ,1,3 ,{PL_STRING,PL_INT,PL_INT}},
{ F_PLISTE, "TINEHISTORY" , f_tinehistorya ,3,3 ,{PL_STRING,PL_INT,PL_INT}},
#endif
{ F_CONST|F_AQUICK, "TRANS" , trans_array ,1,1 ,{PL_ARRAY}},
};
const int anzpafuncs=sizeof(pafuncs)/sizeof(AFUNCTION);
......@@ -7,12 +7,3 @@
*/
ARRAY f_smula(PARAMETER *plist, int e);
ARRAY f_nullmat(PARAMETER *plist, int e);
ARRAY f_einsmat(PARAMETER *plist, int e);
ARRAY f_solvea(PARAMETER *plist, int e);
ARRAY f_csvgeta(char *pos);
ARRAY f_tinegeta(PARAMETER *plist, int e);
ARRAY f_tinehistorya(PARAMETER *plist, int e);
ARRAY f_doocsgeta(PARAMETER *plist, int e);
ARRAY f_doocsnames(PARAMETER *plist, int e);
......@@ -14,6 +14,7 @@
#include "x11basic.h"
#include "variablen.h"
#include "parameter.h"
#include "xbasic.h"
#include "wort_sep.h"
#include "array.h"
......@@ -199,18 +200,6 @@ ARRAY einheitsmatrix(int typ, int dimension, int *dimlist) {
} else puts("Einheitsmatrix nicht definiert !");
return(ergebnis);
}
ARRAY nullmatrix(int typ, int dimension, int *dimlist) {
ARRAY ergebnis;
if(typ & INTTYP) {
ergebnis=create_int_array(dimension,dimlist,0);
} else if(typ & FLOATTYP) {
ergebnis=create_float_array(dimension,dimlist,0);
} else {
ergebnis=create_array(typ,dimension,dimlist);
}
return(ergebnis);
}
/* Uebernimmt einen Speicherbereich in ein Array */
static ARRAY form_array(int typ, int dimension, int *dimlist, char *inhalt) {
......@@ -237,7 +226,7 @@ static ARRAY form_array(int typ, int dimension, int *dimlist, char *inhalt) {
/* Mache ein ARRAY aus Konstante [1,2,3;4,5,6] */
ARRAY array_const(char *s) {
ARRAY array_const(const char *s) {
ARRAY ergebnis;
char t[strlen(s)+1],t2[strlen(s)+1],s2[strlen(s)+1];
int e,i=0,j=0,f,dx=0,dy,anz=1;
......@@ -263,11 +252,11 @@ ARRAY array_const(char *s) {
/*
printf("ARRAY-Const: %s\n",s);
printf("============\n");
printf("Dimension: %d\n",ergebnis->dimension);
printf("Typ: %d\n",ergebnis->typ);
printf("Dimension: %d\n",ergebnis.dimension);
printf("Typ: %d\n",ergebnis.typ);
printf("Dim: %dx%d \n",dy,dx);
printf("Anz: %d \n",anz);
*/
*/
ergebnis.pointer=malloc(ergebnis.dimension*INTSIZE+anz*typlaenge(ergebnis.typ));
if(ergebnis.typ & STRINGTYP) {
......@@ -284,10 +273,11 @@ ARRAY array_const(char *s) {
((int *)(ergebnis.pointer))[1]=dx;
}
i=j=0;
e=wort_sep(s,';',TRUE,t,s2);
e=wort_sep(s,';',TRUE,t,s2);
while(e) {
f=wort_sep(t,',',TRUE,t2,t);
while(f) {
// printf("t2=%s %g\n",t2,parser(t2));
if(ergebnis.typ & INTTYP) ((int *)(ergebnis.pointer+ergebnis.dimension*INTSIZE))[j]=(int)parser(t2);
else if(ergebnis.typ & FLOATTYP) ((double *)(ergebnis.pointer+ergebnis.dimension*INTSIZE))[j]=parser(t2);
else {
......@@ -537,7 +527,7 @@ void array_sub(ARRAY a1, ARRAY a2) {
int *pp1=(int *)(a1.pointer+a1.dimension*INTSIZE);
double *pp2=(double *)(a2.pointer+a2.dimension*INTSIZE);
for(j=0;j<anz;j++) pp1[j]-=(int)pp2[j];
} else puts("ERROR: inkompatible array type.");
} else xberror(96,""); /* inkompatible array type*/
}
......@@ -602,13 +592,16 @@ STRING array_to_string(ARRAY inhalt) {
ARRAY string_to_array(STRING in) {
ARRAY out;
int len,arraylen;
// memdump(in.pointer,in.len);
out.typ=((int *)in.pointer)[0];
out.dimension=((int *)in.pointer)[1];
len=INTSIZE*out.dimension;
out.pointer=in.pointer+2*sizeof(int);
arraylen=anz_eintraege(&out);
len+=arraylen*typlaenge(out.typ);
// printf("Array typ=%x dimension=%d\n",out.typ,out.dimension);
// printf("arraylen=%d\n",arraylen);
out.pointer=malloc(len);
......@@ -618,15 +611,18 @@ ARRAY string_to_array(STRING in) {
arraylen*typlaenge(out.typ));
if(out.typ & STRINGTYP) {
char *ppp=in.pointer+2*sizeof(int)+arraylen*typlaenge(out.typ);
char *ppp=in.pointer+2*sizeof(int)+INTSIZE*out.dimension+arraylen*typlaenge(out.typ);
STRING *a=(STRING *)(out.pointer+INTSIZE*out.dimension);
/* Alle Strings anlegen und pointer relozieren */
unsigned int i;
unsigned long offset;
// memdump(ppp,len);
for(i=0;i<arraylen;i++) {
offset=(unsigned long)a[i].pointer;
a[i].pointer=malloc(a[i].len);
// printf("%d:Offset=%d\n",i,offset);
a[i].pointer=malloc(a[i].len+1);
memcpy(a[i].pointer,ppp+offset,a[i].len);
a[i].pointer[a[i].len]=0;
}
}
return(out);
......@@ -641,7 +637,7 @@ ARRAY get_subarray(ARRAY *arr,int *indexliste) {
ARRAY ergebnis=*arr;
int *aindex=(int *)arr->pointer;
int bindex[arr->dimension];
int adim,dim,dim2=0,i,j,jj,k,anz=1,anz2;
int adim,dim2=0,i,j,jj,k,anz=1,anz2;
adim=arr->dimension;
if(adim) {
......@@ -685,29 +681,8 @@ ARRAY get_subarray(ARRAY *arr,int *indexliste) {
}
int anz_eintraege(ARRAY *a) {/* liefert Anzahl der Elemente in einem ARRAY */
int anz=1,j;
for(j=0;j<a->dimension;j++) anz=anz*((int *)a->pointer)[j];
return(anz);
}
int do_dimension(VARIABLE *v) { /* liefert Anzahl der Elemente in einem ARRAY */
/* printf("DODIM?: vnr=%d \n",vnr); */
if(v->typ & ARRAYTYP) {
return(anz_eintraege(v->pointer.a));
} else return(1);
}
void *arrayvarptr(int vnr, char *n,int size) {
if(vnr!=-1) {
int dim=variablen[vnr].pointer.a->dimension;
int indexliste[dim];
/* Index- Liste aufloesen */
make_indexliste(dim,n,indexliste);
return(arrayvarptr2(vnr,indexliste,size));
} else return(NULL);
}
// wird nicht mehr benoetigt
#if 0
void *arrayvarptr2(int vnr, int *indexliste,int size) {
int a=0,i=0;
if(vnr!=-1) {
......@@ -720,7 +695,7 @@ void *arrayvarptr2(int vnr, int *indexliste,int size) {
return(variablen[vnr].pointer.a->pointer+dim*INTSIZE+a*size);
} else return(NULL);
}
#endif
int make_indexliste(int dim, char *pos, int *index) {
char w1[strlen(pos)+1],w2[strlen(pos)+1];
......@@ -733,17 +708,11 @@ int make_indexliste(int dim, char *pos, int *index) {
flag=1;
break;
}
if(w1[0]==':' || w1[0]==0) {index[i]=-1;flag=1;}
if(*w1==':' || *w1==0) {index[i]=-1;flag=1;}
else index[i]=(int)parser(w1);
e=wort_sep(w2,',',TRUE,w1,w2);
}
return(flag);
}
void make_indexliste_plist(int dim, PARAMETER *p, int *index) {
while(--dim>=0) {
if(p[dim].typ==PL_INT) index[dim]=p[dim].integer;
else if(p[dim].typ==PL_FLOAT) index[dim]=(int)p[dim].real;
else printf("ERROR: Kein int!");
}
}
......@@ -13,12 +13,12 @@ ARRAY create_float_array(int dimension, int *dimlist,double value);
ARRAY create_string_array(int dimension, int *dimlist,STRING *value);
ARRAY nullmatrix(int , int ,int *);
ARRAY einheitsmatrix(int , int ,int *);
ARRAY array_const(char *);
ARRAY array_const(const char *);
ARRAY double_array(ARRAY *);