Skip to content

Commit

Permalink
Merge pull request #3 from kollokollo/master
Browse files Browse the repository at this point in the history
more improvements, including man-page and option to dump INLINE data to files
  • Loading branch information
mmuman committed Feb 2, 2016
2 parents c303b71 + 8fda3a4 commit 9c3fc24
Show file tree
Hide file tree
Showing 12 changed files with 242 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.GFA diff=gfa
70 changes: 53 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# The top level Makefile
# Makefile for GFALIST (c) Peter Backes
# Last modified by Markus Hoffmann 2014,2016

DISTRIB = ons
LIBNO=0.01
RELEASE=1

CC = gcc
# Cross-Compiler fuer MS WINDOWS
WINCC=i586-mingw32msvc-gcc
# Cross-Compiler fuer ATARI ST TOS
TOSCC=m68k-atari-mint-gcc

CFLAGS = -g3 -O2 -Wall
CFLAGS = -g3 -O2 -Wall
LFLAGS = -L.

# Directories
prefix=/usr
exec_prefix=${prefix}
BINDIR=${exec_prefix}/bin
MANDIR=${prefix}/share/man

# Precious targets
PRECIOUS = version.h
TARGETS = libsky.a gfalist
Expand All @@ -18,10 +31,11 @@ GFALIST_OBJS = gfalist.o charset.o

OBJS = $(SKY_OBJS) $(GFALIST_OBJS)

GB36_GEN = default2.out default4.out hell.out default.out default3.out \
default5.out sky.out
# Headerfiles which should be added to the distribution
HSRC=charset.h sky.h tables.h
CSRC= $(OBJS:.o=.c)
BINDIST= gfalist

GEN = $(GB36_GEN)

TRASH = core ons.spec.OLD

Expand All @@ -47,6 +61,10 @@ libsky.a: $(SKY_OBJS)

gfalist: $(GFALIST_OBJS)
$(CC) $(LFLAGS) $+ -o $@ -lsky
gfalist.exe: $(CSRC)
$(WINCC) $+ -o $@
gfalist.ttp: $(CSRC)
$(TOSCC) $+ -o $@

version.h: HISTORY verextr.sh $(SKY_OBJS)
sh verextr.sh -g $< $@
Expand All @@ -55,34 +73,52 @@ version.h: HISTORY verextr.sh $(SKY_OBJS)
$(CC) $(CFLAGS) -c $< -o $@

clean:
rm -f $(OBJS) $(TRASH) $(GEN)
rm -f $(OBJS) $(TRASH)

realclean: clean
rm -f $(TARGETS)
rm -f $(TARGETS) gfalist.exe gfalist.ttp gfalist_$(LIBNO)-$(RELEASE)_*.deb

clobber: realclean
rm -f $(PRECIOUS)

dist: MANIFEST HISTORY packdist.sh
sh packdist.sh -t $(DISTRIB) -m $< -v HISTORY,version.h -s ons.spec ck md


# For the debin package (created with checkinstall)

# Documentation files to be packed into the .deb file:
DEBDOC = README COPYING HISTORY
doc-pak : $(DEBDOC)
mkdir $@
cp $(DEBDOC) $@/

install : gfalist gfalist.1
install -s -m 755 gfalist $(BINDIR)/
install -m 644 gfalist.1 $(MANDIR)/man1/gfalist.1

uninstall :
rm -f $(BINDIR)/gfalist
rm -f $(MANDIR)/man1/gfalist.1


deb : $(BINDIST) doc-pak
sudo checkinstall -D --pkgname gfalist --pkgversion $(LIBNO) \
--pkgrelease $(RELEASE) \
--maintainer kollo@users.sourceforge.net \
--backup \
--pkggroup interpreters \
--pkglicense GPL --strip=yes --stripso=yes --reset-uids
rm -rf backup-*.tgz doc-pak

rpms: dist
sh packdist.sh -t $(DISTRIB) -v HISTORY,version.h mr

ons.spec: README HISTORY packdist.sh
sh packdist.sh -a README -v HISTORY,version.h -t $(DISTRIB) -s ons.spec fs

test: $(GEN)
@for i in $(GEN); do ls -l $$i; done

%.out: gb36test.a gfalist
ar xvo $< $*.gfa $*.lst
./gfalist -b -o $*.tmp $*.gfa
diff $*.lst $*.tmp > $@ || true
rm $*.gfa $*.lst $*.tmp

#DEPEND
gfalist: libsky.a
sky.o: sky.c sky.h tables.h
gfalist.o: gfalist.c charset.h sky.h tables.h version.h
gfalist.o: gfalist.c $(HSRC) version.h

