Commit Graph

189 Commits (master)

Author SHA1 Message Date
Jiří Techet c56047be5a Some minor syncs 2016-10-14 22:59:10 +02:00
Jiří Techet de214944e8 read: backport patch from uctags
See

cd460f4c19bf940fc4290b5ceca1dba873baf7cb
eb347f8fe08ac0d5467b4020aceb1a5ecbdd12aa

That said the readLineRaw() is completely mad and wrong. In the first
iteration pLastChar is set to position -2 where it's assigned '\0' so
there's invalid memory access.

Since iFileGetLine() uses mio_gets() too, we should unify the two.
2016-10-14 22:58:58 +02:00
Jiří Techet bbdd3a1e36 Add typeRef to sTagEntryInfo
Even though we don't use it, we can keep it there and get rid of some
diffs against uctags.
2016-10-14 20:57:42 +02:00
Jiří Techet 97bf03c8f7 grab uctags debug.c/h
If we don't define the DEBUG macro (which we don't), all the assert
operations will be NOOPs. The asserts aren't that terribly useful
(usually the crash happens just the following line) and uctags should
be reasonably well tested by the uctags project so we can drop them.
2016-10-14 20:49:40 +02:00
Jiří Techet 829ea7d38b Grab uctags version of parse.c/h and nestlevel.c/h plus additional fallout
At this point the only remaining files with big changes are parser.c/h
and nestlevel.c/h. However, the amount of changes is big and these
changes cannot be easily separated into individual small patches. Fortunately
by looking at parse.c there doesn't seem to be anything really valuable
in Geany's version and we can just simply take over the ctags one and
only apply the necessary changes on top of that. nestlevel.c/h has to
be synced at the same time as the changes are related to cork introduction
which was done in both of them.

A few points:

createTagsWithFallback1() and createTagsWithFallback() have been modified
so they don't do anything with the output tags file which we don't use.
Because they contain all the reparsing logic we originally had in
tm_ctags_parse(), this function got simplified and just calls
createTagsWithFallback().

In Options EX_PATTERN has been changed to EX_LINENUM (there's some strange
thing with EX_PATTERN in uctags as it always checks the previous line
in the output tags file - and we don't have output tags file so it
crashes).

Lots of previously commented-out lines (because we didn't have all the
functions from uctags at that point) could be uncommented.

lxpath.c has been added.

Parsers had to be adjusted to work with the updated nestlevel and cork.
Changes in asciidoc and rest were based on the "rst.c" parser from uctags.
txt2tags has been modified manually. The ruby changes wer taken directly
from the uctags ruby parser and the python ones were based on the last
commit before the introduction of the token-based parser.

The parser now respects if kinds are enabled/disabled so prototypes
and externvars had to be enabled in the c.c parser to get the same output.

The parse2() function now returns rescanReason union instead of simple
bool to indicate reparsing should happen - c.c and fortran have been
changed accordingly.

tm_ctags_init() has been changed to call all the initialization that
happens in uctags except of output tag file initialization which we don't
use. In addition it calls

initializeParser (LANG_AUTO)

This forces all parsers to get initialized. Without it parsers get
initialized lazily as they are used but the problem is code like

isInputLanguage (Lang_java)

