From ed01b7edb4dd8f24857fdefe9a226fc6e5c7473d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Thu, 6 Oct 2016 19:30:59 +0200 Subject: [PATCH] Grab uctags keyword.c/h and add types.h with type declarations keyword.c/h contains only changes made by me. To make the sync complete, add type.h with type declarations (and remove the added declarations from their original locations). --- ctags/Makefile.am | 1 + ctags/main/entry.h | 5 +++-- ctags/main/keyword.c | 22 +++++++++++++++++----- ctags/main/keyword.h | 4 +++- ctags/main/kind.h | 4 ++-- ctags/main/lcpp.h | 3 +-- ctags/main/parse.h | 1 - ctags/main/types.h | 21 +++++++++++++++++++++ 8 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 ctags/main/types.h diff --git a/ctags/Makefile.am b/ctags/Makefile.am index d85a3bb4..1bae64c0 100644 --- a/ctags/Makefile.am +++ b/ctags/Makefile.am @@ -89,6 +89,7 @@ libctags_la_SOURCES = \ main/sort.h \ main/strlist.c \ main/strlist.h \ + main/types.h \ main/vstring.c \ main/vstring.h \ main/xtag.h \ diff --git a/ctags/main/entry.h b/ctags/main/entry.h index c073b450..5ebd727c 100644 --- a/ctags/main/entry.h +++ b/ctags/main/entry.h @@ -13,6 +13,7 @@ * INCLUDE FILES */ #include "general.h" /* must always come first */ +#include "types.h" #include "mio.h" #include "vstring.h" @@ -51,7 +52,7 @@ typedef struct sTagFields { /* Information about the current tag candidate. */ -typedef struct sTagEntryInfo { +struct sTagEntryInfo { bool lineNumberEntry; /* pattern or line number entry */ unsigned long lineNumber; /* line number of tag */ MIOPos filePosition; /* file position of line containing tag */ @@ -74,7 +75,7 @@ typedef struct sTagEntryInfo { const char *signature; /* Argument list for functions and macros with arguments */ const char *varType; } extensionFields; /* list of extension fields*/ -} tagEntryInfo; +}; /* * GLOBAL VARIABLES diff --git a/ctags/main/keyword.c b/ctags/main/keyword.c index b594ef34..374c311e 100644 --- a/ctags/main/keyword.c +++ b/ctags/main/keyword.c @@ -13,12 +13,12 @@ #include "general.h" /* must always come first */ #include +#include #include "debug.h" #include "keyword.h" #include "options.h" #include "routines.h" -#include "main.h" /* * DATA DECLARATIONS @@ -78,7 +78,7 @@ static unsigned int hashValue (const char *const string, langType language) /* "djb" hash as used in g_str_hash() in glib */ for (p = (const signed char *)string; *p != '\0'; p++) - h = (h << 5) + h + *p; + h = (h << 5) + h + tolower (*p); /* consider language as an extra "character" and add it to the hash */ h = (h << 5) + h + language; @@ -136,15 +136,17 @@ extern void addKeyword (const char *const string, langType language, int value) } } -extern int lookupKeyword (const char *const string, langType language) +static int lookupKeywordFull (const char *const string, bool caseSensitive, langType language) { const unsigned int index = hashValue (string, language) % TableSize; hashEntry *entry = getHashTableEntry (index); - int result = -1; + int result = KEYWORD_NONE; while (entry != NULL) { - if (language == entry->language && strcmp (string, entry->string) == 0) + if (language == entry->language && + ((caseSensitive && strcmp (string, entry->string) == 0) || + (!caseSensitive && strcasecmp (string, entry->string) == 0))) { result = entry->value; break; @@ -154,6 +156,16 @@ extern int lookupKeyword (const char *const string, langType language) return result; } +extern int lookupKeyword (const char *const string, langType language) +{ + return lookupKeywordFull (string, true, language); +} + +extern int lookupCaseKeyword (const char *const string, langType language) +{ + return lookupKeywordFull (string, false, language); +} + extern void freeKeywordTable (void) { if (HashTable != NULL) diff --git a/ctags/main/keyword.h b/ctags/main/keyword.h index 7a365e35..9be3e5b4 100644 --- a/ctags/main/keyword.h +++ b/ctags/main/keyword.h @@ -14,7 +14,8 @@ */ #include "general.h" /* must always come first */ -#include "parse.h" +#include "types.h" +#include "vstring.h" #define KEYWORD_NONE -1 @@ -23,6 +24,7 @@ */ extern void addKeyword (const char *const string, langType language, int value); extern int lookupKeyword (const char *const string, langType language); +extern int lookupCaseKeyword (const char *const string, langType language); extern void freeKeywordTable (void); #ifdef DEBUG extern void printKeywordTable (void); diff --git a/ctags/main/kind.h b/ctags/main/kind.h index 50393de7..b5f5aba1 100644 --- a/ctags/main/kind.h +++ b/ctags/main/kind.h @@ -17,11 +17,11 @@ #define KIND_FILE_DEFAULT 'F' #define KIND_FILE_DEFAULT_LONG "file" -typedef struct sKindOption { +struct sKindOption { bool enabled; /* are tags for kind enabled? */ char letter; /* kind letter */ const char* name; /* kind name */ const char* description; /* displayed in --help output */ -} kindOption; +}; #endif /* CTAGS_MAIN_KIND_H */ diff --git a/ctags/main/lcpp.h b/ctags/main/lcpp.h index fc454a5d..62d17144 100644 --- a/ctags/main/lcpp.h +++ b/ctags/main/lcpp.h @@ -13,8 +13,7 @@ * INCLUDE FILES */ #include "general.h" /* must always come first */ - -#include "ctags.h" /* to define langType */ +#include "types.h" /* * MACROS diff --git a/ctags/main/parse.h b/ctags/main/parse.h index 7312f310..3ee7477f 100644 --- a/ctags/main/parse.h +++ b/ctags/main/parse.h @@ -27,7 +27,6 @@ /* * DATA DECLARATIONS */ -typedef int langType; typedef void (*createRegexTag) (const vString* const name); typedef void (*simpleParser) (void); diff --git a/ctags/main/types.h b/ctags/main/types.h new file mode 100644 index 00000000..70fce701 --- /dev/null +++ b/ctags/main/types.h @@ -0,0 +1,21 @@ +/* +* Copyright (c) 1998-2003, Darren Hiebert +* +* This source code is released for free distribution under the terms of the +* GNU General Public License version 2 or (at your option) any later version. +* +* Private definitions for parsing support. +*/ + +#ifndef CTAGS_MAIN_TYPES_H +#define CTAGS_MAIN_TYPES_H + +typedef int langType; + +struct sTagEntryInfo; +typedef struct sTagEntryInfo tagEntryInfo; + +struct sKindOption; +typedef struct sKindOption kindOption; + +#endif /* CTAGS_MAIN_TYPES_H */