summaryrefslogtreecommitdiffstats
path: root/contrib/groff/soelim
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2001-04-17 12:23:50 +0000
committerru <ru@FreeBSD.org>2001-04-17 12:23:50 +0000
commit61352401d3a90e1f7df92a3b0c656abdd58db6cf (patch)
tree00e2ca5da289f187526a4d9a20bc79d3dbf54dc8 /contrib/groff/soelim
parent42d565388eaa8c9f931d7188a3f2f9c5951f6b3b (diff)
downloadFreeBSD-src-61352401d3a90e1f7df92a3b0c656abdd58db6cf.zip
FreeBSD-src-61352401d3a90e1f7df92a3b0c656abdd58db6cf.tar.gz
This commit was generated by cvs2svn to compensate for changes in r75587,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/groff/soelim')
-rw-r--r--contrib/groff/soelim/Makefile.sub6
-rw-r--r--contrib/groff/soelim/TODO1
-rw-r--r--contrib/groff/soelim/soelim.cc338
-rw-r--r--contrib/groff/soelim/soelim.man76
4 files changed, 0 insertions, 421 deletions
diff --git a/contrib/groff/soelim/Makefile.sub b/contrib/groff/soelim/Makefile.sub
deleted file mode 100644
index 77007e2..0000000
--- a/contrib/groff/soelim/Makefile.sub
+++ /dev/null
@@ -1,6 +0,0 @@
-PROG=soelim
-MAN1=soelim.n
-XLIBS=$(LIBGROFF)
-OBJS=soelim.o
-CCSRCS=$(srcdir)/soelim.cc
-NAMEPREFIX=$(g)
diff --git a/contrib/groff/soelim/TODO b/contrib/groff/soelim/TODO
deleted file mode 100644
index f2a3924..0000000
--- a/contrib/groff/soelim/TODO
+++ /dev/null
@@ -1 +0,0 @@
-Understand .pso.
diff --git a/contrib/groff/soelim/soelim.cc b/contrib/groff/soelim/soelim.cc
deleted file mode 100644
index 257fc88..0000000
--- a/contrib/groff/soelim/soelim.cc
+++ /dev/null
@@ -1,338 +0,0 @@
-// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
- Written by James Clark (jjc@jclark.com)
-
-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 2, or (at your option) any later
-version.
-
-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
-for more details.
-
-You should have received a copy of the GNU General Public License along
-with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "lib.h"
-#include "errarg.h"
-#include "error.h"
-#include "stringclass.h"
-#include "nonposix.h"
-
-static int include_list_length;
-static char **include_list;
-
-int compatible_flag = 0;
-
-extern int interpret_lf_args(const char *);
-
-int do_file(const char *filename);
-
-
-static void
-include_path_append(char *path)
-{
- ++include_list_length;
- size_t nbytes = include_list_length * sizeof(char *);
- if (include_list)
- include_list = (char **)realloc((void *)include_list, nbytes);
- else
- include_list = (char **)malloc(nbytes);
- if (include_list == NULL)
- {
- fprintf(stderr, "%s: out of memory\n", program_name);
- exit(2);
- }
- include_list[include_list_length - 1] = path;
-}
-
-
-void usage()
-{
- fprintf(stderr, "usage: %s [ -vC ] [ -I file ] [ files ]\n", program_name);
- exit(1);
-}
-
-int main(int argc, char **argv)
-{
- program_name = argv[0];
- include_path_append(".");
- int opt;
- while ((opt = getopt(argc, argv, "CI:v")) != EOF)
- switch (opt) {
- case 'v':
- {
- extern const char *Version_string;
- fprintf(stderr, "GNU soelim version %s\n", Version_string);
- fflush(stderr);
- break;
- }
- case 'C':
- compatible_flag = 1;
- break;
- case 'I':
- include_path_append(optarg);
- break;
- case '?':
- usage();
- break;
- default:
- assert(0);
- }
- int nbad = 0;
- if (optind >= argc)
- nbad += !do_file("-");
- else
- for (int i = optind; i < argc; i++)
- nbad += !do_file(argv[i]);
- if (ferror(stdout) || fflush(stdout) < 0)
- fatal("output error");
- return nbad != 0;
-}
-
-void set_location()
-{
- printf(".lf %d %s\n", current_lineno, current_filename);
-}
-
-void do_so(const char *line)
-{
- const char *p = line;
- while (*p == ' ')
- p++;
- string filename;
- int success = 1;
- for (const char *q = p;
- success && *q != '\0' && *q != '\n' && *q != ' ';
- q++)
- if (*q == '\\') {
- switch (*++q) {
- case 'e':
- case '\\':
- filename += '\\';
- break;
- case ' ':
- filename += ' ';
- break;
- default:
- success = 0;
- break;
- }
- }
- else
- filename += char(*q);
- if (success && filename.length() > 0) {
- filename += '\0';
- const char *fn = current_filename;
- int ln = current_lineno;
- current_lineno--;
- if (do_file(filename.contents())) {
- current_filename = fn;
- current_lineno = ln;
- set_location();
- return;
- }
- current_lineno++;
- }
- fputs(".so", stdout);
- fputs(line, stdout);
-}
-
-int do_file(const char *filename)
-{
- FILE *fp;
- string whole_filename;
- if (strcmp(filename, "-") == 0) {
- fp = stdin;
- whole_filename = filename;
- whole_filename += '\0';
- }
- else if (IS_ABSOLUTE(filename)) {
- whole_filename = filename;
- whole_filename += '\0';
- errno = 0;
- fp = fopen(filename, "r");
- if (fp == 0) {
- error("can't open `%1': %2", filename, strerror(errno));
- return 0;
- }
- }
- else {
- size_t j;
- for (j = 0; j < include_list_length; ++j)
- {
- char *path = include_list[j];
- if (0 == strcmp(path, "."))
- whole_filename = filename;
- else
- whole_filename = string(path) + "/" + filename;
- whole_filename += '\0';
- errno = 0;
- fp = fopen(whole_filename.contents(), "r");
- if (fp != 0)
- break;
- if (errno != ENOENT) {
- error("can't open `%1': %2",
- whole_filename.contents(), strerror(errno));
- return 0;
- }
- }
- if (j >= include_list_length)
- {
- errno = ENOENT;
- error("can't open `%1': %2", filename, strerror(errno));
- return 0;
- }
- }
- current_filename = whole_filename.contents();
- current_lineno = 1;
- set_location();
- enum { START, MIDDLE, HAD_DOT, HAD_s, HAD_so, HAD_l, HAD_lf } state = START;
- for (;;) {
- int c = getc(fp);
- if (c == EOF)
- break;
- switch (state) {
- case START:
- if (c == '.')
- state = HAD_DOT;
- else {
- putchar(c);
- if (c == '\n') {
- current_lineno++;
- state = START;
- }
- else
- state = MIDDLE;
- }
- break;
- case MIDDLE:
- putchar(c);
- if (c == '\n') {
- current_lineno++;
- state = START;
- }
- break;
- case HAD_DOT:
- if (c == 's')
- state = HAD_s;
- else if (c == 'l')
- state = HAD_l;
- else {
- putchar('.');
- putchar(c);
- if (c == '\n') {
- current_lineno++;
- state = START;
- }
- else
- state = MIDDLE;
- }
- break;
- case HAD_s:
- if (c == 'o')
- state = HAD_so;
- else {
- putchar('.');
- putchar('s');
- putchar(c);
- if (c == '\n') {
- current_lineno++;
- state = START;
- }
- else
- state = MIDDLE;
- }
- break;
- case HAD_so:
- if (c == ' ' || c == '\n' || compatible_flag) {
- string line;
- for (; c != EOF && c != '\n'; c = getc(fp))
- line += c;
- current_lineno++;
- line += '\n';
- line += '\0';
- do_so(line.contents());
- state = START;
- }
- else {
- fputs(".so", stdout);
- putchar(c);
- state = MIDDLE;
- }
- break;
- case HAD_l:
- if (c == 'f')
- state = HAD_lf;
- else {
- putchar('.');
- putchar('l');
- putchar(c);
- if (c == '\n') {
- current_lineno++;
- state = START;
- }
- else
- state = MIDDLE;
- }
- break;
- case HAD_lf:
- if (c == ' ' || c == '\n' || compatible_flag) {
- string line;
- for (; c != EOF && c != '\n'; c = getc(fp))
- line += c;
- current_lineno++;
- line += '\n';
- line += '\0';
- interpret_lf_args(line.contents());
- printf(".lf%s", line.contents());
- state = START;
- }
- else {
- fputs(".lf", stdout);
- putchar(c);
- state = MIDDLE;
- }
- break;
- default:
- assert(0);
- }
- }
- switch (state) {
- case HAD_DOT:
- fputs(".\n", stdout);
- break;
- case HAD_l:
- fputs(".l\n", stdout);
- break;
- case HAD_s:
- fputs(".s\n", stdout);
- break;
- case HAD_lf:
- fputs(".lf\n", stdout);
- break;
- case HAD_so:
- fputs(".so\n", stdout);
- break;
- case MIDDLE:
- putc('\n', stdout);
- break;
- case START:
- break;
- }
- if (fp != stdin)
- fclose(fp);
- current_filename = 0;
- return 1;
-}
diff --git a/contrib/groff/soelim/soelim.man b/contrib/groff/soelim/soelim.man
deleted file mode 100644
index 0d927f7..0000000
--- a/contrib/groff/soelim/soelim.man
+++ /dev/null
@@ -1,76 +0,0 @@
-.ig \"-*- nroff -*-
-Copyright (C) 1989-2000 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
-..
-.TH @G@SOELIM @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
-.SH NAME
-@g@soelim \- interpret .so requests in groff input
-.SH SYNOPSIS
-.B @g@soelim
-[
-.B \-Cv
-]
-[
-.BI \-I dir
-]
-[
-.IR files \|.\|.\|.\|
-]
-.PP
-It is possible to have whitespace between the
-.B \-I
-command line option and its parameter.
-.SH DESCRIPTION
-.B @g@soelim
-reads
-.I files
-and replaces lines of the form
-.IP
-.BI .so\ file
-.LP
-by the contents of
-.IR file .
-It is useful if files included with
-.B so
-need to be preprocessed.
-Normally,
-.B @g@soelim
-should be invoked with the
-.B \-s
-option of
-.BR groff .
-.SH OPTIONS
-.TP
-.B \-C
-Recognize
-.B .so
-even when followed by a character other than space or newline.
-.TP
-.BI \-I dir
-This option may be used to specify a directory to search for
-files (both those on the command line and those named in
-.B \&.so
-lines).
-The current directory is always searched first.
-This option may be specified more than once,
-the directories will be searched in the order specified.
-No directory search is performed for files specified using an absolute path.
-.TP
-.B \-v
-Print the version number.
-.SH "SEE ALSO"
-.BR groff (@MAN1EXT@)
OpenPOWER on IntegriCloud