in c.c which just does ((lang) == getInputLanguage ()) works incorrectly
because getInputLanguage () returns 0 for C and when uninitialized,
Lang_java is also 0 and we have a problem. This problem isn't present in
uctags because there the 0th parser is always CTagsSelfTestParser
so this cannot happen.
2016-10-14 18:07:31 +02:00
Jiří Techet 40d023dafc lregex: Add the remaining missing functions from uctags
None of them invokes directly GNU regex so no change is needed here.
Sync also the regex part of parse.h.
2016-10-12 22:52:27 +02:00
Jiří Techet fb432c8ccf lregex: sync the remaining parts of the existing code 2016-10-12 22:47:07 +02:00
Jiří Techet 73be5c644d lregex: add new flag processing
For 'b', 'e', 'i' keep the corresponding GRegex flags.
2016-10-12 22:39:24 +02:00
Jiří Techet 56936a8614 lregex: some harmless syncs 2016-10-12 17:55:59 +02:00
Jiří Techet 112f136a0a lregex: introduce findRegexTagsMainloop()
Does the same thing like the previous code.
2016-10-12 17:38:48 +02:00
Jiří Techet ca19e6e3b3 lregex: sync some function prototypes 2016-10-12 17:32:01 +02:00
Jiří Techet 017e1be502 lregex: Add missing fields to regexPattern 2016-10-12 17:13:32 +02:00
Jiří Techet 501ebe94d5 lregex: Initialize lregex structures the universal-ctags way
I didn't check in detail what the changes are but since no GRegex code is
involved and since everything seems to work after the patch, I think it's OK.
2016-10-12 17:09:19 +02:00
Jiří Techet 8c4c570eb6 lregex: remove unused functions
So it's easier to sync them by simply getting the uctags versions.
2016-10-12 13:26:45 +02:00
Jiří Techet 380a662a25 lregex: some simple syncs 2016-10-12 13:26:45 +02:00
Jiří Techet ca1622412f lregex: replace regexBroken with regexAvailable 2016-10-12 13:26:39 +02:00
Jiří Techet 59d6375b09 lregex: sync includes 2016-10-12 11:48:57 +02:00
Jiří Techet b6ca38712f parse: other small syncs 2016-10-11 23:40:20 +02:00
Jiří Techet 051b780745 parse: some simple syncs and include syncs
Addition of dependency.c/h and promise.c/h. Also moved tagEntryFunction
definitions to geany.c/h.
2016-10-11 23:04:13 +02:00
Jiří Techet 2f83d0d164 parse: remove things unused by Geany for simpler merge 2016-10-11 17:30:06 +02:00
Jiří Techet 8436b975ed read: add the remaining stuff from uctags 2016-10-11 17:15:34 +02:00
Jiří Techet 53f83e7cee read: add lineFposMap 2016-10-11 17:09:54 +02:00
Jiří Techet ed03c2042d read: introduce langStack for source files 2016-10-11 17:05:56 +02:00
Jiří Techet f89e9f8014 read: Add function to initialize common parts of input/source files and use it
Also correct input/source file usage in the file and initialize everything
like in universal-ctags.
2016-10-11 16:59:10 +02:00
Jiří Techet aafb127024 read: implement openBuffer() using openInputFile()
In addition, add automatic memory MIO opening to read.c for small files
and remove the same optimization from Geany. Simplify tm_ctags_parse()
as the memory/file branches are identical now.
2016-10-11 12:26:51 +02:00
Jiří Techet 2f4d43ac93 read: Some function renaming 2016-10-11 00:45:15 +02:00
Jiří Techet dac3afbbfa read: use makeFileTag() 2016-10-11 00:24:33 +02:00
Jiří Techet eecfff0da7 read: Add some extra data structures 2016-10-11 00:22:48 +02:00
Jiří Techet c1acde7eff read: move sInputFileInfo, sInputFile and File to read.c 2016-10-11 00:13:25 +02:00
Jiří Techet 63fbe2f6a2 c.c, lcpp.c: Avoid using File.mio
In uctags File is made private and mio gets inaccessible. At the moment
it's used by c.c and lcpp.c to get the parameter list. The C parser
"marks" the position where the argument list starts and once the right
")" is reached, string corresponding to this range is read from MIO,
filtered and used for parameter list.

For macro parameters the end of parameter list is handled in a slightly
obfuscated way - since the code from read.c reads the code by lines,
getInputFilePosition() returns the position of EOL so the parameter list
is read between '(' and EOL.

The code had to be modified to collect the potential parameter string
on the way - vString *signature has been added to lcpp.c and every
getcFromInputFile() and ungetcToInputFile() has been converted to
getcAndCollect() and ungetcAndCollect(), respectively, which in addition
perform the parameter collection when needed. Unfortunately this involves
many places in lcpp.c and we must be careful to always use these instead
of the standard ones from read.c.

We cannot rely on the implicit reading of whole lines and must add such
a code ourselves: just plain reading and collecting is enough. In addition
I added handling of multi-line signatures which was missing before.

In tests "bug1585745.cpp" and "cpp_destructor.cpp" the new code fixes
missing () in destructors when there's a space between tilde and name.
In "simple.d" test it fixes wrong function prototype.

