Changeset e860fa in git


Ignore:
Timestamp:
Apr 30, 2005, 4:41:31 PM (18 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
f45ec2ef6f63ae01a2bba579ec15408dab628fdc
Parents:
f5de432da81d07da14eedd6b7b34d0d515772c5f
Message:
*hannes: readlin stuff


git-svn-id: file:///usr/local/Singular/svn/trunk@7965 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/feread.cc

    rf5de43 re860fa  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: feread.cc,v 1.3 2005-01-13 15:22:24 Singular Exp $ */
     4/* $Id: feread.cc,v 1.4 2005-04-30 14:41:31 Singular Exp $ */
    55/*
    66* ABSTRACT: input from ttys, simulating fgets
     
    5050/* =                   static/dymanic readline                      = */
    5151/* ===================================================================*/
    52 #if defined(HAVE_READLINE) || defined(HAVE_DYN_RL)
     52#if defined(HAVE_READLINE) || defined(HAVE_DYN_RL) || defined(HAVE_LIBREADLINE)
    5353
    5454#include "../Singular/ipshell.h"
     
    9595/* ===================================================================*/
    9696/* some procedure are shared with "dynamic readline" */
    97 #if defined(HAVE_READLINE) && !defined(HAVE_FEREAD)
     97#if (defined(HAVE_READLINE) || defined(HAVE_LIBREADLINE) || defined(HAVE_DYN_RL)) && !defined(HAVE_FEREAD)
    9898#include <unistd.h>
    9999#include <stdio.h>
     
    157157*   array of matches, or NULL if there aren't any.
    158158*/
     159#if defined(HAVE_DYN_RL)
     160extern "C"
     161{
     162  int fe_init_dyn_rl();
     163  char *(*fe_filename_completion_function)(); /* 3 */
     164  char *(* fe_readline) ();                   /* 4 */
     165  void (*fe_add_history) ();                  /* 5 */
     166  char ** fe_rl_readline_name;                /* 6 */
     167  char **fe_rl_line_buffer;                   /* 7 */
     168  char **(*fe_completion_matches)();          /* 8 */
     169  CPPFunction **fe_rl_attempted_completion_function; /* 9 */
     170  FILE ** fe_rl_outstream;                    /* 10 */
     171  int (*fe_write_history) ();                 /* 11 */
     172  int (*fe_history_total_bytes) ();           /* 12 */
     173  void (*fe_using_history) ();                /* 13 */
     174  int (*fe_read_history) ();                  /* 14 */
     175
     176}
     177#endif
    159178char ** singular_completion (char *text, int start, int end)
    160179{
     
    162181     to complete.  Otherwise it may be the name of a file in the current
    163182     directory. */
    164   if (rl_line_buffer[start-1]=='"')
    165     return rl_completion_matches (text, (RL_PROC)rl_filename_completion_function);
    166   char **m=rl_completion_matches (text, (RL_PROC)command_generator);
     183#ifdef HAVE_DYN_RL
     184  #define x_rl_line_buffer (*fe_rl_line_buffer)
     185  #define x_rl_completion_matches (*fe_completion_matches)
     186  #define x_rl_filename_completion_function (*fe_filename_completion_function)
     187#else
     188  #define x_rl_line_buffer rl_line_buffer
     189  #define x_rl_completion_matches rl_completion_matches
     190  #define x_rl_filename_completion_function rl_filename_completion_function
     191#endif
     192  if (x_rl_line_buffer[start-1]=='"')
     193    return x_rl_completion_matches (text, (RL_PROC)x_rl_filename_completion_function);
     194  char **m=x_rl_completion_matches (text, (RL_PROC)command_generator);
     195#undef x_rl_line_buffer
     196#undef x_rl_completion_matches
    167197  if (m==NULL)
    168198  {
     
    175205}
    176206
     207#ifndef HAVE_DYN_RL
    177208char * fe_fgets_stdin_rl(char *pr,char *s, int size)
    178209{
     
    209240}
    210241#endif
     242#endif
    211243
    212244/* ===================================================================*/
     
    233265/* some procedure are shared with "static readline" */
    234266#if defined(HAVE_DYN_RL)
    235 extern "C"
    236 {
    237   extern void * fe_rl_hdl;
    238   extern char ** fe_rl_readline_name;
    239   char * fe_fgets_stdin_rl(char *pr,char *s, int size);
    240   int fe_init_dyn_rl();
    241   extern FILE ** fe_rl_outstream;
    242   void (*fe_add_history)(char *);
    243   char * (*fe_readline)(char *);
    244 }
    245 
    246267char * fe_fgets_stdin_drl(char *pr,char *s, int size)
    247268{
     
    297318static char * fe_fgets_stdin_init(char *pr,char *s, int size)
    298319{
    299 #if defined(HAVE_READLINE) && !defined(HAVE_FEREAD)
     320#if (defined(HAVE_READLINE) || defined(HAVE_LIBREADLINE)) && !defined(HAVE_DYN_RL) && !defined(HAVE_FEREAD)
    300321  /* Allow conditional parsing of the ~/.inputrc file. */
    301322  rl_readline_name = "Singular";
     
    345366    return fe_fgets_stdin(pr,s,size);
    346367  }
     368  else /* could load libreadline: */
     369  {
     370    /* Allow conditional parsing of the ~/.inputrc file. */
     371    *fe_rl_readline_name = "Singular";
     372    /* Tell the completer that we want a crack first. */
     373    *fe_rl_attempted_completion_function = (CPPFunction *)singular_completion;
     374    /* try to read a history */
     375    (*fe_using_history)();
     376    char *p = getenv("SINGULARHIST");
     377    if (p != NULL)
     378    {
     379      (*fe_read_history) (p);
     380    }
     381  }
    347382
    348383  /* set the output stream */
Note: See TracChangeset for help on using the changeset viewer.