Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
bd2416ed
Commit
bd2416ed
authored
11 months ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[extlib] suppress deprecated string-suffix and string-prefix
parent
043b86c5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libraries/stdlib/extlib.ml
+8
-26
8 additions, 26 deletions
src/libraries/stdlib/extlib.ml
src/libraries/stdlib/extlib.mli
+0
-19
0 additions, 19 deletions
src/libraries/stdlib/extlib.mli
with
8 additions
and
45 deletions
src/libraries/stdlib/extlib.ml
+
8
−
26
View file @
bd2416ed
...
...
@@ -329,36 +329,18 @@ let temp_dir_cleanup_at_exit ?(debug=false) base =
(** Strings *)
(* ************************************************************************* *)
let
compare_strings
s1
s2
len
=
try
for
i
=
0
to
len
-
1
do
if
s1
.
[
i
]
<>
s2
.
[
i
]
then
raise
Exit
;
done
;
true
with
Exit
->
false
|
Invalid_argument
_
->
raise
(
Invalid_argument
"Extlib.compare_strings"
)
let
string_prefix
?
(
strict
=
false
)
prefix
s
=
let
add
=
if
strict
then
1
else
0
in
String
.
length
s
>=
String
.
length
prefix
+
add
&&
compare_strings
prefix
s
(
String
.
length
prefix
)
let
string_del_prefix
?
(
strict
=
false
)
prefix
s
=
if
s
tring
_prefix
~
strict
prefix
s
then
Some
(
String
.
sub
s
(
String
.
length
prefix
)
(
String
.
length
s
-
String
.
length
prefix
))
if
S
tring
.
starts_with
~
prefix
s
then
let
n
=
String
.
length
s
in
let
p
=
String
.
length
prefix
in
if
not
strict
||
n
>
p
then
Some
(
String
.
sub
s
p
(
n
-
p
))
else
None
else
None
let
string_suffix
?
(
strict
=
false
)
suffix
s
=
let
len
=
String
.
length
s
in
let
suf_len
=
String
.
length
suffix
in
let
strict_len
=
if
strict
then
suf_len
+
1
else
suf_len
in
len
>=
strict_len
&&
compare_strings
suffix
(
String
.
sub
s
(
len
-
suf_len
)
suf_len
)
suf_len
let
string_del_suffix
?
(
strict
=
false
)
suffix
s
=
if
string_suffix
~
strict
suffix
s
then
Some
(
String
.
sub
s
0
(
String
.
length
s
-
String
.
length
suffix
))
if
String
.
ends_with
~
suffix
s
then
let
n
=
String
.
length
s
in
let
p
=
String
.
length
suffix
in
if
not
strict
||
n
>
p
then
Some
(
String
.
sub
s
0
(
n
-
p
))
else
None
else
None
let
make_unique_name
mem
?
(
sep
=
" "
)
?
(
start
=
2
)
from
=
...
...
This diff is collapsed.
Click to expand it.
src/libraries/stdlib/extlib.mli
+
0
−
19
View file @
bd2416ed
...
...
@@ -193,30 +193,11 @@ val opt_map2: ('a -> 'b -> 'c) -> 'a option -> 'b option -> 'c option
(** {2 Strings} *)
(* ************************************************************************* *)
val
string_prefix
:
?
strict
:
bool
->
string
->
string
->
bool
[
@@
alert
deprecated
"Use String.starts_with instead"
]
(** [string_prefix ~strict p s] returns [true] if and only if [p] is a
prefix of the string [s]. If [strict] is true, the prefix must be strict
(that is, [s] must moreover be strictly longer than [p]). [strict]
is false by default.
@since Boron-20100401
@deprecated 28.0-Nickel use 'String.starts_with' instead
*)
val
string_del_prefix
:
?
strict
:
bool
->
string
->
string
->
string
option
(** [string_del_prefix ~strict p s] returns [None] if [p] is not a prefix of
[s] and Some [s1] iff [s=p^s1].
@since Oxygen-20120901 *)
val
string_suffix
:
?
strict
:
bool
->
string
->
string
->
bool
[
@@
alert
deprecated
"Use String.ends_with instead"
]
(** [string_suffix ~strict suf s] returns [true] iff [suf] is a suffix of
string [s]. [strict], which defaults to [false], indicates whether [s]
should be strictly longer than [p].
@since Aluminium-20160501
@deprecated 28.0-Nickel use 'String.ends_with' instead
*)
val
string_del_suffix
:
?
strict
:
bool
->
string
->
string
->
string
option
(** [string_del_suffix ~strict suf s] returns [Some s1] when [s = s1 ^ suf]
and None of [suf] is not a suffix of [s].
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment