Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/branches/SMLNJ/src/compiler/PervEnv/IO/text-io-fn.sml
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/compiler/PervEnv/IO/text-io-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 113, Fri Jun 5 19:41:21 1998 UTC revision 143, Mon Sep 7 21:46:44 1998 UTC
# Line 235  Line 235 
235                fun loop (v, strm) =                fun loop (v, strm) =
236                      if (V.length v = 0) then [] else v :: loop(bigInput strm)                      if (V.length v = 0) then [] else v :: loop(bigInput strm)
237                val data = V.concat (loop (bigInput strm))                val data = V.concat (loop (bigInput strm))
238                in                in data
                 (data, findEOS buf)  
239                end                end
240        (* Return SOME k, if k <= amount characters can be read without blocking. *)        (* Return SOME k, if k <= amount characters can be read without blocking. *)
241          fun canInput (strm as ISTRM(buf, pos), amount) = let          fun canInput (strm as ISTRM(buf, pos), amount) = let
# Line 289  Line 288 
288                          (* end case *))                          (* end case *))
289                        else false                        else false
290                (* end case *))                (* end case *))
291          fun mkInstream (reader, optData) = let          fun mkInstream (reader, data) = let
292                val PIO.RD{readVec, readVecNB, getPos, setPos, ...} = reader                val PIO.RD{readVec, readVecNB, getPos, setPos, ...} = reader
293                val readVec' = (case readVec                val readVec' = (case readVec
294                       of NONE => (fn _ => raise IO.BlockingNotSupported)                       of NONE => (fn _ => raise IO.BlockingNotSupported)
# Line 318  Line 317 
317                        closed = closedFlg, getPos = getPos, tail = ref more,                        closed = closedFlg, getPos = getPos, tail = ref more,
318                        cleanTag = tag                        cleanTag = tag
319                      }                      }
320                val buf = (case optData                val buf =
                      of NONE => IBUF{  
                             basePos = getPos(), data=empty,  
                             info=info, more=more  
                           }  
321  (** What should we do about the position in this case ?? **)  (** What should we do about the position in this case ?? **)
322  (** Suggestion: When building a stream with supplied initial data,  (** Suggestion: When building a stream with supplied initial data,
323   ** nothing can be said about the positions inside that initial   ** nothing can be said about the positions inside that initial
324   ** data (who knows where that data even came from!).   ** data (who knows where that data even came from!).
325   **)   **)
326                        | (SOME v) => IBUF{                          IBUF{
327                              basePos = NONE, data=v,                              basePos = NONE, data=data,
328                              info=info, more=more}                              info=info, more=more}
                     (* end case *))  
329                in                in
330                  ISTRM(buf, 0)                  ISTRM(buf, 0)
331                end                end
# Line 391  Line 385 
385                in                in
386                  terminate info;                  terminate info;
387                  Option.valOf (#setPos rd) fpos;                  Option.valOf (#setPos rd) fpos;
388                  mkInstream (PIO.RD rd, NONE)                  mkInstream (PIO.RD rd, empty)
389                end                end
390    
391        (** Text stream specific operations **)        (** Text stream specific operations **)
# Line 749  Line 743 
743              strm := strm'; v              strm := strm'; v
744            end            end
745      fun inputAll (strm : instream) = let      fun inputAll (strm : instream) = let
746            val (v, strm') = StreamIO.inputAll(!strm)            val (s as StreamIO.ISTRM(buf, _)) = !strm
747              val v = StreamIO.inputAll s
748            in            in
749              strm := strm'; v              strm := StreamIO.findEOS buf; v
750            end            end
751      fun canInput (strm, n) = StreamIO.canInput (!strm, n)      fun canInput (strm, n) = StreamIO.canInput (!strm, n)
752      fun lookahead (strm : instream) = (case StreamIO.input1(!strm)      fun lookahead (strm : instream) = (case StreamIO.input1(!strm)
# Line 792  Line 787 
787    
788    (** Open files **)    (** Open files **)
789      fun openIn fname =      fun openIn fname =
790            mkInstream(StreamIO.mkInstream(OSPrimIO.openRd fname, NONE))            mkInstream(StreamIO.mkInstream(OSPrimIO.openRd fname, empty))
791              handle ex => raise IO.Io{function="openIn", name=fname, cause=ex}              handle ex => raise IO.Io{function="openIn", name=fname, cause=ex}
792      fun openOut fname = let      fun openOut fname = let
793            val wr = OSPrimIO.openWr fname            val wr = OSPrimIO.openWr fname
# Line 811  Line 806 
806            end            end
807      fun outputSubstr (strm, ss) = StreamIO.outputSubstr (!strm, ss)      fun outputSubstr (strm, ss) = StreamIO.outputSubstr (!strm, ss)
808      fun openString src =      fun openString src =
809            mkInstream(StreamIO.mkInstream(OSPrimIO.strReader src, NONE))            mkInstream(StreamIO.mkInstream(OSPrimIO.strReader src, empty))
810              handle ex => raise IO.Io{function="openIn", name="<string>", cause=ex}              handle ex => raise IO.Io{function="openIn", name="<string>", cause=ex}
811    
812    (* the standard streams *)    (* the standard streams *)
# Line 819  Line 814 
814        structure SIO = StreamIO        structure SIO = StreamIO
815        fun mkStdIn () = let        fun mkStdIn () = let
816              val (strm as SIO.ISTRM(SIO.IBUF{info=SIO.INFO{cleanTag, ...}, ...}, _)) =              val (strm as SIO.ISTRM(SIO.IBUF{info=SIO.INFO{cleanTag, ...}, ...}, _)) =
817                    SIO.mkInstream(OSPrimIO.stdIn(), NONE)                    SIO.mkInstream(OSPrimIO.stdIn(), empty)
818              in              in
819                CleanIO.rebindCleaner (cleanTag, {                CleanIO.rebindCleaner (cleanTag, {
820                    init = fn () => (),                    init = fn () => (),

Legend:
Removed from v.113  
changed lines
  Added in v.143

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0