Changeset 2027


Ignore:
Timestamp:
Jul 17, 2006, 9:40:42 PM (14 years ago)
Author:
orlov
Message:
  • Stream.Get-Line and StdIO.Read-Line! consider a line to be terminated

by any one of a line feed ('\n'), a carriage return ('\r'),
or a carriage return followed immediately by a linefeed.

  • New function Stream.Scanc.
Location:
to-imperative/trunk/library
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/library/StdIO/refal/StdIO.rf

    r1643 r2027  
    6060  <Lookup &Buffers s.channel> : stream =
    6161    <Get-Line stream> : \{
    62       e.line '\n' = e.line;
    63       v.line      = v.line;
     62      e.line '\r\n' = e.line;
     63      e.line '\n'   = e.line;
     64      e.line '\r'   = e.line;
     65      v.line        = v.line;
    6466    };
    6567  <Lib-Error (StdIO Read-Line!) "Channel is not open"> = $fail;
  • to-imperative/trunk/library/Stream/refal/Stream.rf

    r1643 r2027  
    8787
    8888
     89*** $func  Scanc  stream t1   = empty-or-t1;
     90
     91Scanc stream t1, {
     92  <Getc stream> : {
     93    t1 = t1;
     94    t2 = <Ungets stream t2>;
     95  };
     96  /*empty*/;
     97};
     98
     99
    89100*** $func Get-Delim stream t.delim = expr;
    90101
     
    106117*** $func Get-Line stream = expr;
    107118
    108 Get-Line stream = <Get-Delim stream '\n'>;
     119//Get-Line stream = <Get-Delim stream '\n'>;
     120
     121$func? Not-EOL t1 = ;
     122Not-EOL t1 = # t1 : \{ '\n'; '\r'; };
     123
     124Get-Line stream =
     125  <Get-While stream &Not-EOL> <Scanc stream '\r'> <Scanc stream '\n'>;
    109126
    110127
  • to-imperative/trunk/library/Stream/refal/Stream.rfi

    r1643 r2027  
    1111$func? Gets           stream s.n     = expr;
    1212$func  Ungets         stream expr    = ;
     13$func  Scanc          stream t1      = empty-or-t1;
    1314$func  Get-Delim      stream t.delim = expr;
    1415$func  Get-Line       stream         = expr;
Note: See TracChangeset for help on using the changeset viewer.