The output of test "bug507864.c" seems to be worse than before but it was
already broken before and apparently the compiler is confused by it.
2016-10-11 00:03:18 +02:00
Jiří Techet b36c5c54ed 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.
2016-10-09 22:58:59 +02:00
Jiří Techet 8e804b3145 entry: Add the remaining code from uctags
Also enable compilation of forgotten kind.c
2016-10-09 19:58:24 +02:00
Jiří Techet 00920360da entry: Sync initTagEntry() code
For now use "source" instead of "input" for various functions inside
read.c which we need as we don't initialize "input" yet.
2016-10-09 16:49:13 +02:00
Jiří Techet f23b56b027 entry: make makeTakEntry() implementation closer to uctags
For now, comment-out code that we don't use and that doesn't work.
2016-10-09 15:22:42 +02:00
Jiří Techet 6ce628da2c entry: Some more or less formal changes 2016-10-09 14:47:54 +02:00
Colomban Wendling 87111f268f Ferite: Fix a memory leak 2016-10-09 12:58:44 +02:00
Jiří Techet 3f52bfb4ab entry: Take over uctags tag writing code
We don't use it so we can grab whatever is there.
2016-10-09 12:48:49 +02:00
Jiří Techet 4cde630dd7 Sync the beginning of entry.c/h
Mostly sTagEntryInfo and eTagFile taken from uctags and sync of includes.
2016-10-09 12:40:08 +02:00
Jiří Techet 848fa0dce3 Move eTagFile from entry.h to entry.c
Add access functions and use them outside entry.c. In addition to functions
defined in uctags setMaxTagsLine() had to be added because it is needed
in parser.c (at the moment, will be probably gone in some of the next
commits).
2016-10-09 11:56:49 +02:00
Jiří Techet e685d956d6 Some sync of lcpp.c/h
Sync things which are possible to sync from lcpp.c/h. This file is heavily
dependent on c.c and since our c.c differs quite significantly, it's
not possible to use the universal-ctags implementation right now.
2016-10-09 11:04:51 +02:00
Jiří Techet 1a43ee2afa Grab uctags kind.c/h 2016-10-08 17:38:31 +02:00
Jiří Techet 2a9f473d78 Sync options.c/h (and introduce a lot of new garbage)
This commit started innocently as an attempt to grab options.c/h from
uctags. However it started referencing other files (which started
referencing other files) so the result is lots of new files are added.

When trying to make it compile, I run into many differences of existing
code which would have to be resolved. As all the added code is more or
less garbage for Geany, I just simply commented-out various function
bodies so it compiles without additional modifications. Should get fixed
once more files get synced with uctags.
2016-10-08 15:48:42 +02:00
Jiří Techet 0a0ed51792 Create geany.c/h and put isIgnoreToken()
This is a (hopefully) temporary file where we put geany-specific code
that for some reason has to be still in ctags. Put isIgnoreToken()
in this file.
2016-10-08 14:13:41 +02:00
Jiří Techet f1dbf2cb7b Grab ctags implementation of sort.c/h
I haven't studies the changes much but this file is responsible for sorting
tag files which isn't interesing for us.
2016-10-08 14:13:41 +02:00
Jiří Techet 88cbe3871c Grab ctags version of general.h and make related changes
Added e_msoft.h, changed configure.ac to make more checks for header files
so we have corresponding macros defined, drop HAVE_REGEX macro check which
isn't defined any more, drop debugging function from lua parser (complains
about missing definition of errout).

Tested only on Linux (TODO: Windows, OS X)
2016-10-08 14:13:41 +02:00
Jiří Techet 37f015d993 Implement iFileGetLine() using gets() 2016-10-08 14:13:41 +02:00
Jiří Techet a5dea8091b Grab all MIO changes from uctags 2016-10-08 14:13:41 +02:00
Jiří Techet 580beba0c7 Remove all unused code from main.c 2016-10-08 14:13:41 +02:00
Jiří Techet ded5ea3eea Move debug related code to debug.c/h 2016-10-08 14:13:41 +02:00
Jiří Techet 7ebcfb77dc Define gcc attributes inside gcc-attr.h 2016-10-08 14:13:36 +02:00
Jiří Techet 85a894b097 Grab args.c/h uctags implementation
Basically dead code for us.
2016-10-08 14:12:45 +02:00
Jiří Techet c6294e37c9 Grab uctags ctags.h and add repoinfo.c/h 2016-10-08 14:12:45 +02:00
Jiří Techet 2b8c7ae5ad Sync the rest of routines.c/h
Requires checking for errno.h limits.h in autoconf as there are ifdefs
around those in routines.c.
2016-10-08 14:12:45 +02:00
Jiří Techet 65f782b6d2 Don't initialize ExecutableProgram and ExecutableName
We shouldn't need it.
2016-10-08 14:12:45 +02:00
Jiří Techet d5b60d2f21 Use uctags implementation of strstr() 2016-10-08 14:12:45 +02:00
Jiří Techet 3219d9783c Make sure that file extension is taken from file (not preceding directory) 2016-10-08 14:12:45 +02:00
Jiří Techet 9e7eade7c0 Use parse separator utilities in routines.c 2016-10-08 14:12:45 +02:00
Jiří Techet f0e7af2c32 Make combinePathAndFile() return char * instead of vString
Also move eStrdup() to the correct position in the header.

