From bcc5017524dea12048cdbf45635ee987f8e85acc Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Wed, 9 Jun 2004 13:23:55 -0600 Subject: [PATCH] Imported Debian patch 0.1beta-15 --- Makefile | 10 ++--- README | 26 +++++------ config.h | 31 +++++++++---- coree.c | 5 ++- coree.h | 1 + debian/README.debian | 14 ++++++ debian/changelog | 103 +++++++++++++++++++++++++++++++++++++++++++ debian/control | 30 +++++++++++++ debian/copyright | 26 +++++++++++ debian/dirs | 1 + debian/examples | 1 + debian/rules | 58 ++++++++++++++++++++++++ division.c | 11 ++++- file.c | 2 +- hello.yf | 5 +++ udio.c | 57 +++++------------------- ver.h | 2 +- yforth.1 | 17 +++++++ yforth.h | 4 +- 19 files changed, 324 insertions(+), 80 deletions(-) create mode 100644 debian/README.debian create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/examples create mode 100755 debian/rules create mode 100644 hello.yf create mode 100644 yforth.1 diff --git a/Makefile b/Makefile index f5d2108..cd86be7 100644 --- a/Makefile +++ b/Makefile @@ -12,16 +12,14 @@ INCLUDES = block.h blocke.h config.h core.h coree.h defaults.h double.h \ floate.h locals.h localse.h macro.h memall.h search.h searche.h \ string.h tools.h toolse.h udio.h ver.h ycore.h yforth.h -all: - make div - make yforth - -yforth: $(OBJECTS) +yforth: div.h $(OBJECTS) $(CC) $(MATHLIB) -o yforth $(OBJECTS) +div.h: div + ./div + div: division.c $(CC) -o div division.c - div > div.h .c.o: $(CC) -c -o $@ $(OPTIMIZE) $< diff --git a/README b/README index 95d5713..9c90456 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -yForth? v0.1beta - READ THIS (AND ONLY THIS) TO GET yForth? RUNNING. +yForth? v0.1+beta - READ THIS (AND ONLY THIS) TO GET yForth? RUNNING. 0) Hello world! Here's a little file which will help you having yForth? running in few @@ -23,11 +23,6 @@ In fact, you'll find that all the device dependent routines are grouped together in the file "udio.c". If you're using Turbo C, Borland C, or any compiler which supplies the "conio.h", you can define HAVE_CONIO in your "config.h" file and go. -Note that even if in file "udio.c" you'll see some lines telling you: -#ifdef HAVE_CURSES -or similar, yForth? actually doesn't support CURSES library. I've decided to -stop my work as soon as something machine depended that was too messy has -came around. 2) Where does the name yForth? came from? I've been charmed by Forth since the first time I "played" with it, but @@ -58,17 +53,15 @@ type which allows having 32bit Cells. Using Turbo C that's not possible. Below data definition you'll have to change the maximum values of your system. See "limits.h". - terminal -Finally, define HAVE_CONIO if you're using Turbo C, Borland C or GCC for DOS. -You'll have some nice words such as "page"... +Finally, define HAVE_CONIO to 1 if you're using Turbo C, Borland C or GCC +for DOS. You'll have some nice words such as "page"... - special functions "asinh", "acosh", "atanh" aren't provided by all the libraries, if you don't -have them delete the definitions at the end of "config.h". +have them reset the definitions at the end of "config.h". -The second thing to do now is configuring the "Makefile". I know, it's rude, -but yForth? is drifting on my system for too long, I want to finish it -within 1996. -At the moment "Makefile" is ready for GCC (under Linux), it's simple and -you won't find any problem modifying it. +The second thing to do now is configuring the "Makefile". At the moment +"Makefile" is ready for GCC (under Linux), it's simple and you won't find any +problem modifying it. Third, type "make all". Yes, that's all. @@ -128,3 +121,8 @@ Italy email: lpadovan@cs.unibo.it Enjoy yForth? + +********************************************************************** + CONTRIBUTORS +********************************************************************** + diff --git a/config.h b/config.h index 9bae024..5719247 100644 --- a/config.h +++ b/config.h @@ -15,6 +15,8 @@ * excluded word lists may be linked to final code if used by other words. */ +#include + #define COREE_DEF 1L #define DOUBLE_DEF 1L #define DOUBLEE_DEF 1L @@ -61,8 +63,10 @@ * it if your machine is big-endian (e.g. Motorola, Sparc...) * Note that some compilers have LITTLE_ENDIAN yet defined. */ -#ifndef LITTLE_ENDIAN +#if __BYTE_ORDER == __LITTLE_ENDIAN # define LITTLE_ENDIAN +#else +# undef LITTLE_ENDIAN #endif /* When DCELL_MEM is defined, double cell transfer is realized by memory @@ -77,9 +81,15 @@ * Under Linux, Cell may be "int" and DCell "long long". */ -#define Cell int +/* this might work for other 64 bit architectures, too? */ +#if defined(__alpha__) +# define Cell long +#else +# define Cell int +#endif /* __alpha__ */ + #define Char char -#define Real long double +#define Real float #define UCell unsigned Cell #define DCell long long @@ -102,8 +112,13 @@ #define MAX_F 0.0 /* Some compilers doesn't provide some functions in the standard library. - * If you don't have, undefine them - */ -#define HAVE_ACOSH -#define HAVE_ASINH -#define HAVE_ATANH + * If you don't have, turn 1s into 0s + */ +#define HAVE_ACOSH 1 +#define HAVE_ASINH 1 +#define HAVE_ATANH 1 + +/* Set following define to 1 if you're compiling under Turbo C, Borland C, + * or GCC for DOS. + */ +#define HAVE_CONIO 0 diff --git a/coree.c b/coree.c index 8acd708..5d160e0 100644 --- a/coree.c +++ b/coree.c @@ -159,15 +159,16 @@ void _nip() { } void _parse() { - register Char delim = (Char) *sp; + register Char delim = (Char) *sp; register Char *orig = &_input_buffer[_to_in]; register int i = 0; while (_to_in < _in_input_buffer && _input_buffer[_to_in] != delim) { _to_in++; i++; } - *sp = (Cell) orig; + *sp = (Cell)orig; *--sp = i; + if (_to_in < _in_input_buffer) _to_in++; } diff --git a/coree.h b/coree.h index c43a185..8f1ad50 100644 --- a/coree.h +++ b/coree.h @@ -67,6 +67,7 @@ code(u_greater_than, "u>", 0) code(unused, "unused", 0) code(within, "within", 0) code(backslash, "\\", IMMEDIATE) +code(backslash, "#!", IMMEDIATE) code(bracket_compile, "[compile]", COMP_ONLY) code(value, "value", 0) code(to, "to", IMMEDIATE) diff --git a/debian/README.debian b/debian/README.debian new file mode 100644 index 0000000..98d3047 --- /dev/null +++ b/debian/README.debian @@ -0,0 +1,14 @@ +yforth for DEBIAN +---------------------- + +This is a small implementation of the better part of the ANS Forth core +standard. It is less appropriate for hacking Forth scripts under Linux than, +say, gforth... but it has great promise, and I'm sufficiently interested in +playing with it for embedded environments that I've decided to go ahead and +package it. + +The author says it's "freeware", and you can do anything you want with it, +unencumbered even by the GPL. Enjoy. + + +Bdale Garbee , Sat, 1 Feb 1997 20:18:18 -0700 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..dbc46ed --- /dev/null +++ b/debian/changelog @@ -0,0 +1,103 @@ +yforth (0.1beta-15) unstable; urgency=low + + * add amd64 to control file, closes: #252783 + + -- Bdale Garbee Wed, 9 Jun 2004 13:23:55 -0600 + +yforth (0.1beta-14) unstable; urgency=low + + * patch from David N. Welton to make things work on big-endian machines + like powerpc, closes: #96207 + * a few cleanups to make lintian happier + + -- Bdale Garbee Mon, 7 May 2001 10:45:21 -0600 + +yforth (0.1beta-13) unstable; urgency=low + + * patch from Chris Chimelis to work on alpha architecture, closes: #65407 + + -- Bdale Garbee Sun, 18 Jun 2000 21:57:21 -0600 + +yforth (0.1beta-12) unstable; urgency=low + + * lose the dh_du call, closes: #51484 + * update to latest policy + + -- Bdale Garbee Sun, 5 Dec 1999 09:55:40 -0700 + +yforth (0.1beta-11) frozen unstable; urgency=low + + * Hartmut reminds me that yforth compiles and runs on powerpc as well. + + -- Bdale Garbee Tue, 26 Jan 1999 21:02:28 -0700 + +yforth (0.1beta-10) frozen unstable; urgency=low + + * update control file to account for yforth not working on 64 bit machines. + Instead of 'any', specify i386/m68k/sparc/arm. I *think* all of those + should work. Update documentation to include my best contact info for + the upstream author, and acknowledge that there is no longer an upstream + site for this package. Closes 32413. + + -- Bdale Garbee Tue, 26 Jan 1999 09:18:24 -0700 + +yforth (0.1beta-9) frozen unstable; urgency=low + + * return 0 on successful completion of main() in division.c, closes 32217 + + -- Bdale Garbee Fri, 22 Jan 1999 10:34:14 -0700 + +yforth (0.1beta-8) frozen unstable; urgency=low + + * fix a problem in the Makefile, closes 30065. + + -- Bdale Garbee Tue, 15 Dec 1998 00:18:52 -0700 + +yforth (0.1beta-7) frozen unstable; urgency=low + + * patch to Makefile from James Troup so '.' doesn't need to be in PATH, + closes 20990 + + -- Bdale Garbee Sat, 11 Apr 1998 12:37:39 -0600 + +yforth (0.1beta-6) frozen unstable; urgency=low + + * fix typos in description, closes 19007. + + -- Bdale Garbee Fri, 3 Apr 1998 22:20:45 -0700 + +yforth (0.1beta-5) unstable; urgency=low + + * change from debmake to debhelper + * fix errors and warnings from lintian + + -- Bdale Garbee Mon, 9 Feb 1998 22:17:38 -0700 + +yforth (0.1beta-4) unstable; urgency=low + + * libc6 + + -- Bdale Garbee Thu, 4 Sep 1997 03:19:14 -0600 + +yforth (0.1beta-3) unstable; urgency=low + + * Luca accepted my patch, and sent me back some other tweaks... + + -- Bdale Garbee Wed, 5 Feb 1997 08:08:58 -0700 + +yforth (0.1beta-2) unstable; urgency=low + + * Hack in "#!" as an alias for "\" to allow yforth to be used as a script + interpreter. + + -- Bdale Garbee Sun, 2 Feb 1997 12:07:13 -0700 + +yforth (0.1beta-1) unstable; urgency=low + + * Initial Release. + + -- Bdale Garbee Sat, 1 Feb 1997 20:18:18 -0700 + +Local variables: +mode: debian-changelog +End: diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..78cc3f6 --- /dev/null +++ b/debian/control @@ -0,0 +1,30 @@ +Source: yforth +Section: interpreters +Priority: extra +Maintainer: Bdale Garbee +Build-Depends: debhelper +Standards-Version: 3.6.1.0 + +Package: yforth +Architecture: alpha amd64 arm i386 m68k powerpc sparc +Depends: ${shlibs:Depends} +Description: A small freeware Forth environment in ANSI C + yForth? is an interestingly small implementation of Forth for Linux. It + suffers several deficiencies. For general Forth programming or learning + under Linux, yForth? is not the best choice. + . + From the author's README: + . + yForth? is a Forth environment written entirely in ANSI C, making it + extremely portable. The first thing I want to tell you about yForth? is + that it seems a joke compared to other systems such as gForth or PFE. + . + Nevertheless, you could find yForth? nice, in which case you're invited to + explore yForth? + . + It's yours, you can make anything you want with it. If you want an explanation + of the words provided by yForth? please refer to the draft of ANS Forth or + something equivalent. The Net will help you. + . + Do not expect the prompt "ok" to come up when you run yForth?, the standard + says that "ok" shall be printed AFTER every successful command execution... diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..85581e1 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,26 @@ +This package was debianized by Bdale Garbee bdale@gag.com on +Sat, 1 Feb 1997 20:18:18 -0700. + +The sources were retrieved from http://www.cs.unibo.it/~lpadovan/. + +It is not clear that Luca still maintains or develops yforth, as his web page +now just points to the Debian distribution for those interested in yforth. + +Written by + + Luca Padovani + v. Cormons, 12 + 48100 Ravenna (RA) + Italy + + email: lpadovan@cs.unibo.it + +Copyright: + +/* yForth? - Written by Luca Padovani (C) 1996/97 + * ------------------------------------------------------------------------ + * This software is FreeWare as long as it comes with this header in each + * source file, anyway you can use it or any part of it whatever + * you want. It comes without any warranty, so use it at your own risk. + * ------------------------------------------------------------------------ + */ diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..e772481 --- /dev/null +++ b/debian/dirs @@ -0,0 +1 @@ +usr/bin diff --git a/debian/examples b/debian/examples new file mode 100644 index 0000000..01fc080 --- /dev/null +++ b/debian/examples @@ -0,0 +1 @@ +hello.yf diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..f1beb4e --- /dev/null +++ b/debian/rules @@ -0,0 +1,58 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. + +# WARNING - the makefile for this package is not SMP-safe! Don't try +# to build this package with 'make -j' + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 + +build: build-stamp +build-stamp: + dh_testdir + $(MAKE) + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + -$(MAKE) clean + dh_clean + +# Build architecture-independent files here. +binary-indep: build + +# Build architecture-dependent files here. +binary-arch: build +# dh_testversion + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + install -g root -m 755 -o root yforth debian/tmp/usr/bin/yforth + + dh_installdocs + dh_installexamples + dh_installmenu +# dh_installinit + dh_installcron + dh_installmanpages +# dh_undocumented + dh_installchangelogs + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol +# dh_makeshlibs + dh_md5sums + dh_builddeb + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary diff --git a/division.c b/division.c index 2a40498..3e7e916 100644 --- a/division.c +++ b/division.c @@ -1,2 +1,11 @@ #include -main() { printf("#define FLOORED_DIVISION %d\n", (-10 % 7) > 0 ? 1 : 0); } +#include +#include + +main() { + FILE *f = fopen("div.h", "wt"); + assert(f != NULL); + fprintf(f, "#define FLOORED_DIVISION %d\n", (-10 % 7) > 0 ? 1 : 0); + fclose(f); + return 0; +} diff --git a/file.c b/file.c index ec01a2d..7e53a41 100644 --- a/file.c +++ b/file.c @@ -208,7 +208,7 @@ void _write_line() { /**************************************************************************/ Cell truncate_file(FILE *f, UDCell cur, UDCell ud) { - if (cur == cur && fseek(f, ud, SEEK_SET)) return (errno); + if (fseek(f, ud, SEEK_SET)) return (errno); else return (0); } diff --git a/hello.yf b/hello.yf new file mode 100644 index 0000000..9211feb --- /dev/null +++ b/hello.yf @@ -0,0 +1,5 @@ +#! /usr/bin/yforth +\ +\ a simple example of a yforth script +\ +.( Hello World!) cr bye diff --git a/udio.c b/udio.c index d3873a2..817391d 100644 --- a/udio.c +++ b/udio.c @@ -10,77 +10,59 @@ */ #include "yforth.h" -#ifdef HAVE_CONIO +#if HAVE_CONIO # include -#elifdef HAVE_CURSES -# include #endif #include "udio.h" /* d_clrscr: clear the screen */ void d_clrscr() { -#ifdef HAVE_CONIO +#if HAVE_CONIO clrscr(); -#elifdef HAVE_CURSES - clear(); #endif } /* d_clreol: clear to end of line */ void d_clreol() { -#ifdef HAVE_CONIO +#if HAVE_CONIO clreol(); -#elifdef HAVE_CURSES - clrtoeol(); #endif } /* d_setattr: set default attributes */ void d_setaddr(Cell attr) { -#ifdef HAVE_CONIO +#if HAVE_CONIO textattr(attr); -#elifdef HAVE_CURSES #endif } /* d_getattr: get default attributes */ Cell d_getattr() { -#ifdef HAVE_CONIO +#if HAVE_CONIO struct text_info ti; gettextinfo(&ti); return (ti.attribute); -#elifdef HAVE_CURSES #endif } /* d_gotoxy: move the cursor to the location (x, y) of the screen */ void d_gotoxy(Cell x, Cell y) { -#ifdef HAVE_CONIO +#if HAVE_CONIO gotoxy(x, y); -#elifdef HAVE_CURSES - move(y, x); #endif } /* d_wherex: current column position of the cursor */ Cell d_wherex() { -#ifdef HAVE_CONIO +#if HAVE_CONIO return (wherex()); -#elifdef HAVE_CURSES - int x, y; - getyx(stdscr, y, x); - return ((Cell) x); #endif } /* d_wherey: current row position of the cursor */ Cell d_wherey() { -#ifdef HAVE_CONIO +#if HAVE_CONIO return (wherey()); -#elifdef HAVE_CURSES - int x, y; - getyx(stdscr, y, x); - return ((Cell) y); #endif } @@ -89,39 +71,24 @@ Cell d_wherey() { * Return */ Char d_getch() { -#ifdef HAVE_CONIO - return (getch()); -#elifdef HAVE_CURSES +#if HAVE_CONIO return (getch()); #endif } /* d_kbhit: return True if a character is available */ Cell d_kbhit() { -#ifdef HAVE_CONIO +#if HAVE_CONIO return (kbhit()); -#elifdef HAVE_CURSES - return (1); -#endif +#endif } /* d_open: Initialize the Input/Output device */ void d_open() { -#ifdef HAVE_CURSES - initscr(); - cbreak(); - noecho(); - nonl(); - /* intrflush(stdscr, FALSE); */ - /* keypad(stdscr, TRUE); */ -#endif -} +} /* d_close: make some work when program finish to restore Input/Output device */ void d_close() { -#ifdef HAVE_CURSES - endwin(); -#endif } diff --git a/ver.h b/ver.h index 14fa71b..4fce7be 100644 --- a/ver.h +++ b/ver.h @@ -10,5 +10,5 @@ #define VER_HI 0 #define VER_LO 1 -#define VER_TEST "beta" +#define VER_TEST "+beta" diff --git a/yforth.1 b/yforth.1 new file mode 100644 index 0000000..79fbdd9 --- /dev/null +++ b/yforth.1 @@ -0,0 +1,17 @@ +.TH YFORTH 1 +.SH NAME +yforth \- a small, free Forth implementation +.SH SYNOPSIS +.B yforth +.SH DESCRIPTION +This is a small implementation of the Forth programming language, somewhat +easier to read than larger Forth implementations like Gforth. + +It is not being actively developed or maintained. If you find it useful, +great. If not, don't expect much help. The www.forth.org site is a good +place to get more general information on Forth. + +Serious Forth authors would be advised to use Gforth instead of this package. + +.SH AUTHOR +This man page was cobbled up for the Debian distribution by Bdale Garbee. diff --git a/yforth.h b/yforth.h index abdef54..00d77be 100644 --- a/yforth.h +++ b/yforth.h @@ -126,8 +126,8 @@ void put_dcell(Cell *ptr, DCell d); # define GET_DCELL(ptr) get_dcell((Cell *) ptr) # define PUT_DCELL(ptr, d) put_dcell((Cell *) ptr, (DCell) d) # else -# define GET_DCELL(ptr) *((DCell *) ptr) -# define PUT_DCELL(ptr, d) *((DCell *) ptr) = d +# define GET_DCELL(ptr) *((DCell *) (ptr)) +# define PUT_DCELL(ptr, d) *((DCell *) (ptr)) = d # endif #else # ifdef LITTLE_ENDIAN -- 2.30.2