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

@ -167,7 +167,7 @@ static int is_dir (const char *path)
* path file name to check
*
* On Windows, this check seems unnecessary, because fopen() seems to fail
* when applied to a directory.
* when applied to a directory.
*
* RETURNS: == 0 path is not a directory
* > 0 path is a directory
@ -960,7 +960,9 @@ static int list_styles()
fprintf (opt.outfile, "\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",
d->created? d->created: "(unknown)");
@ -1135,11 +1137,23 @@ static int list_styles()
for (i=strlen(yyfilename)+strlen(buf); i>0; --i)
fprintf (opt.outfile, "-");
fprintf (opt.outfile, "\n\n");
for (i=0; i<anz_designs; ++i)
fprintf (opt.outfile, "%s (%s):\n\n%s\n\n", list[i]->name,
list[i]->author? list[i]->author: "unknown artist",
list[i]->sample);
for (i=0; i<anz_designs; ++i) {
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\n%s\n\n", list[i]->name,
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);
}

View File

@ -89,7 +89,8 @@ typedef struct {
typedef struct {
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 *revision; /* revision number of design */
char *revdate; /* date of current revision */

View File

@ -76,7 +76,7 @@ static void inflate_inbuf();
%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]
PBOX Box
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
*/

View File

@ -269,6 +269,7 @@ static void recover()
*/
BFREE (designs[design_idx].name);
BFREE (designs[design_idx].author);
BFREE (designs[design_idx].designer);
BFREE (designs[design_idx].created);
BFREE (designs[design_idx].revision);
BFREE (designs[design_idx].revdate);
@ -387,7 +388,7 @@ design_or_error: design | error
}
}
;
design: YBOX WORD
{
@ -417,7 +418,7 @@ layout YEND WORD
yyerror ("entries SAMPLE, SHAPES, and ELASTIC are mandatory");
YYERROR;
}
for (i=0; i<design_idx; ++i) {
if (strcasecmp ($2, designs[i].name) == 0) {
yyerror ("duplicate box design name -- %s", $2);
@ -484,6 +485,13 @@ entry: KEYWORD STRING
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) {
designs[design_idx].revision = (char *) strdup ($2);
if (designs[design_idx].revision == NULL) {

View File

@ -6,6 +6,7 @@
Complete Design Information for "c":
------------------------------------
Author: Thomas Jensen <boxes(at)thomasjensen(dot)com>
Original Designer: (public domain)
Creation Date: March 18, 1999 (Thursday, 15:25h)
Current Revision: 1.0 as of March 18, 1999 (Thursday, 15:25h)
Indentation Mode: box (indent box)
@ -17,4 +18,4 @@ Default Killblank: yes
Elastic Shapes: N, E, S, W
Defined Shapes: NW: "/*" N: "*" NE: "*/" E: "*/" SE: "*/" S: "*"
SW: "/*" W: "/*"
:EOF
:EOF

View File

@ -5,7 +5,8 @@
:EXPECTED
Complete Design Information for "<Command Line Definition>":
------------------------------------------------------------
Author: (unknown artist)
Author: (unknown author)
Original Designer: (unknown artist)
Creation Date: now
Current Revision: 1.0
Indentation Mode: box (indent box)
@ -17,4 +18,4 @@ Default Killblank: no
Elastic Shapes: N, E, S, W
Defined Shapes: NW: " " N: " " NE: " " E: " " SE: " " S: " "
SW: " " W: "#"
:EOF
:EOF