Minor update of German translation
[geany-mirror.git] / tagmanager / options.c
bloba2ea39c479968729e7e1143669d998a5cb5b5258
1 /*
3 * Copyright (c) 1996-2001, Darren Hiebert
5 * This source code is released for free distribution under the terms of the
6 * GNU General Public License.
8 * This module contains functions to process command line options.
9 */
12 * INCLUDE FILES
14 #include "general.h" /* must always come first */
16 #include <stdlib.h>
17 #include <string.h>
18 #include <stdio.h>
19 #include <ctype.h> /* to declare isspace () */
21 #include "ctags.h"
22 #include "main.h"
23 #define OPTION_WRITE
24 #include "options.h"
25 #include "parse.h"
27 #include <glib.h>
29 #define CTAGS_ENVIRONMENT "CTAGS"
31 #define CTAGS_FILE "tags"
34 /* The following separators are permitted for list options.
36 #define EXTENSION_SEPARATOR '.'
37 #define PATTERN_START '('
38 #define PATTERN_STOP ')'
39 #define IGNORE_SEPARATORS ", \t\n"
41 #ifndef DEFAULT_FILE_FORMAT
42 # define DEFAULT_FILE_FORMAT 2
43 #endif
45 #if defined (MSDOS) || defined (WIN32) || defined (OS2) || defined (AMIGA) || defined (HAVE_OPENDIR)
46 # define RECURSE_SUPPORTED
47 #endif
49 #define isCompoundOption(c) (boolean) (strchr ("fohiILpDb", (c)) != NULL)
54 * DATA DEFINITIONS
57 optionValues Option = {
59 FALSE, /* --extra=f */
60 FALSE, /* --extra=q */
61 TRUE, /* --file-scope */
64 TRUE, /* -fields=a */
65 TRUE, /* -fields=f */
66 FALSE, /* -fields=m */
67 TRUE, /* -fields=i */
68 FALSE, /* -fields=k */
69 TRUE, /* -fields=z */
70 TRUE, /* -fields=K */
71 FALSE, /* -fields=l */
72 TRUE, /* -fields=n */
73 TRUE, /* -fields=s */
74 TRUE, /* -fields=P */
75 TRUE /* -fields=A */
77 NULL, /* -I */
78 FALSE, /* -a */
79 FALSE, /* -B */
80 FALSE, /* -e */
81 #ifdef MACROS_USE_PATTERNS
82 EX_PATTERN, /* -n, --excmd */
83 #else
84 EX_MIX, /* -n, --excmd */
85 #endif
86 FALSE, /* -R */
87 TRUE, /* -u, --sort */
88 FALSE, /* -V */
89 FALSE, /* -x */
90 NULL, /* -L */
91 NULL, /* -o */
92 NULL, /* -h */
93 DEFAULT_FILE_FORMAT,/* --format */
94 FALSE, /* --if0 */
95 FALSE, /* --kind-long */
96 LANG_AUTO, /* --lang */
97 TRUE, /* --links */
98 FALSE, /* --filter */
99 NULL, /* --filter-terminator */
100 FALSE, /* --qualified-tags */
101 FALSE, /* --tag-relative */
102 FALSE, /* --totals */
103 FALSE, /* --line-directives */
104 FALSE,
108 extern void verbose (const char *const format, ...)
112 extern void freeList (stringList** const pList)
114 if (*pList != NULL)
116 stringListDelete (*pList);
117 *pList = NULL;
121 extern void setDefaultTagFileName (void)
123 Option.tagFileName = eStrdup (CTAGS_FILE);
127 * File extension and language mapping
129 extern const char *fileExtension (const char *const fileName)
131 const char *extension;
132 const char *pDelimiter = NULL;
134 if (pDelimiter == NULL)
135 pDelimiter = strrchr (fileName, '.');
137 if (pDelimiter == NULL)
138 extension = "";
139 else
140 extension = pDelimiter + 1; /* skip to first char of extension */
142 return extension;
145 /* Determines whether the specified file name is considered to be a header
146 * file for the purposes of determining whether enclosed tags are global or
147 * static.
149 extern boolean isIncludeFile (const char *const fileName)
151 return FALSE;
154 /* tags_ignore is a NULL-terminated array of strings, read from ~/.config/geany/ignore.tags.
155 * This file contains a space or newline separated list of symbols which should be ignored
156 * by the C/C++ parser, see -I command line option of ctags for details. */
157 gchar **c_tags_ignore = NULL;
159 /* Determines whether or not "name" should be ignored, per the ignore list.
161 extern boolean isIgnoreToken (const char *const name,
162 boolean *const pIgnoreParens,
163 const char **const replacement)
165 boolean result = FALSE;
167 if (c_tags_ignore != NULL)
169 const size_t nameLen = strlen (name);
170 unsigned int i;
171 guint len = g_strv_length (c_tags_ignore);
173 if (pIgnoreParens != NULL)
174 *pIgnoreParens = FALSE;
176 for (i = 0 ; i < len ; ++i)
178 vString *token = vStringNewInit (c_tags_ignore[i]);
180 if (strncmp (vStringValue (token), name, nameLen) == 0)
182 const size_t tokenLen = vStringLength (token);
184 if (nameLen == tokenLen)
186 result = TRUE;
187 break;
189 else if (tokenLen == nameLen + 1 &&
190 vStringChar (token, tokenLen - 1) == '+')
192 result = TRUE;
193 if (pIgnoreParens != NULL)
194 *pIgnoreParens = TRUE;
195 break;
197 else if (vStringChar (token, nameLen) == '=')
199 if (replacement != NULL)
200 *replacement = vStringValue (token) + nameLen + 1;
201 break;
204 vStringDelete (token);
207 return result;
210 void addIgnoreListFromFile (const char *const fileName)
212 stringList* tokens = stringListNewFromFile (fileName);
213 if (Option.ignore == NULL)
214 Option.ignore = tokens;
215 else
216 stringListCombine (Option.ignore, tokens);
222 * Generic option parsing
224 #define readOptionConfiguration
225 #define initOptions
226 #define freeOptionResources
228 /* vi:set tabstop=8 shiftwidth=4: */