Remove some autoconfig files, include nuttx/clock.h in global.c, main.c need to use the NuttX getopt not the system getopt_long

This commit is contained in:
Gregory Nutt 2014-11-01 17:35:27 -06:00
parent 810ea45656
commit 5f84e59abc
8 changed files with 114 additions and 8708 deletions

View File

@ -1,113 +0,0 @@
srcdir= @srcdir@
VPATH= @srcdir@
prefix= @prefix@
exec_prefix= @exec_prefix@
datarootdir= @datarootdir@
localedir= @localedir@
CC= @CC@
RANLIB= @RANLIB@
CFLAGS= @CFLAGS@
CPPFLAGS= @CPPFLAGS@ -DLOCALEDIR=\"$(localedir)\"
LDFLAGS= @LDFLAGS@
LIBS= @LIBS@
CATALOGS= de.mo
all: bas all-po-@USE_NLS@
all-po-no:
all-po-yes: $(CATALOGS)
bas: main.o libbas.a getopt.o getopt1.o
$(CC) -o $@ $(LDFLAGS) main.o libbas.a getopt.o getopt1.o $(LIBS)
token.c: token.l token.h
flex -i -t token.l >token.c
libbas.a: auto.o bas.o fs.o global.o token.o program.o \
str.o value.o var.o
rm -f $@
ar cq $@ auto.o bas.o fs.o global.o token.o program.o \
str.o value.o var.o
@RANLIB@ libbas.a
cppcheck:
cppcheck $(CPPFLAGS) -q --enable=all .
install-po: install-po-@USE_NLS@
install-po-no:
install-po-yes: $(CATALOGS)
for cat in $(CATALOGS); do \
dir=$(localedir)/`basename $$cat .mo`/LC_MESSAGES; \
[ -d $$dir ] || @INSTALL@ -m 755 -d $$dir; \
@INSTALL@ -m 644 $$cat $$dir/bas.mo; \
done
check: bas
for i in test/test*; do ./$$i || break; done
install: all
@INSTALL@ -m 755 -d @bindir@
@INSTALL@ bas @bindir@/bas
@INSTALL@ -m 755 -d @libdir@
@INSTALL@ -m 644 libbas.a @libdir@/libbas.a
@RANLIB@ @libdir@/libbas.a
@INSTALL@ -m 755 -d @mandir@/man1
@INSTALL@ -m 644 bas.1 @mandir@/man1/bas.1
make install-po
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
.SUFFIXES: .po .mo
.po.mo:
msgfmt -o $@ $<
*.po: bas.pot
for cat in *.po; do \
if msgmerge $$cat bas.pot -o $$cat.tmp; then \
mv -f $$cat.tmp $$cat; \
else \
echo "msgmerge for $$cat failed!"; \
rm -f $$cat.tmp; \
fi; \
done
bas.pot: [a-b]*.[ch] [e-s]*.[ch] v*.[ch]
xgettext --add-comments --keyword=_ [a-b]*.[ch] [e-s]*.[ch] v*.[ch] && test -f messages.po && mv messages.po $@
bas.pdf: bas.1
groff -Tps -t -man bas.1 | ps2pdf - $@
#{{{script}}}#{{{ clean
clean:
rm -f *.out core token.c *.o libbas.a *.mo
#}}}
#{{{ distclean
distclean: clean
rm -rf autom4te.cache bas config.cache config.h config.log config.status configure.lineno Makefile bas.1 test/runbas
#}}}
#{{{ tar
tar: bas.pdf distclean
(b=`pwd`; b=`basename $$b`; cd ..; tar zcvf $$b.tar.gz $$b/LICENSE $$b/INSTALL $$b/Makefile.in $$b/README $$b/NEWS $$b/configure $$b/install-sh $$b/test $$b/[a-z]*.*)
#}}}
#{{{ dependencies
auto.o: auto.c config.h auto.h programtypes.h var.h value.h str.h token.h autotypes.h program.h
bas.o: bas.c config.h getopt.h auto.h programtypes.h var.h value.h str.h token.h autotypes.h \
program.h bas.h error.h fs.h global.h statement.c statement.h
fs.o: fs.c config.h fs.h str.h
getopt.o: getopt.c config.h getopt.h
getopt1.o: getopt1.c config.h getopt.h
global.o: global.c config.h auto.h programtypes.h var.h value.h str.h token.h autotypes.h \
program.h bas.h error.h fs.h global.h
main.o: main.c config.h getopt.h bas.h
program.o: program.c config.h auto.h programtypes.h var.h value.h str.h token.h autotypes.h \
program.h error.h fs.h
statement.o: statement.c config.h statement.h
str.o: str.c config.h str.h
token.o: token.c config.h auto.h programtypes.h var.h value.h str.h token.h autotypes.h \
program.h statement.h
value.o: value.c config.h error.h value.h str.h
var.o: var.c config.h error.h var.h value.h str.h
#}}}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +0,0 @@
/* The version string */
#define VERSION @VERSION@
/* The package name. */
#define PACKAGE @PACKAGE@
/* Do you have tgetent()? */
#undef HAVE_TGETENT
/* Should we need to include termcap.h? */
#undef HAVE_TERMCAP_H
/* Should we need to include curses.h? */
#undef HAVE_CURSES_H
/* Is there a tgmath.h? */
#undef HAVE_TGMATH_H
/* Define this as 1 if your system has lrint(). */
#undef HAVE_LRINT
/* Define this as 1 if your system has nanosleep(). */
#undef HAVE_NANOSLEEP
/* What does tputs return? */
#undef TPUTS_RETURNS_VOID
/* Define as 1 if you use dmalloc. */
#undef USE_DMALLOC
/* Define as 1 if you want LR0 parser. */
#undef USE_LR0
/* Define either for large file support, if your OS needs them. */
#undef _FILE_OFFSET_BITS
#undef _LARGE_FILES
/* Define if you have the msgfmt(1) program and the gettext(3) function. */
#undef HAVE_GETTEXT
/* Define if timeouts do not work in your termios (broken termios). */
#undef USE_SELECT

