18 #define READLINE_STATIC
25 #if defined(HAVE_DYN_RL)
30 char * (*fe_fgets_stdin)(
const char *pr,
char *
s,
int size)
38 #if defined(HAVE_READLINE) || defined(HAVE_DYN_RL) || defined(HAVE_LIBREADLINE)
41 #define STDOUT_FILENO 1
71 if (strncmp (
name, text, len) == 0)
80 if (strncmp (
name, text, len) == 0)
85 return ((
char *)
NULL);
93 #if (defined(HAVE_READLINE) || defined(HAVE_LIBREADLINE) || defined(HAVE_DYN_RL))
97 #include <sys/types.h>
104 typedef char * (*RL_PROC)(
const char*,int);
105 #ifdef READLINE_READLINE_H_OK
106 #include <readline/readline.h>
107 #ifdef HAVE_READLINE_HISTORY_H
108 #include <readline/history.h>
112 #ifdef RL_VERSION_MAJOR
113 #if (RL_VERSION_MAJOR >= 4)
114 #define USE_READLINE4
118 #ifndef USE_READLINE4
119 #define rl_filename_completion_function filename_completion_function
120 #define rl_completion_matches completion_matches
122 #ifndef READLINE_READLINE_H_OK
140 typedef char * (*PROC)();
156 #if defined(HAVE_DYN_RL)
160 char *(*fe_filename_completion_function)();
161 char *(* fe_readline) (
char *);
165 char **(*fe_completion_matches)(...);
181 #define x_rl_line_buffer (*fe_rl_line_buffer)
182 #define x_rl_completion_matches (*fe_completion_matches)
183 #define x_rl_filename_completion_function (*fe_filename_completion_function)
185 #define x_rl_line_buffer rl_line_buffer
186 #define x_rl_completion_matches rl_completion_matches
187 #define x_rl_filename_completion_function rl_filename_completion_function
192 #undef x_rl_line_buffer
193 #undef x_rl_completion_matches
196 m=(
char **)
malloc(2*
sizeof(
char*));
197 m[0]=(
char *)
malloc(end-start+2);
198 strncpy(
m[0],text,end-start+1);
220 for (
int i=
l-1;
i>=0;
i--) line[
i]=line[
i]&127;
228 strncpy(
s,line,
size);
246 #if !defined(HAVE_READLINE) && defined(HAVE_FEREAD)
265 #if defined(HAVE_DYN_RL)
275 line = (*fe_readline) ((
char*)pr);
281 for (
int i=
l-1;
i>=0;
i--) line[
i]=line[
i]&127;
285 (*fe_add_history) (line);
289 strncpy(
s,line,
size);
314 char *line=fgets(
s,
size,stdin);
317 for (
int i=strlen(line)-1;
i>=0;
i--) line[
i]=line[
i]&127;
325 case EBADF:
return NULL;
326 case EINTR:
return strcpy(
s,
"\n");
330 fprintf(stderr,
"fgets() failed with errno %d\n%s\n",errsv,strerror(errsv));
343 #if (defined(HAVE_READLINE) || defined(HAVE_LIBREADLINE)) && !defined(HAVE_DYN_RL) && !defined(HAVE_FEREAD)
359 char *fn=ttyname(fileno(stdin));
364 if(isatty(fileno(stdin)))
368 char *
p =
getenv(
"SINGULARHIST");
392 Warn(
"dynamic loading failed: %d\n",
res);
407 (*fe_using_history)();
408 char *
p =
getenv(
"SINGULARHIST");
411 (*fe_read_history) (
p);
420 char *fn=ttyname(fileno(stdin));
433 #if !defined(HAVE_READLINE) && defined(HAVE_FEREAD)
const CanonicalForm int s
char name(const Variable &v)
EXTERN_VAR CPPFunction * rl_attempted_completion_function
char * iiArithGetCmd(int)
EXTERN_VAR FILE * rl_outstream
char * fe_fgets_stdin_emu(const char *pr, char *s, int size)
VAR char ** fe_rl_readline_name
char ** singular_completion(char *text, int start, int end)
VAR char ** fe_rl_line_buffer
#define x_rl_filename_completion_function
VAR int(* fe_read_history)(char *)
char ** RL_CPPFunction(const char *, int, int)
VAR int(* fe_write_history)()
#define x_rl_completion_matches
char *(* RL_PROC)(const char *, int)
static char * fe_fgets_stdin_init(const char *pr, char *s, int size)
VAR void(* fe_using_history)()
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
char * fe_fgets(const char *pr, char *s, int size)
VAR CPPFunction ** fe_rl_attempted_completion_function
VAR int(* fe_history_total_bytes)()
char * command_generator(char *text, int state)
char * fe_fgets_stdin_drl(const char *pr, char *s, int size)
#define rl_completion_matches
char * fe_fgets_stdin_fe(const char *pr, char *s, int size)
EXTERN_VAR char * rl_line_buffer
char * fe_fgets_stdin_rl(const char *pr, char *s, int size)
#define rl_filename_completion_function
int history_total_bytes()
VAR void(* fe_add_history)(char *)
EXTERN_VAR char * rl_readline_name
char * fe_fgets_dummy(const char *, char *, int)
VAR FILE ** fe_rl_outstream
char * readline(const char *)
void * malloc(size_t size)