Date: Sun, 25 Feb 2018 18:26:32 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 217149] seq(1) inconsistently omits 'last' when using float increment Message-ID: <bug-217149-8-Y3SWjpm7s0@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-217149-8@https.bugs.freebsd.org/bugzilla/> References: <bug-217149-8@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149 --- Comment #10 from fernando.apesteguia@gmail.com --- (In reply to Conrad Meyer from comment #9) Do you mean something like this? Index: seq.c =================================================================== --- seq.c (revisión: 329385) +++ seq.c (copia de trabajo) @@ -80,7 +80,10 @@ int equalize = 0; double first = 1.0; double last = 0.0; + double last_shown_value = 0.0; + double cur; double incr = 0.0; + double step; struct lconv *locale; char *fmt = NULL; const char *sep = "\n"; @@ -163,23 +166,19 @@ if (!valid_format(fmt)) errx(1, "invalid format string"); /* - * XXX to be bug for bug compatible with Plan 9 add a + * XXX to be bug for bug compatible with Plan 9 add a * newline if none found at the end of the format string. */ } else fmt = generate_format(first, incr, last, equalize, pad); - if (incr > 0) { - for (; first <= last; first += incr) { - printf(fmt, first); - fputs(sep, stdout); - } - } else { - for (; first >= last; first += incr) { - printf(fmt, first); - fputs(sep, stdout); - } + for (step = 1, cur = first; incr > 0 ? cur <= last + (step/2) : cur >= last; + cur = first + incr * step++) { + printf(fmt, cur); + fputs(sep, stdout); + last_shown_value = cur; } + if (term != NULL) fputs(term, stdout); -- You are receiving this mail because: You are the assignee for the bug.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-217149-8-Y3SWjpm7s0>
