From 77d40567667220ad3e6401e0ec515cacd28655d4 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Tue, 31 Oct 2023 15:40:50 -0400 Subject: [PATCH] Fix up lint --- .github/workflows/main.yml | 7 +++- Doxyfile | 12 ++---- ext/prism/api_pack.c | 2 +- ext/prism/extension.c | 8 ++-- include/prism.h | 20 +++++----- include/prism/defines.h | 2 +- include/prism/enc/pm_encoding.h | 54 +++++++++++++-------------- include/prism/util/pm_constant_pool.h | 2 +- include/prism/util/pm_list.h | 18 +++++---- include/prism/util/pm_strncasecmp.h | 2 +- src/enc/pm_big5.c | 2 +- src/enc/pm_euc_jp.c | 2 +- src/enc/pm_gbk.c | 2 +- src/enc/pm_shift_jis.c | 2 +- src/enc/pm_tables.c | 40 ++++++++++---------- src/enc/pm_unicode.c | 6 +-- src/enc/pm_windows_31j.c | 2 +- src/util/pm_string.c | 6 ++- templates/include/prism/ast.h.erb | 2 +- templates/src/serialize.c.erb | 2 +- 20 files changed, 97 insertions(+), 96 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 57e21872824..4c7de45a4d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -296,11 +296,14 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: + ruby-version: "3.2" bundler-cache: true - - name: Install doxygen + - name: Install doxygen and dependencies run: | sudo apt-get update - sudo apt-get install doxygen + sudo apt-get install doxygen graphviz + - name: Generate the templates + run: bundle exec rake templates - name: Check ruby coverage run: bundle exec rake rdoc:coverage - name: Check C coverage diff --git a/Doxyfile b/Doxyfile index 1a7660e4651..53046fe833a 100644 --- a/Doxyfile +++ b/Doxyfile @@ -19,20 +19,14 @@ # configuration file: # doxygen -x [configFile] -# Non-default options PROJECT_NAME = "Prism Ruby parser" OUTPUT_DIRECTORY = doc JAVADOC_AUTOBRIEF = YES OPTIMIZE_OUTPUT_FOR_C = YES INPUT = src src/enc src/util include include/prism include/prism/enc include/prism/util HTML_OUTPUT = c -WARN_IF_UNDOCUMENTED = YES -WARN_NO_PARAMDOC = YES -WARN_AS_ERROR = FAIL_ON_WARNINGS -WARN_IF_UNDOC_ENUM_VAL = YES SORT_MEMBER_DOCS = NO - -# Default options we might want to edit in the future -HTML_STYLESHEET = -HTML_COLORSTYLE = AUTO_LIGHT GENERATE_LATEX = NO +WARN_NO_PARAMDOC = YES +WARN_AS_ERROR = FAIL_ON_WARNINGS +DOT_GRAPH_MAX_NODES = 200 diff --git a/ext/prism/api_pack.c b/ext/prism/api_pack.c index c746a59634b..c9f0b18a397 100644 --- a/ext/prism/api_pack.c +++ b/ext/prism/api_pack.c @@ -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 diff --git a/ext/prism/extension.c b/ext/prism/extension.c index 824f7ad04e6..42268c85382 100644 --- a/ext/prism/extension.c +++ b/ext/prism/extension.c @@ -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 diff --git a/include/prism.h b/include/prism.h index 4b8755a30d9..d6b18a44a80 100644 --- a/include/prism.h +++ b/include/prism.h @@ -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: * diff --git a/include/prism/defines.h b/include/prism/defines.h index b10f8fa3e08..f89a0bed8e4 100644 --- a/include/prism/defines.h +++ b/include/prism/defines.h @@ -16,7 +16,7 @@ #include #include -/** +/** * 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. diff --git a/include/prism/enc/pm_encoding.h b/include/prism/enc/pm_encoding.h index f8e554e6178..a42be774bc0 100644 --- a/include/prism/enc/pm_encoding.h +++ b/include/prism/enc/pm_encoding.h @@ -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 diff --git a/include/prism/util/pm_constant_pool.h b/include/prism/util/pm_constant_pool.h index 238d0c4cae8..ae5a88fbde3 100644 --- a/include/prism/util/pm_constant_pool.h +++ b/include/prism/util/pm_constant_pool.h @@ -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. diff --git a/include/prism/util/pm_list.h b/include/prism/util/pm_list.h index b05ed0290a9..d29fe07c52a 100644 --- a/include/prism/util/pm_list.h +++ b/include/prism/util/pm_list.h @@ -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 diff --git a/include/prism/util/pm_strncasecmp.h b/include/prism/util/pm_strncasecmp.h index c381ea38f46..5cb88cb5eb5 100644 --- a/include/prism/util/pm_strncasecmp.h +++ b/include/prism/util/pm_strncasecmp.h @@ -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. diff --git a/src/enc/pm_big5.c b/src/enc/pm_big5.c index 6d4fefcf2b7..fc5c4e73f0f 100644 --- a/src/enc/pm_big5.c +++ b/src/enc/pm_big5.c @@ -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, diff --git a/src/enc/pm_euc_jp.c b/src/enc/pm_euc_jp.c index cd0b1a79102..6babcae347a 100644 --- a/src/enc/pm_euc_jp.c +++ b/src/enc/pm_euc_jp.c @@ -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, diff --git a/src/enc/pm_gbk.c b/src/enc/pm_gbk.c index 3dcf41fb996..250b98b33b4 100644 --- a/src/enc/pm_gbk.c +++ b/src/enc/pm_gbk.c @@ -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, diff --git a/src/enc/pm_shift_jis.c b/src/enc/pm_shift_jis.c index ecc3d51b87b..f92956e08b9 100644 --- a/src/enc/pm_shift_jis.c +++ b/src/enc/pm_shift_jis.c @@ -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, diff --git a/src/enc/pm_tables.c b/src/enc/pm_tables.c index c2133649a4e..7b840acfaa1 100644 --- a/src/enc/pm_tables.c +++ b/src/enc/pm_tables.c @@ -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, diff --git a/src/enc/pm_unicode.c b/src/enc/pm_unicode.c index e471d03b6b7..41c1f258129 100644 --- a/src/enc/pm_unicode.c +++ b/src/enc/pm_unicode.c @@ -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 * * 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, diff --git a/src/enc/pm_windows_31j.c b/src/enc/pm_windows_31j.c index ce67cfb04e7..848a9efd363 100644 --- a/src/enc/pm_windows_31j.c +++ b/src/enc/pm_windows_31j.c @@ -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, diff --git a/src/util/pm_string.c b/src/util/pm_string.c index 46913be266a..f4d3033a1b7 100644 --- a/src/util/pm_string.c +++ b/src/util/pm_string.c @@ -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; } diff --git a/templates/include/prism/ast.h.erb b/templates/include/prism/ast.h.erb index 3f279d9779d..dd1c6bcd744 100644 --- a/templates/include/prism/ast.h.erb +++ b/templates/include/prism/ast.h.erb @@ -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. */ diff --git a/templates/src/serialize.c.erb b/templates/src/serialize.c.erb index 2f755094920..5e166f1eef2 100644 --- a/templates/src/serialize.c.erb +++ b/templates/src/serialize.c.erb @@ -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);