Evaluate new 'designer' keyword and show it in box design information output #22

This commit is contained in:
Thomas Jensen 2016-01-05 22:39:11 +01:00
parent 9239b15ad5
commit af85c0c255
6 changed files with 40 additions and 15 deletions

View File

@ -960,7 +960,9 @@ static int list_styles()
fprintf (opt.outfile, "\n"); fprintf (opt.outfile, "\n");
fprintf (opt.outfile, "Author: %s\n", fprintf (opt.outfile, "Author: %s\n",
d->author? d->author: "(unknown artist)"); d->author? d->author: "(unknown author)");
fprintf (opt.outfile, "Original Designer: %s\n",
d->designer? d->designer: "(unknown artist)");
fprintf (opt.outfile, "Creation Date: %s\n", fprintf (opt.outfile, "Creation Date: %s\n",
d->created? d->created: "(unknown)"); d->created? d->created: "(unknown)");
@ -1135,11 +1137,23 @@ static int list_styles()
for (i=strlen(yyfilename)+strlen(buf); i>0; --i) for (i=strlen(yyfilename)+strlen(buf); i>0; --i)
fprintf (opt.outfile, "-"); fprintf (opt.outfile, "-");
fprintf (opt.outfile, "\n\n"); fprintf (opt.outfile, "\n\n");
for (i=0; i<anz_designs; ++i) for (i=0; i<anz_designs; ++i) {
fprintf (opt.outfile, "%s (%s):\n\n%s\n\n", list[i]->name, if (list[i]->author && list[i]->designer && strcmp(list[i]->author, list[i]->designer) != 0) {
list[i]->author? list[i]->author: "unknown artist", fprintf(opt.outfile, "%s\n%s, coded by %s:\n\n%s\n\n", list[i]->name,
list[i]->sample); list[i]->designer, list[i]->author, list[i]->sample);
}
else if (list[i]->designer) {
fprintf(opt.outfile, "%s\n%s:\n\n%s\n\n", list[i]->name,
list[i]->designer, list[i]->sample);
}
else if (list[i]->author) {
fprintf(opt.outfile, "%s\nunknown artist, coded by %s:\n\n%s\n\n", list[i]->name,
list[i]->author, list[i]->sample);
}
else {
fprintf(opt.outfile, "%s:\n\n%s\n\n", list[i]->name, list[i]->sample);
}
}
BFREE (list); BFREE (list);
} }

View File

@ -89,7 +89,8 @@ typedef struct {
typedef struct { typedef struct {
char *name; char *name;
char *author; char *author; /* creator of the configuration file entry */
char *designer; /* creator of the original ASCII artwork */
char *created; /* date created, free format */ char *created; /* date created, free format */
char *revision; /* revision number of design */ char *revision; /* revision number of design */
char *revdate; /* date of current revision */ char *revdate; /* date of current revision */

View File

@ -76,7 +76,7 @@ static void inflate_inbuf();
%s ELASTIC %s ELASTIC
PWORD [a-zA-ZäöüÄÖÜ][a-zA-Z0-9\-_üäöÜÄÖß]* PWORD [a-zA-Z<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>][a-zA-Z0-9\-_<><5F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>]*
PWHITE [\n \r\t] PWHITE [\n \r\t]
PBOX Box PBOX Box
SDELIM [\"~\'`!@\%\&\*=:;<>\?/|\.\\] SDELIM [\"~\'`!@\%\&\*=:;<>\?/|\.\\]
@ -288,7 +288,7 @@ Once { yylval.c = 'o'; return YRXPFLAG; }
} }
author|created|revision|revdate|indent { author|designer|created|revision|revdate|indent {
/* /*
* general key words * general key words
*/ */

View File

@ -269,6 +269,7 @@ static void recover()
*/ */
BFREE (designs[design_idx].name); BFREE (designs[design_idx].name);
BFREE (designs[design_idx].author); BFREE (designs[design_idx].author);
BFREE (designs[design_idx].designer);
BFREE (designs[design_idx].created); BFREE (designs[design_idx].created);
BFREE (designs[design_idx].revision); BFREE (designs[design_idx].revision);
BFREE (designs[design_idx].revdate); BFREE (designs[design_idx].revdate);
@ -484,6 +485,13 @@ entry: KEYWORD STRING
YYABORT; YYABORT;
} }
} }
else if (strcasecmp ($1, "designer") == 0) {
designs[design_idx].designer = (char *) strdup ($2);
if (designs[design_idx].designer == NULL) {
perror (PROJECT);
YYABORT;
}
}
else if (strcasecmp ($1, "revision") == 0) { else if (strcasecmp ($1, "revision") == 0) {
designs[design_idx].revision = (char *) strdup ($2); designs[design_idx].revision = (char *) strdup ($2);
if (designs[design_idx].revision == NULL) { if (designs[design_idx].revision == NULL) {

View File

@ -6,6 +6,7 @@
Complete Design Information for "c": Complete Design Information for "c":
------------------------------------ ------------------------------------
Author: Thomas Jensen <boxes(at)thomasjensen(dot)com> Author: Thomas Jensen <boxes(at)thomasjensen(dot)com>
Original Designer: (public domain)
Creation Date: March 18, 1999 (Thursday, 15:25h) Creation Date: March 18, 1999 (Thursday, 15:25h)
Current Revision: 1.0 as of March 18, 1999 (Thursday, 15:25h) Current Revision: 1.0 as of March 18, 1999 (Thursday, 15:25h)
Indentation Mode: box (indent box) Indentation Mode: box (indent box)

View File

@ -5,7 +5,8 @@
:EXPECTED :EXPECTED
Complete Design Information for "<Command Line Definition>": Complete Design Information for "<Command Line Definition>":
------------------------------------------------------------ ------------------------------------------------------------
Author: (unknown artist) Author: (unknown author)
Original Designer: (unknown artist)
Creation Date: now Creation Date: now
Current Revision: 1.0 Current Revision: 1.0
Indentation Mode: box (indent box) Indentation Mode: box (indent box)