[m-rev.] diff: back out string module changes

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Jan 29 17:48:19 AEDT 2009


Back out Ralph's recent change to the string module since it breaks boostrapping
on 32-bit machines; the lexer is no longer able to recognise some hex literals
used within the compiler.

NEWS:
library/string.m:
 	Back out the change.

Julien.

Index: NEWS
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/NEWS,v
retrieving revision 1.500
diff -u -r1.500 NEWS
--- NEWS	28 Jan 2009 07:19:41 -0000	1.500
+++ NEWS	29 Jan 2009 06:42:22 -0000
@@ -33,11 +33,6 @@
  * A new module, parsing_utils, has been added to provide support for
    implementing recursive descent parsers.

-* The string.to_int family of predicates now fail (or throw an exception
-  for the det_ versions) if the number being converted is not in the range
-  [int.min_int+1, int.max_int], identifying overflow errors when
-  converting strings to ints.
-
  * We have added extra modes to many of the fold style predicates in the
    library in order to better support (mostly-)unique accumulators.

Index: library/string.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.277
diff -u -r1.277 string.m
--- library/string.m	28 Jan 2009 07:19:41 -0000	1.277
+++ library/string.m	29 Jan 2009 06:42:24 -0000
@@ -1,7 +1,7 @@
  %---------------------------------------------------------------------------%
  % vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
  %---------------------------------------------------------------------------%
-% Copyright (C) 1993-2009 The University of Melbourne.
+% Copyright (C) 1993-2008 The University of Melbourne.
  % This file may only be copied under the terms of the GNU Library General
  % Public License - see the file COPYING.LIB in the Mercury distribution.
  %---------------------------------------------------------------------------%
@@ -306,7 +306,6 @@

      % As above, but fail instead of throwing an exception if the
      % list contains a null character.
-    %
  :- pred string.semidet_from_char_list(list(char)::in, string::uo) is semidet.

      % Same as string.from_char_list, except that it reverses the order
@@ -324,14 +323,12 @@

      % Converts a signed base 10 string to an int; throws an exception
      % if the string argument does not match the regexp [+-]?[0-9]+
-    % or the number is not in the range [int.min_int+1, int.max_int].
      %
  :- func string.det_to_int(string) = int.

      % Convert a string to an int. The string must contain only digits,
      % optionally preceded by a plus or minus sign. If the string does
-    % not match this syntax or the number is not in the range
-    % [int.min_int+1, int.max_int], string.to_int fails.
+    % not match this syntax, string.to_int fails.
      %
  :- pred string.to_int(string::in, int::out) is semidet.

@@ -339,15 +336,13 @@
      % must contain one or more digits in the specified base, optionally
      % preceded by a plus or minus sign. For bases > 10, digits 10 to 35
      % are represented by the letters A-Z or a-z. If the string does not match
-    % this syntax or the number is not in the range
-    % [int.min_int+1, int.max_int], the predicate fails.
+    % this syntax, the predicate fails.
      %
  :- pred string.base_string_to_int(int::in, string::in, int::out) is semidet.

      % Converts a signed base N string to an int; throws an exception
      % if the string argument is not precisely an optional sign followed by
-    % a non-empty string of base N digits and the number is in the range
-    % [int.min_int+1, int.max_int].
+    % a non-empty string of base N digits.
      %
  :- func string.det_base_string_to_int(int, string) = int.

@@ -949,11 +944,9 @@

  :- pred accumulate_int(int::in, char::in, int::in, int::out) is semidet.

-accumulate_int(Base, Char, N0, N) :-
+accumulate_int(Base, Char, N, (Base * N) + M) :-
      char.digit_to_int(Char, M),
-    M < Base,
-    N = (Base * N0) + M,
-    N0 =< N.                             % Fail on overflow.
+    M < Base.

  % It is important to inline string.index and string.index_det.
  % so that the compiler can do loop invariant hoisting

--------------------------------------------------------------------------
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