1 change: 1 addition & 0 deletions description-pak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GFA-Basic .gfa file to .lst converter
File renamed without changes.
73 changes: 73 additions & 0 deletions gfalist.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
.TH gfalist 1 "06 May 2003"
.SH NAME
gfalist - Reads tokenized GFA BASIC version 3.x source files (.GFA) and converts them to human readable ASCII listings (.LST).

.SH SYNOPSIS
.B gfalist
\fR[\fB-o lstfile\fR]
.RB [ -vcthi ]
.RI gfafile

.SH DESCRIPTION
Reads an .gfa file as input. Produces a .lst (ASCII)
file as output.

.SH OPTIONS
.TP
.BI "\-o " file
Place output in file \c
.I file\c
\&. INLINE data will not be saved.
.TP
.BI "\-i "
Save INLINE data into separate files, named after the pointers, ending .inl.
.TP
.B -h,--help
makes
.B gfalist
print a short usage information and exit.
.TP
.B -v,--verbose
.B gfalist
prints information about its processing on Standard Error.

For detailed help and description of the implemented commands take a
look at the README file and manual which comes with the gfalist package.

.SH EXAMPLES
.nf
gfalist testme.gfa
prints the code to stdout
gfalist testme.gfa -o testme.lst
converts testme.gfa into testme.lst (ASCII listing)
gfalist testme.gfa > testme.lst
converts testme.gfa into testme.lst (ASCII listing) including
INLINE DATA converted to HEXDUMP
.fi

.SH LIMITATIONS
The support to GFA-BASIC version 3 is limited.

.SH VERSION
This Page was created for V.0.01

.SH AUTHOR
Copyright (C) 1992-2001 by Peter Backes.
Man-Page created by Markus Hoffmann

.SH COPYRIGHT
Copyright (C) 1992-2001 Peter Backes

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License, not any
earlier or later version.

This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more
details.
.SH "SEE ALSO"
OUR NEXT STEP -- The GFABASIC4 development package

6 changes: 5 additions & 1 deletion gfalist.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ int main(int argc, char *argv[])

gf4tp_init(output, rvsimp);

