From dab53bee0de888619c55b9ff7d7427dda67d9186 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Wed, 17 Nov 1999 19:58:28 +0000 Subject: [PATCH] - put everything in "GiNaC" namespace - ginsh should work on systems that don't have libreadline (untested) --- ginsh/ginsh.h | 19 +++++++++++++++++++ ginsh/ginsh_lexer.ll | 23 +++++++++++++---------- ginsh/ginsh_parser.yy | 12 +----------- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/ginsh/ginsh.h b/ginsh/ginsh.h index fcd00390..bd65a6a7 100644 --- a/ginsh/ginsh.h +++ b/ginsh/ginsh.h @@ -22,6 +22,25 @@ #ifndef GINSH_H #define GINSH_H +#include +#include +#include + +#ifdef HAVE_READLINE_READLINE_H +extern "C" { +#include +} +#endif + +#ifdef HAVE_READLINE_HISTORY_H +extern "C" { +#include +} +#endif + +#include +using namespace GiNaC; + // yacc stack type #define YYSTYPE ex diff --git a/ginsh/ginsh_lexer.ll b/ginsh/ginsh_lexer.ll index 42a432b8..961c8564 100644 --- a/ginsh/ginsh_lexer.ll +++ b/ginsh/ginsh_lexer.ll @@ -28,16 +28,9 @@ %{ #include "config.h" -#include -extern "C" { -#include -#include -} #include -#include #include "ginsh.h" - #include "ginsh_parser.h" #define YY_INPUT(buf, result, max_size) (result = ginsh_input(buf, max_size)) @@ -131,9 +124,9 @@ static int ginsh_input(char *buf, int max_size) { int result; if (yy_current_buffer->yy_is_interactive) { - int actual; - +#ifdef HAVE_LIBREADLINE // Do we need to read a new line? + int actual; if (line_length == 0) { // Free old line @@ -164,7 +157,17 @@ static int ginsh_input(char *buf, int max_size) line_length -= actual; line_ptr += actual; result = actual; - +#else + printf("> "); fflush(stdout); + int c = '*', n; + for (n = 0; n < max_size && (c = getc(yyin)) != EOF && c != '\n'; ++n) + buf[n] = (char)c; + if (c == '\n') + buf[n++] = (char)c; + if (c == EOF && ferror(yyin)) + YY_FATAL_ERROR("input in flex scanner failed"); + result = n; +#endif } else if (((result = fread(buf, 1, max_size, yyin)) == 0) && ferror(yyin)) YY_FATAL_ERROR("input in flex scanner failed"); diff --git a/ginsh/ginsh_parser.yy b/ginsh/ginsh_parser.yy index dc282383..99478df7 100644 --- a/ginsh/ginsh_parser.yy +++ b/ginsh/ginsh_parser.yy @@ -35,20 +35,10 @@ #include #endif -#include -#include -#include - -extern "C" { -#include -#include -} - #include #include #include -#include #include "ginsh.h" // Original readline settings @@ -497,7 +487,7 @@ static ex f_ginac_function(const exprseq &es, int serial) return function(serial, es).eval(1); } -void ginsh_get_ginac_functions(void) +void GiNaC::ginsh_get_ginac_functions(void) { vector::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end(); unsigned serial = 0; -- 2.49.0