Commit Graph

23 Commits

Author SHA1 Message Date
Don Lewis
e4efa066e1 Instead of ignoring the EEXIST from link(), unconditionally unlink
the terget before calling link().  This should prevent links to an
old copy of the file from being retained.
2016-05-13 05:49:02 +00:00
Don Lewis
52af39633a If fchdir() fails, call err() instead of warn(). 2016-05-12 23:37:58 +00:00
Don Lewis
3694294ca5 Avoid Coverity NUL termination warning about strncpy() by using
memcpy() instead.  It's probably a bit more optimal in this case
anyway. [1]

The program logic leading up to the creation of the strncpy/memcpy
destination buffer is a bit hairy.  Add a call to assert() to make
it clear what is happening here and detect any potential buffer
overruns in the future.

Check a couple syscall error returns.  Ignore the EEXIST error from
link() to preserve existing behavior. [2] [3]

Reported by:	Coverity
CID:		1009659 [1], 1009349 [2], 1009350 [3]
2016-05-12 23:14:31 +00:00
Ed Schouten
1a5054d3fb Add missing static keywords to catman(1) 2011-11-06 08:14:09 +00:00
Ulrich Spörlein
72baa018d0 For POLA reasons, disable SGR sequences in catpages.
See r222647 for a similar change to bsd.doc.mk after SGR was generally
turned on in groff.

Suggested by:	ru
Approved by:	re (kib)
2011-08-05 15:07:28 +00:00
Ulrich Spörlein
a9c153d033 Unbreak catman(1) by removing calls to col(1).
col(1) was mangling the SGR escapes and is not strictly required.

See r222647, r222648, r222650, and r222653 for more details.

Reported by:	delphij
Reviewed by:	ru
Approved by:	re (kib)
MFC after:	3 weeks
2011-08-03 19:26:57 +00:00
Konstantin Belousov
4176dd5267 Modernize scandir(3) and alphasort(3) interfaces according to the IEEE
Std 1003.1-2008. Both Linux and Solaris conforms to the new definitions,
so we better follow too (older glibc used old BSDish alphasort prototype
and corresponding type of the comparision function for scandir). While
there, change the definitions of the functions to ANSI C and fix several
style issues nearby.

Remove requirement for "sys/types.h" include for functions from manpage.

POSIX also requires that alphasort(3) sorts as if strcoll(3) was used,
but leave the strcmp(3) call in the function for now.

Adapt in-tree callers of scandir(3) to new declaration. The fact that
select_sections() from catman(1) could modify supplied struct dirent is
a bug.

PR:	standards/142255
MFC after:	2 weeks
2010-01-04 15:40:17 +00:00
Brooks Davis
5255c009dd Restore the check against running as root that I accidentally removed in
r194493.
2009-06-20 18:24:29 +00:00
Brooks Davis
68cc62cec1 When checking if we can write to a file, use access() instead of a
manual permission check based on stat output.  Also, get rid of the
executability check since it is not used.

MFC after:	2 weeks
2009-06-19 15:52:35 +00:00
Ruslan Ermilov
8c7a62275a Prepare for MACHINE and hw.machine switching to "pc98" on FreeBSD/pc98.
Reviewed by:	nyan
2005-12-05 14:22:12 +00:00
Ruslan Ermilov
f682f10c76 Sync program's usage() with manpage's SYNOPSIS. 2005-05-21 09:55:10 +00:00
Ruslan Ermilov
7f36b97c54 Look into machine-specific manpage subdirectories too.
PR:		bin/72243
MFC after:	3 weeks
2004-12-22 16:04:58 +00:00
Ruslan Ermilov
482c89954d Fixed the only warning and mark as WARNS=6 clean. 2004-12-22 15:25:51 +00:00
Ruslan Ermilov
0ab4b27257 - Fixed handling of manpage subdirectories:
catman /usr/share/man/man8
  cd /usr/share/man; catman man8

- Don't print false warnings about invalid cat pages which are
  machine-specific cat page subdirectories (visible with -v).

- Fixed one memory leak.
2004-12-22 15:24:48 +00:00
Andrey A. Chernov
4aeece6a14 Add (unsigned char) cast to ctype macros 2003-06-10 02:18:00 +00:00
Andrey A. Chernov
ddcab7eeac Use setlocale & nl_langinfo to parse locale name 2003-06-10 02:15:00 +00:00
Andrey A. Chernov
1d35769ff1 Remove deprecated locale names 2003-06-10 01:54:10 +00:00
Ruslan Ermilov
b140b63058 Fixed catman(1) so that if the source files are compressed,
the preformatted files are compressed with the same program
as the source, and if the source files are uncompressed, the
preformatted files are also uncompressed.

PR:		bin/52213
Submitted by:	Krister Joas <krister@gazonk.net>, ru
Approved by:	re (jhb)
2003-05-21 13:26:37 +00:00
David E. O'Brien
26f06d8b13 Mostly support alternate manpage zipping. 2002-10-29 09:20:22 +00:00
Ruslan Ermilov
b17996a47e Revert last delta. SGR support in grotty(1) is disabled system-wide
in /usr/share/tmac/troffrc pending the issue resolution on -arch.
2002-10-18 09:14:17 +00:00
Ruslan Ermilov
65b1f0f74e Groff 1.18.1 comes in with ANSI color support, enabled by default.
In "nroff" mode, italic font renders as an underlined text, which
makes it indistinguishable from the bold text on color monitors
(cons25 terminal type), yet it requires the less(1)'s -R option.
(Refer to the new grotty(1) manpage for details.)

So turn off the color support for now (when generating catpages),
until we figure out what do we do with this new feature.  I have
a patch for grotty(1) that tells it to use the "reverse video"
attribute to render the italic font.  Once this is accepted, we
can turn color support back on (if there won't be any objections
from the community).
2002-10-11 09:16:24 +00:00
David Malone
2698bbe2da No need to declare optind as an external int. 2002-09-04 21:16:51 +00:00
Mark Murray
bf7bec3366 Add C rewrites of catman and makewhatis. These aren't quite as
the submitter supplied them, as I did some WARNS=n fixups (mostly
const-ification).

Submitted by:	John Rochester <john@jrochester.org>
2002-05-18 09:19:08 +00:00