Skip to content

Commit 7a2487a

Browse files
committed
CHUTIL: add utility function
1 parent 03bd92c commit 7a2487a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CodeHawk/CH/chutil/cHUtil.ml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Copyright (c) 2005-2020 Kestrel Technology LLC
88
Copyright (c) 2020 Henny B. Sipma
9-
Copyright (c) 2021-2024 Aarno Labs LLC
9+
Copyright (c) 2021-2025 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal
@@ -91,6 +91,15 @@ let has_control_characters (s: string): bool =
9191
!found
9292

9393

94+
let startswith (s: string) (substr: string): bool =
95+
let lens = String.length s in
96+
let lensub = String.length substr in
97+
if lens < lensub then
98+
false
99+
else
100+
(String.sub s 0 lensub) = substr
101+
102+
94103
let hex_string (s: string): string =
95104
let ch = IO.input_string s in
96105
let h = ref "" in

CodeHawk/CH/chutil/cHUtil.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Copyright (c) 2005-2020 Kestrel Technology LLC
88
Copyright (c) 2020 Henny B. Sipma
9-
Copyright (c) 2021-2024 Aarno Labs LLC
9+
Copyright (c) 2021-2025 Aarno Labs LLC
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal
@@ -38,6 +38,8 @@ val string_nsplit: char -> string -> string list
3838

3939
val has_control_characters: string -> bool
4040

41+
val startswith: string -> string -> bool
42+
4143
val byte_to_string: int -> string
4244

4345
val value_from_byte: int -> int

0 commit comments

Comments
 (0)