[m-rev.] For review: pretty print c_pointers as addresses

Mark Brown mark at csse.unimelb.edu.au
Tue Aug 22 13:55:31 AEST 2006


On 22-Aug-2006, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> On Tue, 22 Aug 2006, Mark Brown wrote:
> >library/string.m:
> >	Export c_pointer_to_string for getting a string representation
> >	of the pointer address.
> >
> For consistency with the rest of the library I would add
> string.from_c_pointer as a synonym.

Okay.  I've added a NEWS entry too.

Cheers,
Mark.

Estimated hours taken: 0.1
Branches: main

library/string.m:
	Add string.from_c_pointer as a synonym for string.c_pointer_to_string,
	for consistency with other similar predicates/functions.

NEWS:
	Mention the new predicates/functions.

Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.419
diff -u -r1.419 NEWS
--- NEWS	17 Aug 2006 01:36:06 -0000	1.419
+++ NEWS	22 Aug 2006 03:46:55 -0000
@@ -17,6 +17,8 @@
 * We have added io.update_globals/3 which allows for atomic updates to
   the globals field in the I/O state in the presence of multiple threads.
 
+* We have added string.c_pointer_to_string/{1,2} and string.from_c_pointer/1
+  to convert c_pointers to a human readable form.
 
 DETAILED LISTING
 ================
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.247
diff -u -r1.247 string.m
--- library/string.m	22 Aug 2006 02:33:42 -0000	1.247
+++ library/string.m	22 Aug 2006 03:45:04 -0000
@@ -181,6 +181,10 @@
 :- func string.c_pointer_to_string(c_pointer::in) = (string::uo) is det.
 :- pred string.c_pointer_to_string(c_pointer::in, string::uo) is det.
 
+    % A synonym for string.c_pointer_to_string/1.
+    %
+:- func string.from_c_pointer(c_pointer::in) = (string::uo) is det.
+
     % string.first_char(String, Char, Rest) is true iff Char is the first
     % character of String, and Rest is the remainder.
     %
@@ -3972,6 +3976,9 @@
 string.c_pointer_to_string(P) = S :-
     string.c_pointer_to_string(P, S).
 
+string.from_c_pointer(P) = S :-
+    string.c_pointer_to_string(P, S).
+
 string.replace_all(S1, S2, S3) = S4 :-
     string.replace_all(S1, S2, S3, S4).
 
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list