From 16fd5a99e1a8c433077e70c1a48e42cc01bf7d29 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 15 Aug 2006 21:02:55 +0000 Subject: 2006-08-15 Kolja Waschk * linkcmds.c, linkcmds.h, memory.c, memory.h, sample.ptf: New files. * bridges.c: corrected detection of bridged connections * clocks.c: removed a printf * linkcmds.[ch] new files, added output of linker script * Makefile.am: added new files * memory.[ch]: new files, detection of memory in SOPC configuration * nios2gen.c: updated command line parsing and output control * output.[ch]: improved output of BSP header file * ptf.[ch]: added ptf_dump_ptf_item and small fixes * sample.ptf: new file, sample configuration for nios2gen * README: updated --- tools/cpu/nios2/ptf.c | 62 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 8 deletions(-) (limited to 'tools/cpu/nios2/ptf.c') diff --git a/tools/cpu/nios2/ptf.c b/tools/cpu/nios2/ptf.c index 43a38ea522..6f8943d0b3 100644 --- a/tools/cpu/nios2/ptf.c +++ b/tools/cpu/nios2/ptf.c @@ -9,6 +9,7 @@ */ #include +#include #include #include "ptf.h" @@ -364,7 +365,7 @@ void parse_char(struct ptf_parser_state *state, int c) default: #if DEBUG&DEBUG_EXPECTATIONS - printf("Expectation: %d (???)\n", state->expectation); + printf("Expectation: %d (?)\n", state->expectation); #endif parse_error(state, "Internal error: Unhandled state of expectation"); @@ -510,6 +511,44 @@ struct ptf *ptf_parse_file(char *filename) /***************************************************************************/ +struct ptf *ptf_concat(struct ptf *a, struct ptf *b) +{ + struct ptf *leaf = a; + + if(!a) return b; + if(!b) return a; + + for(leaf = a; leaf->next != NULL; leaf = leaf->next); + leaf->next = b; + return a; +} + +/***************************************************************************/ + +void ptf_dump_ptf_item(FILE *f, struct ptf_item *pi) +{ + int i; + fprintf(f, "level=%d in %p\n", pi->level, pi); + for(i=pi->level;i>=0;i--) + { + if(pi->item[i] != NULL) + { + fprintf(f, " %d: %s name=%s value=%s\n", + i, + pi->item[i]->type == item ? "item":"section", + pi->item[i]->name, + pi->item[i]->value); + } + else + { + fprintf(f, " %d: NULL\n"); + } + fflush(f); + } +} + +/***************************************************************************/ + void ptf_printf(FILE *s, struct ptf *tree, char *prefix) { struct ptf *leaf; @@ -532,12 +571,12 @@ void ptf_printf(FILE *s, struct ptf *tree, char *prefix) strcat(new_prefix, leaf->name); if(leaf->value != NULL && leaf->value[0] != 0) { - strcat(new_prefix, "_"); + strcat(new_prefix, ":"); strcat(new_prefix, leaf->value); }; strcat(new_prefix, "/"); fputs(new_prefix, s); - fputs("\r\n", s); + fputs("\n", s); ptf_printf(s, leaf->sub, new_prefix); break; }; @@ -548,12 +587,19 @@ void ptf_printf(FILE *s, struct ptf *tree, char *prefix) fputs(prefix, s); fputs(leaf->name, s); fputs(" = \"", s); - for(c=leaf->value; *c; c++) + if(leaf->value == NULL) { - if(*c=='\\' || *c=='"') putc('\\', s); - putc(*c, s); - }; - fprintf(s, "\"\r\n"); + fputs("(NULL)", s); + } + else + { + for(c=leaf->value; *c; c++) + { + if(*c=='\\' || *c=='"') putc('\\', s); + putc(*c, s); + }; + } + fprintf(s, "\"\n"); break; }; -- cgit v1.2.3