Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F162848987
D40601.id123398.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D40601.id123398.diff
View Options
Index: usr.bin/seq/seq.c
===================================================================
--- usr.bin/seq/seq.c
+++ usr.bin/seq/seq.c
@@ -88,14 +88,14 @@
{
const char *sep, *term;
struct lconv *locale;
- char pad, *fmt, *cur_print, *last_print;
- double first, last, incr, last_shown_value, cur, step;
+ char pad, *fmt, *cur_print, *last_print, *prev_print;
+ double first, last, incr, prev, cur, step;
int c, errflg, equalize;
pad = ZERO;
fmt = NULL;
first = 1.0;
- last = incr = last_shown_value = 0.0;
+ last = incr = prev = 0.0;
c = errflg = equalize = 0;
sep = "\n";
term = NULL;
@@ -186,7 +186,7 @@
cur = first + incr * step++) {
printf(fmt, cur);
fputs(sep, stdout);
- last_shown_value = cur;
+ prev = cur;
}
/*
@@ -194,10 +194,9 @@
*
* We might have, so check if the printable version of the last
* computed value ('cur') and desired 'last' value are equal. If they
- * are equal after formatting truncation, but 'cur' and
- * 'last_shown_value' are not equal, it means the exit condition of the
- * loop held true due to a rounding error and we still need to print
- * 'last'.
+ * are equal after formatting truncation, but 'cur' and 'prev' are not
+ * equal, it means the exit condition of the loop held true due to a
+ * rounding error and we still need to print 'last'.
*/
if (asprintf(&cur_print, fmt, cur) < 0) {
err(1, "asprintf");
@@ -205,12 +204,17 @@
if (asprintf(&last_print, fmt, last) < 0) {
err(1, "asprintf");
}
- if (strcmp(cur_print, last_print) == 0 && cur != last_shown_value) {
+ if (asprintf(&prev_print, fmt, prev) < 0) {
+ err(1, "asprintf");
+ }
+ if (strcmp(cur_print, last_print) == 0 &&
+ strcmp(cur_print, prev_print) != 0) {
fputs(last_print, stdout);
fputs(sep, stdout);
}
free(cur_print);
free(last_print);
+ free(prev_print);
if (term != NULL)
fputs(term, stdout);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jul 18, 2:23 PM (6 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35198763
Default Alt Text
D40601.id123398.diff (1 KB)
Attached To
Mode
D40601: seq: fix check for rounding error/truncation
Attached
Detach File
Event Timeline
Log In to Comment