Permalink
Browse files

Merge pull request #7 from gknops/deploy

New option "--config-filename"
  • Loading branch information...
2 parents 47089f9 + 2a2abf6 commit b852acb936b42b0aec4fc408684922b26b06b3d3 @fishman fishman committed Jan 18, 2012
Showing with 33 additions and 6 deletions.
  1. +32 −6 options.c
  2. +1 −0 options.h
View
@@ -137,6 +137,7 @@ optionValues Option = {
NULL, /* -L */
NULL, /* -o */
NULL, /* -h */
+ NULL, /* --config-filename */
NULL, /* --etags-include */
DEFAULT_FILE_FORMAT,/* --format */
FALSE, /* --if0 */
@@ -195,6 +196,8 @@ static optionDescription LongOptionDescription [] = {
{1," -x Print a tabular cross reference file to standard output."},
{1," --append=[yes|no]"},
{1," Should tags should be appended to existing tag file [no]?"},
+ {1," --config-filename=fileName"},
+ {1," Use 'fileName' instead of 'ctags' in option file names."},
{1," --etags-include=file"},
{1," Include reference to 'file' in Emacs-style tag file (requires -e)."},
{1," --exclude=pattern"},
@@ -714,6 +717,13 @@ extern boolean isIncludeFile (const char *const fileName)
* Specific option processing
*/
+ static void processConfigFilenameOption (
+ const char *const option __unused__, const char *const parameter)
+ {
+ freeString (&Option.configFilename);
+ Option.configFilename = stringCopy (parameter);
+ }
+
static void processEtagsInclude (
const char *const option, const char *const parameter)
{
@@ -1370,6 +1380,7 @@ static void processVersionOption (
*/
static parametricOption ParametricOptions [] = {
+ { "config-filename", processConfigFilenameOption, TRUE },
{ "etags-include", processEtagsInclude, FALSE },
{ "exclude", processExcludeOption, FALSE },
{ "excmd", processExcmdOption, FALSE },
@@ -1676,7 +1687,7 @@ extern void previewFirstOption (cookedArgs* const args)
{
while (cArgIsOption (args))
{
- if (strcmp (args->item, "V") == 0 || strcmp (args->item, "verbose") == 0)
+ if (strcmp (args->item, "V") == 0 || strcmp (args->item, "verbose") == 0 || strcmp (args->item, "config-filename") == 0 )
parseOption (args);
else if (strcmp (args->item, "options") == 0 &&
strcmp (args->parameter, "NONE") == 0)
@@ -1699,24 +1710,39 @@ static void parseConfigurationFileOptionsInDirectoryWithLeafname (const char* di
static void parseConfigurationFileOptionsInDirectory (const char* directory)
{
- parseConfigurationFileOptionsInDirectoryWithLeafname (directory, ".ctags");
+ char *leafname = NULL;
+
+ asprintf (&leafname,".%s",(Option.configFilename)?Option.configFilename:"ctags");
+ parseConfigurationFileOptionsInDirectoryWithLeafname (directory, leafname);
+ free (leafname);
#ifdef MSDOS_STYLE_PATH
- parseConfigurationFileOptionsInDirectoryWithLeafname (directory, "ctags.cnf");
+ asprintf (&leafname,"%s.cnf",(Option.configFilename)?Option.configFilename:"ctags");
+ parseConfigurationFileOptionsInDirectoryWithLeafname (directory, leafname);
+ free (leafname);
#endif
}
static void parseConfigurationFileOptions (void)
{
/* We parse .ctags on all systems, and additionally ctags.cnf on DOS. */
const char* const home = getenv ("HOME");
+ char *filename = NULL;
+
#ifdef CUSTOM_CONFIGURATION_FILE
parseFileOptions (CUSTOM_CONFIGURATION_FILE);
#endif
#ifdef MSDOS_STYLE_PATH
- parseFileOptions ("/ctags.cnf");
+
+ asprintf (&filename,"/%s.cnf",(Option.configFilename)?Option.configFilename:"ctags");
+ parseFileOptions (filename);
+ free (filename);
#endif
- parseFileOptions ("/etc/ctags.conf");
- parseFileOptions ("/usr/local/etc/ctags.conf");
+ asprintf (&filename,"/etc/%s.conf",(Option.configFilename)?Option.configFilename:"ctags");
+ parseFileOptions (filename);
+ free (filename);
+ asprintf (&filename,"/usr/local/etc/%s.conf",(Option.configFilename)?Option.configFilename:"ctags");
+ parseFileOptions (filename);
+ free (filename);
if (home != NULL)
{
parseConfigurationFileOptionsInDirectory (home);
View
@@ -97,6 +97,7 @@ typedef struct sOptionValues {
char *fileList; /* -L name of file containing names of files */
char *tagFileName; /* -o name of tags file */
stringList* headerExt; /* -h header extensions */
+ char* configFilename; /* --config-filename use instead of 'ctags' in option file names */
stringList* etagsInclude;/* --etags-include list of TAGS files to include*/
unsigned int tagFileFormat;/* --format tag file format (level) */
boolean if0; /* --if0 examine code within "#if 0" branch */

0 comments on commit b852acb

Please sign in to comment.