[geany/geany] 082a97: Use ARRAY_SIZE() in parsers
Jiří Techet
git-noreply at xxxxx
Sat Sep 10 07:26:20 UTC 2016
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Sun, 07 Aug 2016 00:01:38 UTC
Commit: 082a9724f12d2beda1002081b2ed16611e04e12f
https://github.com/geany/geany/commit/082a9724f12d2beda1002081b2ed16611e04e12f
Log Message:
-----------
Use ARRAY_SIZE() in parsers
Modified Paths:
--------------
ctags/parsers/c.c
ctags/parsers/perl.c
ctags/parsers/php.c
ctags/parsers/powershell.c
ctags/parsers/ruby.c
ctags/parsers/verilog.c
Modified: ctags/parsers/c.c
14 lines changed, 7 insertions(+), 7 deletions(-)
===================================================================
@@ -668,7 +668,7 @@ static const char *accessString (const accessType laccess)
static const char *const names [] = {
"?", "private", "protected", "public", "default"
};
- Assert (sizeof (names) / sizeof (names [0]) == ACCESS_COUNT);
+ Assert (ARRAY_SIZE (names) == ACCESS_COUNT);
Assert ((int) laccess < ACCESS_COUNT);
return names[(int) laccess];
}
@@ -678,7 +678,7 @@ static const char *implementationString (const impType imp)
static const char *const names [] = {
"?", "abstract", "virtual", "pure virtual"
};
- Assert (sizeof (names) / sizeof (names [0]) == IMP_COUNT);
+ Assert (ARRAY_SIZE (names) == IMP_COUNT);
Assert ((int) imp < IMP_COUNT);
return names [(int) imp];
}
@@ -697,7 +697,7 @@ static const char *tokenString (const tokenType type)
"none", "args", "}", "{", "comma", "double colon", "keyword", "name",
"package", "paren-name", "semicolon", "specifier", "*", "[]"
};
- Assert (sizeof (names) / sizeof (names [0]) == TOKEN_COUNT);
+ Assert (ARRAY_SIZE (names) == TOKEN_COUNT);
Assert ((int) type < TOKEN_COUNT);
return names [(int) type];
}
@@ -707,7 +707,7 @@ static const char *scopeString (const tagScope scope)
static const char *const names [] = {
"global", "static", "extern", "friend", "typedef"
};
- Assert (sizeof (names) / sizeof (names [0]) == SCOPE_COUNT);
+ Assert (ARRAY_SIZE (names) == SCOPE_COUNT);
Assert ((int) scope < SCOPE_COUNT);
return names [(int) scope];
}
@@ -719,14 +719,14 @@ static const char *declString (const declType declaration)
"function template", "ignore", "interface", "module", "namespace",
"no mangle", "package", "struct", "union",
};
- Assert (sizeof (names) / sizeof (names [0]) == DECL_COUNT);
+ Assert (ARRAY_SIZE (names) == DECL_COUNT);
Assert ((int) declaration < DECL_COUNT);
return names [(int) declaration];
}
static const char *keywordString (const keywordId keyword)
{
- const size_t count = sizeof (KeywordTable) / sizeof (KeywordTable [0]);
+ const size_t count = ARRAY_SIZE (KeywordTable);
const char *name = "none";
size_t i;
for (i = 0 ; i < count ; ++i)
@@ -3172,7 +3172,7 @@ static boolean findCTags (const unsigned int passCount)
static void buildKeywordHash (const langType language, unsigned int idx)
{
- const size_t count = sizeof (KeywordTable) / sizeof (KeywordTable [0]);
+ const size_t count = ARRAY_SIZE (KeywordTable);
size_t i;
for (i = 0 ; i < count ; ++i)
{
Modified: ctags/parsers/perl.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -71,7 +71,7 @@ static boolean isPodWord (const char *word)
"head1", "head2", "head3", "head4", "over", "item", "back",
"pod", "begin", "end", "for"
};
- const size_t count = sizeof (pods) / sizeof (pods [0]);
+ const size_t count = ARRAY_SIZE (pods);
const char *white = strpbrk (word, " \t");
const size_t len = (white!=NULL) ? (size_t)(white-word) : strlen (word);
char *const id = (char*) eMalloc (len + 1);
Modified: ctags/parsers/php.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -449,7 +449,7 @@ static void printToken (const tokenInfo *const token)
case TOKEN_KEYWORD:
{
- size_t n = sizeof PhpKeywordTable / sizeof PhpKeywordTable[0];
+ size_t n = ARRAY_SIZE (PhpKeywordTable);
size_t i;
fprintf (stderr, "\tkeyword:\t");
@@ -548,7 +548,7 @@ static void parseHeredoc (vString *const string)
quote = c;
c = getcFromInputFile ();
}
- for (len = 0; len < (sizeof delimiter / sizeof delimiter[0]) - 1; len++)
+ for (len = 0; len < ARRAY_SIZE (delimiter) - 1; len++)
{
if (! isIdentChar (c))
break;
Modified: ctags/parsers/powershell.c
4 lines changed, 1 insertions(+), 3 deletions(-)
===================================================================
@@ -26,8 +26,6 @@
#define SCOPE_SEPARATOR "::"
-#define ARRAY_LENGTH(array) (sizeof array / sizeof array[0])
-
#define ACCESS_UNDEFINED NULL
static const char *const accessTypes[] = {
ACCESS_UNDEFINED,
@@ -85,7 +83,7 @@ static const char *findValidAccessType (const char *const access)
unsigned int i;
if (access == ACCESS_UNDEFINED)
return ACCESS_UNDEFINED; /* early out to save the for-loop if possible */
- for (i = 0; i < ARRAY_LENGTH(accessTypes); i++)
+ for (i = 0; i < ARRAY_SIZE(accessTypes); i++)
{
if (accessTypes[i] == ACCESS_UNDEFINED)
continue;
Modified: ctags/parsers/ruby.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -216,7 +216,7 @@ static void emitRubyTag (vString* name, rubyKind kind)
initTagEntry (&tag, unqualified_name, &(RubyKinds [kind]));
if (vStringLength (scope) > 0) {
Assert (0 <= parent_kind &&
- (size_t) parent_kind < (sizeof RubyKinds / sizeof RubyKinds[0]));
+ (size_t) parent_kind < (ARRAY_SIZE (RubyKinds)));
tag.extensionFields.scopeKind = &(RubyKinds [parent_kind]);
tag.extensionFields.scopeName = vStringValue (scope);
Modified: ctags/parsers/verilog.c
3 lines changed, 1 insertions(+), 2 deletions(-)
===================================================================
@@ -102,8 +102,7 @@ static keywordTable VerilogKeywordTable [] = {
static void initialize (const langType language)
{
size_t i;
- const size_t count =
- sizeof (VerilogKeywordTable) / sizeof (VerilogKeywordTable [0]);
+ const size_t count = ARRAY_SIZE (VerilogKeywordTable);
Lang_verilog = language;
for (i = 0 ; i < count ; ++i)
{
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list