]>
cygwin.com Git - cygwin-apps/cygutils.git/blob - src/colcrt/colcrt.c
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
32 * added Native Language Support
33 * 1999-09-19 Bruno Haible <haible@clisp.cons.org>
34 * modified to work correctly in multi-byte locales
35 * 2002-07-12 Charles Wilson <cwilson@ece.gatech.edu>
36 * modified to work on cygwin; integrated into cygutils package
44 /* included by common.h *//*
52 #define LOCALEDIR "/usr/share/locale"
59 # undef setlocale(a, b)
60 # define setlocale(a, b) /* empty */
65 # define _(Text) gettext (Text)
67 # define N_(String) gettext_noop (String)
69 # define N_(String) (String)
72 # undef bindtextdomain
73 # define bindtextdomain(Domain, Directory) /* empty */
75 # define textdomain(Domain) /* empty */
76 # define _(Text) (Text)
77 # define N_(Text) (Text)
82 int plus(wchar_t c
, wchar_t d
);
83 void move(int l
, int m
);
87 * colcrt - replaces col for crts with new nroff esp. when using tbl.
88 * Bill Joy UCB July 14, 1977
90 * This filter uses a screen buffer, 267 half-lines by 132 columns.
91 * It interprets the up and down sequences generated by the new
92 * nroff when used with tbl and by \u \d and \r.
93 * General overstriking doesn't work correctly.
94 * Underlining is split onto multiple lines, etc.
96 * Option - suppresses all underlining.
97 * Option -2 forces printing of all half lines.
100 wchar_t page
[267][132];
109 void colcrt(FILE *f
);
112 main(int argc
, char **argv
) {
115 setlocale(LC_ALL
, "");
116 bindtextdomain(PACKAGE
, LOCALEDIR
);
121 while (argc
> 0 && argv
[0][0] == '-') {
122 switch (argv
[0][1]) {
130 printf(_("usage: %s [ - ] [ -2 ] [ file ... ]\n"), progname
);
140 if (!(f
= fopen(argv
[0], "r"))) {
153 if (ferror(stdout
) || fclose(stdout
))
212 if (outcol
+ w
> 132) {
216 cp
= &page
[outline
][outcol
];
228 dp
= cp
- (outcol
-w
);
229 for (cp
--; cp
>= dp
&& *cp
== 0; cp
--)
232 if (plus(c
, *cp
) || plus(*cp
, c
))
234 else if (*cp
== ' ' || *cp
== 0) {
236 if (cp
[i
] != ' ' && cp
[i
] != 0)
247 int plus(wchar_t c
, wchar_t d
)
250 return (c
== '|' && (d
== '-' || d
== '_'));
258 register wchar_t *cp
;
268 for (i
= first
| 1; i
< l
; i
++) {
272 for (i
= first
; i
< l
; i
++) {
274 if (printall
== 0 && lastomit
== 0 && *cp
== 0) {
280 if ((w
= wcwidth(*cp
)) > 0) {
288 bcopy(page
[ol
], page
, (267 - ol
) * 132 * sizeof(wchar_t));
289 bzero(page
[267- ol
], ol
* 132 * sizeof(wchar_t));
295 void move(int l
, int m
)
297 register wchar_t *cp
, *dp
;
299 for (cp
= page
[l
], dp
= page
[m
]; *cp
; cp
++, dp
++) {
302 if (*dp
!= ' ' && *dp
!= '|' && *dp
!= 0)
312 for (cp
= page
[l
], dp
= page
[m
]; *cp
; cp
++, dp
++)
This page took 0.051869 seconds and 5 git commands to generate.