Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / groff / src / libs / libgroff / lf.cpp
blob8947d58cafc23eaa0055982d4f0270c6ff595744
1 /* $NetBSD$ */
3 // -*- C++ -*-
4 /* Copyright (C) 1989, 1990, 1991, 1992, 2004 Free Software Foundation, Inc.
5 Written by James Clark (jjc@jclark.com)
7 This file is part of groff.
9 groff is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
12 version.
14 groff is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
19 You should have received a copy of the GNU General Public License along
20 with groff; see the file COPYING. If not, write to the Free Software
21 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
23 #include <ctype.h>
25 #include "lib.h"
26 #include "cset.h"
27 #include "stringclass.h"
29 extern void change_filename(const char *);
30 extern void change_lineno(int);
32 int interpret_lf_args(const char *p)
34 while (*p == ' ')
35 p++;
36 if (!csdigit(*p))
37 return 0;
38 int ln = 0;
39 do {
40 ln *= 10;
41 ln += *p++ - '0';
42 } while (csdigit(*p));
43 if (*p != ' ' && *p != '\n' && *p != '\0')
44 return 0;
45 while (*p == ' ')
46 p++;
47 if (*p == '\0' || *p == '\n') {
48 change_lineno(ln);
49 return 1;
51 const char *q;
52 for (q = p;
53 *q != '\0' && *q != ' ' && *q != '\n' && *q != '\\';
54 q++)
56 string tem(p, q - p);
57 while (*q == ' ')
58 q++;
59 if (*q != '\n' && *q != '\0')
60 return 0;
61 tem += '\0';
62 change_filename(tem.contents());
63 change_lineno(ln);
64 return 1;