In addition add the same includes into debug.h as those in uctags (the
removal of vstring inclusion inside routines.h causes compilation errors -
it would be best to explicitly include all needed files in every source to
avoid problems like this but let's do just syncing the two implementations
for now).
2016-10-08 14:12:45 +02:00
Jiří Techet fb4fc07b6a Make tempFile() return MIO 2016-10-08 14:12:45 +02:00
Jiří Techet ed01b7edb4 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).
2016-10-08 14:12:44 +02:00
Jiří Techet a52137f414 Grab uctags implementation of strlist
Except missing mio_free() in stringListNewFromFile() which has been ported
to uctags.

Except the use of ptrarray for strlist implementation, there's nothing
interesting in the Geany version which would be worth preserving.
2016-10-08 14:12:44 +02:00
Jiří Techet ed6d24bb9a Remove unused functions from options.c/h 2016-10-08 14:12:44 +02:00
Jiří Techet 2f1ad0232b Remove most uses of glib calls
Some special cases which require more work still remain, plus there's
still GRegex.
2016-10-08 14:12:44 +02:00
Jiří Techet 560107804c Drop some more unused functions from routines.c/h
Also get the error() implementation from error.c/h (modified slightly to
make sure exit() isn't called and which doesn't call errorPrinter() as
this one should be set somewhere else in the code and it doesn't happen
now).
2016-10-08 14:12:35 +02:00
Jiří Techet d88a9dd3fc Eliminate uses of g_stat()
Convert g_stat() to stat() and introduce eStat() to routines.c/h and use
it instead of getFileSize() and isExecutable().

