From 9a5c688ae40ce8264ebd2eacdb037017e5ebd07f Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 12 Aug 2018 14:55:42 +0200 Subject: [PATCH] style: src: remove useless reference to 'int' in integral types * src/AnnotationList.c, src/AnnotationList.h, src/InadequacyList.h, * src/closure.c, src/closure.h, src/gram.c, src/gram.h, src/ielr.c, * src/location.c, src/output.c, src/reader.c, src/relation.c, * src/scan-code.l, src/scan-gram.l, src/tables.c, src/tables.h: Prefer 'unsigned' to 'unsigned int'. Likewise for long and short. --- src/AnnotationList.c | 2 +- src/AnnotationList.h | 2 +- src/InadequacyList.h | 2 +- src/closure.c | 2 +- src/closure.h | 2 +- src/gram.c | 8 ++++---- src/gram.h | 2 +- src/ielr.c | 8 ++++---- src/location.c | 2 +- src/output.c | 10 +++++----- src/reader.c | 2 +- src/relation.c | 4 ++-- src/scan-code.l | 4 ++-- src/scan-gram.l | 14 +++++++------- src/tables.c | 12 ++++++------ src/tables.h | 4 ++-- 16 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/AnnotationList.c b/src/AnnotationList.c index a5d015e4..a78deb8a 100644 --- a/src/AnnotationList.c +++ b/src/AnnotationList.c @@ -275,7 +275,7 @@ AnnotationList__computePredecessorAnnotations (AnnotationList *self, state *s, - 2])) { Sbitset items; - unsigned int rulei; + unsigned rulei; for (rulei = s->items[self_item]; !item_number_is_rule_number (ritem[rulei]); ++rulei) diff --git a/src/AnnotationList.h b/src/AnnotationList.h index 739f377f..f770f6f0 100644 --- a/src/AnnotationList.h +++ b/src/AnnotationList.h @@ -25,7 +25,7 @@ # include "InadequacyList.h" # include "state.h" -typedef unsigned int AnnotationIndex; +typedef unsigned AnnotationIndex; /** * A node in a list of annotations on a particular LR(0) state. Each diff --git a/src/InadequacyList.h b/src/InadequacyList.h index 42f11fc4..a05b99da 100644 --- a/src/InadequacyList.h +++ b/src/InadequacyList.h @@ -31,7 +31,7 @@ * This must remain unsigned so that the overflow check in * \c InadequacyList__new_conflict works properly. */ -typedef unsigned long long int InadequacyListNodeCount; +typedef unsigned long long InadequacyListNodeCount; /** * For a conflict, each rule in the grammar can have at most one contributing diff --git a/src/closure.c b/src/closure.c index 235391cd..6729d702 100644 --- a/src/closure.c +++ b/src/closure.c @@ -168,7 +168,7 @@ set_fderives (void) void -new_closure (unsigned int n) +new_closure (unsigned n) { itemset = xnmalloc (n, sizeof *itemset); diff --git a/src/closure.h b/src/closure.h index d80eae5e..1d728984 100644 --- a/src/closure.h +++ b/src/closure.h @@ -27,7 +27,7 @@ data so that closure can be called. n is the number of elements to allocate for itemset. */ -void new_closure (unsigned int n); +void new_closure (unsigned n); /* Given the kernel (aka core) of a state (a sorted vector of item numbers diff --git a/src/gram.c b/src/gram.c index fb2593e2..1dbe88e7 100644 --- a/src/gram.c +++ b/src/gram.c @@ -32,7 +32,7 @@ /* Comments for these variables are in gram.h. */ item_number *ritem = NULL; -unsigned int nritems = 0; +unsigned nritems = 0; rule *rules = NULL; rule_number nrules = 0; @@ -126,7 +126,7 @@ rule_rhs_print_xml (rule const *r, FILE *out, int level) void ritem_print (FILE *out) { - unsigned int i; + unsigned i; fputs ("RITEM\n", out); for (i = 0; i < nritems; ++i) if (ritem[i] >= 0) @@ -254,8 +254,8 @@ grammar_dump (FILE *out, const char *title) { rule const *rule_i = &rules[i]; item_number *rp = NULL; - unsigned int rhs_itemno = rule_i->rhs - ritem; - unsigned int rhs_count = 0; + unsigned rhs_itemno = rule_i->rhs - ritem; + unsigned rhs_count = 0; /* Find the last RHS index in ritems. */ for (rp = rule_i->rhs; *rp >= 0; ++rp) ++rhs_count; diff --git a/src/gram.h b/src/gram.h index a2b55ead..bbae54b4 100644 --- a/src/gram.h +++ b/src/gram.h @@ -115,7 +115,7 @@ extern int nvars; typedef int item_number; # define ITEM_NUMBER_MAX INT_MAX extern item_number *ritem; -extern unsigned int nritems; +extern unsigned nritems; /* There is weird relationship between OT1H item_number and OTOH symbol_number and rule_number: we store the latter in diff --git a/src/ielr.c b/src/ielr.c index 30f8be1c..43763567 100644 --- a/src/ielr.c +++ b/src/ielr.c @@ -49,7 +49,7 @@ static bitset ielr_compute_ritem_sees_lookahead_set (void) { bitset result = bitset_create (nritems, BITSET_FIXED); - unsigned int i = nritems-1; + unsigned i = nritems-1; while (i>0) { --i; @@ -397,7 +397,7 @@ ielr_item_has_lookahead (state *s, symbol_number lhs, size_t item, top-level invocation), go get it. */ if (!lhs) { - unsigned int i; + unsigned i; for (i = s->items[item]; !item_number_is_rule_number (ritem[i]); ++i) @@ -475,7 +475,7 @@ ielr_compute_annotation_lists (bitsetv follow_kernel_items, AnnotationIndex *annotation_counts = xnmalloc (nstates, sizeof *annotation_counts); ContributionIndex max_contributions = 0; - unsigned int total_annotations = 0; + unsigned total_annotations = 0; *inadequacy_listsp = xnmalloc (nstates, sizeof **inadequacy_listsp); *annotation_listsp = xnmalloc (nstates, sizeof **annotation_listsp); @@ -611,7 +611,7 @@ ielr_compute_lookaheads (bitsetv follow_kernel_items, bitsetv always_follows, { if (item_number_is_rule_number (ritem[t->items[t_item] - 2])) { - unsigned int rule_item; + unsigned rule_item; for (rule_item = t->items[t_item]; !item_number_is_rule_number (ritem[rule_item]); ++rule_item) diff --git a/src/location.c b/src/location.c index faceb5c9..5962ef0c 100644 --- a/src/location.c +++ b/src/location.c @@ -37,7 +37,7 @@ static inline int add_column_width (int column, char const *buf, size_t bufsize) { size_t width; - unsigned int remaining_columns = INT_MAX - column; + unsigned remaining_columns = INT_MAX - column; if (buf) { diff --git a/src/output.c b/src/output.c index b07d0f1e..a193b78e 100644 --- a/src/output.c +++ b/src/output.c @@ -64,8 +64,8 @@ Name (char const *name, \ { \ Type min = first; \ Type max = first; \ - long int lmin; \ - long int lmax; \ + long lmin; \ + long lmax; \ int i; \ int j = 1; \ \ @@ -97,7 +97,7 @@ Name (char const *name, \ MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmax); \ } -GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_unsigned_int_table, unsigned int) +GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_unsigned_int_table, unsigned) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_int_table, int) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_base_table, base_number) GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_rule_number_table, rule_number) @@ -213,9 +213,9 @@ prepare_symbols (void) static void prepare_rules (void) { - unsigned int *rline = xnmalloc (nrules, sizeof *rline); + unsigned *rline = xnmalloc (nrules, sizeof *rline); symbol_number *r1 = xnmalloc (nrules, sizeof *r1); - unsigned int *r2 = xnmalloc (nrules, sizeof *r2); + unsigned *r2 = xnmalloc (nrules, sizeof *r2); int *dprec = xnmalloc (nrules, sizeof *dprec); int *merger = xnmalloc (nrules, sizeof *merger); int *immediate = xnmalloc (nrules, sizeof *immediate); diff --git a/src/reader.c b/src/reader.c index 49bf2d1f..18a3fc2d 100644 --- a/src/reader.c +++ b/src/reader.c @@ -564,7 +564,7 @@ grammar_current_rule_predicate_append (const char *pred, location loc) static void packgram (void) { - unsigned int itemno = 0; + unsigned itemno = 0; rule_number ruleno = 0; ritem = xnmalloc (nritems + 1, sizeof *ritem); diff --git a/src/relation.c b/src/relation.c index 71473278..148f5540 100644 --- a/src/relation.c +++ b/src/relation.c @@ -34,10 +34,10 @@ relation_print (relation r, relation_node size, FILE *out) for (i = 0; i < size; ++i) { - fprintf (out, "%3lu: ", (unsigned long int) i); + fprintf (out, "%3lu: ", (unsigned long) i); if (r[i]) for (j = 0; r[i][j] != END_NODE; ++j) - fprintf (out, "%3lu ", (unsigned long int) r[i][j]); + fprintf (out, "%3lu ", (unsigned long) r[i][j]); fputc ('\n', out); } fputc ('\n', out); diff --git a/src/scan-code.l b/src/scan-code.l index 0723224d..faa620ff 100644 --- a/src/scan-code.l +++ b/src/scan-code.l @@ -415,7 +415,7 @@ show_sub_messages (warnings warning, /* Parse named or positional reference. In case of positional references, can return negative values for $-n "deep" stack accesses. */ -static long int +static long parse_ref (char *cp, symbol_list *rule, int rule_length, int midrule_rhs_index, char *text, location text_loc, char dollar_or_at) @@ -432,7 +432,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length, if (c_isdigit (*cp) || (*cp == '-' && c_isdigit (* (cp + 1)))) { - long int num = strtol (cp, &cp, 10); + long num = strtol (cp, &cp, 10); if (1 - INT_MAX + rule_length <= num && num <= rule_length) return num; else diff --git a/src/scan-gram.l b/src/scan-gram.l index ff5c056e..2b2a7f2a 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -96,7 +96,7 @@ gram_scanner_last_string_free (void) } static void handle_syncline (char *, location); -static unsigned long int scan_integer (char const *p, int base, location loc); +static unsigned long scan_integer (char const *p, int base, location loc); static int convert_ucn_to_byte (char const *hex_text); static void unexpected_eof (boundary, char const *); static void unexpected_newline (boundary, char const *); @@ -591,7 +591,7 @@ eqopt ([[:space:]]*=)? { \\[0-7]{1,3} { - unsigned long int c = strtoul (yytext + 1, NULL, 8); + unsigned long c = strtoul (yytext + 1, NULL, 8); if (!c || UCHAR_MAX < c) complain (loc, complaint, _("invalid number after \\-escape: %s"), yytext+1); @@ -601,7 +601,7 @@ eqopt ([[:space:]]*=)? \\x[0-9abcdefABCDEF]+ { verify (UCHAR_MAX < ULONG_MAX); - unsigned long int c = strtoul (yytext + 2, NULL, 16); + unsigned long c = strtoul (yytext + 2, NULL, 16); if (!c || UCHAR_MAX < c) complain (loc, complaint, _("invalid number after \\-escape: %s"), yytext+1); @@ -844,11 +844,11 @@ no_cr_read (FILE *fp, char *buf, size_t size) | Scan NUMBER for a base-BASE integer at location LOC. | `------------------------------------------------------*/ -static unsigned long int +static unsigned long scan_integer (char const *number, int base, location loc) { verify (INT_MAX < ULONG_MAX); - unsigned long int num = strtoul (number, NULL, base); + unsigned long num = strtoul (number, NULL, base); if (INT_MAX < num) { @@ -871,7 +871,7 @@ static int convert_ucn_to_byte (char const *ucn) { verify (UCHAR_MAX <= INT_MAX); - unsigned long int code = strtoul (ucn + 2, NULL, 16); + unsigned long code = strtoul (ucn + 2, NULL, 16); /* FIXME: Currently we assume Unicode-compatible unibyte characters on ASCII hosts (i.e., Latin-1 on hosts with 8-bit bytes). On @@ -926,7 +926,7 @@ static void handle_syncline (char *args, location loc) { char *file; - unsigned long int lineno = strtoul (args, &file, 10); + unsigned long lineno = strtoul (args, &file, 10); if (INT_MAX <= lineno) { complain (&loc, Wother, _("line number overflow")); diff --git a/src/tables.c b/src/tables.c index 3481ffb7..7da2788a 100644 --- a/src/tables.c +++ b/src/tables.c @@ -83,7 +83,7 @@ int nvectors; static base_number **froms; static base_number **tos; -static unsigned int **conflict_tos; +static unsigned **conflict_tos; static size_t *tally; static base_number *width; @@ -112,9 +112,9 @@ base_number *base = NULL; base_number base_ninf = 0; static base_number *pos = NULL; -static unsigned int *conflrow; -unsigned int *conflict_table; -unsigned int *conflict_list; +static unsigned *conflrow; +unsigned *conflict_table; +unsigned *conflict_list; int conflict_list_cnt; static int conflict_list_free; @@ -394,7 +394,7 @@ save_row (state_number s) /* Allocate non defaulted actions. */ base_number *sp1 = froms[s] = xnmalloc (count, sizeof *sp1); base_number *sp2 = tos[s] = xnmalloc (count, sizeof *sp2); - unsigned int *sp3 = conflict_tos[s] = + unsigned *sp3 = conflict_tos[s] = nondeterministic_parser ? xnmalloc (count, sizeof *sp3) : NULL; /* Store non defaulted actions. */ @@ -670,7 +670,7 @@ pack_vector (vector_number vector) size_t t = tally[i]; base_number *from = froms[i]; base_number *to = tos[i]; - unsigned int *conflict_to = conflict_tos[i]; + unsigned *conflict_to = conflict_tos[i]; aver (t != 0); diff --git a/src/tables.h b/src/tables.h index 349078a0..0eb0e5cd 100644 --- a/src/tables.h +++ b/src/tables.h @@ -122,8 +122,8 @@ extern base_number *base; keep parser tables small. */ extern base_number base_ninf; -extern unsigned int *conflict_table; -extern unsigned int *conflict_list; +extern unsigned *conflict_table; +extern unsigned *conflict_list; extern int conflict_list_cnt; extern base_number *table;