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=3D217149 --- Comment #10 from fernando.apesteguia@gmail.com --- (In reply to Conrad Meyer from comment #9) Do you mean something like this? Index: seq.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- seq.c (revisi=C3=B3n: 329385) +++ seq.c (copia de trabajo) @@ -80,7 +80,10 @@ int equalize =3D 0; double first =3D 1.0; double last =3D 0.0; + double last_shown_value =3D 0.0; + double cur; double incr =3D 0.0; + double step; struct lconv *locale; char *fmt =3D NULL; const char *sep =3D "\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 =3D generate_format(first, incr, last, equalize, pad); - if (incr > 0) { - for (; first <=3D last; first +=3D incr) { - printf(fmt, first); - fputs(sep, stdout); - } - } else { - for (; first >=3D last; first +=3D incr) { - printf(fmt, first); - fputs(sep, stdout); - } + for (step =3D 1, cur =3D first; incr > 0 ? cur <=3D last + (step/2)= : cur >=3D last; + cur =3D first + incr * step++) { + printf(fmt, cur); + fputs(sep, stdout); + last_shown_value =3D cur; } + if (term !=3D NULL) fputs(term, stdout); --=20 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>