Commit 8bede453 by Eric Coissac

Patch a memory bug in the progress bar printing leading to a bus error

with some C compiler and the new version of Cython (0.2.4)
parent 8cbac7a7
......@@ -129,25 +129,29 @@ cpdef object progressBar(object pos,
sec = remain.tm_sec
fraction=<int>(percent * 50.)
if fraction < 0:
fraction=0
if fraction > 50:
fraction=50
arrow=(arrow+1) % 4
diese[fraction]=0
spaces[50 - fraction]=0
if days:
<void>fprintf(stderr,b'\r%s %5.1f %% |%s%c%s] remain : %d days %02d:%02d:%02d',
<void>fprintf(stderr,b'\r%s %5.1f %% |%.*s%c%.*s] remain : %d days %02d:%02d:%02d',
<char*>head,
percent*100,
diese,wheel[arrow],spaces,
fraction,diese,
wheel[arrow],
50-fraction,spaces,
days,hour,minu,sec)
else:
<void>fprintf(stderr,b'\r%s %5.1f %% |%s%c%s] remain : %02d:%02d:%02d',
<void>fprintf(stderr,b'\r%s %5.1f %% |%.*s%c%.*s] remain : %02d:%02d:%02d',
<char*>head,
percent*100.,
diese,wheel[arrow],spaces,
fraction,diese,
wheel[arrow],
50-fraction,spaces,
hour,minu,sec)
diese[fraction]='#'
spaces[50 - fraction]=' '
else:
cycle+=1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment