mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
Estimated hours taken: 0.5
Branches: main
library/string.m:
Fix a bug in string__contains_char which broke
Fergus's string quoting change, causing C compilation
errors due to ill-formed char constants in the generated
code. The C function strchr() considers the terminating
'\0' to be part of the string, so searches for '\0' were
always succeeded. In Mercury, the '\0' is just an
implementation detail, so it shouldn't be considered
to be part of the string.
Improve the efficiency of the Mercury version
of string__contains_char by not recomputing the
length of the string for each character.
tests/hard_coded/Mmakefile:
tests/hard_coded/contains_char.{m,exp}:
Test case.
2 lines
15 B
Plaintext
2 lines
15 B
Plaintext
test succeeded
|