diff options
| author | Yuan Fu | 2022-05-09 12:49:55 -0700 |
|---|---|---|
| committer | Yuan Fu | 2022-05-09 12:49:55 -0700 |
| commit | eebe5a1d6114ed54eb3cdd5576f43da76590b8fa (patch) | |
| tree | a9e23462b32ba598d6723988dedc9af34c562b44 | |
| parent | 0d4155826a523f28c616295a91e7859c1fc05426 (diff) | |
| download | emacs-eebe5a1d6114ed54eb3cdd5576f43da76590b8fa.tar.gz emacs-eebe5a1d6114ed54eb3cdd5576f43da76590b8fa.zip | |
Fix compilation warnings
* src/treesit.c: Add static keywords, remove unused variables, add
const qualifier.
| -rw-r--r-- | src/treesit.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/treesit.c b/src/treesit.c index beeb2b78554..91114b06f10 100644 --- a/src/treesit.c +++ b/src/treesit.c | |||
| @@ -100,7 +100,7 @@ ts_calloc_wrapper (size_t n, size_t size) | |||
| 100 | return xzalloc (n * size); | 100 | return xzalloc (n * size); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | void | 103 | static void |
| 104 | ts_initialize () | 104 | ts_initialize () |
| 105 | { | 105 | { |
| 106 | if (!ts_initialized) | 106 | if (!ts_initialized) |
| @@ -114,7 +114,7 @@ ts_initialize () | |||
| 114 | 114 | ||
| 115 | /* Translates a symbol treesit-<lang> to a C name | 115 | /* Translates a symbol treesit-<lang> to a C name |
| 116 | treesit_<lang>. */ | 116 | treesit_<lang>. */ |
| 117 | void | 117 | static void |
| 118 | ts_symbol_to_c_name (char *symbol_name) | 118 | ts_symbol_to_c_name (char *symbol_name) |
| 119 | { | 119 | { |
| 120 | for (int idx=0; idx < strlen (symbol_name); idx++) | 120 | for (int idx=0; idx < strlen (symbol_name); idx++) |
| @@ -124,7 +124,7 @@ ts_symbol_to_c_name (char *symbol_name) | |||
| 124 | } | 124 | } |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | bool | 127 | static bool |
| 128 | ts_find_override_name | 128 | ts_find_override_name |
| 129 | (Lisp_Object language_symbol, Lisp_Object *name, Lisp_Object *c_symbol) | 129 | (Lisp_Object language_symbol, Lisp_Object *name, Lisp_Object *c_symbol) |
| 130 | { | 130 | { |
| @@ -149,7 +149,7 @@ ts_find_override_name | |||
| 149 | thsi function pushes "lib_base_name.so" and "lib_base_name.dylib" | 149 | thsi function pushes "lib_base_name.so" and "lib_base_name.dylib" |
| 150 | into *path_candidates. Obiviously path_candidates should be a Lisp | 150 | into *path_candidates. Obiviously path_candidates should be a Lisp |
| 151 | list of Lisp strings. */ | 151 | list of Lisp strings. */ |
| 152 | void | 152 | static void |
| 153 | ts_load_language_push_for_each_suffix | 153 | ts_load_language_push_for_each_suffix |
| 154 | (Lisp_Object lib_base_name, Lisp_Object *path_candidates) | 154 | (Lisp_Object lib_base_name, Lisp_Object *path_candidates) |
| 155 | { | 155 | { |
| @@ -168,7 +168,7 @@ ts_load_language_push_for_each_suffix | |||
| 168 | 168 | ||
| 169 | If SIGNAL is true, signal an error when failed to load LANGUAGE; if | 169 | If SIGNAL is true, signal an error when failed to load LANGUAGE; if |
| 170 | false, return NULL when failed. */ | 170 | false, return NULL when failed. */ |
| 171 | TSLanguage * | 171 | static TSLanguage * |
| 172 | ts_load_language (Lisp_Object language_symbol, bool signal) | 172 | ts_load_language (Lisp_Object language_symbol, bool signal) |
| 173 | { | 173 | { |
| 174 | Lisp_Object symbol_name = Fsymbol_name (language_symbol); | 174 | Lisp_Object symbol_name = Fsymbol_name (language_symbol); |
| @@ -242,7 +242,7 @@ ts_load_language (Lisp_Object language_symbol, bool signal) | |||
| 242 | 242 | ||
| 243 | /* Load TSLanguage. */ | 243 | /* Load TSLanguage. */ |
| 244 | dynlib_error (); | 244 | dynlib_error (); |
| 245 | TSLanguage *(*langfn) (); | 245 | TSLanguage *(*langfn) (void); |
| 246 | langfn = dynlib_sym (handle, c_name); | 246 | langfn = dynlib_sym (handle, c_name); |
| 247 | error = dynlib_error (); | 247 | error = dynlib_error (); |
| 248 | if (error != NULL) | 248 | if (error != NULL) |
| @@ -348,10 +348,9 @@ ts_record_change (ptrdiff_t start_byte, ptrdiff_t old_end_byte, | |||
| 348 | } | 348 | } |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | void | 351 | static void |
| 352 | ts_ensure_position_synced (Lisp_Object parser) | 352 | ts_ensure_position_synced (Lisp_Object parser) |
| 353 | { | 353 | { |
| 354 | TSParser *ts_parser = XTS_PARSER (parser)->parser; | ||
| 355 | TSTree *tree = XTS_PARSER (parser)->tree; | 354 | TSTree *tree = XTS_PARSER (parser)->tree; |
| 356 | 355 | ||
| 357 | if (tree == NULL) | 356 | if (tree == NULL) |
| @@ -406,7 +405,7 @@ ts_ensure_position_synced (Lisp_Object parser) | |||
| 406 | XTS_PARSER (parser)->visible_end = visible_end; | 405 | XTS_PARSER (parser)->visible_end = visible_end; |
| 407 | } | 406 | } |
| 408 | 407 | ||
| 409 | void | 408 | static void |
| 410 | ts_check_buffer_size (struct buffer *buffer) | 409 | ts_check_buffer_size (struct buffer *buffer) |
| 411 | { | 410 | { |
| 412 | ptrdiff_t buffer_size = | 411 | ptrdiff_t buffer_size = |
| @@ -419,7 +418,7 @@ ts_check_buffer_size (struct buffer *buffer) | |||
| 419 | 418 | ||
| 420 | /* Parse the buffer. We don't parse until we have to. When we have | 419 | /* Parse the buffer. We don't parse until we have to. When we have |
| 421 | to, we call this function to parse and update the tree. */ | 420 | to, we call this function to parse and update the tree. */ |
| 422 | void | 421 | static void |
| 423 | ts_ensure_parsed (Lisp_Object parser) | 422 | ts_ensure_parsed (Lisp_Object parser) |
| 424 | { | 423 | { |
| 425 | if (!XTS_PARSER (parser)->need_reparse) | 424 | if (!XTS_PARSER (parser)->need_reparse) |
| @@ -456,7 +455,7 @@ ts_ensure_parsed (Lisp_Object parser) | |||
| 456 | /* This is the read function provided to tree-sitter to read from a | 455 | /* This is the read function provided to tree-sitter to read from a |
| 457 | buffer. It reads one character at a time and automatically skips | 456 | buffer. It reads one character at a time and automatically skips |
| 458 | the gap. */ | 457 | the gap. */ |
| 459 | const char* | 458 | static const char* |
| 460 | ts_read_buffer (void *parser, uint32_t byte_index, | 459 | ts_read_buffer (void *parser, uint32_t byte_index, |
| 461 | TSPoint position, uint32_t *bytes_read) | 460 | TSPoint position, uint32_t *bytes_read) |
| 462 | { | 461 | { |
| @@ -647,7 +646,7 @@ DEFUN ("treesit-parser-root-node", | |||
| 647 | 646 | ||
| 648 | /* Checks that the RANGES argument of | 647 | /* Checks that the RANGES argument of |
| 649 | treesit-parser-set-included-ranges is valid. */ | 648 | treesit-parser-set-included-ranges is valid. */ |
| 650 | void | 649 | static void |
| 651 | ts_check_range_argument (Lisp_Object ranges) | 650 | ts_check_range_argument (Lisp_Object ranges) |
| 652 | { | 651 | { |
| 653 | EMACS_INT last_point = 1; | 652 | EMACS_INT last_point = 1; |
| @@ -706,7 +705,6 @@ is nil, set PARSER to parse the whole buffer. */) | |||
| 706 | /* Set ranges for PARSER. */ | 705 | /* Set ranges for PARSER. */ |
| 707 | ptrdiff_t len = list_length (ranges); | 706 | ptrdiff_t len = list_length (ranges); |
| 708 | TSRange *ts_ranges = malloc (sizeof(TSRange) * len); | 707 | TSRange *ts_ranges = malloc (sizeof(TSRange) * len); |
| 709 | struct buffer *buffer = XBUFFER (XTS_PARSER (parser)->buffer); | ||
| 710 | 708 | ||
| 711 | for (int idx=0; !NILP (ranges); idx++, ranges = XCDR (ranges)) | 709 | for (int idx=0; !NILP (ranges); idx++, ranges = XCDR (ranges)) |
| 712 | { | 710 | { |
| @@ -1246,7 +1244,7 @@ explanation. */) | |||
| 1246 | query, build_pure_c_string (" ")); | 1244 | query, build_pure_c_string (" ")); |
| 1247 | } | 1245 | } |
| 1248 | 1246 | ||
| 1249 | char* | 1247 | static const char* |
| 1250 | ts_query_error_to_string (TSQueryError error) | 1248 | ts_query_error_to_string (TSQueryError error) |
| 1251 | { | 1249 | { |
| 1252 | switch (error) | 1250 | switch (error) |
| @@ -1285,7 +1283,7 @@ struct capture_range | |||
| 1285 | 1283 | ||
| 1286 | /* Collect predicates for this match and return them in a list. Each | 1284 | /* Collect predicates for this match and return them in a list. Each |
| 1287 | predicate is a list of strings and symbols. */ | 1285 | predicate is a list of strings and symbols. */ |
| 1288 | Lisp_Object | 1286 | static Lisp_Object |
| 1289 | ts_predicates_for_pattern | 1287 | ts_predicates_for_pattern |
| 1290 | (TSQuery *query, uint32_t pattern_index) | 1288 | (TSQuery *query, uint32_t pattern_index) |
| 1291 | { | 1289 | { |
| @@ -1327,7 +1325,7 @@ ts_predicates_for_pattern | |||
| 1327 | 1325 | ||
| 1328 | /* Translate a capture NAME (symbol) to the text of the captured node. | 1326 | /* Translate a capture NAME (symbol) to the text of the captured node. |
| 1329 | Signals treesit-query-error if such node is not captured. */ | 1327 | Signals treesit-query-error if such node is not captured. */ |
| 1330 | Lisp_Object | 1328 | static Lisp_Object |
| 1331 | ts_predicate_capture_name_to_text | 1329 | ts_predicate_capture_name_to_text |
| 1332 | (Lisp_Object name, struct capture_range captures) | 1330 | (Lisp_Object name, struct capture_range captures) |
| 1333 | { | 1331 | { |
| @@ -1360,7 +1358,7 @@ ts_predicate_capture_name_to_text | |||
| 1360 | false otherwise. A and B can be either string, or a capture name. | 1358 | false otherwise. A and B can be either string, or a capture name. |
| 1361 | The capture name evaluates to the text its captured node spans in | 1359 | The capture name evaluates to the text its captured node spans in |
| 1362 | the buffer. */ | 1360 | the buffer. */ |
| 1363 | bool | 1361 | static bool |
| 1364 | ts_predicate_equal | 1362 | ts_predicate_equal |
| 1365 | (Lisp_Object args, struct capture_range captures) | 1363 | (Lisp_Object args, struct capture_range captures) |
| 1366 | { | 1364 | { |
| @@ -1383,7 +1381,7 @@ ts_predicate_equal | |||
| 1383 | /* Handles predicate (#match "regexp" @node). Return true if "regexp" | 1381 | /* Handles predicate (#match "regexp" @node). Return true if "regexp" |
| 1384 | matches the text spanned by @node; return false otherwise. Matching | 1382 | matches the text spanned by @node; return false otherwise. Matching |
| 1385 | is case-sensitive. */ | 1383 | is case-sensitive. */ |
| 1386 | bool | 1384 | static bool |
| 1387 | ts_predicate_match | 1385 | ts_predicate_match |
| 1388 | (Lisp_Object args, struct capture_range captures) | 1386 | (Lisp_Object args, struct capture_range captures) |
| 1389 | { | 1387 | { |
| @@ -1420,7 +1418,7 @@ ts_predicate_match | |||
| 1420 | 1418 | ||
| 1421 | /* If all predicates in PREDICATES passes, return true; otherwise | 1419 | /* If all predicates in PREDICATES passes, return true; otherwise |
| 1422 | return false. */ | 1420 | return false. */ |
| 1423 | bool | 1421 | static bool |
| 1424 | ts_eval_predicates | 1422 | ts_eval_predicates |
| 1425 | (struct capture_range captures, Lisp_Object predicates) | 1423 | (struct capture_range captures, Lisp_Object predicates) |
| 1426 | { | 1424 | { |