4 * Copyright (c) 2000-2002, Darren Hiebert
5 * Copyright (c) 2009-2010, Enrico Tröger
7 * This source code is released for free distribution under the terms of the
8 * GNU General Public License.
10 * This module contains functions for generating tags for NSIS scripts (based on sh.c).
16 #include "general.h" /* must always come first */
34 static kindOption NsisKinds
[] = {
35 { TRUE
, 'n', "namespace", "sections"},
36 { TRUE
, 'f', "function", "functions"},
37 { TRUE
, 'v', "variable", "variables"}
41 * FUNCTION DEFINITIONS
44 static void findNsisTags (void)
46 vString
*name
= vStringNew ();
47 const unsigned char *line
;
49 while ((line
= fileReadLine ()) != NULL
)
51 const unsigned char* cp
= line
;
56 if (*cp
== '#' || *cp
== ';')
60 if (strncasecmp ((const char*) cp
, "function", (size_t) 8) == 0 &&
61 isspace ((int) cp
[8]))
64 /* skip all whitespace */
65 while (isspace ((int) *cp
))
67 while (isalnum ((int) *cp
) || *cp
== '_' || *cp
== '-' || *cp
== '.' || *cp
== '!')
69 vStringPut (name
, (int) *cp
);
72 vStringTerminate (name
);
73 makeSimpleTag (name
, NsisKinds
, K_FUNCTION
);
77 else if (strncasecmp ((const char*) cp
, "var", (size_t) 3) == 0 &&
78 isspace ((int) cp
[3]))
81 /* skip all whitespace */
82 while (isspace ((int) *cp
))
88 while (! isspace ((int) *cp
))
90 while (isspace ((int) *cp
))
93 while (isalnum ((int) *cp
) || *cp
== '_')
95 vStringPut (name
, (int) *cp
);
98 vStringTerminate (name
);
99 makeSimpleTag (name
, NsisKinds
, K_VARIABLE
);
103 else if (strncasecmp ((const char*) cp
, "section", (size_t) 7) == 0 &&
104 isspace ((int) cp
[7]))
106 boolean in_quotes
= FALSE
;
108 /* skip all whitespace */
109 while (isspace ((int) *cp
))
111 while (isalnum ((int) *cp
) || isspace ((int) *cp
) ||
112 *cp
== '_' || *cp
== '-' || *cp
== '.' || *cp
== '!' || *cp
== '"')
125 vStringPut (name
, (int) *cp
);
128 vStringTerminate (name
);
129 makeSimpleTag (name
, NsisKinds
, K_SECTION
);
133 vStringDelete (name
);
136 extern parserDefinition
* NsisParser (void)
138 static const char *const extensions
[] = {
141 parserDefinition
* def
= parserNew ("NSIS");
142 def
->kinds
= NsisKinds
;
143 def
->kindCount
= KIND_COUNT (NsisKinds
);
144 def
->extensions
= extensions
;
145 def
->parser
= findNsisTags
;
149 /* vi:set tabstop=8 shiftwidth=4: */