[m-rev.] Fix read_from_string problem in lex.m

Ralph Becket rafe at cs.mu.OZ.AU
Tue Oct 29 14:16:34 AEDT 2002


Estimated hours taken: 0.2
Branches: main

extras/lex/lex.m:
	Fixed a problem whereby it was not possible to use
	read_from_string as intended.

Index: lex.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/lex/lex.m,v
retrieving revision 1.3
diff -u -r1.3 lex.m
--- lex.m	22 Jan 2002 05:05:16 -0000	1.3
+++ lex.m	29 Oct 2002 03:14:05 -0000
@@ -168,9 +168,13 @@
 :- mode read_from_stdin(in, out, di, uo) is det.
 
 :- pred read_from_string(offset, read_result, string, string).
-:- mode read_from_string(in, out, in, out) is det.
+:- mode read_from_string(in, out, di, uo) is det.
 
     % Generate a running instance of a lexer on some input source.
+    % If you want to lex strings, you must ensure they are unique
+    % by calling either copy/1 or unsafe_promise_unique/1 on the
+    % source string argument.
+    %
     % Note that you can't get the input source back until you stop
     % lexing.
     %
@@ -548,7 +552,7 @@
 
 %------------------------------------------------------------------------------%
 
-read_from_string(Offset, Result, String, String) :-
+read_from_string(Offset, Result, String, unsafe_promise_unique(String)) :-
     ( if   Offset < string__length(String)
       then Result = ok(string__unsafe_index(String, Offset))
       else Result = eof
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list