From 1b226da5330a6c3c2770ec313d29bfe0c4932bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Thu, 26 Feb 2009 21:05:52 +0000 Subject: [PATCH] [ 2638083 ] SVF progress indicator not visible for some .svf files git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1442 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 7 +++++++ jtag/src/svf/svf_flex.l | 24 ++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 531846b8..b79a2b9b 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,6 +1,13 @@ +2009-02-26 Arnim Laeuger + + * src/svf/svf_flex.l: + [ 2638083 ] SVF progress indicator not visible for some .svf files + (William) + 2009-02-25 Arnim Laeuger * src/svf/svf_flex.l: [ 2635979 ] Replace index() to strchr() + (MURANAKA Masaki) 2009-02-23 Arnim Laeuger diff --git a/jtag/src/svf/svf_flex.l b/jtag/src/svf/svf_flex.l index f7730651..546b23e2 100644 --- a/jtag/src/svf/svf_flex.l +++ b/jtag/src/svf/svf_flex.l @@ -50,6 +50,7 @@ static void align_string(char *); static void fix_yylloc(YYLTYPE *, char *); static void fix_yylloc_nl(YYLTYPE *, char *, YY_EXTRA_TYPE); +static void progress_nl(YYLTYPE *, YY_EXTRA_TYPE); int yywrap(yyscan_t scanner) { @@ -177,6 +178,7 @@ COMMENT (!.*)|("//".*)[^\n] yylloc->first_column = yylloc->last_column; ++yylloc->last_line; yylloc->last_column = 0; + progress_nl(yylloc, yyget_extra(yyscanner)); } /* end of new line */ @@ -328,12 +330,7 @@ fix_yylloc_nl(YYLTYPE * mylloc, char *str, YY_EXTRA_TYPE extra) if (*p == '\n') { mylloc->last_column = 0; ++mylloc->last_line; - if (extra->print_progress) { - printf( "\r" ); - printf( _("Parsing %6d/%d (%3.0d%%)"), - mylloc->last_line, extra->num_lines, - ((mylloc->last_line * 100) + 1) / extra->num_lines ); - } + progress_nl(mylloc, extra); } else { ++mylloc->last_column; } @@ -341,6 +338,21 @@ fix_yylloc_nl(YYLTYPE * mylloc, char *str, YY_EXTRA_TYPE extra) } +static void +progress_nl(YYLTYPE * mylloc, YY_EXTRA_TYPE extra) +{ + int percent; + + if ((extra->print_progress) && (mylloc->last_line % 10==0)) { + percent = ((mylloc->last_line * 100) + 1) / extra->num_lines; + if (percent <= 1) return; // dont bother printing < 1 % + printf( "\r" ); + printf( _("Parsing %6d/%d (%3.0d%%)"), + mylloc->last_line, extra->num_lines, percent); + } +} + + void *svf_flex_init(FILE *f, int num_lines, int print_progress) { YY_EXTRA_TYPE extra;