File diff suppressed because it is too large Load Diff

View File

@ -1,141 +0,0 @@
AC_INIT(bas.c)
AC_CONFIG_HEADER(config.h)
AC_CANONICAL_HOST
VERSION=2.4
UPDATED='October 25, 2014'
ALL_LINGUAS="de"
case $host in
*-linux-*)
if test "$prefix" = NONE
then
prefix=/usr
AC_MSG_RESULT([using prefix $prefix])
fi
;;
hppa1.1-hp-hpux11.00)
EXTRA_CFLAGS='+O2 +Onolimit -D_XOPEN_SOURCE_EXTENDED '
EXTRA_LDFLAGS='-z '
EXTRA_GCFLAGS='-D_XOPEN_SOURCE_EXTENDED '
EXTRA_LDFLAGS='-Wl,-z '
;;
*-cygwin)
AC_DEFINE(USE_SELECT)
;;
*)
prefix=$ac_default_prefix
;;
esac
AC_PROG_CC
if test "$GCC" = yes
then
CFLAGS="${CFLAGS} ${EXTRA_GCFLAGS}-pipe -Wall -Wshadow -Wbad-function-cast -Wmissing-prototypes -Wstrict-prototypes -Wcast-align -Wcast-qual -Wpointer-arith -Wwrite-strings -Wmissing-declarations -Wnested-externs -Wundef -pedantic -fno-common"
LDFLAGS="${LDFLAGS} ${EXTRA_GLDFLAGS}-g"
else
CFLAGS="${CFLAGS} ${EXTRA_CFLAGS}"
LDFLAGS="${LDFLAGS} ${EXTRA_LDFLAGS}"
fi
AC_PROG_RANLIB
AC_CHECK_HEADERS(termcap.h,have_termcap_h=yes)
if test "$have_termcap_h" != yes; then
AC_CHECK_HEADERS(curses.h,have_curses_h=yes)
fi
AC_MSG_CHECKING(for tputs return type)
AC_TRY_COMPILE([#ifdef HAVE_TERMCAP_H
#include <termcap.h>
#else
#include <curses.h>
#endif
static int outc(int c){ return c; }
],[return tputs((char*)0,0,outc);
],AC_MSG_RESULT(int),AC_DEFINE(TPUTS_RETURNS_VOID) AC_MSG_RESULT(void))
AC_CHECK_FUNC(fmod, [have_fmod=yes])
if test "$have_fmod" != yes; then
AC_CHECK_LIB(m, fmod, [have_fmod=yes; LIBS="-lm $LIBS"])
fi
if test "$have_fmod" != yes
then
AC_MSG_RESULT([no fmod() found, configure failed.])
exit 1
fi
AC_CHECK_HEADERS(tgmath.h,have_tgmath_h=yes)
AC_CHECK_FUNCS(lrint)
AC_CHECK_FUNCS(nanosleep)
AC_CHECK_FUNCS(tgetent,have_tgetent=yes)
if test "$have_tgetent" != yes; then
AC_CHECK_LIB(curses, tgetent,AC_DEFINE(HAVE_TGETENT) have_tgetent=yes; LIBS="-lcurses $LIBS")
fi
if test "$have_tgetent" != yes; then
AC_CHECK_LIB(termcap, tgetent, AC_DEFINE(HAVE_TGETENT) [have_tgetent=yes; LIBS="-ltermcap $LIBS"])
fi
# The following applies to sick Linux distributions.
if test "$have_tgetent" != yes; then
AC_CHECK_LIB(ncurses, tgetent, AC_DEFINE(HAVE_TGETENT) [have_tgetent=yes; LIBS="-lncurses $LIBS"])
fi
AC_ARG_WITH(dmalloc,
[ --with-dmalloc=DIR dmalloc include/library installation prefix],
[CPPFLAGS="$CPPFLAGS -I$with_dmalloc/include"
LDFLAGS="$LDFLAGS -L$with_dmalloc/lib"
LIBS="$LIBS -ldmalloc"
AC_DEFINE(USE_DMALLOC)]
)
AC_ARG_WITH(efence,
[ --with-efence=DIR efence include/library installation prefix],
[CPPFLAGS="$CPPFLAGS -I$with_efence/include"
LDFLAGS="$LDFLAGS -L$with_efence/lib"
LIBS="$LIBS -lefence"]
)
AC_ARG_WITH(valgrind,
[ --with-valgrind run regression tests with valgrind],
[VALGRIND="valgrind"
AC_SUBST(VALGRIND)]
)
AC_MSG_CHECKING(whether to use LR0 parser)
AC_ARG_ENABLE(lr0,
[ --enable-lr0 use LR0 parser (default is recursive descending)],
[
case "$enableval" in
yes)
AC_DEFINE(USE_LR0)
AC_MSG_RESULT(yes)
;;
no)
AC_MSG_RESULT(no)
;;
esac],
[AC_MSG_RESULT(no)]
)
USE_NLS=no
AC_CHECK_PROG(MSGFMT,msgfmt,yes,no)
if test "$MSGFMT" = yes
then
AC_CHECK_HEADERS(libintl.h,[LIBINTL=yes])
if test "$LIBINTL" = yes
then
AC_SEARCH_LIBS(gettext,intl,[AC_DEFINE(HAVE_GETTEXT) USE_NLS=yes])
fi
fi
AC_SYS_LARGEFILE
AC_PROG_INSTALL
AC_DEFINE_UNQUOTED(VERSION,"$VERSION")
AC_SUBST(VERSION)
AC_SUBST(UPDATED)
AC_SUBST(USE_NLS)
AC_OUTPUT(Makefile bas.1 test/runbas)
chmod 755 test/runbas

