Normalize leading line break in sample text

This commit is contained in:
Thomas Jensen 2021-03-22 20:35:13 +01:00
parent f6913d6684
commit 157f4a136b
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
2 changed files with 10 additions and 5 deletions

View File

@ -972,18 +972,18 @@ static int list_styles()
else { else {
char *all_names = names(list[i]); char *all_names = names(list[i]);
if (list[i]->author && list[i]->designer && strcmp(list[i]->author, list[i]->designer) != 0) { if (list[i]->author && list[i]->designer && strcmp(list[i]->author, list[i]->designer) != 0) {
fprintf(opt.outfile, "%s\n%s, coded by %s:\n%s\n\n", all_names, fprintf(opt.outfile, "%s\n%s, coded by %s:\n\n%s\n\n", all_names,
list[i]->designer, list[i]->author, list[i]->sample); list[i]->designer, list[i]->author, list[i]->sample);
} }
else if (list[i]->designer) { else if (list[i]->designer) {
fprintf(opt.outfile, "%s\n%s:\n%s\n\n", all_names, list[i]->designer, list[i]->sample); fprintf(opt.outfile, "%s\n%s:\n\n%s\n\n", all_names, list[i]->designer, list[i]->sample);
} }
else if (list[i]->author) { else if (list[i]->author) {
fprintf(opt.outfile, "%s\nunknown artist, coded by %s:\n%s\n\n", all_names, fprintf(opt.outfile, "%s\nunknown artist, coded by %s:\n\n%s\n\n", all_names,
list[i]->author, list[i]->sample); list[i]->author, list[i]->sample);
} }
else { else {
fprintf(opt.outfile, "%s:\n%s\n\n", all_names, list[i]->sample); fprintf(opt.outfile, "%s:\n\n%s\n\n", all_names, list[i]->sample);
} }
BFREE(all_names); BFREE(all_names);
} }

View File

@ -796,7 +796,12 @@ block: YSAMPLE STRING YENDSAMPLE
yyerror(bison_args, "duplicate SAMPLE block"); yyerror(bison_args, "duplicate SAMPLE block");
YYERROR; YYERROR;
} }
line = (char *) strdup ($2);
char *p = $2;
while ((*p == '\r' || *p == '\n') && *p != '\0') {
p++;
}
line = (char *) strdup (p);
if (line == NULL) { if (line == NULL) {
perror (PROJECT); perror (PROJECT);
YYABORT; YYABORT;