This is a backport of two commits from universal-ctags which have a great potential to introduce conflicts: most importantly the use of C99 bool, true, false, but also the removal of vStringTerminate() which is not needed. Better to merge sooner than later. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1251
-- Commit Summary --
* ctags: Use bool definitions from stdbool.h * ctags: drop vStringTerminate()
-- File Changes --
M HACKING (1) M ctags/main/args.c (12) M ctags/main/args.h (4) M ctags/main/entry.c (14) M ctags/main/entry.h (10) M ctags/main/general.h (12) M ctags/main/keyword.c (8) M ctags/main/kind.h (2) M ctags/main/lcpp.c (147) M ctags/main/lcpp.h (6) M ctags/main/lregex.c (51) M ctags/main/main.c (8) M ctags/main/main.h (2) M ctags/main/mio.c (44) M ctags/main/mio.h (4) M ctags/main/options.c (89) M ctags/main/options.h (68) M ctags/main/parse.c (93) M ctags/main/parse.h (24) M ctags/main/read.c (63) M ctags/main/read.h (14) M ctags/main/routines.c (69) M ctags/main/routines.h (10) M ctags/main/sort.c (6) M ctags/main/sort.h (4) M ctags/main/strlist.c (44) M ctags/main/strlist.h (12) M ctags/main/vstring.c (7) M ctags/main/vstring.h (3) M ctags/main/xtag.c (32) M ctags/main/xtag.h (8) M ctags/parsers/abaqus.c (11) M ctags/parsers/abc.c (23) M ctags/parsers/asciidoc.c (12) M ctags/parsers/asm.c (56) M ctags/parsers/basic.c (15) M ctags/parsers/c.c (459) M ctags/parsers/conf.c (17) M ctags/parsers/css.c (18) M ctags/parsers/diff.c (7) M ctags/parsers/docbook.c (17) M ctags/parsers/erlang.c (19) M ctags/parsers/fortran.c (215) M ctags/parsers/go.c (72) M ctags/parsers/haskell.c (9) M ctags/parsers/haxe.c (22) M ctags/parsers/jscript.c (186) M ctags/parsers/json.c (31) M ctags/parsers/latex.c (21) M ctags/parsers/lua.c (13) M ctags/parsers/make.c (44) M ctags/parsers/markdown.c (16) M ctags/parsers/matlab.c (10) M ctags/parsers/nsis.c (13) M ctags/parsers/objc.c (82) M ctags/parsers/pascal.c (72) M ctags/parsers/perl.c (79) M ctags/parsers/php.c (121) M ctags/parsers/powershell.c (46) M ctags/parsers/python.c (72) M ctags/parsers/r.c (8) M ctags/parsers/rest.c (15) M ctags/parsers/ruby.c (68) M ctags/parsers/rust.c (142) M ctags/parsers/sh.c (13) M ctags/parsers/sql.c (170) M ctags/parsers/tcl.c (13) M ctags/parsers/txt2tags.c (17) M ctags/parsers/verilog.c (39) M ctags/parsers/vhdl.c (45)
-- Patch Links --
https://github.com/geany/geany/pull/1251.patch https://github.com/geany/geany/pull/1251.diff
Hmm, the tests fail on MINGW. What's inside stdbool.h on MINGW? It seems to get included alright as there's no error related to that but the definition of "bool" seems to be missing for some reason.
No problem to add some ifdef, just wondering what's going on.
I suspect it's because `bool` is a macro and is explicitly undefined for some reason, for example here: https://github.com/geany/geany/pull/1251/commits/accf8e9e064b67438147c511280...
looks like a global change of `boolean` to `bool` error :)
b4n requested changes on this pull request.
I didn't review the changes on U-CTags side, so some comments might be slightly irrelevant (e.g. alignment, while nice, doesn't make much sense if it's not kept on U-CTags side), or on the contrary relevant to apply to U-CTags.
unsigned long lineNumber; /* line number of tag */
MIOPos filePosition; /* file position of line containing tag */ const char* language; /* language of source file */ - boolean isFileScope; /* is tag visible only within source file? */ - boolean isFileEntry; /* is this just an entry for a file name? */ - boolean truncateLine; /* truncate tag line at end of tag name? */ + bool isFileScope; /* is tag visible only within source file? */ + bool isFileEntry; /* is this just an entry for a file name? */ + bool truncateLine; /* truncate tag line at end of tag name? */
maybe keep alignment
@@ -46,7 +46,7 @@
# include <sys/types.h> /* required by dirent.h */ # endif # include <dirent.h> /* to declare opendir() */ -# undef boolean +# undef bool
as @codebrainz pointed out, that's not good as the C standard explicitly states that `bool` is a macro. So while here this probably restored the `typedef` from *general.h*, now it removes any definition. I think it must be safe to drop this `undef` altogether, as *stdbool.h* being standard there's no reason for *dirent.h* to mess it up.
@@ -225,8 +225,8 @@ MIO *mio_new_memory (unsigned char *data,
mio->impl.mem.allocated_size = size; mio->impl.mem.realloc_func = realloc_func; mio->impl.mem.free_func = free_func; - mio->impl.mem.eof = FALSE; - mio->impl.mem.error = FALSE; + mio->impl.mem.eof = false; + mio->impl.mem.error = false;
(I definitely need to do something about MIO sync)
} extensionFields;
stringList* ignore; /* -I name of file containing tokens to ignore */ - boolean append; /* -a append to "tags" file */ - boolean backward; /* -B regexp patterns search backwards */ + bool append; /* -a append to "tags" file */ + bool backward; /* -B regexp patterns search backwards */
comment alignment? :) (continues below)
@@ -71,7 +71,7 @@ typedef struct {
/* used internally */ unsigned int id; /* id assigned to language */ - boolean enabled; /* currently enabled? */ + bool enabled; /* currently enabled? */
alignment
@@ -294,10 +294,10 @@ extern boolean fileOpen (const char *const fileName, const langType language)
* This func is NOT THREAD SAFE. * The user should not tamper with the buffer while this func is executing. */ -extern boolean bufferOpen (unsigned char *buffer, size_t buffer_size, +extern bool bufferOpen (unsigned char *buffer, size_t buffer_size, const char *const fileName, const langType language )
parenthesis alignment (ok, it's not very visible here)
@@ -113,7 +113,7 @@ extern void ungetcToInputFile (int c);
extern const unsigned char *readLineFromInputFile (void); extern char *readLineRaw (vString *const vLine, MIO *const mio); extern char *readSourceLine (vString *const vLine, MIOPos location, long *const pSeekValue); -extern boolean bufferOpen (unsigned char *buffer, size_t buffer_size, +extern bool bufferOpen (unsigned char *buffer, size_t buffer_size, const char *const fileName, const langType language );
alignment
@@ -103,7 +103,7 @@ static void printXtag (xtagType i)
printf((Option.machinable? "%c\t%s\t%s\t%s\n": MAKE_XTAG_FMT(c)), xtagDescs[i].letter, xtagDescs[i].name, - getXtagDesc (i)->enabled? "TRUE": "FALSE", + getXtagDesc (i)->enabled? "true": "false",
that's probably wrong
@@ -404,7 +404,7 @@ static const keywordDesc KeywordTable [] = {
{ "bind_var", KEYWORD_BIND_VAR, { 0, 0, 0, 0, 1, 0, 0 } }, { "bit", KEYWORD_BIT, { 0, 0, 0, 0, 1, 0, 0 } }, { "body", KEYWORD_BODY, { 0, 0, 0, 0, 0, 0, 1 } }, - { "boolean", KEYWORD_BOOLEAN, { 0, 0, 0, 1, 0, 0, 0 } }, + { "bool", KEYWORD_BOOLEAN, { 0, 0, 0, 1, 0, 0, 0 } },
Nope!
@@ -689,7 +689,7 @@ static const char *implementationString (const impType imp)
#ifdef DEBUG
-#define boolString(c) ((c) ? "TRUE" : "FALSE") +#define boolString(c) ((c) ? "true" : "false")
this should probably be left out (although well, it's only used in debugging output, so doesn't matter so much)
else if (isType (token, TOKEN_BRACE_CLOSE))
/* Java, D, C#, Vala do not require semicolons to end a block. Neither do * C++ namespaces. All other blocks require a semicolon to terminate them. */ - isEnd = (boolean) (isInputLanguage (Lang_java) || isInputLanguage (Lang_d) || + isEnd = (bool) (isInputLanguage (Lang_java) || isInputLanguage (Lang_d) || isInputLanguage (Lang_csharp) || isInputLanguage (Lang_vala) || ! isContextualStatement (st));
alignment
@@ -70,12 +70,12 @@ typedef enum {
static langType Lang_json;
static kindOption JsonKinds [] = { - { TRUE, 'o', "object", "objects" }, - { TRUE, 'a', "array", "arrays" }, - { TRUE, 'n', "number", "numbers" }, - { TRUE, 's', "string", "strings" }, - { TRUE, 'b', "boolean", "booleans" }, - { TRUE, 'z', "null", "nulls" } + { true, 'o', "object", "objects" }, + { true, 'a', "array", "arrays" }, + { true, 'n', "number", "numbers" }, + { true, 's', "string", "strings" }, + { true, 'b', "bool", "booleans" },
not the string
@@ -87,7 +87,7 @@ static boolean isTxt2tagsLine (const unsigned char *line)
return len >= 20 && *line == 0; }
-static boolean parseTxt2tagsTitle (const unsigned char *line, +static bool parseTxt2tagsTitle (const unsigned char *line, vString *const title, int *const depth_)
alignment
techee commented on this pull request.
@@ -46,7 +46,7 @@
# include <sys/types.h> /* required by dirent.h */ # endif # include <dirent.h> /* to declare opendir() */ -# undef boolean +# undef bool
Crap, yeah, I should have gone through all the uses manually instead of thinking simple rename will do the right thing. Will go through all the renames and fix issues.
b4n commented on this pull request.
@@ -46,7 +46,7 @@
# include <sys/types.h> /* required by dirent.h */ # endif # include <dirent.h> /* to declare opendir() */ -# undef boolean +# undef bool
@techee I already reviewed the whole diff, so while I might of course have missed something, I flagged what I saw, and the rest seemed just fine.
techee commented on this pull request.
@@ -156,15 +156,15 @@ static void findPascalTags (void)
char *arglist = NULL; char *vartype = NULL; pascalKind kind = K_FUNCTION; - /* each of these flags is TRUE iff: */ - boolean incomment = FALSE; /* point is inside a comment */ + /* each of these flags is true iff: */ + bool incomment = false; /* point is inside a comment */ int comment_char = '\0'; /* type of current comment */
Note to self: alignment of comment
@techee pushed 1 commit.
0e69692 Fix crap after myself
Fixed, it passes the travis build now. If it's OK like this, I can squash the last commit with the original commit.
b4n commented on this pull request.
If we care about alignment, there are a few more to fix. Apart that, LGTM.
}
}
-static boolean enableLanguageKind (const langType language, - const int kind, const boolean mode) +static bool enableLanguageKind (const langType language, + const int kind, const bool mode)
alignment
@@ -526,10 +525,10 @@ static void processLangKindOption (const langType language,
} }
-extern boolean processKindOption (const char *const option, +extern bool processKindOption (const char *const option, const char *const parameter)
alignment
tag.lineNumber = 1;
makeTagEntry (&tag); } }
-static boolean createTagsForFile (const char *const fileName, +static bool createTagsForFile (const char *const fileName, const langType language, const unsigned int passCount)
ditto
@@ -636,13 +635,13 @@ static boolean createTagsForFile (const char *const fileName,
return retried; }
-static boolean createTagsWithFallback (const char *const fileName, +static bool createTagsWithFallback (const char *const fileName, const langType language)
more
@@ -48,7 +48,7 @@ typedef struct {
const char* const name; const char* const kinds; const char *const flags; - boolean *disabled; + bool *disabled;
more or less the same, but meh
@@ -66,7 +66,7 @@ typedef struct sInputFileInfo {
when `resetInputFile' is called on the input stream. This is needed for nested stream. */ - boolean isHeader; /* is input file a header file? */ + bool isHeader; /* is input file a header file? */
more
@@ -78,8 +78,8 @@ typedef struct sInputFile {
MIOPos filePosition; /* file position of current line */ unsigned int ungetchIdx; int ungetchBuf[3]; /* characters that were ungotten */ - boolean eof; /* have we reached the end of file? */ - boolean newLine; /* will the next character begin a new line? */ + bool eof; /* have we reached the end of file? */ + bool newLine; /* will the next character begin a new line? */
more or less
@@ -1535,7 +1534,7 @@ static void qualifyCompoundTag (const statementInfo *const st,
const tagType type = declToTagType (st->declaration);
if (type != TAG_UNDEFINED) - makeTag (nameToken, st, (boolean) (! isInputLanguage (Lang_java) && + makeTag (nameToken, st, (bool) (! isInputLanguage (Lang_java) && ! isInputLanguage (Lang_csharp) && ! isInputLanguage (Lang_vala)), type);
more
else if (isType (token, TOKEN_BRACE_CLOSE))
/* Java, D, C#, Vala do not require semicolons to end a block. Neither do * C++ namespaces. All other blocks require a semicolon to terminate them. */ - isEnd = (boolean) (isInputLanguage (Lang_java) || isInputLanguage (Lang_d) || - isInputLanguage (Lang_csharp) || isInputLanguage (Lang_vala) || - ! isContextualStatement (st)); + isEnd = (bool) (isInputLanguage (Lang_java) || isInputLanguage (Lang_d) || + isInputLanguage (Lang_csharp) || isInputLanguage (Lang_vala) || + ! isContextualStatement (st));
:+1:
{
const char *const scriptName = baseFilename (getInputFileName ()); - boolean result = (boolean) (strcmp (scriptName, "configure") == 0 && + bool result = (bool) (strcmp (scriptName, "configure") == 0 && strcmp (vStringValue (tagName), "main") == 0);
more
@techee pushed 1 commit.
c2222c9 Some alignment fixes
If we care about alignment, there are a few more to fix.
Fixed. (Though ctags indentation is rather messy and it would deserve major cleanup and small things like these won't make it much worse.)
OK to squash the last two patches with the first one? Once merged I'd continue working on ctags syncing.
@techee yeah perfect thanks, please go ahead and squash.
@b4n Done.
b4n approved this pull request.
Merged #1251.
github-comments@lists.geany.org