mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
parent
690f3bbf5d
commit
3551abab06
18 changed files with 89 additions and 85 deletions
|
@ -167,7 +167,7 @@ pack_encoding_to_ruby(pm_pack_encoding encoding) {
|
|||
/**
|
||||
* call-seq:
|
||||
* Pack::parse(version, variant, source) -> Format
|
||||
*
|
||||
*
|
||||
* Parse the given source and return a format object.
|
||||
*/
|
||||
static VALUE
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
/**
|
||||
* By default, we compile with -fvisibility=hidden. When this is enabled, we
|
||||
* need to mark certain functions as being publically-visible. This macro does
|
||||
* that in a compiler-agnostic way.
|
||||
|
|
|
@ -43,7 +43,7 @@ pm_encoding_big5_isupper_char(const uint8_t *b, ptrdiff_t n) {
|
|||
}
|
||||
|
||||
/** Big5 encoding */
|
||||
const pm_encoding_t pm_encoding_big5 = {
|
||||
pm_encoding_t pm_encoding_big5 = {
|
||||
.name = "big5",
|
||||
.char_width = pm_encoding_big5_char_width,
|
||||
.alnum_char = pm_encoding_big5_alnum_char,
|
||||
|
|
|
@ -155,32 +155,32 @@ extern const uint8_t pm_encoding_unicode_table[256];
|
|||
// Below are the encodings that are supported by the parser. They are defined in
|
||||
// their own files in the src/enc directory.
|
||||
|
||||
const extern pm_encoding_t pm_encoding_ascii;
|
||||
const extern pm_encoding_t pm_encoding_ascii_8bit;
|
||||
const extern pm_encoding_t pm_encoding_big5;
|
||||
const extern pm_encoding_t pm_encoding_euc_jp;
|
||||
const extern pm_encoding_t pm_encoding_gbk;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_1;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_2;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_3;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_4;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_5;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_6;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_7;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_8;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_9;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_10;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_11;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_13;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_14;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_15;
|
||||
const extern pm_encoding_t pm_encoding_iso_8859_16;
|
||||
const extern pm_encoding_t pm_encoding_koi8_r;
|
||||
const extern pm_encoding_t pm_encoding_shift_jis;
|
||||
const extern pm_encoding_t pm_encoding_utf_8;
|
||||
const extern pm_encoding_t pm_encoding_utf8_mac;
|
||||
const extern pm_encoding_t pm_encoding_windows_31j;
|
||||
const extern pm_encoding_t pm_encoding_windows_1251;
|
||||
const extern pm_encoding_t pm_encoding_windows_1252;
|
||||
extern pm_encoding_t pm_encoding_ascii;
|
||||
extern pm_encoding_t pm_encoding_ascii_8bit;
|
||||
extern pm_encoding_t pm_encoding_big5;
|
||||
extern pm_encoding_t pm_encoding_euc_jp;
|
||||
extern pm_encoding_t pm_encoding_gbk;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_1;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_2;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_3;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_4;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_5;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_6;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_7;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_8;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_9;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_10;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_11;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_13;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_14;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_15;
|
||||
extern pm_encoding_t pm_encoding_iso_8859_16;
|
||||
extern pm_encoding_t pm_encoding_koi8_r;
|
||||
extern pm_encoding_t pm_encoding_shift_jis;
|
||||
extern pm_encoding_t pm_encoding_utf_8;
|
||||
extern pm_encoding_t pm_encoding_utf8_mac;
|
||||
extern pm_encoding_t pm_encoding_windows_31j;
|
||||
extern pm_encoding_t pm_encoding_windows_1251;
|
||||
extern pm_encoding_t pm_encoding_windows_1252;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@ pm_encoding_euc_jp_isupper_char(const uint8_t *b, ptrdiff_t n) {
|
|||
}
|
||||
|
||||
/** EUC-JP encoding */
|
||||
const pm_encoding_t pm_encoding_euc_jp = {
|
||||
pm_encoding_t pm_encoding_euc_jp = {
|
||||
.name = "euc-jp",
|
||||
.char_width = pm_encoding_euc_jp_char_width,
|
||||
.alnum_char = pm_encoding_euc_jp_alnum_char,
|
||||
|
|
|
@ -52,7 +52,7 @@ pm_encoding_gbk_isupper_char(const uint8_t *b, ptrdiff_t n) {
|
|||
}
|
||||
|
||||
/** GBK encoding */
|
||||
const pm_encoding_t pm_encoding_gbk = {
|
||||
pm_encoding_t pm_encoding_gbk = {
|
||||
.name = "gbk",
|
||||
.char_width = pm_encoding_gbk_char_width,
|
||||
.alnum_char = pm_encoding_gbk_alnum_char,
|
||||
|
|
|
@ -47,7 +47,7 @@ pm_encoding_shift_jis_isupper_char(const uint8_t *b, ptrdiff_t n) {
|
|||
}
|
||||
|
||||
/** Shift_JIS encoding */
|
||||
const pm_encoding_t pm_encoding_shift_jis = {
|
||||
pm_encoding_t pm_encoding_shift_jis = {
|
||||
.name = "shift_jis",
|
||||
.char_width = pm_encoding_shift_jis_char_width,
|
||||
.alnum_char = pm_encoding_shift_jis_alnum_char,
|
||||
|
|
|
@ -543,7 +543,7 @@ PRISM_ENCODING_TABLE(windows_1252)
|
|||
#undef PRISM_ENCODING_TABLE
|
||||
|
||||
/** ASCII encoding */
|
||||
const pm_encoding_t pm_encoding_ascii = {
|
||||
pm_encoding_t pm_encoding_ascii = {
|
||||
.name = "ascii",
|
||||
.char_width = pm_encoding_ascii_char_width,
|
||||
.alnum_char = pm_encoding_ascii_alnum_char,
|
||||
|
@ -553,7 +553,7 @@ const pm_encoding_t pm_encoding_ascii = {
|
|||
};
|
||||
|
||||
/** ASCII-8BIT encoding */
|
||||
const pm_encoding_t pm_encoding_ascii_8bit = {
|
||||
pm_encoding_t pm_encoding_ascii_8bit = {
|
||||
.name = "ascii-8bit",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_ascii_alnum_char,
|
||||
|
@ -563,7 +563,7 @@ const pm_encoding_t pm_encoding_ascii_8bit = {
|
|||
};
|
||||
|
||||
/** ISO-8859-1 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_1 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_1 = {
|
||||
.name = "iso-8859-1",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_1_alnum_char,
|
||||
|
@ -573,7 +573,7 @@ const pm_encoding_t pm_encoding_iso_8859_1 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-2 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_2 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_2 = {
|
||||
.name = "iso-8859-2",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_2_alnum_char,
|
||||
|
@ -583,7 +583,7 @@ const pm_encoding_t pm_encoding_iso_8859_2 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-3 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_3 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_3 = {
|
||||
.name = "iso-8859-3",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_3_alnum_char,
|
||||
|
@ -593,7 +593,7 @@ const pm_encoding_t pm_encoding_iso_8859_3 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-4 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_4 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_4 = {
|
||||
.name = "iso-8859-4",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_4_alnum_char,
|
||||
|
@ -603,7 +603,7 @@ const pm_encoding_t pm_encoding_iso_8859_4 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-5 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_5 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_5 = {
|
||||
.name = "iso-8859-5",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_5_alnum_char,
|
||||
|
@ -613,7 +613,7 @@ const pm_encoding_t pm_encoding_iso_8859_5 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-6 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_6 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_6 = {
|
||||
.name = "iso-8859-6",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_6_alnum_char,
|
||||
|
@ -623,7 +623,7 @@ const pm_encoding_t pm_encoding_iso_8859_6 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-7 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_7 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_7 = {
|
||||
.name = "iso-8859-7",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_7_alnum_char,
|
||||
|
@ -633,7 +633,7 @@ const pm_encoding_t pm_encoding_iso_8859_7 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-8 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_8 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_8 = {
|
||||
.name = "iso-8859-8",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_8_alnum_char,
|
||||
|
@ -643,7 +643,7 @@ const pm_encoding_t pm_encoding_iso_8859_8 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-9 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_9 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_9 = {
|
||||
.name = "iso-8859-9",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_9_alnum_char,
|
||||
|
@ -653,7 +653,7 @@ const pm_encoding_t pm_encoding_iso_8859_9 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-10 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_10 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_10 = {
|
||||
.name = "iso-8859-10",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_10_alnum_char,
|
||||
|
@ -663,7 +663,7 @@ const pm_encoding_t pm_encoding_iso_8859_10 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-11 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_11 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_11 = {
|
||||
.name = "iso-8859-11",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_11_alnum_char,
|
||||
|
@ -673,7 +673,7 @@ const pm_encoding_t pm_encoding_iso_8859_11 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-13 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_13 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_13 = {
|
||||
.name = "iso-8859-13",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_13_alnum_char,
|
||||
|
@ -683,7 +683,7 @@ const pm_encoding_t pm_encoding_iso_8859_13 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-14 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_14 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_14 = {
|
||||
.name = "iso-8859-14",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_14_alnum_char,
|
||||
|
@ -693,7 +693,7 @@ const pm_encoding_t pm_encoding_iso_8859_14 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-15 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_15 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_15 = {
|
||||
.name = "iso-8859-15",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_15_alnum_char,
|
||||
|
@ -703,7 +703,7 @@ const pm_encoding_t pm_encoding_iso_8859_15 = {
|
|||
};
|
||||
|
||||
/** ISO-8859-16 */
|
||||
const pm_encoding_t pm_encoding_iso_8859_16 = {
|
||||
pm_encoding_t pm_encoding_iso_8859_16 = {
|
||||
.name = "iso-8859-16",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_iso_8859_16_alnum_char,
|
||||
|
@ -713,7 +713,7 @@ const pm_encoding_t pm_encoding_iso_8859_16 = {
|
|||
};
|
||||
|
||||
/** KOI8-R */
|
||||
const pm_encoding_t pm_encoding_koi8_r = {
|
||||
pm_encoding_t pm_encoding_koi8_r = {
|
||||
.name = "koi8-r",
|
||||
.char_width = pm_encoding_koi8_r_char_width,
|
||||
.alnum_char = pm_encoding_koi8_r_alnum_char,
|
||||
|
@ -723,7 +723,7 @@ const pm_encoding_t pm_encoding_koi8_r = {
|
|||
};
|
||||
|
||||
/** Windows-1251 */
|
||||
const pm_encoding_t pm_encoding_windows_1251 = {
|
||||
pm_encoding_t pm_encoding_windows_1251 = {
|
||||
.name = "windows-1251",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_windows_1251_alnum_char,
|
||||
|
@ -733,7 +733,7 @@ const pm_encoding_t pm_encoding_windows_1251 = {
|
|||
};
|
||||
|
||||
/** Windows-1252 */
|
||||
const pm_encoding_t pm_encoding_windows_1252 = {
|
||||
pm_encoding_t pm_encoding_windows_1252 = {
|
||||
.name = "windows-1252",
|
||||
.char_width = pm_encoding_single_char_width,
|
||||
.alnum_char = pm_encoding_windows_1252_alnum_char,
|
||||
|
|
|
@ -2207,7 +2207,7 @@ pm_unicode_codepoint_match(pm_unicode_codepoint_t codepoint, const pm_unicode_co
|
|||
|
||||
/**
|
||||
* A state transition table for decoding UTF-8.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
@ -2349,7 +2349,7 @@ pm_encoding_utf_8_isupper_char(const uint8_t *b, ptrdiff_t n) {
|
|||
#undef UNICODE_ISUPPER_CODEPOINTS_LENGTH
|
||||
|
||||
/** UTF-8 */
|
||||
const pm_encoding_t pm_encoding_utf_8 = {
|
||||
pm_encoding_t pm_encoding_utf_8 = {
|
||||
.name = "utf-8",
|
||||
.char_width = pm_encoding_utf_8_char_width,
|
||||
.alnum_char = pm_encoding_utf_8_alnum_char,
|
||||
|
@ -2359,7 +2359,7 @@ const pm_encoding_t pm_encoding_utf_8 = {
|
|||
};
|
||||
|
||||
/** UTF8-mac */
|
||||
const pm_encoding_t pm_encoding_utf8_mac = {
|
||||
pm_encoding_t pm_encoding_utf8_mac = {
|
||||
.name = "utf8-mac",
|
||||
.char_width = pm_encoding_utf_8_char_width,
|
||||
.alnum_char = pm_encoding_utf_8_alnum_char,
|
||||
|
|
|
@ -47,7 +47,7 @@ pm_encoding_windows_31j_isupper_char(const uint8_t *b, ptrdiff_t n) {
|
|||
}
|
||||
|
||||
/** Windows-31J */
|
||||
const pm_encoding_t pm_encoding_windows_31j = {
|
||||
pm_encoding_t pm_encoding_windows_31j = {
|
||||
.name = "windows-31j",
|
||||
.char_width = pm_encoding_windows_31j_char_width,
|
||||
.alnum_char = pm_encoding_windows_31j_alnum_char,
|
||||
|
|
|
@ -84,7 +84,7 @@ dump_input(pm_string_t *input, const char *filepath) {
|
|||
/**
|
||||
* call-seq:
|
||||
* Prism::dump(source, filepath = nil) -> dumped
|
||||
*
|
||||
*
|
||||
* Dump the AST corresponding to the given string to a string.
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -115,7 +115,7 @@ dump(int argc, VALUE *argv, VALUE self) {
|
|||
/**
|
||||
* call-seq:
|
||||
* Prism::dump_file(filepath) -> dumped
|
||||
*
|
||||
*
|
||||
* Dump the AST corresponding to the given file to a string.
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -373,7 +373,7 @@ parse_lex_input(pm_string_t *input, const char *filepath, bool return_nodes) {
|
|||
/**
|
||||
* call-seq:
|
||||
* Prism::lex(source, filepath = nil) -> Array
|
||||
*
|
||||
*
|
||||
* Return an array of Token instances corresponding to the given string.
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -391,7 +391,7 @@ lex(int argc, VALUE *argv, VALUE self) {
|
|||
/**
|
||||
* call-seq:
|
||||
* Prism::lex_file(filepath) -> Array
|
||||
*
|
||||
*
|
||||
* Return an array of Token instances corresponding to the given file.
|
||||
*/
|
||||
static VALUE
|
||||
|
|
|
@ -207,15 +207,15 @@ PRISM_EXPORTED_FUNCTION const char * pm_token_type_to_str(pm_token_type_t token_
|
|||
* visible.
|
||||
*
|
||||
* @section parsing Parsing
|
||||
*
|
||||
*
|
||||
* In order to parse Ruby code, the structures and functions that you're going
|
||||
* to want to use and be aware of are:
|
||||
*
|
||||
* * pm_parser_t - the main parser structure
|
||||
* * pm_parser_init - initialize a parser
|
||||
* * pm_parse - parse and return the root node
|
||||
* * pm_node_destroy - deallocate the root node returned by `pm_parse`
|
||||
* * pm_parser_free - free the internal memory of the parser
|
||||
* * `pm_parser_t` - the main parser structure
|
||||
* * `pm_parser_init` - initialize a parser
|
||||
* * `pm_parse` - parse and return the root node
|
||||
* * `pm_node_destroy` - deallocate the root node returned by `pm_parse`
|
||||
* * `pm_parser_free` - free the internal memory of the parser
|
||||
*
|
||||
* Putting all of this together would look something like:
|
||||
*
|
||||
|
@ -244,10 +244,10 @@ PRISM_EXPORTED_FUNCTION const char * pm_token_type_to_str(pm_token_type_t token_
|
|||
* parse Ruby code. The structures and functions that you're going to want to
|
||||
* use and be aware of are:
|
||||
*
|
||||
* * pm_buffer_t - a small buffer object that will hold the serialized AST
|
||||
* * pm_buffer_free - free the memory associated with the buffer
|
||||
* * pm_serialize - serialize the AST into a buffer
|
||||
* * pm_parse_serialize - parse and serialize the AST into a buffer
|
||||
* * `pm_buffer_t` - a small buffer object that will hold the serialized AST
|
||||
* * `pm_buffer_free` - free the memory associated with the buffer
|
||||
* * `pm_serialize` - serialize the AST into a buffer
|
||||
* * `pm_parse_serialize` - parse and serialize the AST into a buffer
|
||||
*
|
||||
* Putting all of this together would look something like:
|
||||
*
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
typedef enum pm_token_type {
|
||||
<%- tokens.each do |token| -%>
|
||||
/** <%= token.comment %> */
|
||||
PM_TOKEN_<%= token.name %><% " = #{token.value}" if token.value %>,
|
||||
PM_TOKEN_<%= token.name %><%= " = #{token.value}" if token.value %>,
|
||||
|
||||
<%- end -%>
|
||||
/** The maximum token value. */
|
||||
|
|
|
@ -299,7 +299,7 @@ pm_lex_serialize(const uint8_t *source, size_t size, const char *filepath, pm_bu
|
|||
parser.lex_callback = &lex_callback;
|
||||
pm_node_t *node = pm_parse(&parser);
|
||||
|
||||
// Append 0 to mark end of tokens
|
||||
// Append 0 to mark end of tokens.
|
||||
pm_buffer_append_byte(buffer, 0);
|
||||
|
||||
pm_serialize_encoding(&parser.encoding, buffer);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @file pm_constant_pool.h
|
||||
*
|
||||
* A data structure that stores a set of strings.
|
||||
*
|
||||
*
|
||||
* Each string is assigned a unique id, which can be used to compare strings for
|
||||
* equality. This comparison ends up being much faster than strcmp, since it
|
||||
* only requires a single integer comparison.
|
||||
|
|
|
@ -26,16 +26,18 @@
|
|||
*
|
||||
* For example, if we want to store a list of integers, we can do the following:
|
||||
*
|
||||
* typedef struct {
|
||||
* pm_list_node_t node;
|
||||
* int value;
|
||||
* } pm_int_node_t;
|
||||
* ```c
|
||||
* typedef struct {
|
||||
* pm_list_node_t node;
|
||||
* int value;
|
||||
* } pm_int_node_t;
|
||||
*
|
||||
* pm_list_t list = { 0 };
|
||||
* pm_int_node_t *node = malloc(sizeof(pm_int_node_t));
|
||||
* node->value = 5;
|
||||
* pm_list_t list = { 0 };
|
||||
* pm_int_node_t *node = malloc(sizeof(pm_int_node_t));
|
||||
* node->value = 5;
|
||||
*
|
||||
* pm_list_append(&list, &node->node);
|
||||
* pm_list_append(&list, &node->node);
|
||||
* ```
|
||||
*
|
||||
* The pm_list_t struct is used to represent the overall linked list. It
|
||||
* contains a pointer to the head and tail of the list. This allows for easy
|
||||
|
|
|
@ -81,7 +81,8 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
|
|||
// the source to a constant empty string and return.
|
||||
if (file_size == 0) {
|
||||
CloseHandle(file);
|
||||
*string = PM_STRING_EMPTY;
|
||||
const uint8_t source[] = "";
|
||||
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -127,7 +128,8 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
|
|||
|
||||
if (size == 0) {
|
||||
close(fd);
|
||||
*string = PM_STRING_EMPTY;
|
||||
const uint8_t source[] = "";
|
||||
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue