Changeset 5ad50e in git


Ignore:
Timestamp:
Oct 13, 2016, 1:52:44 PM (8 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b52fc4b2495505785981d640dcf7eb3e456778ef')
Children:
0750b0232fb64224c4524f35243e993f0bbfc3fa
Parents:
2f0e59ef2bb6687c4bd3dca4c82a1d6283b28dec
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2016-10-13 13:52:44+02:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2016-10-13 13:53:27+02:00
Message:
fix for readline7: fix tr. #776

use fgets instead of readline if stdin is not a tty
Location:
kernel/oswrapper
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/oswrapper/feread.cc

    r2f0e59e r5ad50e  
    342342      rl_outstream = fopen( "/dev/tty", "w" );
    343343    #else
    344       rl_outstream = fopen( ttyname(fileno(stdout)), "w" );
     344      char *fn=ttyname(fileno(stdin));//if stdout is not a tty, maybe stdin is?
     345      if (fn!=NULL) rl_outstream = fopen( fn, "w" );
    345346    #endif
    346347  }
    347348
    348   /* try to read a history */
    349   using_history();
    350   char *p = getenv("SINGULARHIST");
    351   if (p != NULL)
    352   {
    353     read_history (p);
    354   }
    355   fe_fgets_stdin=fe_fgets_stdin_rl;
    356   return(fe_fgets_stdin_rl(pr,s,size));
     349  if(isatty(fileno(stdin)))
     350  {
     351    /* try to read a history */
     352    using_history();
     353    char *p = getenv("SINGULARHIST");
     354    if (p != NULL)
     355    {
     356      read_history (p);
     357    }
     358    fe_fgets_stdin=fe_fgets_stdin_rl;
     359    return(fe_fgets_stdin_rl(pr,s,size));
     360  }
     361  else
     362  {
     363    fe_fgets_stdin=fe_fgets;
     364    return(fe_fgets(pr,s,size));
     365  }
    357366#endif
    358367#ifdef HAVE_DYN_RL
     
    374383    return fe_fgets_stdin(pr,s,size);
    375384  }
    376   else /* could load libreadline: */
     385  else if (isatty(STDIN_FILENO))/*and could load libreadline: */
    377386  {
    378387    /* Allow conditional parsing of the ~/.inputrc file. */
     
    387396      (*fe_read_history) (p);
    388397    }
    389   }
    390 
    391   /* set the output stream */
    392   if(!isatty(STDOUT_FILENO))
    393   {
    394     #ifdef atarist
    395       *fe_rl_outstream = fopen( "/dev/tty", "w" );
    396     #else
    397       *fe_rl_outstream = fopen( ttyname(fileno(stdout)), "w" );
    398     #endif
    399   }
    400 
    401   fe_fgets_stdin=fe_fgets_stdin_drl;
    402   return fe_fgets_stdin_drl(pr,s,size);
     398
     399    /* set the output stream */
     400    if(!isatty(STDOUT_FILENO))
     401    {
     402      #ifdef atarist
     403        *fe_rl_outstream = fopen( "/dev/tty", "w" );
     404      #else
     405        char *fn=ttyname(fileno(stdin));//if stdout is not a tty, maybe stdin is?
     406        if (fn!=NULL) *fe_rl_outstream = fopen( fn, "w" );
     407      #endif
     408    }
     409    fe_fgets_stdin=fe_fgets_stdin_drl;
     410    return fe_fgets_stdin_drl(pr,s,size);
     411  }
     412  else
     413  {
     414    fe_fgets_stdin=fe_fgets;
     415    return fe_fgets(pr,s,size);
     416  }
    403417#else
    404418  #if !defined(HAVE_READLINE) && defined(HAVE_FEREAD)
  • kernel/oswrapper/fereadl.c

    r2f0e59e r5ad50e  
    804804    fe_read_history=dynl_sym(fe_rl_hdl,"read_history");
    805805    if (fe_read_history==NULL) { res=14; break; }
    806     return 0;
    807   }
    808   dynl_close(fe_rl_hdl);
    809   if (res==0)
     806    break;
     807  }
     808  if (res!=0) dynl_close(fe_rl_hdl);
     809  else
    810810  {
    811811    char *p;
Note: See TracChangeset for help on using the changeset viewer.