From b8108fd2ddf77ae79cd014f4f37798a52be13fd1 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 18 Feb 2008 18:38:52 +0100 Subject: seq: give a proper diagnostic for an invalid --format=% option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/seq.c (long_double_format): Handle '%' at end of string. * tests/misc/seq [fmt-eos1, fmt-eos2]: New tests for the bug. * NEWS: Mention this. Reported by Pádraig Brady. --- src/seq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/seq.c b/src/seq.c index 261a44bbb..b073fd169 100644 --- a/src/seq.c +++ b/src/seq.c @@ -1,5 +1,5 @@ /* seq - print sequence of numbers to standard output. - Copyright (C) 1994-2007 Free Software Foundation, Inc. + Copyright (C) 1994-2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -209,7 +209,7 @@ long_double_format (char const *fmt, struct layout *layout) length_modifier_offset = i; has_L = (fmt[i] == 'L'); i += has_L; - if (! strchr ("efgaEFGA", fmt[i])) + if (fmt[i] == '\0' || ! strchr ("efgaEFGA", fmt[i])) return NULL; for (i++; ! (fmt[i] == '%' && fmt[i + 1] != '%'); i += (fmt[i] == '%') + 1) -- cgit v1.2.3-54-g00ecf