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)
This commit is contained in:
Jiří Techet 2016-10-07 15:26:42 +02:00
parent 37f015d993
commit 88cbe3871c
8 changed files with 97 additions and 125 deletions

View File

@ -38,7 +38,12 @@ AC_PROG_LN_S
# autoscan start
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h fnmatch.h glob.h stdlib.h sys/time.h errno.h limits.h])
AC_CHECK_HEADERS([fcntl.h glob.h stdlib.h sys/time.h errno.h limits.h])
# Checks for dependencies needed by ctags
AC_CHECK_HEADERS([fnmatch.h direct.h io.h sys/dir.h])
AH_TEMPLATE([USE_STDBOOL_H], [whether or not to use <stdbool.h>.])
AC_DEFINE([USE_STDBOOL_H])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_OFF_T

View File

@ -58,6 +58,7 @@ libctags_la_SOURCES = \
main/ctags.h \
main/debug.h \
main/debug.c \
main/e_msoft.h \
main/entry.c \
main/entry.h \
main/error.c \

71
ctags/main/e_msoft.h Normal file
View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2002-2003, Darren Hiebert
*
* This source code is released for free distribution under the terms of the
* GNU General Public License version 2 or (at your option) any later version.
*
* Configures ctags for Microsoft environment.
*/
#ifndef E_MSOFT_H
#define E_MSOFT_H
#define CASE_INSENSITIVE_FILENAMES 1
#define MANUAL_GLOBBING 1
#define MSDOS_STYLE_PATH 1
#define HAVE_FCNTL_H 1
#define HAVE_IO_H 1
#define HAVE_LIMITS_H 1
#define HAVE_STDLIB_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_TIME_H 1
#define HAVE_CLOCK 1
#define HAVE_CHSIZE 1
#define HAVE_FGETPOS 1
#define HAVE_STRICMP 1
#define HAVE_STRNICMP 1
#define HAVE_STRSTR 1
#define HAVE_STRERROR 1
#define HAVE_FINDNEXT 1
#define HAVE_TEMPNAM 1
#define HAVE_FNMATCH 1
#define HAVE_FNMATCH_H 1
#define HAVE_PUTENV 1
#define tempnam(dir,pfx) _tempnam(dir,pfx)
#define TMPDIR "\\"
#ifdef _MSC_VER
# define HAVE__FINDFIRST 1
# define HAVE_DIRECT_H 1
# if _MSC_VER < 1900
# define snprintf _snprintf
# endif
# define findfirst_t intptr_t
#if (_MSC_VER >= 1800) // Visual Studio 2013 or newer
#define HAVE_STDBOOL_H 1
#else
typedef enum { false, true } bool;
#endif
# ifndef _CRT_SECURE_NO_DEPRECATE
# define _CRT_SECURE_NO_DEPRECATE 1
# endif
# pragma warning(disable : 4996)
#elif defined (__MINGW32__)
# include <_mingw.h>
# define HAVE_STDBOOL_H 1
# define HAVE_DIR_H 1
# define HAVE_DIRENT_H 1
# define HAVE__FINDFIRST 1
# define findfirst_t long
# define ffblk _finddata_t
# define FA_DIREC _A_SUBDIR
# define ff_name name
#endif
#endif

View File

