/* Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.uucp)
This file is part of groff.
groff is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any later
groff is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
You should have received a copy of the GNU General Public License along
with groff; see the file LICENSE. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
extern int interpret_lf_args(const char *);
int do_file(const char *filename
);
fprintf(stderr
, "usage: %s [ -vC ] [ files ]\n", program_name
);
int main(int argc
, char **argv
)
while ((opt
= getopt(argc
, argv
, "vC")) != EOF
)
extern const char *version_string
;
fprintf(stderr
, "GNU soelim version %s\n", version_string
);
for (int i
= optind
; i
< argc
; i
++)
nbad
+= !do_file(argv
[i
]);
if (ferror(stdout
) || fflush(stdout
) < 0)
printf(".lf %d %s\n", current_lineno
, current_filename
);
void do_so(const char *line
)
success
&& *q
!= '\0' && *q
!= '\n' && *q
!= ' ';
if (success
&& filename
.length() > 0) {
const char *fn
= current_filename
;
if (do_file(filename
.contents())) {
int do_file(const char *filename
)
if (strcmp(filename
, "-") == 0)
fp
= fopen(filename
, "r");
error("can't open `%1': %2", filename
, strerror(errno
));
current_filename
= filename
;
enum { START
, MIDDLE
, HAD_DOT
, HAD_s
, HAD_so
, HAD_l
, HAD_lf
} state
= START
;
if (c
== ' ' || c
== '\n' || compatible_flag
) {
for (; c
!= EOF
&& c
!= '\n'; c
= getc(fp
))
if (c
== ' ' || c
== '\n' || compatible_flag
) {
for (; c
!= EOF
&& c
!= '\n'; c
= getc(fp
))
interpret_lf_args(line
.contents());
printf(".lf%s", line
.contents());