lf.cpp revision 151497
1104862Sru// -*- C++ -*- 2104862Sru/* Copyright (C) 1989, 1990, 1991, 1992, 2004 Free Software Foundation, Inc. 3104862Sru Written by James Clark (jjc@jclark.com) 4104862Sru 5104862SruThis file is part of groff. 6104862Sru 7104862Srugroff is free software; you can redistribute it and/or modify it under 8104862Sruthe terms of the GNU General Public License as published by the Free 9104862SruSoftware Foundation; either version 2, or (at your option) any later 10104862Sruversion. 11104862Sru 12104862Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY 13104862SruWARRANTY; without even the implied warranty of MERCHANTABILITY or 14104862SruFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15104862Srufor more details. 16104862Sru 17104862SruYou should have received a copy of the GNU General Public License along 18104862Sruwith groff; see the file COPYING. If not, write to the Free Software 19114402SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ 20104862Sru 21104862Sru#include <ctype.h> 22104862Sru 23104862Sru#include "lib.h" 24104862Sru#include "cset.h" 25104862Sru#include "stringclass.h" 26104862Sru 27104862Sruextern void change_filename(const char *); 28104862Sruextern void change_lineno(int); 29104862Sru 30114402Sruint interpret_lf_args(const char *p) 31114402Sru{ 32104862Sru while (*p == ' ') 33104862Sru p++; 34104862Sru if (!csdigit(*p)) 35104862Sru return 0; 36104862Sru int ln = 0; 37104862Sru do { 38104862Sru ln *= 10; 39104862Sru ln += *p++ - '0'; 40104862Sru } while (csdigit(*p)); 41104862Sru if (*p != ' ' && *p != '\n' && *p != '\0') 42104862Sru return 0; 43104862Sru while (*p == ' ') 44104862Sru p++; 45104862Sru if (*p == '\0' || *p == '\n') { 46104862Sru change_lineno(ln); 47104862Sru return 1; 48104862Sru } 49104862Sru const char *q; 50104862Sru for (q = p; 51104862Sru *q != '\0' && *q != ' ' && *q != '\n' && *q != '\\'; 52114402Sru q++) 53104862Sru ; 54104862Sru string tem(p, q - p); 55104862Sru while (*q == ' ') 56104862Sru q++; 57104862Sru if (*q != '\n' && *q != '\0') 58104862Sru return 0; 59104862Sru tem += '\0'; 60104862Sru change_filename(tem.contents()); 61104862Sru change_lineno(ln); 62104862Sru return 1; 63114402Sru} 64114402Sru