Changeset f4edee in git


Ignore:
Timestamp:
Aug 13, 1999, 1:21:44 PM (25 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
e0c1011389506713adc137a01e7cb3051d1ac59d
Parents:
9fa15ad44663bb926f22bf8c03d6a601739127a3
Message:
* hannes:  made fe_fgets_stdin an function pointer instead of a macro


git-svn-id: file:///usr/local/Singular/svn/trunk@3430 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Singular/ChangeLog

    r9fa15a rf4edee  
     1Fri Aug 13 13:20:01 MET DST 1999 hannes
     2* made fe_fgets_stdin an function pointer instead of a macro
     3  ( febase.cc febase.h feread.cc misc.cc sing_mp.cc tesths.cc)
     4
    15Thu Aug 12 12:57:49 MET DST 1999 hannes
    26* integrated "spectrum" by Stefan Endrass, inactive by default
  • Singular/febase.cc

    r9fa15a rf4edee  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: febase.cc,v 1.78 1999-08-05 11:28:02 obachman Exp $ */
     4/* $Id: febase.cc,v 1.79 1999-08-13 11:21:42 Singular Exp $ */
    55/*
    66* ABSTRACT: i/o system
     
    6060;}
    6161BOOLEAN errorreported = FALSE;
    62 BOOLEAN feBatch = FALSE;
    6362char *  feErrors=NULL;
    6463int     feErrorsLen=0;
     
    261260{
    262261#ifdef HAVE_MPSR
    263   if (feBatch)
     262  if (fe_fgets_stdin==fe_fgets_dummy)
    264263  {
    265264    if (feErrors==NULL)
  • Singular/febase.h

    r9fa15a rf4edee  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: febase.h,v 1.34 1999-08-06 14:06:38 obachman Exp $ */
     6/* $Id: febase.h,v 1.35 1999-08-13 11:21:43 Singular Exp $ */
    77/*
    88* ABSTRACT: basic i/o
     
    6767#endif
    6868extern BOOLEAN errorreported;
    69 extern BOOLEAN fe_use_fgets;
    70 extern BOOLEAN feBatch;
    7169extern BOOLEAN feProt;
    7270extern BOOLEAN feWarn;
     
    173171#else
    174172#define PrintTCL(A,B,C) Print("TCL-Err:%s",C)
    175 #endif
    176 #endif
     173#endif /* HAVE_TCL */
     174#endif /* __MWERKS__ */
    177175
    178176char *  StringAppend(char *fmt, ...);
     
    229227
    230228/* feread.cc: */
    231 #ifdef HAVE_FEREAD
    232   //void fe_set_input_mode (void);
    233   //void fe_temp_set (void);
    234   //void fe_temp_reset (void);
    235   char * fe_fgets_stdin(char *pr,char *s, int size);
    236 #else
    237   #ifdef HAVE_READLINE
    238     void fe_set_input_mode (void);
    239     void fe_reset_input_mode (void);
    240     char * fe_fgets_stdin_rl(char *pr,char *s, int size);
    241     #define fe_fgets_stdin(p,A,B) fe_fgets_stdin_rl(p,A,B)
    242   #else
    243     #define fe_fgets_stdin(p,A,B) fgets(A,B,stdin)
     229
     230/* the interface for reading: */
     231extern  char * (*fe_fgets_stdin)(char *pr,char *s, int size);
     232
     233/* possible implementations: */
     234
     235  /* readline, linked in: */
     236  char * fe_fgets_stdin_rl(char *pr,char *s, int size);
     237
     238  /* emulated readline: */
     239  char * fe_fgets_stdin_emu(char *pr,char *s, int size);
     240
     241  /* fgets: */
     242  char * fe_fgets(char *pr,char *s, int size);
     243 
     244  #ifdef HAVE_TCL
     245  /* tcl: */
     246  char * fe_fgets_tcl(char *pr,char *s, int size);
    244247  #endif
    245 #endif
    246 #endif /* ifndef __MWERKS__ */
     248
     249  /* dummy (for batch mode): */
     250  char * fe_fgets_dummy(char *pr,char *s, int size);
     251
     252#endif /* c++ only */
    247253
    248254/* everything in between calls to these procedures is printed into a string
  • Singular/feread.cc

    r9fa15a rf4edee  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: feread.cc,v 1.20 1998-10-29 13:15:14 Singular Exp $ */
     4/* $Id: feread.cc,v 1.21 1999-08-13 11:21:43 Singular Exp $ */
    55/*
    66* ABSTRACT: input from ttys, simulating fgets
     
    1717
    1818
     19static char * fe_fgets_stdin_init(char *pr,char *s, int size);
     20char * (*fe_fgets_stdin)(char *pr,char *s, int size)
     21 = fe_fgets_stdin_init;
    1922#if defined(HAVE_READLINE) && !defined(HAVE_FEREAD)
    2023#include <unistd.h>
     
    5255#include "ipshell.h"
    5356
    54 BOOLEAN fe_use_fgets=FALSE;
     57char * fe_fgets_stdin_rl(char *pr,char *s, int size);
    5558
    5659
     
    112115}
    113116
    114 void fe_set_input_mode(void)
    115 {
     117void fe_reset_input_mode (void)
     118{
     119  char *p = getenv("SINGULARHIST");
     120  if (p != NULL)
     121  {
     122    if(history_total_bytes()!=0)
     123      write_history (p);
     124  }
     125}
     126
     127char * fe_fgets_stdin_rl(char *pr,char *s, int size)
     128{
     129  if (!BVERBOSE(V_PROMPT))
     130  {
     131    pr="";
     132  }
     133  mflush();
     134
     135  char *line;
     136  line = readline (pr);
     137
     138  if (line==NULL)
     139    return NULL;
     140
     141  if (*line!='\0')
     142  {
     143    add_history (line);
     144  }
     145  int l=strlen(line);
     146  if (l>=size-1)
     147  {
     148    strncpy(s,line,size);
     149  }
     150  else
     151  {
     152    strncpy(s,line,l);
     153    s[l]='\n';
     154    s[l+1]='\0';
     155  }
     156  free (line);
     157
     158  return s;
     159}
     160#endif
     161/*--------------------------------------------------------------*/
     162#if !defined(HAVE_READLINE) && defined(HAVE_FEREAD)
     163extern "C" {
     164char * fe_fgets_stdin_fe(char *pr,char *s, int size);
     165}
     166char * fe_fgets_stdin_emu(char *pr,char *s, int size)
     167{
     168  if (!BVERBOSE(V_PROMPT))
     169  {
     170    pr="";
     171  }
     172  mflush();
     173  return fe_fgets_stdin_fe(pr,s,size);
     174}
     175#endif
     176
     177static char * fe_fgets_stdin_init(char *pr,char *s, int size)
     178{
     179#if defined(HAVE_READLINE) && !defined(HAVE_FEREAD)
    116180  /* Allow conditional parsing of the ~/.inputrc file. */
    117181  rl_readline_name = "Singular";
     
    119183  rl_attempted_completion_function = (CPPFunction *)singular_completion;
    120184
    121   if(!fe_use_fgets)
    122   {
    123 
    124     /* set the output stream */
    125     if(!isatty(STDOUT_FILENO))
    126     {
    127       #ifdef atarist
    128         rl_outstream = fopen( "/dev/tty", "w" );
    129       #else
    130         rl_outstream = fopen( ttyname(fileno(stdin)), "w" );
    131       #endif
    132     }
    133 
    134     /* try to read a history */
    135     using_history();
    136     char *p = getenv("SINGULARHIST");
    137     if (p != NULL)
    138     {
    139       read_history (p);
    140     }
    141   }
    142 }
    143 
    144 void fe_reset_input_mode (void)
    145 {
     185  /* set the output stream */
     186  if(!isatty(STDOUT_FILENO))
     187  {
     188    #ifdef atarist
     189      rl_outstream = fopen( "/dev/tty", "w" );
     190    #else
     191      rl_outstream = fopen( ttyname(fileno(stdin)), "w" );
     192    #endif
     193  }
     194
     195  /* try to read a history */
     196  using_history();
    146197  char *p = getenv("SINGULARHIST");
    147198  if (p != NULL)
    148199  {
    149     if(!feBatch && !fe_use_fgets && (history_total_bytes()!=0))
    150       write_history (p);
    151   }
    152 }
    153 
    154 char * fe_fgets_stdin_rl(char *pr,char *s, int size)
    155 {
    156   if (feBatch)
    157     return NULL;
    158   if(fe_use_fgets)
    159   {
    160     #ifdef HAVE_TCL
    161     if (tclmode)
    162     {
    163       if(currRing!=NULL) PrintTCLS('P',pr);
    164       else               PrintTCLS('U',pr);
    165     }
    166     else
    167     #endif
    168     if (BVERBOSE(V_PROMPT))
    169     {
    170       PrintS(pr);
    171     }
    172     mflush();
    173     return fgets(s,size,stdin);
    174   }
    175 
    176   if (!BVERBOSE(V_PROMPT))
    177   {
    178     pr="";
    179   }
    180   mflush();
    181 
    182   char *line;
    183   line = readline (pr);
    184 
    185   if (line==NULL)
    186     return NULL;
    187 
    188   if (*line!='\0')
    189   {
    190     add_history (line);
    191   }
    192   int l=strlen(line);
    193   if (l>=size-1)
    194   {
    195     strncpy(s,line,size);
    196   }
    197   else
    198   {
    199     strncpy(s,line,l);
    200     s[l]='\n';
    201     s[l+1]='\0';
    202   }
    203   free (line);
    204 
    205   return s;
    206 }
    207 #endif
    208 /*--------------------------------------------------------------*/
     200    read_history (p);
     201  }
     202  fe_fgets_stdin=fe_fgets_stdin_rl;
     203  return(fe_fgets_stdin_rl(pr,s,size));
     204#endif
    209205#if !defined(HAVE_READLINE) && defined(HAVE_FEREAD)
    210 extern "C" {
    211 char * fe_fgets_stdin_fe(char *pr,char *s, int size);
    212 }
    213 char * fe_fgets_stdin(char *pr,char *s, int size)
    214 {
    215   if (feBatch)
    216     return NULL;
    217   if(fe_use_fgets)
    218   {
    219     #ifdef HAVE_TCL
    220     if (tclmode)
    221     {
    222       if(currRing!=NULL) PrintTCLS('P',pr);
    223       else               PrintTCLS('U',pr);
    224     }
    225     else
    226     #endif
    227     if (BVERBOSE(V_PROMPT))
    228     {
    229       PrintS(pr);
    230     }
    231     mflush();
    232     return fgets(s,size,stdin);
    233   }
    234 
    235   if (!BVERBOSE(V_PROMPT))
    236   {
    237     pr="";
    238   }
    239   mflush();
    240 
    241 
    242   return fe_fgets_stdin_fe(pr,s,size);
    243 }
    244 #endif
     206  fe_fgets_stdin=fe_fgets_stdin_emu;
     207  return(fe_fgets_stdin_emu(pr,s,size));
     208#endif
     209}
     210
     211/* fgets: */
     212char * fe_fgets(char *pr,char *s, int size)
     213{
     214  if (BVERBOSE(V_PROMPT))
     215  {
     216    fprintf(stdout,pr);
     217  }
     218  mflush();
     219  return fgets(s,size,stdin);
     220}
     221
     222#ifdef HAVE_TCL
     223/* tcl: */
     224char * fe_fgets_tcl(char *pr,char *s, int size)
     225{
     226  if(currRing!=NULL) PrintTCLS('P',pr);
     227  else               PrintTCLS('U',pr);
     228  mflush();
     229  return fgets(s,size,stdin);
     230}
     231#endif
     232
     233/* dummy (for batch mode): */
     234char * fe_fgets_dummy(char *pr,char *s, int size)
     235{
     236  return NULL;
     237}
  • Singular/misc.cc

    r9fa15a rf4edee  
    114114      #ifdef HAVE_FEREAD
    115115        #ifdef HAVE_ATEXIT
    116           fe_reset_input_mode();
     116          //fe_reset_input_mode();
    117117        #else
    118           fe_reset_input_mode(0,NULL);
     118          //fe_reset_input_mode(0,NULL);
    119119        #endif
    120120      #else
    121121        #ifdef HAVE_READLINE
    122           fe_reset_input_mode();
     122          //fe_reset_input_mode();
    123123        #endif
    124124      #endif
  • Singular/sing_mp.cc

    r9fa15a rf4edee  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: sing_mp.cc,v 1.25 1999-08-03 16:33:44 obachman Exp $ */
     4/* $Id: sing_mp.cc,v 1.26 1999-08-13 11:21:44 Singular Exp $ */
    55
    66/*
     
    276276      SI_LINK_SET_RW_OPEN_P(l);
    277277      l->data = (void *) link;
    278       feBatch=TRUE;
     278      fe_fgets_stdin=fe_fgets_dummy;
    279279      _exit(Batch_ReadEval(slCopy(l)));
    280280    }
  • Singular/tesths.cc

    r9fa15a rf4edee  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: tesths.cc,v 1.67 1999-08-06 14:06:41 obachman Exp $ */
     4/* $Id: tesths.cc,v 1.68 1999-08-13 11:21:44 Singular Exp $ */
    55
    66/*
     
    113113
    114114// mention only documented options here
    115 // or let help string start with // then option is like undocumented 
     115// or let help string start with // then option is like undocumented
    116116static struct sing_option sing_longopts[] =
    117117{
     
    194194#ifdef NDEBUG
    195195        && *(sopt->help) != '/'
    196 #endif 
     196#endif
    197197        )
    198198    {
     
    315315        case 'b':
    316316#ifdef HAVE_MPSR
    317           feBatch=TRUE;
     317          fe_fgets_stdin=fe_fgets_dummy;
    318318          mainSetSingOptionValue(LON_BATCH, (char*) 1);
    319319          break;
     
    334334        case 't':
    335335#if defined(HAVE_FEREAD) || defined(HAVE_READLINE)
    336           fe_use_fgets=TRUE;
     336          fe_fgets_stdin=fe_fgets;
    337337#endif
    338338          mainSetSingOptionValue(LON_NO_TTY, (char*) 1);
     
    340340
    341341        case 'd':
    342           sdb_flags = 1;
    343           break;
     342          sdb_flags = 1;
     343          break;
    344344
    345345        case 'v':
     
    356356#ifdef HAVE_TCL
    357357          tclmode = TRUE;
     358          fe_fgets_stdin=fe_fgets_tcl;
    358359          mainSetSingOptionValue(LON_TCLMODE, (char*) 1);
    359360          verbose|=Sy_bit(V_SHOW_MEM);
     
    436437            // print EmacsDir and InfoFile so that Emacs
    437438            // mode can pcik it up
    438             Warn("EmacsDir: %s", (feResource("EmacsDir") != NULL ?
    439                                   feResource("EmacsDir") : ""));
    440             Warn("InfoFile: %s", (feResource("InfoFile") != NULL ?
    441                                   feResource("InfoFile") : ""));
    442            
     439            Warn("EmacsDir: %s", (feResource('e' /*"EmacsDir"*/) != NULL ?
     440                                  feResource('e' /*"EmacsDir"*/) : ""));
     441            Warn("InfoFile: %s", (feResource('i' /*"InfoFile"*/) != NULL ?
     442                                  feResource('i' /*"InfoFile"*/) : ""));
    443443          }
    444444          else if (strcmp(longopts[option_index].name, LON_NO_RC) == 0)
     
    522522#endif /* HAVE_NAMESPACES */
    523523  }
    524   if (BVERBOSE(0) && !feBatch)
     524  if (BVERBOSE(0))
    525525  {
    526526    printf(
     
    542542  {
    543543    sdb_flags = 0;
    544     if (!feBatch)
    545     {
    546544#ifdef __MWERKS__
    547       memcpy(stderr,stdout,sizeof(FILE));
     545    memcpy(stderr,stdout,sizeof(FILE));
    548546#else
    549       dup2(1,2);
    550 #endif
    551     }
     547    dup2(1,2);
     548#endif
    552549  }
    553550  slStandardInit();
     
    567564  errorreported = 0;
    568565  mmMarkInitDBMCB();
    569 #ifndef macintosh
    570 #if defined(HAVE_READLINE)
    571   fe_set_input_mode();
    572 #endif
    573 #endif
    574566  setjmp(si_start_jmpbuf);
    575567
     
    624616
    625617  /* start shell */
    626   if (feBatch)
     618  if (fe_fgets_stdin==fe_fgets_dummy)
    627619  {
    628620#ifdef HAVE_MPSR
Note: See TracChangeset for help on using the changeset viewer.