mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-03-06 18:21:16 +01:00
Add config file location to each design #5
This commit is contained in:
parent
9315e62528
commit
46aab3faa6
@ -629,6 +629,7 @@ static int build_design(design_t **adesigns, const char *cld)
|
|||||||
dp->sample = "n/a";
|
dp->sample = "n/a";
|
||||||
dp->indentmode = DEF_INDENTMODE;
|
dp->indentmode = DEF_INDENTMODE;
|
||||||
dp->padding[BLEF] = 1;
|
dp->padding[BLEF] = 1;
|
||||||
|
dp->defined_in = "(command line)";
|
||||||
|
|
||||||
dp->tags = (char *) calloc(10, sizeof(char));
|
dp->tags = (char *) calloc(10, sizeof(char));
|
||||||
strcpy(dp->tags, "transient");
|
strcpy(dp->tags, "transient");
|
||||||
@ -760,6 +761,8 @@ static int list_styles()
|
|||||||
d->revision && d->revdate ? " as of " : "",
|
d->revision && d->revdate ? " as of " : "",
|
||||||
d->revdate ? d->revdate : (d->revision ? "" : "(unknown)"));
|
d->revdate ? d->revdate : (d->revision ? "" : "(unknown)"));
|
||||||
|
|
||||||
|
fprintf(opt.outfile, "Configuration File: %s\n", d->defined_in);
|
||||||
|
|
||||||
fprintf(opt.outfile, "Indentation Mode: ");
|
fprintf(opt.outfile, "Indentation Mode: ");
|
||||||
switch (d->indentmode) {
|
switch (d->indentmode) {
|
||||||
case 'b':
|
case 'b':
|
||||||
|
@ -105,6 +105,7 @@ typedef struct {
|
|||||||
size_t minheight;
|
size_t minheight;
|
||||||
int padding[ANZ_SIDES];
|
int padding[ANZ_SIDES];
|
||||||
char *tags;
|
char *tags;
|
||||||
|
char *defined_in; /* path to config file where this was defined */
|
||||||
|
|
||||||
reprule_t *current_rule;
|
reprule_t *current_rule;
|
||||||
reprule_t *reprules; /* applied when drawing a box */
|
reprule_t *reprules; /* applied when drawing a box */
|
||||||
|
@ -38,6 +38,9 @@ typedef struct {
|
|||||||
/** index into `*designs` */
|
/** index into `*designs` */
|
||||||
int design_idx;
|
int design_idx;
|
||||||
|
|
||||||
|
/** the path to the config file we are parsing */
|
||||||
|
char *config_file;
|
||||||
|
|
||||||
/** the flex scanner, which is explicitly passed to reentrant bison */
|
/** the flex scanner, which is explicitly passed to reentrant bison */
|
||||||
void *lexer_state;
|
void *lexer_state;
|
||||||
} pass_to_bison;
|
} pass_to_bison;
|
||||||
@ -315,6 +318,7 @@ static void recover(pass_to_bison *bison_args)
|
|||||||
BFREE (curdes.tags);
|
BFREE (curdes.tags);
|
||||||
memset (bison_args->designs + bison_args->design_idx, 0, sizeof(design_t));
|
memset (bison_args->designs + bison_args->design_idx, 0, sizeof(design_t));
|
||||||
curdes.indentmode = DEF_INDENTMODE;
|
curdes.indentmode = DEF_INDENTMODE;
|
||||||
|
curdes.defined_in = bison_args->config_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -407,6 +411,7 @@ first_rule:
|
|||||||
}
|
}
|
||||||
bison_args->num_designs = 1;
|
bison_args->num_designs = 1;
|
||||||
bison_args->designs->indentmode = DEF_INDENTMODE;
|
bison_args->designs->indentmode = DEF_INDENTMODE;
|
||||||
|
bison_args->designs->defined_in = bison_args->config_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
config_file
|
config_file
|
||||||
@ -484,9 +489,6 @@ parent_def: YPARENT STRING
|
|||||||
parent_configs[num_parent_configs] = filepath;
|
parent_configs[num_parent_configs] = filepath;
|
||||||
++num_parent_configs;
|
++num_parent_configs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO HERE
|
|
||||||
// TODO each design should know where it was defined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config_file: config_file design_or_error | design_or_error | config_file parent_def | parent_def ;
|
config_file: config_file design_or_error | design_or_error | config_file parent_def | parent_def ;
|
||||||
@ -579,6 +581,7 @@ layout YEND WORD
|
|||||||
bison_args->designs = tmp;
|
bison_args->designs = tmp;
|
||||||
memset (&curdes, 0, sizeof(design_t));
|
memset (&curdes, 0, sizeof(design_t));
|
||||||
curdes.indentmode = DEF_INDENTMODE;
|
curdes.indentmode = DEF_INDENTMODE;
|
||||||
|
curdes.defined_in = bison_args->config_file;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -123,12 +123,11 @@ static design_t *parse_config_file(const char *config_file, size_t *r_num_design
|
|||||||
fprintf (stderr, "Parsing Config File %s ...\n", config_file);
|
fprintf (stderr, "Parsing Config File %s ...\n", config_file);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO the parser reallocs the global designs array, do this with module-local vars
|
|
||||||
|
|
||||||
pass_to_bison bison_args;
|
pass_to_bison bison_args;
|
||||||
bison_args.designs = NULL;
|
bison_args.designs = NULL;
|
||||||
bison_args.num_designs = 0;
|
bison_args.num_designs = 0;
|
||||||
bison_args.design_idx = 0;
|
bison_args.design_idx = 0;
|
||||||
|
bison_args.config_file = (char *) config_file;
|
||||||
bison_args.lexer_state = NULL;
|
bison_args.lexer_state = NULL;
|
||||||
current_bison_args = &bison_args;
|
current_bison_args = &bison_args;
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ Author: Thomas Jensen
|
|||||||
Original Designer: (public domain)
|
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)
|
||||||
|
Configuration File: ../boxes-config
|
||||||
Indentation Mode: box (indent box)
|
Indentation Mode: box (indent box)
|
||||||
Replacement Rules: 1. (glob) "\*/" WITH "*\\/"
|
Replacement Rules: 1. (glob) "\*/" WITH "*\\/"
|
||||||
Reversion Rules: 1. (glob) "\*\\/" TO "*/"
|
Reversion Rules: 1. (glob) "\*\\/" TO "*/"
|
||||||
|
@ -9,6 +9,7 @@ Author: (unknown author)
|
|||||||
Original Designer: (unknown artist)
|
Original Designer: (unknown artist)
|
||||||
Creation Date: now
|
Creation Date: now
|
||||||
Current Revision: 1.0
|
Current Revision: 1.0
|
||||||
|
Configuration File: (command line)
|
||||||
Indentation Mode: box (indent box)
|
Indentation Mode: box (indent box)
|
||||||
Replacement Rules: none
|
Replacement Rules: none
|
||||||
Reversion Rules: none
|
Reversion Rules: none
|
||||||
|
Loading…
Reference in New Issue
Block a user