@ -14,99 +14,44 @@
*/
#if defined (HAVE_CONFIG_H)
# include <config.h>
#if (defined (HAVE_FORK) && defined (HAVE_WAITPID) && defined (HAVE_EXECV) && defined (HAVE_PIPE))
#define HAVE_COPROC
#endif
#ifdef macintosh
# include "mac.h"
#elif defined (WIN32)
# include "e_msoft.h"
#endif
/* include unistd.h preventively because at least under MacOSX it is needed for off_t */
#include <unistd.h>
#include <stdbool.h>
/*
* MACROS
*/
#include "gcc-attr.h"
/* MS-DOS doesn't allow manipulation of standard error, so we send it to
* stdout instead.
/*
* Portability macros
*/
#if defined (WIN32)
# define errout stdout
#else
# define errout stderr
#endif
#if defined (__CYGWIN__)
# define UNIX_PATH_SEPARATOR 1
# define MSDOS_STYLE_PATH
#endif
#if defined (WIN32)
# define CASE_INSENSITIVE_FILENAMES
# define MSDOS_STYLE_PATH
# define HAVE_DOS_H 1
# define HAVE_FCNTL_H 1
# define HAVE_IO_H 1
# define HAVE_STDLIB_H 1
# define HAVE_SYS_STAT_H 1
# define HAVE_SYS_TYPES_H 1
# define HAVE_TIME_H 1
# define HAVE_CLOCK 1
# define HAVE_CHSIZE 1
# define HAVE_FGETPOS 1
# define HAVE_STRICMP 1
# define HAVE_STRNICMP 1
# define HAVE_STRSTR 1
# define HAVE_STRERROR 1
# define HAVE_FINDNEXT 1
# ifdef _MSC_VER
# define HAVE__FINDFIRST 1
# define HAVE_DIRECT_H 1
# elif defined (__MINGW32__)
# define HAVE_DIR_H 1
# define HAVE_DIRENT_H 1
# define HAVE__FINDFIRST 1
# define ffblk _finddata_t
# define FA_DIREC _A_SUBDIR
# define ff_name name
#if !defined(HAVE_STRCASECMP) && !defined(strcasecmp)
# ifdef HAVE_STRICMP
# define strcasecmp(s1,s2) stricmp(s1,s2)
# else
# define strcasecmp(s1,s2) struppercmp(s1,s2)
# endif
/* provide the prototype for cross-compiling/Windows */
char *lrealpath(const char *filename);
#endif
#ifndef HAVE_FNMATCH_H
/* provide the prototype for cross-compiling/Windows */
int fnmatch(const char *pattern, const char *string, int flags);
#if !defined(HAVE_STRNCASECMP) && !defined(strncasecmp)
# ifdef HAVE_STRNICMP
# define strncasecmp(s1,s2,n) strnicmp(s1,s2,n)
# else
# define strncasecmp(s1,s2,n) strnuppercmp(s1,s2,n)
# endif
#endif
#if defined (__MWERKS__) && defined (__MACINTOSH__)
# define HAVE_STAT_H 1
#endif
#ifdef __FreeBSD__
#include <sys/types.h>
#endif /* __FreeBSD__ */
/* Define regex if supported */
#if (defined (HAVE_REGCOMP) && !defined (REGCOMP_BROKEN)) || defined (HAVE_RE_COMPILE_PATTERN)
# define HAVE_REGEX 1
#endif
/*
* DATA DECLARATIONS
*/
#if ! defined (HAVE_FGETPOS) && ! defined (fpos_t)
# define fpos_t long
#endif
/* Work-around for broken implementation of fgetpos()/fsetpos() on Mingw32 */
#if defined (__MINGW32__) && defined (__MSVCRT__)
# undef HAVE_FGETPOS
#ifdef USE_STDBOOL_H
# include <stdbool.h>
#endif
/*

View File

@ -35,8 +35,6 @@
#include "kind.h"
#include "routines.h"
#ifdef HAVE_REGEX
/*
* MACROS
*/
@ -528,8 +526,6 @@ extern void findRegexTags (void)
;
}
#endif /* HAVE_REGEX */
extern void addTagRegex (
const langType language CTAGS_ATTR_UNUSED,
const char* const regex CTAGS_ATTR_UNUSED,
@ -537,7 +533,6 @@ extern void addTagRegex (
const char* const kinds CTAGS_ATTR_UNUSED,
const char* const flags CTAGS_ATTR_UNUSED)
{
#ifdef HAVE_REGEX
Assert (regex != NULL);
Assert (name != NULL);
if (! regexBroken)
@ -553,7 +548,6 @@ extern void addTagRegex (
kind, kindName, description);
}
}
#endif
}
extern void addCallbackRegex (
@ -562,7 +556,6 @@ extern void addCallbackRegex (
const char* const flags CTAGS_ATTR_UNUSED,
const regexCallback callback CTAGS_ATTR_UNUSED)
{
#ifdef HAVE_REGEX
Assert (regex != NULL);
if (! regexBroken)
{
@ -570,13 +563,11 @@ extern void addCallbackRegex (
if (cp != NULL)
addCompiledCallbackPattern (language, cp, callback);
}
#endif
}
extern void addLanguageRegex (
const langType language CTAGS_ATTR_UNUSED, const char* const regex CTAGS_ATTR_UNUSED)
{
#ifdef HAVE_REGEX
if (! regexBroken)
{
char *const regex_pat = eStrdup (regex);
@ -587,7 +578,6 @@ extern void addLanguageRegex (
eFree (regex_pat);
}
}
#endif
}
/*
@ -601,17 +591,12 @@ extern bool processRegexOption (const char *const option,
const char* const dash = strchr (option, '-');
if (dash != NULL && strncmp (option, "regex", dash - option) == 0)
{
#ifdef HAVE_REGEX
langType language;
language = getNamedLanguage (dash + 1);
if (language == LANG_IGNORE)
printf ("regex: unknown language \"%s\" in --%s option\n", (dash + 1), option);
else
processLanguageRegex (language, parameter);
#else
printf ("regex: regex support not available; required for --%s option\n",
option);
#endif
handled = true;
}
return handled;
@ -619,7 +604,6 @@ extern bool processRegexOption (const char *const option,
extern void disableRegexKinds (const langType language CTAGS_ATTR_UNUSED)
{
#ifdef HAVE_REGEX
if (language <= SetUpper && Sets [language].count > 0)
{
patternSet* const set = Sets + language;
@ -628,7 +612,6 @@ extern void disableRegexKinds (const langType language CTAGS_ATTR_UNUSED)
if (set->patterns [i].type == PTRN_TAG)
set->patterns [i].u.tag.kind.enabled = false;
}
#endif
}
extern bool enableRegexKind (
@ -636,7 +619,6 @@ extern bool enableRegexKind (
const int kind CTAGS_ATTR_UNUSED, const bool mode CTAGS_ATTR_UNUSED)
{
bool result = false;
#ifdef HAVE_REGEX
if (language <= SetUpper && Sets [language].count > 0)
{
patternSet* const set = Sets + language;
@ -649,13 +631,11 @@ extern bool enableRegexKind (
result = true;
}
}
#endif
return result;
}
extern void printRegexKinds (const langType language CTAGS_ATTR_UNUSED, bool indent CTAGS_ATTR_UNUSED)
{
#ifdef HAVE_REGEX
if (language <= SetUpper && Sets [language].count > 0)
{
patternSet* const set = Sets + language;
@ -664,12 +644,10 @@ extern void printRegexKinds (const langType language CTAGS_ATTR_UNUSED, bool ind
if (set->patterns [i].type == PTRN_TAG)
printRegexKind (set->patterns, i, indent);
}
#endif
}
extern void freeRegexResources (void)
{
#ifdef HAVE_REGEX
int i;
for (i = 0 ; i <= SetUpper ; ++i)
clearPatternSet (i);
@ -677,7 +655,6 @@ extern void freeRegexResources (void)
eFree (Sets);
Sets = NULL;
SetUpper = -1;
#endif
}
/* Check for broken regcomp() on Cygwin */

View File

@ -339,10 +339,8 @@ extern void initializeParsing (void)
error (FATAL, "parser definition must contain name\n");
else if (def->method & METHOD_REGEX)
{
#ifdef HAVE_REGEX
def->parser = findRegexTags;
accepted = true;
#endif
}
else if ((def->parser == NULL) == (def->parser2 == NULL))
error (FATAL,
@ -384,7 +382,6 @@ extern void freeParserResources (void)
extern void processLanguageDefineOption (const char *const option,
const char *const parameter CTAGS_ATTR_UNUSED)
{
#ifdef HAVE_REGEX
if (parameter [0] == '\0')
error (WARNING, "No language specified for \"%s\" option", option);
else if (getNamedLanguage (parameter) != LANG_IGNORE)
@ -402,10 +399,6 @@ extern void processLanguageDefineOption (const char *const option,
LanguageTable = xRealloc (LanguageTable, i + 1, parserDefinition*);
LanguageTable [i] = def;
}
#else
error (WARNING, "regex support not available; required for --%s option",
option);
#endif
}
static kindOption *langKindOption (const langType language, const int flag)
@ -465,11 +458,7 @@ extern void processLegacyKindOption (const char *const parameter)
static void disableLanguageKinds (const langType language)
{
if (LanguageTable [language]->method & METHOD_REGEX)
#ifdef HAVE_REGEX
disableRegexKinds (language);
#else
;
#endif
else
{
unsigned int i;
@ -483,11 +472,7 @@ static bool enableLanguageKind (const langType language,
{
bool result = false;
if (LanguageTable [language]->method & METHOD_REGEX)
#ifdef HAVE_REGEX
result = enableRegexKind (language, kind, mode);
#else
;
#endif
else
{
kindOption* const opt = langKindOption (language, kind);
@ -569,9 +554,7 @@ static void printLangugageKindOptions (const langType language)
if (lang->kinds != NULL)
for (i = 0 ; i < lang->kindCount ; ++i)
printLangugageKindOption (lang->kinds + i);
#ifdef HAVE_REGEX
/*printRegexKindOptions (language);*/ /* unused */
#endif
}
}

View File

@ -134,10 +134,8 @@ extern bool parseFile (const char *const fileName);
extern void installKeywordTable (const langType language);
/* Regex interface */
#ifdef HAVE_REGEX
extern void findRegexTags (void);
extern bool matchRegex (const vString* const line, const langType language);
#endif
extern bool processRegexOption (const char *const option, const char *const parameter);
extern void addLanguageRegex (const langType language, const char* const regex);
extern void installTagRegexTable (const langType language);

View File

@ -34,14 +34,6 @@ static kindOption LuaKinds [] = {
* FUNCTION DEFINITIONS
*/
/* for debugging purposes */
static void CTAGS_ATTR_UNUSED print_string (char *p, char *q)
{
for ( ; p != q; p++)
fprintf (errout, "%c", *p);
fprintf (errout, "\n");
}
/*
* Helper function.
* Returns 1 if line looks like a line of Lua code.