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>
105 typedef char * (*RL_PROC)(
const char*,int);
106 #ifdef READLINE_READLINE_H_OK
107 #include <readline/readline.h>
108 #ifdef HAVE_READLINE_HISTORY_H
109 #include <readline/history.h>
113 #ifdef RL_VERSION_MAJOR
114 #if (RL_VERSION_MAJOR >= 4)
115 #define USE_READLINE4
119 #ifndef USE_READLINE4
120 #define rl_filename_completion_function filename_completion_function
121 #define rl_completion_matches completion_matches
123 #ifndef READLINE_READLINE_H_OK
141 typedef char * (*PROC)();
157 #if defined(HAVE_DYN_RL)
161 char *(*fe_filename_completion_function)();
162 char *(* fe_readline) (
char *);
166 char **(*fe_completion_matches)(...);
182 #define x_rl_line_buffer (*fe_rl_line_buffer)
183 #define x_rl_completion_matches (*fe_completion_matches)
184 #define x_rl_filename_completion_function (*fe_filename_completion_function)
186 #define x_rl_line_buffer rl_line_buffer
187 #define x_rl_completion_matches rl_completion_matches
188 #define x_rl_filename_completion_function rl_filename_completion_function
193 #undef x_rl_line_buffer
194 #undef x_rl_completion_matches
197 m=(
char **)
malloc(2*
sizeof(
char*));
198 m[0]=(
char *)
malloc(end-start+2);
199 strncpy(
m[0],text,end-start+1);
221 for (
int i=
l-1;
i>=0;
i--) line[
i]=line[
i]&127;
229 strncpy(
s,line,
size);
247 #if !defined(HAVE_READLINE) && defined(HAVE_FEREAD)
266 #if defined(HAVE_DYN_RL)
276 line = (*fe_readline) ((
char*)pr);
282 for (
int i=
l-1;
i>=0;
i--) line[
i]=line[
i]&127;
286 (*fe_add_history) (line);
290 strncpy(
s,line,
size);
315 char *line=fgets(
s,
size,stdin);
318 for (
int i=strlen(line)-1;
i>=0;
i--) line[
i]=line[
i]&127;
326 case EBADF:
return NULL;
327 case EINTR:
return strcpy(
s,
"\n");
331 fprintf(stderr,
"fgets() failed with errno %d\n%s\n",errsv,strerror(errsv));
344 #if (defined(HAVE_READLINE) || defined(HAVE_LIBREADLINE)) && !defined(HAVE_DYN_RL) && !defined(HAVE_FEREAD)
360 char *fn=ttyname(fileno(stdin));
366 if(isatty(fileno(stdin)))
371 char *
p =
getenv(
"SINGULARHIST");
397 Warn(
"dynamic loading failed: %d\n",
res);
412 (*fe_using_history)();
414 char *
p =
getenv(
"SINGULARHIST");
417 (*fe_read_history) (
p);
426 char *fn=ttyname(fileno(stdin));
439 #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 BOOLEAN using_history_called
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 *)
#define SINGULARHIST_FILE
void * malloc(size_t size)