2 * Copyright (c) 2000-2002, Darren Hiebert
3 * Copyright (c) 2009-2011, Enrico Tröger
5 * This source code is released for free distribution under the terms of the
6 * GNU General Public License.
8 * This module contains functions for generating tags for NSIS scripts (based on sh.c).
14 #include "general.h" /* must always come first */
32 static kindOption NsisKinds
[] = {
33 { TRUE
, 'n', "namespace", "sections"},
34 { TRUE
, 'f', "function", "functions"},
35 { TRUE
, 'v', "variable", "variables"}
39 * FUNCTION DEFINITIONS
42 static void findNsisTags (void)
44 vString
*name
= vStringNew ();
45 const unsigned char *line
;
47 while ((line
= fileReadLine ()) != NULL
)
49 const unsigned char* cp
= line
;
54 if (*cp
== '#' || *cp
== ';')
58 if (strncasecmp ((const char*) cp
, "function", (size_t) 8) == 0 &&
59 isspace ((int) cp
[8]))
62 /* skip all whitespace */
63 while (isspace ((int) *cp
))
65 while (isalnum ((int) *cp
) || *cp
== '_' || *cp
== '-' || *cp
== '.' || *cp
== '!')
67 vStringPut (name
, (int) *cp
);
70 vStringTerminate (name
);
71 makeSimpleTag (name
, NsisKinds
, K_FUNCTION
);
75 else if (strncasecmp ((const char*) cp
, "var", (size_t) 3) == 0 &&
76 isspace ((int) cp
[3]))
79 /* skip all whitespace */
80 while (isspace ((int) *cp
))
86 while (! isspace ((int) *cp
))
88 while (isspace ((int) *cp
))
91 while (isalnum ((int) *cp
) || *cp
== '_')
93 vStringPut (name
, (int) *cp
);
96 vStringTerminate (name
);
97 makeSimpleTag (name
, NsisKinds
, K_VARIABLE
);
101 else if (strncasecmp ((const char*) cp
, "section", (size_t) 7) == 0 &&
102 isspace ((int) cp
[7]))
104 boolean in_quotes
= FALSE
;
106 /* skip all whitespace */
107 while (isspace ((int) *cp
))
109 while (isalnum ((int) *cp
) || isspace ((int) *cp
) ||
110 *cp
== '_' || *cp
== '-' || *cp
== '.' || *cp
== '!' || *cp
== '"')
123 vStringPut (name
, (int) *cp
);
126 vStringTerminate (name
);
127 makeSimpleTag (name
, NsisKinds
, K_SECTION
);
131 vStringDelete (name
);
134 extern parserDefinition
* NsisParser (void)
136 static const char *const extensions
[] = {
139 parserDefinition
* def
= parserNew ("NSIS");
140 def
->kinds
= NsisKinds
;
141 def
->kindCount
= KIND_COUNT (NsisKinds
);
142 def
->extensions
= extensions
;
143 def
->parser
= findNsisTags
;
147 /* vi:set tabstop=8 shiftwidth=4: */