/*
* Copyright (c) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2010, 2011,
* 2015
* Tama Communications Corporation
*
* This file is part of GNU GLOBAL.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#ifdef STDC_HEADERS
#include
#endif
#ifdef HAVE_STRING_H
#include
#else
#include
#endif
#include
#if defined(_WIN32) && !defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN
#include
#undef SLIST_ENTRY
#endif
#include "parser.h"
#include "internal.h"
#include "checkalloc.h"
#include "conf.h"
#include "die.h"
#include "gtagsop.h"
#include "langmap.h"
#include "locatestring.h"
#include "path.h"
#include "queue.h"
#include "strbuf.h"
#include "strmake.h"
#include "test.h"
#define NOTFUNCTION ".notfunction"
#ifdef __DJGPP__
#define DOS_NOTFUNCTION "_notfunction"
#endif
struct words {
const char *name;
};
static struct words *words;
static int tablesize;
static int
cmp(const void *s1, const void *s2)
{
return strcmp(((struct words *)s1)->name, ((struct words *)s2)->name);
}
static void
load_notfunction(const char *filename)
{
FILE *ip;
STRBUF *sb = strbuf_open(0);
STRBUF *ib = strbuf_open(0);
char *p;
int i;
if ((ip = fopen(filename, "r")) == NULL)
die("'%s' cannot read.", filename);
for (tablesize = 0; (p = strbuf_fgets(ib, ip, STRBUF_NOCRLF)) != NULL; tablesize++) {
if (*p == ';') /* Lines starting with ';' are comment lines. */
continue;
strbuf_puts0(sb, p);
}
fclose(ip);
words = (struct words *)check_malloc(sizeof(struct words) * tablesize);
/*
* Don't free *p.
*/
p = (char *)check_malloc(strbuf_getlen(sb) + 1);
memcpy(p, strbuf_value(sb), strbuf_getlen(sb) + 1);
for (i = 0; i < tablesize; i++) {
words[i].name = p;
p += strlen(p) + 1;
}
qsort(words, tablesize, sizeof(struct words), cmp);
strbuf_close(sb);
strbuf_close(ib);
}
static int
isnotfunction(const char *name)
{
struct words tmp;
struct words *result;
if (words == NULL)
return 0;
tmp.name = name;
result = (struct words *)bsearch(&tmp, words, tablesize, sizeof(struct words), cmp);
return (result != NULL) ? 1 : 0;
}
/*----------------------------------------------------------------------*/
/* Parser switch */
/*----------------------------------------------------------------------*/
/**
* This is the linkage section of each parsers.
* If you want to support new language, you must define parser procedure
* which requires file name as an argument.
*/
struct lang_entry {
const char *lang_name;
PARSER parser; /**< parser procedure */
const char *parser_name;
const char *lt_dl_name;
};
struct plugin_entry {
STAILQ_ENTRY(plugin_entry) next;
lt_dlhandle handle;
struct lang_entry entry;
};
static STAILQ_HEAD(plugin_list, plugin_entry)
plugin_list = STAILQ_HEAD_INITIALIZER(plugin_list);
static char *langmap_saved, *pluginspec_saved;
/**
* load_plugin_parser: Load plug-in parsers.
*
* @param[in] pluginspec described below
*
* Syntax:
* ::=