160 Commits

Author SHA1 Message Date
Jiří Techet
9b44e9fa42 Fix parsing with sub-parsers
The previous code would skip parsing with sub-parsers so these would not
work. Running full createTagsWithFallback1() in this case would cause
two problems:

1. We would have to propagate the extra callback arguments to
runParserInNarrowedInputStream()

2. And the callbacks after each pass should not actually be called in this
case because the caller expects these are called for the master parser,
not the sub-parsers.

So instead just do simple parsing without re-tries which are used only in
the C and Fortran parsers which lack sub-parser capability anyway.
2018-10-13 13:33:23 +02:00
Jiří Techet
bf4eb8f093 lcpp: use eStrdup() instead of strdup() 2017-02-15 12:03:41 +01:00
Jiří Techet
df0ae9b77a python: minor cleanups 2017-02-15 12:00:17 +01:00
Jiří Techet
e5b5326cc0 python: Rename corkPair struct to corkInfo 2017-02-15 11:58:02 +01:00
Jiří Techet
3e8365c7f2 asciidoc, rest: Remove unnecessary scope assignments
Should be handled by cork.
2017-02-15 11:50:22 +01:00
Jiří Techet
cf6653a4ce Don't check if kind is enabled for library
Library users probably want all found tags and decide themselves whether
the tag is interesting for them or not. Revert "enabled" values in c.c
to their previous values to match uctags as these are ignored now.
2017-02-15 01:13:57 +01:00
Jiří Techet
634719aff6 c.c: Eliminate useless kind_for_define variable 2017-02-15 00:35:56 +01:00
Jiří Techet
d5823ced94 c.c: Reinitialize rescan variable in case longjmp() happens 2017-02-15 00:34:34 +01:00
Jiří Techet
8455f8e70d lcpp, c: Fix signature collection
First, make sure that when calling cppGetc() and cppUngetc() the signature
is properly updated.

Second, make sure that signature is cleared when preparing for new token
read.
2017-02-15 00:31:10 +01:00
Jiří Techet
0a6acff818 Remove mbcs.c/h
Currently unused by Geany.
2016-10-24 14:52:11 +02:00
Jiří Techet
efc40f4007 #if 0 most of options.c
We don't need command-line options parsing so we can remove most of the
file. Add dummy implementations of functions called from elsewhere.
2016-10-24 13:11:43 +02:00
Jiří Techet
40ed52cf64 Remove output writer implementations
Not needed by Geany, just keep dummy implementation so we don't have to
change the rest of the files.
2016-10-24 12:47:50 +02:00
Jiří Techet
b8df6e02ad Eliminate use of fnmatch() which isn't present on MINGW
We could add the fnmatch implementation from uctags (see the fnmatch
directory) but since we don't use fileNameMatched(), we can just drop it.
2016-10-15 19:40:17 +02:00
Jiří Techet
0dd9f3a362 Eliminate use of regex from read.c
readLineFromBypassSlow() isn't used in Geany so we can drop it for now.
Preferably in the future part of this code should be moved to lregex.c.
2016-10-15 19:24:20 +02:00
Jiří Techet
09e13d50cf Don't compile bigger part of main for CTAGS_LIB
Without this clock_t definition is missing (haven't investigated why)
but we don't need the stuff from main anyway.
2016-10-15 18:17:57 +02:00
Jiří Techet
38403d1ca0 Annotate geany-specific diffs
This makes it clearer to see which diffs are related to Geany. Only for
files which are synced, not e.g. for lcpp where changes are everywhere.
2016-10-15 16:55:52 +02:00
Jiří Techet
e1b4d14097 Add the remaining missing files from uctags 2016-10-15 16:43:14 +02:00
Jiří Techet
06f1a19c4b Make LanguageTable variable private in parse.c
This requires having some accessor to LanguageTable for the API functions
which is done by getParserDefinition().
2016-10-15 16:29:40 +02:00
Jiří Techet
3390e2acc8 Move ctags "API" from Geany to ctags
This commit basically just moves stuff from tm_ctags_wrappers.c/h to
ctags. The "api.h" file has been renamed to "ctags-api.h" to make it
clearer it belongs to ctags when included.

The code also tries to completely isolate ctags from the caller;
previously we were using tagEntryInfo to pass information to Geany. This
however required including entry.h which added lots of other stuff we
don't want in the API. Instead create an auxiliary struct that holds
all the needed information from tagEntryInfo (currently only the stuff
used by Geany) and copy all the info from tagEntryInfo before invoking
the callback.
2016-10-15 15:16:45 +02:00
Jiří Techet
32dfa2878a Some initial work on ctags as a library
Protect library-specific stuff by CTAGS_LIB macro which also makes it
better visible what changes had to be made to convert ctags into library.
Changes which need further Geany sync and aren't library-related aren't
protected by the macro.

Move things from geany.c/h to the locations where they belong and rename
geany.c/h to api.c/h into which API-like functions will be moved in the
next commits (mostly things from tm_ctags_wrappers.c/h).

Add complete main.c from uctags and just remove main() using the CTAGS_LIB
macro.
2016-10-15 00:14:37 +02:00
Jiří Techet
29d801aa7b tmp 2016-10-14 23:28:30 +02:00
Jiří Techet
f82218ab07 Sync error.c completely and create a custom error printer
Make sure the custom error printer never ends with fatal errors terminating
the application.
2016-10-14 23:26:59 +02:00
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