Fixef bad tag when parsing empty OCaml file, reported by Marc Weber.

git-svn-id: svn://svn.code.sf.net/p/ctags/code/trunk@766 c5d04d22-be80-434c-894e-aa346cc9e8e8
This commit is contained in:
dhiebert 2010-09-11 18:59:45 +00:00
parent 0c703a48eb
commit 02abf6e258
4 changed files with 16 additions and 5 deletions

3
NEWS
View File

@ -1,12 +1,13 @@
Current Version: @VERSION@
ctags-@VERSION@ (@DATE@)
* Added support for new "detachable" keyword [Eiffel].
* Added support for new "attached" and "detachable" keywords [Eiffel].
* Fixed parsing of comments after import statements and other tags, contributed by Huandari Lopez to Geany [Python].
* Fixed PHP parser to ignore keywords inside comments [PHP, Bug #1795926].
* Fixed regular expressions for Ant so they won't span multiple tags [Ant].
* Fixed infinite loop with malformed Makefiles, contributed by Martin Dorey [Make, Bug #2959889].
* Fixed Verilog parameter parsing, contributed by Nicolas Vincent [Verilog, Patch #2747828].
* Fixed error when parsing empty file [OCaml].
* Enabled Large File System support. [Bug #3062068]
ctags-5.8 (09 Jul 2009)

0
Test/ocaml_empty.ml Normal file
View File

View File

@ -772,6 +772,8 @@ static int writePatternEntry (const tagEntryInfo *const tag)
boolean newlineTerminated;
int length = 0;
if (line == NULL)
error (FATAL, "bad tag in %s", vStringValue (File.name));
if (tag->truncateLine)
truncateTagLine (line, tag->name, FALSE);
newlineTerminated = (boolean) (line [strlen (line) - 1] == '\n');

16
ocaml.c
View File

@ -866,6 +866,11 @@ static void prepareTag (tagEntryInfo * tag, vString const *name, ocamlKind kind)
tag->kindName = OcamlKinds[kind].name;
tag->kind = OcamlKinds[kind].letter;
if (kind == K_MODULE)
{
tag->lineNumberEntry = TRUE;
tag->lineNumber = 1;
}
parentIndex = getLastNamedIndex ();
if (parentIndex >= 0)
{
@ -880,9 +885,12 @@ static void prepareTag (tagEntryInfo * tag, vString const *name, ocamlKind kind)
* more information to it in the future */
static void addTag (vString * const ident, int kind)
{
tagEntryInfo toCreate;
prepareTag (&toCreate, ident, kind);
makeTagEntry (&toCreate);
if (OcamlKinds [kind].enabled && ident != NULL && vStringLength (ident) > 0)
{
tagEntryInfo toCreate;
prepareTag (&toCreate, ident, kind);
makeTagEntry (&toCreate);
}
}
boolean needStrongPoping = FALSE;
@ -1769,7 +1777,7 @@ static void computeModuleName ( void )
if (isLowerAlpha (moduleName->buffer[0]))
moduleName->buffer[0] += ('A' - 'a');
makeSimpleTag (moduleName, OcamlKinds, K_MODULE);
addTag (moduleName, K_MODULE);
vStringDelete (moduleName);
}