Skip to content
This repository
Browse code

Merge pull request #7 from gknops/deploy

New option "--config-filename"
  • Loading branch information...
commit b852acb936b42b0aec4fc408684922b26b06b3d3 2 parents 47089f9 + 2a2abf6
Reza Jelveh authored

Showing 2 changed files with 33 additions and 6 deletions. Show diff stats Hide diff stats

  1. +32 6 options.c
  2. +1 0  options.h
38 options.c
@@ -137,6 +137,7 @@ optionValues Option = {
137 137 NULL, /* -L */
138 138 NULL, /* -o */
139 139 NULL, /* -h */
  140 + NULL, /* --config-filename */
140 141 NULL, /* --etags-include */
141 142 DEFAULT_FILE_FORMAT,/* --format */
142 143 FALSE, /* --if0 */
@@ -195,6 +196,8 @@ static optionDescription LongOptionDescription [] = {
195 196 {1," -x Print a tabular cross reference file to standard output."},
196 197 {1," --append=[yes|no]"},
197 198 {1," Should tags should be appended to existing tag file [no]?"},
  199 + {1," --config-filename=fileName"},
  200 + {1," Use 'fileName' instead of 'ctags' in option file names."},
198 201 {1," --etags-include=file"},
199 202 {1," Include reference to 'file' in Emacs-style tag file (requires -e)."},
200 203 {1," --exclude=pattern"},
@@ -714,6 +717,13 @@ extern boolean isIncludeFile (const char *const fileName)
714 717 * Specific option processing
715 718 */
716 719
  720 + static void processConfigFilenameOption (
  721 + const char *const option __unused__, const char *const parameter)
  722 + {
  723 + freeString (&Option.configFilename);
  724 + Option.configFilename = stringCopy (parameter);
  725 + }
  726 +
717 727 static void processEtagsInclude (
718 728 const char *const option, const char *const parameter)
719 729 {
@@ -1370,6 +1380,7 @@ static void processVersionOption (
1370 1380 */
1371 1381
1372 1382 static parametricOption ParametricOptions [] = {
  1383 + { "config-filename", processConfigFilenameOption, TRUE },
1373 1384 { "etags-include", processEtagsInclude, FALSE },
1374 1385 { "exclude", processExcludeOption, FALSE },
1375 1386 { "excmd", processExcmdOption, FALSE },
@@ -1676,7 +1687,7 @@ extern void previewFirstOption (cookedArgs* const args)
1676 1687 {
1677 1688 while (cArgIsOption (args))
1678 1689 {
1679   - if (strcmp (args->item, "V") == 0 || strcmp (args->item, "verbose") == 0)
  1690 + if (strcmp (args->item, "V") == 0 || strcmp (args->item, "verbose") == 0 || strcmp (args->item, "config-filename") == 0 )
1680 1691 parseOption (args);
1681 1692 else if (strcmp (args->item, "options") == 0 &&
1682 1693 strcmp (args->parameter, "NONE") == 0)
@@ -1699,9 +1710,15 @@ static void parseConfigurationFileOptionsInDirectoryWithLeafname (const char* di
1699 1710
1700 1711 static void parseConfigurationFileOptionsInDirectory (const char* directory)
1701 1712 {
1702   - parseConfigurationFileOptionsInDirectoryWithLeafname (directory, ".ctags");
  1713 + char *leafname = NULL;
  1714 +
  1715 + asprintf (&leafname,".%s",(Option.configFilename)?Option.configFilename:"ctags");
  1716 + parseConfigurationFileOptionsInDirectoryWithLeafname (directory, leafname);
  1717 + free (leafname);
1703 1718 #ifdef MSDOS_STYLE_PATH
1704   - parseConfigurationFileOptionsInDirectoryWithLeafname (directory, "ctags.cnf");
  1719 + asprintf (&leafname,"%s.cnf",(Option.configFilename)?Option.configFilename:"ctags");
  1720 + parseConfigurationFileOptionsInDirectoryWithLeafname (directory, leafname);
  1721 + free (leafname);
1705 1722 #endif
1706 1723 }
1707 1724
@@ -1709,14 +1726,23 @@ static void parseConfigurationFileOptions (void)
1709 1726 {
1710 1727 /* We parse .ctags on all systems, and additionally ctags.cnf on DOS. */
1711 1728 const char* const home = getenv ("HOME");
  1729 + char *filename = NULL;
  1730 +
1712 1731 #ifdef CUSTOM_CONFIGURATION_FILE
1713 1732 parseFileOptions (CUSTOM_CONFIGURATION_FILE);
1714 1733 #endif
1715 1734 #ifdef MSDOS_STYLE_PATH
1716   - parseFileOptions ("/ctags.cnf");
  1735 +
  1736 + asprintf (&filename,"/%s.cnf",(Option.configFilename)?Option.configFilename:"ctags");
  1737 + parseFileOptions (filename);
  1738 + free (filename);
1717 1739 #endif
1718   - parseFileOptions ("/etc/ctags.conf");
1719   - parseFileOptions ("/usr/local/etc/ctags.conf");
  1740 + asprintf (&filename,"/etc/%s.conf",(Option.configFilename)?Option.configFilename:"ctags");
  1741 + parseFileOptions (filename);
  1742 + free (filename);
  1743 + asprintf (&filename,"/usr/local/etc/%s.conf",(Option.configFilename)?Option.configFilename:"ctags");
  1744 + parseFileOptions (filename);
  1745 + free (filename);
1720 1746 if (home != NULL)
1721 1747 {
1722 1748 parseConfigurationFileOptionsInDirectory (home);
1  options.h
@@ -97,6 +97,7 @@ typedef struct sOptionValues {
97 97 char *fileList; /* -L name of file containing names of files */
98 98 char *tagFileName; /* -o name of tags file */
99 99 stringList* headerExt; /* -h header extensions */
  100 + char* configFilename; /* --config-filename use instead of 'ctags' in option file names */
100 101 stringList* etagsInclude;/* --etags-include list of TAGS files to include*/
101 102 unsigned int tagFileFormat;/* --format tag file format (level) */
102 103 boolean if0; /* --if0 examine code within "#if 0" branch */

0 comments on commit b852acb

Please sign in to comment.
Something went wrong with that request. Please try again.