- ginsh should work on systems that don't have libreadline (untested)
#ifndef GINSH_H
#define GINSH_H
#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
// yacc stack type
#define YYSTYPE ex
-#include <stdio.h>
-extern "C" {
-#include <readline/readline.h>
-#include <readline/history.h>
-}
-#include <ginac/ginac.h>
#include "ginsh_parser.h"
#define YY_INPUT(buf, result, max_size) (result = ginsh_input(buf, max_size))
#include "ginsh_parser.h"
#define YY_INPUT(buf, result, max_size) (result = ginsh_input(buf, max_size))
{
int result;
if (yy_current_buffer->yy_is_interactive) {
{
int result;
if (yy_current_buffer->yy_is_interactive) {
// Do we need to read a new line?
// Do we need to read a new line?
if (line_length == 0) {
// Free old line
if (line_length == 0) {
// Free old line
line_length -= actual;
line_ptr += actual;
result = actual;
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");
} else if (((result = fread(buf, 1, max_size, yyin)) == 0) && ferror(yyin))
YY_FATAL_ERROR("input in flex scanner failed");
#include <unistd.h>
#endif
#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 <map>
#include <string>
#include <stdexcept>
-#include <ginac/ginac.h>
#include "ginsh.h"
// Original readline settings
#include "ginsh.h"
// Original readline settings
return function(serial, es).eval(1);
}
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;
{
vector<registered_function_info>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
unsigned serial = 0;