diff --git a/src/seq.c b/src/seq.c
index cedd25d..1a6eaf7 100644
--- a/src/seq.c
+++ b/src/seq.c
@@ -338,6 +338,8 @@ get_default_format (operand first, operand step, operand last)
/* The NUL-terminated string S0 of length S_LEN represents a valid
non-negative decimal integer. Adjust the string and length so
that the pair describe the next-larger value. */
+// New function, called from seq_fast(), which is a new function as well
+// and is invoked in a newly-added block of code
static void
incr (char **s0, size_t *s_len)
{
@@ -357,6 +359,8 @@ incr (char **s0, size_t *s_len)
/* Compare A and B (each a NUL-terminated digit string), with lengths
given by A_LEN and B_LEN. Return +1 if A < B, -1 if B < A, else 0. */
+// New function, called from seq_fast(), which is a new function as well
+// and is invoked in a newly-added block of code
static int
cmp (char const *a, size_t a_len, char const *b, size_t b_len)
{
@@ -369,6 +373,8 @@ cmp (char const *a, size_t a_len, char const *b, size_t b_len)
/* Trim leading 0's from S, but if S is all 0's, leave one.
Return a pointer to the trimmed string. */
+// New function, called from seq_fast(), which is a new function as well
+// and is invoked in a newly-added block of code
static char const * _GL_ATTRIBUTE_PURE
trim_leading_zeros (char const *s)
{
@@ -385,6 +391,7 @@ trim_leading_zeros (char const *s)
/* Print all whole numbers from A to B, inclusive -- to stdout, each
followed by a newline. If B < A, return false and print nothing.
Otherwise, return true. */
+// New function invoked in a newly-added block of code
static bool
seq_fast (char const *a, char const *b)
{
@@ -438,6 +445,7 @@ seq_fast (char const *a, char const *b)
}
/* Return true if S consists of at least one digit and no non-digits. */
+// New function invoked in a newly-added block of code
static bool _GL_ATTRIBUTE_PURE
all_digits_p (char const *s)
{
@@ -508,13 +516,13 @@ main (int argc, char **argv)
}
unsigned int n_args = argc - optind;
- if (n_args < 1)
+ if (change(argc - optind, n_args) < 1)
{
error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
}
- if (3 < n_args)
+ if (3 < change(argc - optind, n_args))
{
error (0, 0, _("extra operand %s"), quote (argv[optind + 3]));
usage (EXIT_FAILURE);
@@ -523,7 +531,7 @@ main (int argc, char **argv)
if (format_str)
format_str = long_double_format (format_str, &layout);
- if (format_str != NULL && equal_width)
+ if (change(0, format_str != NULL && equal_width))
{
error (0, 0, _("format string may not be specified"
" when printing equal width strings"));
@@ -536,10 +544,10 @@ main (int argc, char **argv)
- integer end
- increment == 1 or not specified [FIXME: relax this, eventually]
then use the much more efficient integer-only code. */
- if (format_str == NULL
+ if (change(0, format_str == NULL
&& all_digits_p (argv[1])
&& (n_args == 1 || all_digits_p (argv[2]))
- && (n_args < 3 || STREQ ("1", argv[3])))
+ && (n_args < 3 || STREQ ("1", argv[3]))))
{
char const *s1 = n_args == 1 ? "1" : argv[1];
char const *s2 = n_args == 1 ? argv[1] : argv[2];
@@ -563,6 +571,13 @@ main (int argc, char **argv)
}
}
+ if (change(format_str != NULL && equal_width, 0))
+ {
+ error (0, 0, _("format string may not be specified"
+ " when printing equal width strings"));
+ usage (EXIT_FAILURE);
+ }
+
if (format_str == NULL)
format_str = get_default_format (first, step, last);