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/trunk/src/system/Basis/Implementation/Unix/posix-text-prim-io.sml
ViewVC logotype

Diff of /sml/trunk/src/system/Basis/Implementation/Unix/posix-text-prim-io.sml

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

revision 1714, Wed Nov 24 19:59:47 2004 UTC revision 1715, Wed Nov 24 20:27:30 2004 UTC
# Line 11  Line 11 
11  local  local
12      structure String = StringImp      structure String = StringImp
13      structure Int = IntImp      structure Int = IntImp
14        structure Position = PositionImp
15  in  in
16  structure PosixTextPrimIO : sig  structure PosixTextPrimIO : sig
17    
# Line 96  Line 97 
97            val closed = ref false            val closed = ref false
98            fun checkClosed () = if !closed then raise IO.ClosedStream else ()            fun checkClosed () = if !closed then raise IO.ClosedStream else ()
99            val len = String.size src            val len = String.size src
100            fun avail () = (len - !pos)            val plen = Position.fromInt len
101              fun avail () = len - !pos
102            fun readV n = let            fun readV n = let
103                  val p = !pos                  val p = !pos
104                  val m = Int.min(n, len-p)                  val m = Int.min(n, len-p)
# Line 118  Line 120 
120                      dst = buf, di = i };                      dst = buf, di = i };
121                m                m
122            end            end
123            fun getPos () = (checkClosed(); !pos)            fun getPos () = (checkClosed(); Position.fromInt (!pos))
124              fun setPos p =
125                  (checkClosed ();
126                   if p < 0 orelse p > plen then raise Subscript
127                   else pos := Position.toInt p)
128            in            in
129              PrimIO.RD{              PrimIO.RD{
130                  name      = "<string>",                  name      = "<string>",
# Line 131  Line 137 
137                  canInput  = SOME(fn () => (checkClosed(); true)),                  canInput  = SOME(fn () => (checkClosed(); true)),
138                  avail     = SOME o avail,                  avail     = SOME o avail,
139                  getPos    = SOME getPos,                  getPos    = SOME getPos,
140                  setPos    = SOME(fn i => (                  setPos    = SOME setPos,
141                                  checkClosed();                  endPos    = SOME(fn () => (checkClosed(); plen)),
                                 if (i < 0) orelse (len < i)  
                                   then raise Subscript  
                                   else ();  
                                 pos := i)),  
                 endPos    = SOME(fn () => (checkClosed(); len)),  
142                  verifyPos = SOME getPos,                  verifyPos = SOME getPos,
143                  close     = fn () => closed := true,                  close     = fn () => closed := true,
144                  ioDesc    = NONE                  ioDesc    = NONE

Legend:
Removed from v.1714  
changed lines
  Added in v.1715

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