On the way grab implementations of isSameFile() and tempFile() from
universal-ctags (I haven't checked in detail if all the ifdef cases do the
right thing but these functions aren't probably called in Geany so
we don't have to worry much). Also drop unused setCurrentDirectory().
2016-10-06 17:20:36 +02:00
Jiří Techet 992306aec3 Add generic pointer array 2016-10-06 15:41:19 +02:00
Jiří Techet 227b808799 Grab the complete uctags vString implementation
All the changes in the first half of .c/.h were introduced by me in uctags
(and thus they are guaranteed to be great ;-).

The following functions were missing in our ctags implementation and are
added by this commit (currently unused):

extern vString *vStringNewOrClear (vString *const string);
extern char    *vStringDeleteUnwrap (vString *const string);
extern void vStringCatSWithEscaping (vString* b, const char *s);
extern void vStringCatSWithEscapingAsPattern (vString *output, const char* input);

read.c has been updated to use vStringResize() instead of
vStringAutoResize().
2016-10-06 15:33:24 +02:00
Jiří Techet 40396a392e ctags: drop vStringTerminate()
It's call is unnecesssary. Corresponds to universal-ctags commit
cfc45e3bd9000e8ce193399c7e0ecf2bbeb57977.
2016-10-04 18:06:33 +02:00
Jiří Techet 662765852f ctags: Use bool definitions from stdbool.h
Since Geany requires C99 parser, the patch just simply includes stdbool.h
in general.h and drops the TRUE, FALSE definitions inside the same file.
The rest is purely mechanical

boolean -> bool
TRUE -> true
FALSE -> false

plus some alignment fixes.

This patch corresponds to universal-ctags commit ce990805a0a0269c.
2016-10-04 18:05:54 +02:00
Jiří Techet 63c054a61e #if 0 currently unused code to avoid compiler warning 2016-09-09 18:00:41 +02:00
Jiří Techet f511787f31 Add missing prototypes 2016-09-09 17:46:13 +02:00
Jiří Techet 1e14667bbc Don't compare foreign values to enumeration type
Clang warns when comparing an enumeration type with a value not found
in this enumeration:

warning: comparison of constant VALUE with expression of type 'TYPE' is
      always false [-Wtautological-constant-out-of-range-compare]

If the compiler then decides to optimize the test away because it
assumes the it is indeed always false, it can lead to pretty subtle and
nasty issues.

Ported universal-ctags patch from Colomban Wendling
2016-09-09 17:18:17 +02:00
Jiří Techet cb7da79824 Add CTAGS_ATTR_ prefix to UNUSED() and PRINTF() macros
Also fix the macro use in objc.c to appear behind variables.
2016-08-22 14:54:19 +02:00
Jiří Techet b7f7ce2675 Drop vi modelines 2016-08-19 15:16:32 +01:00
Jiří Techet a974f35752 Define KEYWORD_NONE in keyword.h so it doesn't have to be defined by parsers 2016-08-16 13:18:50 +01:00
Jiří Techet d0cc3dc132 Remove TagEntryFunction check in c.c
It's always non-null in Geany, it's value is checked in makeTagEntry()
anyway and parsers shouldn't know about it.
2016-08-10 11:55:02 +02:00
Jiří Techet 0eca258e58 Fix incorrect use of MIO 2016-08-09 00:34:29 +02:00
Jiří Techet e866a976c9 entry: Move functions around a bit to reduce the amount of diffs 2016-08-08 23:01:14 +02:00
Jiří Techet ca65fa2236 Sync whitespace and comments in main 2016-08-07 18:31:30 +02:00
Jiří Techet 967b572240 Rename MIO variables from fp to mio 2016-08-07 18:31:30 +02:00
Jiří Techet 02138f9e59 Rename TM_DEBUG macro to DEBUG 2016-08-07 18:31:30 +02:00
Jiří Techet 25c1d220cf objc: Remove unnecessary redefinition of UNUSED 2016-08-07 18:31:30 +02:00
Jiří Techet a59f82ec69 Rename getArglistFromFilePos() to cppGetArglistFromFilePos() to match the rest 2016-08-07 18:31:30 +02:00
Jiří Techet 20ad9ad428 Make getArglistFromStr() static 2016-08-07 18:31:30 +02:00
Jiří Techet d122229902 Rename skipOverCComment() to cppSkipOverCComment() 2016-08-07 18:31:30 +02:00
Jiří Techet 4910e2554b Rename getDirectiveNestLevel() to cppGetDirectiveNestLevel() 2016-08-07 18:31:30 +02:00
Jiří Techet 2638899379 Rename isBraceFormat to cppIsBraceFormat() 2016-08-07 18:31:30 +02:00
Jiří Techet 88a8724d1c Rename isident1() to cppIsident1() 2016-08-07 18:31:30 +02:00
Jiří Techet 95f94629f0 Rename isident() to cppIsident() 2016-08-07 18:31:30 +02:00
Jiří Techet 1d48599d3c Remove R regex parser
Unused by us, not present in uctags.
2016-08-07 18:31:30 +02:00
Jiří Techet 2671d73b67 Use skipToCharacterInInputFile() in all parsers 2016-08-07 18:31:30 +02:00
Jiří Techet 76818f9439 Change getSourceFileName() to getInputFileName() 2016-08-07 18:31:25 +02:00
Jiří Techet 2161b73864 Change isHeaderFile() to isInputHeaderFile() 2016-08-07 18:22:49 +02:00
Jiří Techet 7bd81abc1d Change isLanguage() to isInputLanguage() 2016-08-07 02:15:12 +02:00
Jiří Techet 082a9724f1 Use ARRAY_SIZE() in parsers 2016-08-07 02:01:38 +02:00
Jiří Techet 9745d470c6 Sync whitespace in parsers 2016-08-07 02:01:33 +02:00
Jiří Techet 11dcc5e3e5 Fix indentation 2016-08-06 22:42:37 +02:00
Jiří Techet 026da60fd0 Move selected() under Miscellaneous macros 2016-08-06 22:42:15 +02:00
Jiří Techet 0650707ce5 Fix pascal tag initizalization 2016-08-06 22:06:41 +02:00
Jiří Techet 0ec3590e19 Remove makeSimpleScopedTag() and fix scope for conf filetype 2016-08-06 22:01:05 +02:00