diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2012-04-15 13:46:35 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2012-04-15 13:46:35 +0000 |
commit | b8d7e068fc930321dbd1d9850ef8e6e1203e99d9 (patch) | |
tree | 57b3c54b4ed39697ca1d5f98aa83b90bfcde1863 | |
parent | bf62018cc75dedc0df840f728eb6c1637babe3e1 (diff) | |
download | zsh-b8d7e068fc930321dbd1d9850ef8e6e1203e99d9.tar.gz zsh-b8d7e068fc930321dbd1d9850ef8e6e1203e99d9.tar.xz zsh-b8d7e068fc930321dbd1d9850ef8e6e1203e99d9.zip |
30410 plus one other case: avoid divide-by-zero errors
in TIMEFMT interpretation
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Src/jobs.c | 13 |
2 files changed, 16 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog index 614bc9dcf..743f3b2c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-04-15 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 30410 (with the addition of one other case): Src/jobs.c: avoid + some divide-by-zero errors in TIMEFMT interpretation. + 2012-04-14 Peter Stephenson <p.w.stephenson@ntlworld.com> * 30402: Doc/.distfiles, Doc/Makefile.in: turn intro.ms into @@ -16194,5 +16199,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5629 $ +* $Revision: 1.5630 $ ***************************************************** diff --git a/Src/jobs.c b/Src/jobs.c index 94d25bb85..b17060175 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -716,17 +716,22 @@ printtime(struct timeval *real, child_times_t *ti, char *desc) #endif #ifdef HAVE_STRUCT_RUSAGE_RU_IXRSS case 'X': - fprintf(stderr, "%ld", (long)(ti->ru_ixrss / total_time)); + fprintf(stderr, "%ld", + total_time ? + (long)(ti->ru_ixrss / total_time) : + (long)0); break; #endif #ifdef HAVE_STRUCT_RUSAGE_RU_IDRSS case 'D': fprintf(stderr, "%ld", + total_time ? (long) ((ti->ru_idrss #ifdef HAVE_STRUCT_RUSAGE_RU_ISRSS + ti->ru_isrss #endif - ) / total_time)); + ) / total_time) : + (long)0); break; #endif #if defined(HAVE_STRUCT_RUSAGE_RU_IDRSS) || \ @@ -735,6 +740,7 @@ printtime(struct timeval *real, child_times_t *ti, char *desc) case 'K': /* treat as D if X not available */ fprintf(stderr, "%ld", + total_time ? (long) (( #ifdef HAVE_STRUCT_RUSAGE_RU_IXRSS ti->ru_ixrss @@ -747,7 +753,8 @@ printtime(struct timeval *real, child_times_t *ti, char *desc) #ifdef HAVE_STRUCT_RUSAGE_RU_ISRSS + ti->ru_isrss #endif - ) / total_time)); + ) / total_time) : + (long)0); break; #endif #ifdef HAVE_STRUCT_RUSAGE_RU_MAXRSS |