*/
keywords (description|{whitespace}(build(_cmds)?|files|install(_cmds)?|prepare_cmds|provides|(pre)?requires|_posttrans))
template {whitespace}template.*$
+script {whitespace}script.*$
%s DEFINE
pakfire_free(buffer);
}
+<INITIAL>^{script} {
+ // Find the name of the template
+ char* name = NULL;
+ for (unsigned int i = yyleng; i > 0; i--) {
+ if (isspace(yytext[i]))
+ break;
+
+ name = yytext + i;
+ }
+
+ size_t length = strlen("define script:") + strlen(name);
+
+ char* buffer = pakfire_malloc(length + 1);
+ snprintf(buffer, length + 1, "define script:%s", name);
+
+ // Put the whole string back onto the stack (backwards)
+ for (int i = length - 1; i >= 0; i--) {
+ unput(buffer[i]);
+ }
+
+ pakfire_free(buffer);
+ }
+
<INITIAL>^{keywords}$ {
// Determine the length of the string
size_t length = strlen("define ") + yyleng;