File tree Expand file tree Collapse file tree 5 files changed +39
-5
lines changed Expand file tree Collapse file tree 5 files changed +39
-5
lines changed Original file line number Diff line number Diff line change 5
5
#include "prism/util/pm_buffer.h"
6
6
#include "prism/util/pm_char.h"
7
7
#include "prism/util/pm_memchr.h"
8
+ #include "prism/util/pm_strncasecmp.h"
8
9
#include "prism/util/pm_strpbrk.h"
9
10
#include "prism/ast.h"
10
11
#include "prism/diagnostic.h"
Original file line number Diff line number Diff line change 49
49
# define snprintf _snprintf
50
50
#endif
51
51
52
- int pm_strncasecmp (const uint8_t * string1 , const uint8_t * string2 , size_t length );
53
-
54
52
#endif
Original file line number Diff line number Diff line change
1
+ #ifndef PRISM_STRNCASECMP_H
2
+ #define PRISM_STRNCASECMP_H
3
+
4
+ #include "prism/defines.h"
5
+
6
+ #include <ctype.h>
7
+ #include <stddef.h>
8
+ #include <stdint.h>
9
+
10
+ /**
11
+ * Compare two strings, ignoring case, up to the given length. Returns 0 if the
12
+ * strings are equal, a negative number if string1 is less than string2, or a
13
+ * positive number if string1 is greater than string2.
14
+ *
15
+ * Note that this is effectively our own implementation of strncasecmp, but it's
16
+ * not available on all of the platforms we want to support so we're rolling it
17
+ * here.
18
+ *
19
+ * @param string1 The first string to compare.
20
+ * @param string2 The second string to compare
21
+ * @param length The maximum number of characters to compare.
22
+ * @return 0 if the strings are equal, a negative number if string1 is less than
23
+ * string2, or a positive number if string1 is greater than string2.
24
+ */
25
+ int pm_strncasecmp (const uint8_t * string1 , const uint8_t * string2 , size_t length );
26
+
27
+ #endif
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ Gem::Specification.new do |spec|
57
57
"include/prism/util/pm_memchr.h" ,
58
58
"include/prism/util/pm_newline_list.h" ,
59
59
"include/prism/util/pm_state_stack.h" ,
60
+ "include/prism/util/pm_strncasecmp.h" ,
60
61
"include/prism/util/pm_string.h" ,
61
62
"include/prism/util/pm_string_list.h" ,
62
63
"include/prism/util/pm_strpbrk.h" ,
Original file line number Diff line number Diff line change 1
- #include <ctype.h>
2
- #include <stddef.h>
3
- #include <stdint.h>
1
+ #include "prism/util/pm_strncasecmp.h"
4
2
3
+ /**
4
+ * Compare two strings, ignoring case, up to the given length. Returns 0 if the
5
+ * strings are equal, a negative number if string1 is less than string2, or a
6
+ * positive number if string1 is greater than string2.
7
+ *
8
+ * Note that this is effectively our own implementation of strncasecmp, but it's
9
+ * not available on all of the platforms we want to support so we're rolling it
10
+ * here.
11
+ */
5
12
int
6
13
pm_strncasecmp (const uint8_t * string1 , const uint8_t * string2 , size_t length ) {
7
14
size_t offset = 0 ;
You can’t perform that action at this time.
0 commit comments