while ((opt = getopt(argc, argv, "o:vctVb")) != -1)
while ((opt = getopt(argc, argv, "o:vctVbih")) != -1)
switch (opt) {
case 'o': /* Output */
if (outfile != NULL) {
Expand All @@ -256,6 +256,10 @@ int main(int argc, char *argv[])
case 't': /* Timer */
flags |= TP_TIME;
break;
case 'i': /* save INLINE data into .inl files*/
flags |= TP_SAVEINLINE;
break;
case 'h': /* display short help and exit */
case 'V': /* display Version and exit */
#ifdef PAPAYA
output("GF4TP Part of OUR NEXT STEP, the GFABASIC4 devel package.\n"
Expand Down
13 changes: 7 additions & 6 deletions ons.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# RPM spec file for package OUR NEXT STEP
# RPM spec file for package OUR NEXT STEP (gfalist)
#
# Please send bugfixes or comments to <m.hoffmann@uni-bonn.de>.
# Please send bugfixes or comments to <kollo@users.sourceforge.net>.
#

Summary: The GFABASIC4 development package
Expand All @@ -11,9 +11,9 @@ Version: 0.01.a
Release: 1
License: GPL
Group: Development/Languages
Source: http://www-cip.uni-bonn.de/~hoffmann/X11-Basic/%{name}-%{version}.tar.gz
URL: http://www-cip.uni-bonn.de/~hoffmann/X11-Basic
Packager: Markus Hoffmann <m.hoffmann@uni-bonn.de>
Source: https://github.com/mmuman/gfalist
URL: https://github.com/mmuman/gfalist
Packager: Markus Hoffmann <kollo@users.sourceforge.net>
BuildRoot: %{_tmppath}/%{name}-%{version}-root

%description
Expand Down Expand Up @@ -59,6 +59,8 @@ test "$RPM_BUILD_ROOT" != / && rm -rf $RPM_BUILD_ROOT
%{_libdir}/libsky.a

%changelog
* 2016-01-29 update of URL / contact email

* Mon Sep 9 2002 Peter Backes <rtc@gmx.de> 0.00.a.pl11-1
- Removed version.h from package as it's not required.
- Replaced obsolete Copyright tag by License tag.
Expand All @@ -73,4 +75,3 @@ test "$RPM_BUILD_ROOT" != / && rm -rf $RPM_BUILD_ROOT

* Tue Sep 7 2001 Markus Hoffmann <m.hoffmann@uni-bonn.de>
- 1st release

71 changes: 61 additions & 10 deletions sky.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
#include <ctype.h> /* tolower() */
#include <assert.h> /* assert() */
#include <string.h> /* strncpy() */
#include <sys/types.h> /* open() */
#include <sys/stat.h> /* open() */
#include <unistd.h> /* open() */
#include <errno.h> /* write() */
#include <fcntl.h> /* open() */

#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef S_IRGRP
#define S_IRGRP 0
#endif

#include "sky.h"
#include "tables.h"
Expand All @@ -10,6 +22,19 @@ static int (*gf4tp_output)(const char *format, ...);
static unsigned char *(*gf4tp_resvar)(struct gfainf *gi, unsigned short type,
unsigned short var);

static void io_error(int e,char *n) { gf4tp_output("IO-ERROR #%d %s\n",e,n); }

/* Saves an area in memory starting at adr with length len to a file
with filename name. MH 2016, taken from X11-Basic
RETURNS: 0 on success and -1 on error */

static int bsave(const char *name, char *adr, size_t len) {
int fdis=open(name,O_CREAT|O_BINARY|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR|S_IRGRP);
if(fdis==-1) return(-1);
if(write(fdis,adr,len)==-1) io_error(errno,"write");
return(close(fdis));
}

void gf4tp_init(int (*output)(const char *format, ...),
unsigned char *(*resvar)(struct gfainf *gi,
unsigned short type,
Expand All @@ -20,8 +45,7 @@ void gf4tp_init(int (*output)(const char *format, ...),
}

unsigned char *gf4tp_tp(unsigned char *dst, struct gfainf *gi,
struct gfalin *gl, unsigned int flags)
{
struct gfalin *gl, unsigned int flags) {
/* Current source, marker, top and bottom pointers */
const unsigned char *src = gl->line, *mrk, *top = gl->line,
*bot = gl->line + gl->size;
Expand All @@ -39,6 +63,10 @@ unsigned char *gf4tp_tp(unsigned char *dst, struct gfainf *gi,
/* double conversion string */
char *dcs;
int num;

unsigned char *linestart=dst;


union {
unsigned long long int ull;
double d;
Expand Down Expand Up @@ -338,7 +366,7 @@ unsigned char *gf4tp_tp(unsigned char *dst, struct gfainf *gi,



while (src < bot)
while (src < bot) {
switch (pft = *src++) {
case 70:
src += (src - top) & 0x01;
Expand All @@ -364,13 +392,34 @@ unsigned char *gf4tp_tp(unsigned char *dst, struct gfainf *gi,
*/
src = mrk;

} else { /* Added hex printing of INLINE data / Markus Hoffmann 2013 */
printf("' ## INLINE: src=%p bot=%p",src,bot);
for (mrk = src; mrk < bot; mrk++) {
if((mrk-src)%16==0) printf("\n' $%04x: ",mrk-src);
printf("%02x ",*mrk);

} printf("\n' %d Bytes.\n",mrk-src);
} else {
/* treat INLINE data... */
if(flags&TP_SAVEINLINE) {
/* find out pointer name and save the data into file.... */
unsigned char filename[256];
unsigned char *p=linestart;
unsigned char *d=filename;
while(p<dst && *p==' ') p++;
while(p<dst && *p) {
if(*p==' ') *d++='-';
else if(*p=='%') *d++='.';
else if(*p==',') break;
else if(isprint(*p)) *d++=*p;
else *d++='_';
p++;
}
*d++='i';*d++='n';*d++='l';
*d=0;
bsave(filename,src,(size_t)(bot-src));
gf4tp_output("Saved INLINE data into file --> %s (%d bytes.)\n",filename,bot-src);
} else {
/* Added hex printing of INLINE data / Markus Hoffmann 2013 */
printf("' ## INLINE:");
for (mrk = src; mrk < bot; mrk++) {
if((mrk-src)%16==0) printf("\n' $%04x: ",mrk-src);
printf("%02x ",*mrk);
} printf("\n' %d Bytes.\n",mrk-src);
}
src = bot;
}
break;
Expand Down Expand Up @@ -553,6 +602,7 @@ unsigned char *gf4tp_tp(unsigned char *dst, struct gfainf *gi,
case 229: case 230: case 231: case 232: case 233:
case 234: case 235: case 236: case 237: case 238:
case 239:
// varstart=dst; /* save marker for variable name for INLINE*/
i = pft - 224;
v = *src++;
pushvar(dst, mrk, i, v, gi, gf4tp_resvar);
Expand All @@ -571,6 +621,7 @@ unsigned char *gf4tp_tp(unsigned char *dst, struct gfainf *gi,
while (*mrk != 0x00)
*dst++ = *mrk++;
}
}
*dst = '\0';
return dst;
}
Expand Down
1 change: 1 addition & 0 deletions sky.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define TP_VERB 0x04 /* Be verbose */
#define TP_TIME 0x08 /* Measure time */
#define TP_BUGEM 0x10 /* Emulate bugs */
#define TP_SAVEINLINE 0x20 /* Save INLINE data into .inl files */

struct gfahdr {
unsigned char resvd:7;
Expand Down
Loading

0 comments on commit 9c3fc24

Please sign in to comment.