Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 09 Oct 2016 20:58:59 UTC Commit: b36c5c54ede9120590fc79db1165c4bbf205702e https://github.com/geany/geany/commit/b36c5c54ede9120590fc79db1165c4bbf20570...
Log Message: ----------- read: change macros into functions and move them into c
Still with commented-out code at some places and using "source" instead of "input".
Also syncs includes and some minor stuff.
Modified Paths: -------------- ctags/main/read.c ctags/main/read.h ctags/parsers/c.c ctags/parsers/php.c
Modified: ctags/main/read.c 83 lines changed, 83 insertions(+), 0 deletions(-) =================================================================== @@ -23,6 +23,16 @@ #include "main.h" #include "routines.h" #include "options.h" +#ifdef HAVE_ICONV +# include "mbcs.h" +#endif + +#include <ctype.h> +#include <stddef.h> +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> /* declare off_t (not known to regex.h on FreeBSD) */ +#endif +#include <regex.h>
/* * DATA DEFINITIONS @@ -35,6 +45,36 @@ static MIOPos StartOfLine; /* holds deferred position of start of line */ * FUNCTION DEFINITIONS */
+extern unsigned long getInputLineNumber (void) +{ + return File.input.lineNumber; +} + +extern int getInputLineOffset (void) +{ + unsigned char *base = (unsigned char *) vStringValue (File.line); + int ret = File.currentLine - base - File.ungetchIdx; + return ret >= 0 ? ret : 0; +} + +extern const char *getInputFileName (void) +{ + return vStringValue (File.input.name); +} + +extern MIOPos getInputFilePosition (void) +{ + return File.filePosition; +} + +extern MIOPos getInputFilePositionForLine (int line) +{ + MIOPos pos; + return pos; +/* return File.lineFposMap.pos[(((File.lineFposMap.count > (line - 1)) \ + && (line > 0))? (line - 1): 0)];*/ +} + extern langType getInputLanguage (void) { return File.source.language; @@ -50,11 +90,54 @@ extern const char *getInputFileTagPath (void) return vStringValue (File.source.tagPath); }
+extern bool isInputLanguage (langType lang) +{ + return (bool)((lang) == getInputLanguage ()); +} + +extern bool isInputHeaderFile (void) +{ + return File.input.isHeader; +} + +extern bool isInputLanguageKindEnabled (char c) +{ + return false; +/* return isLanguageKindEnabled (getInputLanguage (), c); */ +} + +extern bool doesInputLanguageAllowNullTag (void) +{ + return false; +/* return doesLanguageAllowNullTag (getInputLanguage ()); */ +} + extern kindOption *getInputLanguageFileKind (void) { return getLanguageFileKind (File.input.language); }
+extern bool doesInputLanguageRequestAutomaticFQTag (void) +{ + return false; +/* return doesLanguageRequestAutomaticFQTag (getInputLanguage ()); */ +} + +extern const char *getSourceFileTagPath (void) +{ + return vStringValue (File.source.tagPath); +} + +extern const char *getSourceLanguageName (void) +{ + return getLanguageName (File.source.language); +} + +extern unsigned long getSourceLineNumber (void) +{ + return File.source.lineNumber; +} + extern void freeSourceFileResources (void) { vStringDelete (File.input.name);
Modified: ctags/main/read.h 30 lines changed, 18 insertions(+), 12 deletions(-) =================================================================== @@ -17,22 +17,13 @@ #include <stdio.h> #include <ctype.h>
-#include "mio.h" #include "parse.h" #include "vstring.h" +#include "mio.h"
/* * MACROS */ -#define getInputLineNumber() File.input.lineNumber -#define getInputFileName() vStringValue (File.input.name) -#define getInputFilePosition() File.filePosition -#define getSourceFileTagPath() vStringValue (File.source.tagPath) -#define getSourceLanguage() File.source.language -#define getSourceLanguageName() getLanguageName (File.source.language) -#define getSourceLineNumber() File.source.lineNumber -#define isInputLanguage(lang) (bool)((lang) == File.input.language) -#define isInputHeaderFile() File.input.isHeader
/* * DATA DECLARATIONS @@ -52,8 +43,9 @@ enum eCharacters { SINGLE_QUOTE = ''', BACKSLASH = '\',
- STRING_SYMBOL = ('S' + 0x80), - CHAR_SYMBOL = ('C' + 0x80) + /* symbolic representations, above 0xFF not to conflict with any byte */ + STRING_SYMBOL = ('S' + 0xff), + CHAR_SYMBOL = ('C' + 0xff) };
/* Maintains the state of the current input file. @@ -98,10 +90,20 @@ extern inputFile File; */
/* InputFile: reading from fp in inputFile with updating fields in input fields */ +extern unsigned long getInputLineNumber (void); +extern int getInputLineOffset (void); +extern const char *getInputFileName (void); +extern MIOPos getInputFilePosition (void); +extern MIOPos getInputFilePositionForLine (int line); extern langType getInputLanguage (void); extern const char *getInputLanguageName (void); extern const char *getInputFileTagPath (void); +extern bool isInputLanguage (langType lang); +extern bool isInputHeaderFile (void); +extern bool isInputLanguageKindEnabled (char c); +extern bool doesInputLanguageAllowNullTag (void); extern kindOption *getInputLanguageFileKind (void); +extern bool doesInputLanguageRequestAutomaticFQTag (void);
extern void freeSourceFileResources (void); extern bool fileOpen (const char *const fileName, const langType language); @@ -117,6 +119,10 @@ extern bool bufferOpen (unsigned char *buffer, size_t buffer_size, const char *const fileName, const langType language ); #define bufferClose fileClose
+extern const char *getSourceFileTagPath (void); +extern const char *getSourceLanguageName (void); +extern unsigned long getSourceLineNumber (void); + /* Bypass: reading from fp in inputFile WITHOUT updating fields in input fields */ extern char *readLineFromBypass (vString *const vLine, MIOPos location, long *const pSeekValue);
Modified: ctags/parsers/c.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -1723,7 +1723,7 @@ static void skipBraces (void)
static keywordId analyzeKeyword (const char *const name) { - const keywordId id = (keywordId) lookupKeyword (name, getSourceLanguage ()); + const keywordId id = (keywordId) lookupKeyword (name, getInputLanguage ());
/* ignore D @attributes and Java @annotations(...), but show them in function signatures */ if ((isInputLanguage(Lang_d) || isInputLanguage(Lang_java)) && id == KEYWORD_NONE && name[0] == '@')
Modified: ctags/parsers/php.c 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -940,7 +940,7 @@ static void readToken (tokenInfo *const token) else { parseIdentifier (token->string, c); - token->keyword = analyzeToken (token->string, getSourceLanguage ()); + token->keyword = analyzeToken (token->string, getInputLanguage ()); if (token->keyword == KEYWORD_NONE) token->type = TOKEN_IDENTIFIER; else @@ -1145,7 +1145,7 @@ static bool parseFunction (tokenInfo *const token, const tokenInfo *name) }
/* if parsing Zephir, skip function return type hint */ - if (getSourceLanguage () == Lang_zephir && token->type == TOKEN_OPERATOR) + if (getInputLanguage () == Lang_zephir && token->type == TOKEN_OPERATOR) { do readToken (token);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).