View File

@ -31,8 +31,9 @@
#ifdef USE_DMALLOC
#include "dmalloc.h"
#endif
/*}}}*/
/* #defines */ /*{{{*/
#include <nuttx/clock.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

View File

@ -1,4 +1,3 @@
/* #includes */ /*{{{C}}}*//*{{{*/
#undef _POSIX_SOURCE
#define _POSIX_SOURCE 1
#undef _POSIX_C_SOURCE
@ -6,24 +5,25 @@
#include "config.h"
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#ifdef HAVE_GETTEXT
#include <libintl.h>
#define _(String) gettext(String)
# include <libintl.h>
# define _(String) gettext(String)
#else
#define _(String) String
# define _(String) String
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef USE_DMALLOC
#include "dmalloc.h"
# include "dmalloc.h"
#endif
#include "getopt.h"
#include "bas.h"
/*}}}*/
#ifdef CONFIG_BUILD_KERNEL
@ -32,88 +32,115 @@ int main(int argc, FAR char *argv[])
int bas_main(int argc, char *argv[])
#endif
{
/* variables */ /*{{{*/
char *runFile=(char*)0;
int usage=0,o;
const char *lp="/dev/null";
int backslash_colon=0;
int uppercase=0;
int restricted=0;
/* variables *//* {{{ */
char *runFile = (char *)0;
int usage = 0, o;
const char *lp = "/dev/null";
int backslash_colon = 0;
int uppercase = 0;
int restricted = 0;
int lpfd;
static struct option lopts[]=
{
{ "lp", required_argument, 0, 'l' },
{ "help", no_argument, 0, 'h' },
{ "restricted", no_argument, 0, 'r' },
{ "uppercase", no_argument, 0, 'u' },
{ "backslash-colon", no_argument, 0, 'b' },
{ "version", no_argument, 0, 'V' },
#if defined(__STDC__) && __STDC__
{ (const char*)0, 0, 0, '\0' }
#else
{ (char*)0, 0, 0, '\0' }
#endif
};
/*}}}*/
/* }}} */
#ifdef HAVE_GETTEXT
bindtextdomain("bas",LOCALEDIR);
bindtextdomain("bas", LOCALEDIR);
textdomain("bas");
#endif
/* parse arguments */ /*{{{*/
while ((o=getopt_long(argc,argv,"+bl:ruVh?",lopts,(int*)0))!=EOF) switch (o)
{
case 'b': backslash_colon=1; break;
case 'l': lp=optarg; break;
case 'u': uppercase=1; break;
case 'r': restricted=1; break;
case 'V': printf("bas %s\n", VERSION); exit(0); break;
case 'h': usage=2; break;
default: usage=1; break;
}
if (optind<argc) runFile=argv[optind++];
if (usage==1)
{
fputs(_("Usage: bas [-b] [-l file] [-r] [-u] [program [argument ...]]\n"),stderr);
fputs(_(" bas [--backslash-colon] [--lp file] [--restricted] [--uppercase] [program [argument ...]]\n"),stderr);
fputs(_(" bas -h|--help\n"),stderr);
fputs(_(" bas --version\n"),stderr);
fputs( "\n",stderr);
fputs(_("Try `bas -h' or `bas --help' for more information.\n"),stderr);
exit(1);
}
if (usage==2)
{
fputs(_("Usage: bas [-b] [-l file] [-u] [program [argument ...]]\n"),stdout);
fputs(_(" bas [--backslash-colon] [--lp file] [--restricted] [--uppercase] [program [argument ...]]\n"),stdout);
fputs(_(" bas -h|--help\n"),stdout);
fputs(_(" bas --version\n"),stdout);
fputs("\n",stdout);
fputs(_("BASIC interpreter.\n"),stdout);
fputs("\n",stdout);
fputs(_("-b, --backslash-colon convert backslashs to colons\n"),stdout);
fputs(_("-l, --lp write LPRINT output to file\n"),stdout);
fputs(_("-r, --restricted forbid SHELL\n"),stdout);
fputs(_("-u, --uppercase output all tokens in uppercase\n"),stdout);
fputs(_("-h, --help display this help and exit\n"),stdout);
fputs(_(" --version output version information and exit\n"),stdout);
fputs("\n",stdout);
fputs(_("Report bugs to <michael@moria.de>.\n"),stdout);
exit(0);
}
if ((lpfd=open(lp,O_WRONLY|O_CREAT|O_TRUNC,0666))==-1)
{
fprintf(stderr,_("bas: Opening `%s' for line printer output failed (%s).\n"),lp,strerror(errno));
exit(2);
}
bas_argc=argc-optind;
bas_argv=&argv[optind];
bas_argv0=runFile;
/*}}}*/
bas_init(backslash_colon,restricted,uppercase,lpfd);
if (runFile) bas_runFile(runFile);
else bas_interpreter();
/* parse arguments */
while ((o = getopt(argc, argv, ":bl:ruVh")) != EOF)
{
switch (o)
{
case 'b':
backslash_colon = 1;
break;
case 'l':
lp = optarg;
break;
case 'u':
uppercase = 1;
break;
case 'r':
restricted = 1;
break;
case 'V':
printf("bas %s\n", VERSION);
exit(0);
break;
case 'h':
usage = 2;
break;
default:
usage = 1;
break;
}
}
if (optind < argc)
{
runFile = argv[optind++];
}
if (usage == 1)
{
fputs(_("Usage: bas [-b] [-l file] [-r] [-u] [program [argument ...]]\n"),
stderr);
fputs(_(" bas [--backslash-colon] [--lp file] [--restricted] [--uppercase] [program [argument ...]]\n"),
stderr);
fputs(_(" bas -h|--help\n"), stderr);
fputs(_(" bas --version\n"), stderr);
fputs("\n", stderr);
fputs(_("Try `bas -h' or `bas --help' for more information.\n"), stderr);
exit(1);
}
if (usage == 2)
{
fputs(_("Usage: bas [-b] [-l file] [-u] [program [argument ...]]\n"),
stdout);
fputs(_(" bas [--backslash-colon] [--lp file] [--restricted] [--uppercase] [program [argument ...]]\n"),
stdout);
fputs(_(" bas -h|--help\n"), stdout);
fputs(_(" bas --version\n"), stdout);
fputs("\n", stdout);
fputs(_("BASIC interpreter.\n"), stdout);
fputs("\n", stdout);
fputs(_("-b, --backslash-colon convert backslashs to colons\n"), stdout);
fputs(_("-l, --lp write LPRINT output to file\n"), stdout);
fputs(_("-r, --restricted forbid SHELL\n"), stdout);
fputs(_("-u, --uppercase output all tokens in uppercase\n"),
stdout);
fputs(_("-h, --help display this help and exit\n"), stdout);
fputs(_(" --version output version information and exit\n"),
stdout);
fputs("\n", stdout);
fputs(_("Report bugs to <michael@moria.de>.\n"), stdout);
exit(0);
}
if ((lpfd = open(lp, O_WRONLY | O_CREAT | O_TRUNC, 0666)) == -1)
{
fprintf(stderr,
_("bas: Opening `%s' for line printer output failed (%s).\n"), lp,
strerror(errno));
exit(2);
}
bas_argc = argc - optind;
bas_argv = &argv[optind];
bas_argv0 = runFile;
bas_init(backslash_colon, restricted, uppercase, lpfd);
if (runFile)
{
bas_runFile(runFile);
}
else
{
bas_interpreter();
}
bas_exit();
return(0);
return (0);
}
/*}}}*/