From owner-svn-src-head@FreeBSD.ORG Fri May 1 23:54:11 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 08CCBB3C; Fri, 1 May 2015 23:54:11 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D24301E17; Fri, 1 May 2015 23:54:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t41NsAKS064176; Fri, 1 May 2015 23:54:10 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t41NsA86064172; Fri, 1 May 2015 23:54:10 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201505012354.t41NsA86064172@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Fri, 1 May 2015 23:54:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r282330 - head/usr.bin/soelim X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2015 23:54:11 -0000 Author: bapt Date: Fri May 1 23:54:09 2015 New Revision: 282330 URL: https://svnweb.freebsd.org/changeset/base/282330 Log: Improve compatibility groff's soelim While here implement -C from GNU groff Reported by: delphij Modified: head/usr.bin/soelim/soelim.1 head/usr.bin/soelim/soelim.c Modified: head/usr.bin/soelim/soelim.1 ============================================================================== --- head/usr.bin/soelim/soelim.1 Fri May 1 22:43:26 2015 (r282329) +++ head/usr.bin/soelim/soelim.1 Fri May 1 23:54:09 2015 (r282330) @@ -48,9 +48,9 @@ it replace the line by processing Otherwise the line is printed to stdout. .Bl -tag -width "-I dir" .It Fl C -Compatibility with GNU groff's -.Xr soelim 1 -(does nothing). +Recognise +.Em .so +when not followed by a space character. .It Fl r Compatibility with GNU groff's .Xr soelim 1 Modified: head/usr.bin/soelim/soelim.c ============================================================================== --- head/usr.bin/soelim/soelim.c Fri May 1 22:43:26 2015 (r282329) +++ head/usr.bin/soelim/soelim.c Fri May 1 23:54:09 2015 (r282330) @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include #include +#define C_OPTION 0x1 + static StringList *includes; static void @@ -81,10 +83,10 @@ soelim_fopen(const char *name) } static int -soelim_file(FILE *f) +soelim_file(FILE *f, int flag) { char *line = NULL; - char *walk; + char *walk, *cp; size_t linecap = 0; ssize_t linelen; @@ -96,13 +98,27 @@ soelim_file(FILE *f) printf("%s", line); continue; } + walk = line + 3; + if (!isspace(*walk) && ((flag & C_OPTION) == 0)) { + printf("%s", line); + continue; + } + while (isspace(*walk)) walk++; - while (isspace(walk[strlen(walk) - 1])) - walk[strlen(walk) - 1] = '\0'; - if (soelim_file(soelim_fopen(walk)) == 1) { + cp = walk + strlen(walk) - 1; + while (cp > walk && isspace(*cp)) { + *cp = 0; + cp--; + } + + if (*walk == '\0') { + printf("%s", line); + continue; + } + if (soelim_file(soelim_fopen(walk), flag) == 1) { free(line); return (1); } @@ -119,6 +135,7 @@ main(int argc, char **argv) { int ch, i; int ret = 0; + int flags = 0; includes = sl_init(); if (includes == NULL) @@ -127,6 +144,8 @@ main(int argc, char **argv) while ((ch = getopt(argc, argv, "CrtvI:")) != -1) { switch (ch) { case 'C': + flags |= C_OPTION; + break; case 'r': case 'v': case 't': @@ -145,10 +164,10 @@ main(int argc, char **argv) argv += optind; if (argc == 0) - ret = soelim_file(stdin); + ret = soelim_file(stdin, flags); for (i = 0; i < argc; i++) - ret = soelim_file(soelim_fopen(argv[i])); + ret = soelim_file(soelim_fopen(argv[i]), flags); sl_free(includes, 0);