1114402Sru// -*- C++ -*-
2151497Sru/* Copyright (C) 1989, 1990, 1991, 1992, 2004 Free Software Foundation, Inc.
3114402Sru     Written by James Clark (jjc@jclark.com)
4114402Sru
5114402SruThis file is part of groff.
6114402Sru
7114402Srugroff is free software; you can redistribute it and/or modify it under
8114402Sruthe terms of the GNU General Public License as published by the Free
9114402SruSoftware Foundation; either version 2, or (at your option) any later
10114402Sruversion.
11114402Sru
12114402Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY
13114402SruWARRANTY; without even the implied warranty of MERCHANTABILITY or
14114402SruFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15114402Srufor more details.
16114402Sru
17114402SruYou should have received a copy of the GNU General Public License along
18114402Sruwith groff; see the file COPYING.  If not, write to the Free Software
19151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
20114402Sru
21114402Sru#include <ctype.h>
22151497Sru
23151497Sru#include "lib.h"
24114402Sru#include "cset.h"
25114402Sru#include "stringclass.h"
26114402Sru
27114402Sruextern void change_filename(const char *);
28114402Sruextern void change_lineno(int);
29114402Sru
30114402Sruint interpret_lf_args(const char *p)
31114402Sru{
32114402Sru  while (*p == ' ')
33114402Sru    p++;
34114402Sru  if (!csdigit(*p))
35114402Sru    return 0;
36114402Sru  int ln = 0;
37114402Sru  do {
38114402Sru    ln *= 10;
39114402Sru    ln += *p++ - '0';
40114402Sru  } while (csdigit(*p));
41114402Sru  if (*p != ' ' && *p != '\n' && *p != '\0')
42114402Sru    return 0;
43114402Sru  while (*p == ' ')
44114402Sru    p++;
45114402Sru  if (*p == '\0' || *p == '\n')  {
46114402Sru    change_lineno(ln);
47114402Sru    return 1;
48114402Sru  }
49114402Sru  const char *q;
50114402Sru  for (q = p;
51114402Sru       *q != '\0' && *q != ' ' && *q != '\n' && *q != '\\';
52114402Sru       q++)
53114402Sru    ;
54114402Sru  string tem(p, q - p);
55114402Sru  while (*q == ' ')
56114402Sru    q++;
57114402Sru  if (*q != '\n' && *q != '\0')
58114402Sru    return 0;
59114402Sru  tem += '\0';
60114402Sru  change_filename(tem.contents());
61114402Sru  change_lineno(ln);
62114402Sru  return 1;
63114402Sru}
64