Allow alternate labels for patch names
This commit is contained in:
@@ -344,16 +344,26 @@ struct Buffer *process_template(const char *template_filename, const char *patch
|
||||
case '[':
|
||||
// "[...]" is a patch label; buffer its contents
|
||||
putc(c, output);
|
||||
bool alternate = false;
|
||||
buffer->size = 0;
|
||||
for (c = getc(input); c != EOF; c = getc(input)) {
|
||||
putc(c, output);
|
||||
if (c == ']') {
|
||||
if (!alternate && c == '@') {
|
||||
// "@" designates an alternate name for the ".VC_" label
|
||||
alternate = true;
|
||||
buffer->size = 0;
|
||||
} else if (c == ']') {
|
||||
putc(c, output);
|
||||
break;
|
||||
} else if (!isalnum(c) && c != '_' && c != '@' && c != '#') {
|
||||
// Convert non-identifier characters to underscores
|
||||
c = '_';
|
||||
} else {
|
||||
if (!alternate) {
|
||||
putc(c, output);
|
||||
if (!isalnum(c) && c != '_') {
|
||||
// Convert non-identifier characters to underscores
|
||||
c = '_';
|
||||
}
|
||||
}
|
||||
buffer_append(buffer, &c);
|
||||
}
|
||||
buffer_append(buffer, &c);
|
||||
}
|
||||
buffer_append(buffer, &(char []){'\0'});
|
||||
// The current patch should have a corresponding ".VC_" label
|
||||
|
Reference in New Issue
Block a user