lf.cpp revision 114402
1114402Sru// -*- C++ -*-
2114402Sru/* Copyright (C) 1989, 1990, 1991, 1992 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
19114402SruFoundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20114402Sru
21114402Sru#include <string.h>
22114402Sru#include <ctype.h>
23114402Sru#include "cset.h"
24114402Sru#include "stringclass.h"
25114402Sru
26114402Sruextern void change_filename(const char *);
27114402Sruextern void change_lineno(int);
28114402Sru
29114402Sruint interpret_lf_args(const char *p)
30114402Sru{
31114402Sru  while (*p == ' ')
32114402Sru    p++;
33114402Sru  if (!csdigit(*p))
34114402Sru    return 0;
35114402Sru  int ln = 0;
36114402Sru  do {
37114402Sru    ln *= 10;
38114402Sru    ln += *p++ - '0';
39114402Sru  } while (csdigit(*p));
40114402Sru  if (*p != ' ' && *p != '\n' && *p != '\0')
41114402Sru    return 0;
42114402Sru  while (*p == ' ')
43114402Sru    p++;
44114402Sru  if (*p == '\0' || *p == '\n')  {
45114402Sru    change_lineno(ln);
46114402Sru    return 1;
47114402Sru  }
48114402Sru  const char *q;
49114402Sru  for (q = p;
50114402Sru       *q != '\0' && *q != ' ' && *q != '\n' && *q != '\\';
51114402Sru       q++)
52114402Sru    ;
53114402Sru  string tem(p, q - p);
54114402Sru  while (*q == ' ')
55114402Sru    q++;
56114402Sru  if (*q != '\n' && *q != '\0')
57114402Sru    return 0;
58114402Sru  tem += '\0';
59114402Sru  change_filename(tem.contents());
60114402Sru  change_lineno(ln);
61114402Sru  return 1;
62114402Sru}
63