Skip to content

Commit

Permalink
Changed --langmap to first unmap each supplied extension from other l…
Browse files Browse the repository at this point in the history
…anguages.

git-svn-id: https://ctags.svn.sourceforge.net/svnroot/ctags/trunk@420 c5d04d22-be80-434c-894e-aa346cc9e8e8
  • Loading branch information
Darren Hiebert committed Aug 18, 2004
1 parent ec605f2 commit 6d11d5c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
3 changes: 2 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Current Version: @@VERSION@@

ctags-5.5.5 (Mon July 12 2004)
ctags-5.5.5 (Sun Aug 15 2004)
* Changed --langmap to first unmap each supplied extension from other languages.
* Added support for ASP constants [ASP, Patch #961842].
* Fixed creation of TAGS file with etags-include but no files [Bug #941233].
* Fixed problem reading last line of list file (-L) without final newline.
Expand Down
3 changes: 2 additions & 1 deletion ctags.1
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ expanded by the shell before being passed to \fBctags\fP). You can determine
if shell wildcards are available on your platform by examining the output of
the \fB--version\fP option, which will include "+wildcards" in the compiled
feature list; otherwise, the file name patterns are matched against file names
using a simple textual comparison.
using a simple textual comparison. When mapping a file extension, it will
first be unmapped from any other languages.

If the first character in a map is a plus sign, then the extensions and file
name patterns in that map will be appended to the current map for that
Expand Down
2 changes: 2 additions & 0 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ static void addExtensionList (stringList *const slist,
{
printf ("\n now: ");
stringListPrint (slist);
putchar ('\n');
}
eFree (extensionList);
}
Expand Down Expand Up @@ -1212,6 +1213,7 @@ static void installHeaderListDefaults (void)
{
printf (" Setting default header extensions: ");
stringListPrint (Option.headerExt);
putchar ('\n');
}
}

Expand Down
20 changes: 13 additions & 7 deletions parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,18 @@ extern void addLanguagePatternMap (const langType language, const char* ptrn)
stringListAdd (LanguageTable [language]->currentPatterns, str);
}

extern boolean removeLanaguageExtensionMap (const char *const extension)
extern boolean removeLanguageExtensionMap (const char *const extension)
{
boolean result = FALSE;
unsigned int i;
for (i = 0 ; i < LanguageCount && ! result ; ++i)
{
stringList* const exts = LanguageTable [i]->currentExtensions;
if (exts != NULL && stringListRemoveExtension (exts, extension))
{
verbose (" (removed from %s)", getLanguageName (i));
result = TRUE;
}
}
return result;
}
Expand All @@ -278,6 +281,7 @@ extern void addLanguageExtensionMap (
{
vString* const str = vStringNewInit (extension);
Assert (0 <= language && language < (int) LanguageCount);
removeLanguageExtensionMap (extension);
stringListAdd (LanguageTable [language]->currentExtensions, str);
}

Expand Down Expand Up @@ -526,12 +530,14 @@ static void printMaps (const langType language)
Assert (0 <= language && language < (int) LanguageCount);
lang = LanguageTable [language];
printf ("%-8s", lang->name);
if (lang->extensions != NULL)
for (i = 0 ; lang->extensions [i] != NULL ; ++i)
printf (" *.%s", lang->extensions [i]);
if (lang->patterns != NULL)
for (i = 0 ; lang->patterns [i] != NULL ; ++i)
printf (" %s", lang->patterns [i]);
if (lang->currentExtensions != NULL)
for (i = 0 ; i < stringListCount (lang->currentExtensions) ; ++i)
printf (" *.%s", vStringValue (
stringListItem (lang->currentExtensions, i)));
if (lang->currentPatterns != NULL)
for (i = 0 ; i < stringListCount (lang->currentPatterns) ; ++i)
printf (" %s", vStringValue (
stringListItem (lang->currentPatterns, i)));
putchar ('\n');
}

Expand Down
6 changes: 3 additions & 3 deletions parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ typedef struct {
char* name; /* name of language */
kindOption* kinds; /* tag kinds handled by parser */
unsigned int kindCount; /* size of `kinds' list */
const char* const* extensions; /* list of default extensions */
const char* const* patterns; /* list of default file name patterns */
const char *const *extensions; /* list of default extensions */
const char *const *patterns; /* list of default file name patterns */
parserInitialize initialize; /* initialization routine, if needed */
simpleParser parser; /* simple parser (common case) */
rescanParser parser2; /* rescanning parser (unusual case) */
Expand Down Expand Up @@ -93,7 +93,7 @@ extern langType getFileLanguage (const char *const fileName);
extern void installLanguageMapDefault (const langType language);
extern void installLanguageMapDefaults (void);
extern void clearLanguageMap (const langType language);
extern boolean removeLanaguageExtensionMap (const char *const extension);
extern boolean removeLanguageExtensionMap (const char *const extension);
extern void addLanguageExtensionMap (const langType language, const char* extension);
extern void addLanguagePatternMap (const langType language, const char* ptrn);
extern void printLanguageMap (const langType language);
Expand Down
6 changes: 3 additions & 3 deletions strlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ extern boolean stringListHasTest (
}

extern boolean stringListRemoveExtension (
const stringList* const current, const char* const extension)
stringList* const current, const char* const extension)
{
boolean result = FALSE;
int where;
Expand All @@ -214,8 +214,9 @@ extern boolean stringListRemoveExtension (
if (where != -1)
{
memmove (current->list + where, current->list + where + 1,
current->count - where);
(current->count - where) * sizeof (*current->list));
current->list [current->count - 1] = NULL;
--current->count;
result = TRUE;
}
return result;
Expand Down Expand Up @@ -260,7 +261,6 @@ extern void stringListPrint (const stringList *const current)
Assert (current != NULL);
for (i = 0 ; i < current->count ; ++i)
printf ("%s%s", (i > 0) ? ", " : "", vStringValue (current->list [i]));
putchar ('\n');
}

/* vi:set tabstop=8 shiftwidth=4: */
2 changes: 1 addition & 1 deletion strlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extern void stringListDelete (stringList *const current);
extern boolean stringListHasInsensitive (const stringList *const current, const char *const string);
extern boolean stringListHas (const stringList *const current, const char *const string);
extern boolean stringListHasTest (const stringList *const current, boolean (*test)(const char *s));
extern boolean stringListRemoveExtension (const stringList* const current, const char* const extension);
extern boolean stringListRemoveExtension (stringList* const current, const char* const extension);
extern boolean stringListExtensionMatched (const stringList* const list, const char* const extension);
extern boolean stringListFileMatched (const stringList* const list, const char* const str);
extern void stringListPrint (const stringList *const current);
Expand Down

0 comments on commit 6d11d5c

Please sign in to comment.