[ruby/prism] Documentation for pm_strncasecmp

https://github.com/ruby/prism/commit/26934263b7
This commit is contained in:
Kevin Newton 2023-10-30 23:33:04 -04:00
Родитель e8a72b516f
Коммит 493439c9ce
5 изменённых файлов: 39 добавлений и 5 удалений

Просмотреть файл

@ -57,6 +57,7 @@ Gem::Specification.new do |spec|
"include/prism/util/pm_memchr.h",
"include/prism/util/pm_newline_list.h",
"include/prism/util/pm_state_stack.h",
"include/prism/util/pm_strncasecmp.h",
"include/prism/util/pm_string.h",
"include/prism/util/pm_string_list.h",
"include/prism/util/pm_strpbrk.h",

Просмотреть файл

@ -49,6 +49,4 @@
# define snprintf _snprintf
#endif
int pm_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length);
#endif

Просмотреть файл

@ -5,6 +5,7 @@
#include "prism/util/pm_buffer.h"
#include "prism/util/pm_char.h"
#include "prism/util/pm_memchr.h"
#include "prism/util/pm_strncasecmp.h"
#include "prism/util/pm_strpbrk.h"
#include "prism/ast.h"
#include "prism/diagnostic.h"

Просмотреть файл

@ -1,7 +1,14 @@
#include <ctype.h>
#include <stddef.h>
#include <stdint.h>
#include "prism/util/pm_strncasecmp.h"
/**
* Compare two strings, ignoring case, up to the given length. Returns 0 if the
* strings are equal, a negative number if string1 is less than string2, or a
* positive number if string1 is greater than string2.
*
* Note that this is effectively our own implementation of strncasecmp, but it's
* not available on all of the platforms we want to support so we're rolling it
* here.
*/
int
pm_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length) {
size_t offset = 0;

Просмотреть файл

@ -0,0 +1,27 @@
#ifndef PRISM_STRNCASECMP_H
#define PRISM_STRNCASECMP_H
#include "prism/defines.h"
#include <ctype.h>
#include <stddef.h>
#include <stdint.h>
/**
* Compare two strings, ignoring case, up to the given length. Returns 0 if the
* strings are equal, a negative number if string1 is less than string2, or a
* positive number if string1 is greater than string2.
*
* Note that this is effectively our own implementation of strncasecmp, but it's
* not available on all of the platforms we want to support so we're rolling it
* here.
*
* @param string1 The first string to compare.
* @param string2 The second string to compare
* @param length The maximum number of characters to compare.
* @return 0 if the strings are equal, a negative number if string1 is less than
* string2, or a positive number if string1 is greater than string2.
*/
int pm_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length);
#endif