From d126c4c797a56ad8375f0f47625b8f5aa5cb6ce4 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Fri, 16 May 2003 23:37:43 +0000 Subject: [PATCH] 2003-05-16 Marcel Telka * include/part.h (part_print): New function declaration. * src/part/part.c: Marked all user visible messages for translation. (part_print): New function. (parts_print): Simplified. Added part_print() call. * po/POTFILES.in: Added src/part/part.c. * src/Makefile.am (jtag_DEPENDENCIES): Added flash/libflash.a. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@431 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 10 +++++++ jtag/include/part.h | 1 + jtag/po/POTFILES.in | 1 + jtag/src/Makefile.am | 2 +- jtag/src/part/part.c | 66 +++++++++++++++++++++++++++++++------------- 5 files changed, 60 insertions(+), 20 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index fefaecc1..ae345ddb 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,13 @@ +2003-05-16 Marcel Telka + + * include/part.h (part_print): New function declaration. + * src/part/part.c: Marked all user visible messages for translation. + (part_print): New function. + (parts_print): Simplified. Added part_print() call. + * po/POTFILES.in: Added src/part/part.c. + + * src/Makefile.am (jtag_DEPENDENCIES): Added flash/libflash.a. + 2003-05-15 Marcel Telka * include/cfi.h (detect_cfi): Added new parameter `adr'. diff --git a/jtag/include/part.h b/jtag/include/part.h index 56bda921..04856955 100644 --- a/jtag/include/part.h +++ b/jtag/include/part.h @@ -59,6 +59,7 @@ data_register *part_find_data_register( part_t *p, const char *drname ); void part_set_instruction( part_t *p, const char *iname ); void part_set_signal( part_t *p, const char *pname, int out, int val ); int part_get_signal( part_t *p, const char *pname ); +void part_print( part_t *p ); typedef struct parts parts_t; diff --git a/jtag/po/POTFILES.in b/jtag/po/POTFILES.in index 2c361a9d..34980bb0 100644 --- a/jtag/po/POTFILES.in +++ b/jtag/po/POTFILES.in @@ -2,6 +2,7 @@ src/help.c src/jtag.c +src/part/part.c src/tap/chain.c src/tap/parport/direct.c src/tap/parport/ppdev.c diff --git a/jtag/src/Makefile.am b/jtag/src/Makefile.am index 1bb1f6ef..83f7e41e 100644 --- a/jtag/src/Makefile.am +++ b/jtag/src/Makefile.am @@ -44,7 +44,7 @@ jtag_SOURCES = \ bsdl2jtag_SOURCES = \ bsdl2jtag.c -jtag_DEPENDENCIES = lib/libjtaglib.a tap/libtap.a part/libpart.a bus/libbus.a +jtag_DEPENDENCIES = lib/libjtaglib.a tap/libtap.a part/libpart.a bus/libbus.a flash/libflash.a jtag_LDADD = -Ltap -ltap -Lpart -lpart -Llib -ljtaglib -Lbus -lbus -Lflash -lflash @LIBINTL@ diff --git a/jtag/src/part/part.c b/jtag/src/part/part.c index 0ad4c681..1b5cc5c7 100644 --- a/jtag/src/part/part.c +++ b/jtag/src/part/part.c @@ -22,6 +22,15 @@ * */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gettext.h" +#define _(s) gettext(s) +#define N_(s) gettext_noop(s) +#define P_(s,p,n) ngettext(s,p,n) + #include #include @@ -137,7 +146,7 @@ part_set_signal( part_t *p, const char *pname, int out, int val ) /* search for Boundary Scan Register */ data_register *bsr = part_find_data_register( p, "BSR" ); if (!bsr) { - printf( "%s(%s:%d) Boundary Scan Register (BSR) not found\n", __FUNCTION__, __FILE__, __LINE__ ); + printf( _("%s(%s:%d) Boundary Scan Register (BSR) not found\n"), __FUNCTION__, __FILE__, __LINE__ ); return; } @@ -150,7 +159,7 @@ part_set_signal( part_t *p, const char *pname, int out, int val ) } if (!s) { - printf( "signal %s not found\n", pname ); + printf( _("signal %s not found\n"), pname ); return; } @@ -158,7 +167,7 @@ part_set_signal( part_t *p, const char *pname, int out, int val ) if (out) { int control; if (!s->output) { - printf( "signal %s cannot be set as output\n", pname ); + printf( _("signal %s cannot be set as output\n"), pname ); return; } bsr->in->data[s->output->bit] = val & 1; @@ -168,7 +177,7 @@ part_set_signal( part_t *p, const char *pname, int out, int val ) bsr->in->data[control] = p->bsbits[s->output->bit]->control_value ^ 1; } else { if (!s->input) { - printf( "signal %s cannot be set as input\n", pname ); + printf( _("signal %s cannot be set as input\n"), pname ); return; } if (s->output) @@ -184,7 +193,7 @@ part_get_signal( part_t *p, const char *pname ) /* search for Boundary Scan Register */ data_register *bsr = part_find_data_register( p, "BSR" ); if (!bsr) { - printf( "%s(%s:%d) Boundary Scan Register (BSR) not found\n", __FUNCTION__, __FILE__, __LINE__ ); + printf( _("%s(%s:%d) Boundary Scan Register (BSR) not found\n"), __FUNCTION__, __FILE__, __LINE__ ); return -1; } @@ -197,18 +206,41 @@ part_get_signal( part_t *p, const char *pname ) } if (!s) { - printf( "signal %s not found\n", pname ); + printf( _("signal %s not found\n"), pname ); return -1; } if (!s->input) { - printf( "signal %s is not input signal\n", pname ); + printf( _("signal %s is not input signal\n"), pname ); return -1; } return bsr->out->data[s->input->bit]; } +void +part_print( part_t *p ) +{ + char *instruction; + char *dr; + char format[100]; + + if (!p) + return; + + snprintf( format, 100, _("%%-%ds %%-%ds %%-%ds %%-%ds %%-%ds\n"), MAXLEN_MANUFACTURER, MAXLEN_PART, MAXLEN_STEPPING, + MAXLEN_INSTRUCTION, MAXLEN_DATA_REGISTER ); + + if (p->active_instruction) { + instruction = p->active_instruction->name; + dr = p->active_instruction->data_register->name; + } else { + instruction = _("(none)"); + dr = _("(none)"); + } + printf( format, p->manufacturer, p->part, p->stepping, instruction, dr ); +} + /* parts */ parts_t * @@ -268,13 +300,12 @@ parts_print( parts_t *ps, int header ) int i; char format[100]; - snprintf( format, 100, " %%-%ds %%-%ds %%-%ds %%-%ds %%-%ds \n", MAXLEN_MANUFACTURER, MAXLEN_PART, MAXLEN_STEPPING, + snprintf( format, 100, _(" No. %%-%ds %%-%ds %%-%ds %%-%ds %%-%ds\n"), MAXLEN_MANUFACTURER, MAXLEN_PART, MAXLEN_STEPPING, MAXLEN_INSTRUCTION, MAXLEN_DATA_REGISTER ); if (header) { - printf( " No." ); - printf( format, "Manufacturer", "Part", "Stepping", "Instruction", "Register" ); - for (i = 0; i < 10 + MAXLEN_MANUFACTURER + MAXLEN_PART + MAXLEN_STEPPING + MAXLEN_INSTRUCTION + MAXLEN_DATA_REGISTER; i++ ) + printf( format, _("Manufacturer"), _("Part"), _("Stepping"), _("Instruction"), _("Register") ); + for (i = 0; i < strlen( format ) + 1; i++ ) putchar( '-' ); putchar( '\n' ); } @@ -283,15 +314,12 @@ parts_print( parts_t *ps, int header ) return; for (i = 0; i < ps->len; i++) { - char *instruction = "(none)"; - char *dr = "(none)"; part_t *p = ps->parts[i]; - if (p->active_instruction) { - instruction = p->active_instruction->name; - dr = p->active_instruction->data_register->name; - } - printf( " %3d", i ); - printf( format, p->manufacturer, p->part, p->stepping, instruction, dr ); + if (!p) + continue; + + printf( _(" %3d "), i ); + part_print( p ); } }