Files
mercury/tests/general/string_foldr_substring.exp
Peter Wang b1af59cb29 Deprecate string.substring, string.foldl_substring, etc. in favour of
Branches: main

Deprecate string.substring, string.foldl_substring, etc. in favour of
new procedures named string.between, string.foldl_between, etc.
The "between" procedures take a pair of [Start, End) endpoints instead
of Start, Count arguments.  The reasons for this change are:

- the "between" procedures are more convenient

- "between" should be unambiguous.  You can guess that it takes an End
  argument instead of a Count argument without looking up the manual.

- Count arguments necessarily counted code units, but when working with
  non-ASCII strings, almost the only way that the values would be arrived at
  is by substracting one end point from another.

- it paves the way for a potential change to replace string offsets with an
  abstract type.  We cannot do that if users regularly have to perform a
  subtraction between two offsets.

library/string.m:
	Add string.foldl_between, string.foldl2_between,
	string.foldr_between, string.between.

	Deprecate the old substring names.

	Replace string.substring_by_codepoint by string.between_codepoints.

compiler/elds_to_erlang.m:
compiler/error_util.m:
compiler/rbmm.live_variable_analysis.m:
compiler/timestamp.m:
extras/posix/samples/mdprof_cgid.m:
library/bitmap.m:
library/integer.m:
library/lexer.m:
library/parsing_utils.m:
mdbcomp/trace_counts.m:
profiler/demangle.m:
	Conform to changes.

tests/general/Mercury.options:
tests/general/string_foldl_substring.exp:
tests/general/string_foldl_substring.m:
tests/general/string_foldr_substring.exp:
tests/general/string_foldr_substring.m:
tests/hard_coded/Mercury.options:
tests/hard_coded/string_substring.m:
	Test both between and substring procedures.

tests/hard_coded/string_codepoint.exp:
tests/hard_coded/string_codepoint.exp2:
tests/hard_coded/string_codepoint.m:
	Update names in test outputs.

NEWS:
	Announce the change.
2011-06-15 01:05:34 +00:00

17 lines
673 B
Plaintext

sub("Hello, World!", 0, 5) = "Hello"
sub("Hello, World!", 0, 50) = "Hello, World!"
sub("Hello, World!", 0, -5) = ""
sub("Hello, World!", -5, 12) = "Hello, World"
sub("Hello, World!", -5, 50) = "Hello, World!"
sub("Hello, World!", 7, 0) = ""
sub("Hello, World!", 7, 12) = "World"
sub("Hello, World!", 50, 10) = ""
sub_old("Hello, World!", 0, 5) = "Hello"
sub_old("Hello, World!", 0, 50) = "Hello, World!"
sub_old("Hello, World!", 0, -5) = ""
sub_old("Hello, World!", -5, 12) = "Hello, World"
sub_old("Hello, World!", -5, 50) = "Hello, World!"
sub_old("Hello, World!", 7, 0) = ""
sub_old("Hello, World!", 7, 12) = "World!"
sub_old("Hello, World!", 50, 10) = ""