From 02ab57d02e48395e2c436ee74b0ae5ceeb2f5d19 Mon Sep 17 00:00:00 2001 From: wl Date: Sun, 9 May 2010 10:58:39 +0000 Subject: Handle ditroff command `Dt' without argument gracefully. Without this patch, grotty goes into an infinite loop if it tries to process x T utf8 x res 240 24 40 x init p1 Dt * src/libs/libdriver/input.cpp (get_integer_arg): Emit a fatal error on a non-integer argument, bringing the code into line with the behaviour documented in the header comment. (get_possibly_integer_args): Terminate the loop on a non-integer argument. (next_arg_begin): Return newline or EOF after emitting the corresponding error, rather than continuing on to the next line. --- src/libs/libdriver/input.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/libs') diff --git a/src/libs/libdriver/input.cpp b/src/libs/libdriver/input.cpp index ae68e86d..3d837882 100644 --- a/src/libs/libdriver/input.cpp +++ b/src/libs/libdriver/input.cpp @@ -3,13 +3,13 @@ // /src/libs/libdriver/input.cpp /* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004, 2005, - 2006, 2008, 2009 + 2006, 2008, 2009, 2010 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) Major rewrite 2001 by Bernd Warken (bwarken@mayn.de) - Last update: 5 Jan 2009 + Last update: 9 May 2010 This file is part of groff, the GNU roff text processing system. @@ -790,7 +790,7 @@ get_integer_arg(void) c = get_char(); } if (!isdigit((int) c)) - error("integer argument expected"); + fatal("integer argument expected"); while (isdigit((int) c)) { buf.append(c); c = get_char(); @@ -879,6 +879,7 @@ get_possibly_integer_args() break; default: error("integer argument expected"); + done = true; break; } } @@ -946,7 +947,7 @@ next_arg_begin(void) case '\n': case EOF: error("missing argument"); - break; + return c; default: // first essential character return c; } -- cgit v1.2.1