-/* $OpenBSD: seq.c,v 1.5 2022/02/22 23:25:44 tb Exp $ */
+/* $OpenBSD: seq.c,v 1.6 2022/02/25 16:00:39 tb Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
static const char *decimal_point = "."; /* default */
static char default_format[] = { "%g" }; /* default */
-static const struct option long_opts[] =
-{
+static const struct option long_opts[] = {
{"format", required_argument, NULL, 'f'},
{"help", no_argument, NULL, 'h'},
{"separator", required_argument, NULL, 's'},
incr = e_atof(argv[1]);
/* Plan 9/GNU don't do zero */
if (incr == 0.0)
- errx(1, "zero %screment", (first < last)? "in" : "de");
+ errx(1, "zero %screment", (first < last) ? "in" : "de");
}
/* default is one for Plan 9/GNU work alike */
for (step = 1, cur = first; incr > 0 ? cur <= last : cur >= last;
cur = first + incr * step++) {
if (cur != first)
- fputs(sep, stdout);
+ fputs(sep, stdout);
printf(fmt, cur);
last_shown_value = cur;
}
err(1, "asprintf");
if (strcmp(cur_print, last_print) == 0 && cur != last_shown_value) {
if (cur != first)
- fputs(sep, stdout);
+ fputs(sep, stdout);
fputs(last_print, stdout);
}
free(cur_print);
/* conversion */
switch (*fmt) {
- case 'A':
- case 'a':
- case 'E':
- case 'e':
- case 'F':
- case 'f':
- case 'G':
- case 'g':
+ case 'A':
+ case 'a':
+ case 'E':
+ case 'e':
+ case 'F':
+ case 'f':
+ case 'G':
+ case 'g':
/* floating point formats are accepted */
conversions++;
break;
- default:
+ default:
/* anything else is not */
return 0;
}
/* XXX if incr is floating point fix the precision */
if (precision) {
snprintf(buf, sizeof(buf), "%%%c%d.%d%c", pad,
- MAXIMUM(width1, width2) + (int) strlen(decimal_point) +
+ MAXIMUM(width1, width2) + (int)strlen(decimal_point) +
precision, precision, (cc) ? cc : 'f');
} else {
snprintf(buf, sizeof(buf), "%%%c%d%c", pad,