]> www.ginac.de Git - ginac.git/commitdiff
- put everything in "GiNaC" namespace
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 17 Nov 1999 19:58:28 +0000 (19:58 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 17 Nov 1999 19:58:28 +0000 (19:58 +0000)
- ginsh should work on systems that don't have libreadline (untested)

ginsh/ginsh.h
ginsh/ginsh_lexer.ll
ginsh/ginsh_parser.yy

index fcd00390d9c7dc64d9de3610cab8342992a46249..bd65a6a752c7a0c122e82b4185ad285464dbcbc0 100644 (file)
 #ifndef GINSH_H
 #define GINSH_H
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef HAVE_READLINE_READLINE_H
+extern "C" {
+#include <readline/readline.h>
+}
+#endif
+
+#ifdef HAVE_READLINE_HISTORY_H
+extern "C" {
+#include <readline/history.h>
+}
+#endif
+
+#include <ginac/ginac.h>
+using namespace GiNaC;
+
 // yacc stack type
 #define YYSTYPE ex
 
index 42a432b8afbb0c3ed257df0c1a05aa879bc7a628..961c8564c1af4179183bf958a65b2d9c3987d78d 100644 (file)
 %{
 #include "config.h"
 
-#include <stdio.h>
-extern "C" {
-#include <readline/readline.h>
-#include <readline/history.h>
-}
 #include <map>
 
-#include <ginac/ginac.h>
 #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");
 
index dc282383a405876e30eecde9275e02be2ac22c45..99478df7ecbc44a67ee2095b03b3ee1066a5cf5a 100644 (file)
 #include <unistd.h>
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-extern "C" {
-#include <readline/readline.h>
-#include <readline/history.h>
-}
-
 #include <map>
 #include <string>
 #include <stdexcept>
 
-#include <ginac/ginac.h>
 #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<registered_function_info>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
        unsigned serial = 0;