History log of /openbsd-current/lib/libc/gen/vis.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.26 04-May-2022 deraadt

Found two multiple evaluation macros. One of them so long and scary it
too many people to unravel correctly and place into a static function.
While here, move the flags bits into local variables, which reduces
the amount of () in the checks.
help from millert, miod, tedu


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.25 13-Sep-2015 guenther

Wrap <vis.h> so that calls go direct and the symbols are all weak


Revision tags: OPENBSD_5_8_BASE
# 1.24 20-Jul-2015 millert

Add VIS_DQ to escape double quotes. OK deraadt@ semarie@ reyk@


Revision tags: OPENBSD_5_7_BASE
# 1.23 17-Nov-2014 millert

Add stravis(), an allocating version of strvis(). OK doug@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.22 13-Mar-2011 guenther

Fix handling of VIS_ALL: in vis(), actually encode all characters
as requested and give a correct estimate when they don't all fit,
and in unvis() decode them instead of erroring

ok nicm@, deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 24-Aug-2010 djm

backout VIS_HEX. guenther@ points out that the C89 \xff encoding
idiotically accepts more then two hex digits following the \x, even
on platforms where a char has 8 bits. It is therefore dangerous to have
an almost-bit-not-quite compatible format in vis(3).

The VIS_ALL (encode all characters) option introduced in the same commit
remains.


# 1.20 21-Aug-2010 djm

Two new flags: VIS_ALL - encode all characters, not just invisible ones
and VIS_HEX - use C89 \xff style hexadecimal encoding.

Teach unvis(3) how to deal with the hex encoding.

feedback and ok millert@ chl@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.19 01-Sep-2005 millert

repair VIS_GLOB; deraadt@ otto@ OK


# 1.18 29-Aug-2005 otto

Remove spurious call to isgraph() that sneaked in in rev 1.16.
ok millert@ deraadt@


# 1.17 28-Aug-2005 millert

Fix the VIS_GLOB checks added in rev 1.16
Add missing casts to u_char so 0xff is treated the same on machines
with signed and unsigned chars.
OK deraadt@ espie@


# 1.16 09-Aug-2005 millert

Add VIS_GLOB to escape special characters used by shell-style globbing.
From Solar Designer based on changes in FreeBSD. OK deraadt@


# 1.15 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.14 25-Mar-2005 otto

deregister (and deauto!). ok millert@ marco@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.13 18-May-2004 jfb

ansify function definitions and zap some `register'

ok millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.12 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.11 14-May-2003 pjanzen

sync vis() behaviour when VIS_SAFE to man page: don't do anything if isgraph()
is true, even if the character isn't 7-bit.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 01-Jul-2002 deraadt

need string.h


# 1.9 01-Jul-2002 pjanzen

Fix strnvis(): don't truncate unnecessarily, set the return value correctly
if we had to truncate, and don't NUL-terminate if size == 0.


Revision tags: OPENBSD_3_1_BASE
# 1.8 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


Revision tags: OPENBSD_3_0_BASE
# 1.7 13-Aug-2001 millert

Explicitly NUL terminate dst in strvis() and strvisx() in case
we are passes an empty string. vis() and strnvis() were already OK.
Based on patch by wilfried@openbsd.org


Revision tags: OPENBSD_2_9_BASE
# 1.6 21-Nov-2000 millert

Add strnvis(3) -- a length-bounded version of strvis(3) with a return
value similar to snprintf(3) and strlcpy(3).


Revision tags: OPENBSD_2_8_BASE
# 1.5 19-Jul-2000 deraadt

off-by-one calculation error; getcwd() would return NULL if the buffer was
the needed length + terminating byte + 1; that 1 is not needed; assar


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE
# 1.4 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.3 09-Jul-1997 millert

Clean up some -Wall complaints.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.25 13-Sep-2015 guenther

Wrap <vis.h> so that calls go direct and the symbols are all weak


Revision tags: OPENBSD_5_8_BASE
# 1.24 20-Jul-2015 millert

Add VIS_DQ to escape double quotes. OK deraadt@ semarie@ reyk@


Revision tags: OPENBSD_5_7_BASE
# 1.23 17-Nov-2014 millert

Add stravis(), an allocating version of strvis(). OK doug@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.22 13-Mar-2011 guenther

Fix handling of VIS_ALL: in vis(), actually encode all characters
as requested and give a correct estimate when they don't all fit,
and in unvis() decode them instead of erroring

ok nicm@, deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 24-Aug-2010 djm

backout VIS_HEX. guenther@ points out that the C89 \xff encoding
idiotically accepts more then two hex digits following the \x, even
on platforms where a char has 8 bits. It is therefore dangerous to have
an almost-bit-not-quite compatible format in vis(3).

The VIS_ALL (encode all characters) option introduced in the same commit
remains.


# 1.20 21-Aug-2010 djm

Two new flags: VIS_ALL - encode all characters, not just invisible ones
and VIS_HEX - use C89 \xff style hexadecimal encoding.

Teach unvis(3) how to deal with the hex encoding.

feedback and ok millert@ chl@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.19 01-Sep-2005 millert

repair VIS_GLOB; deraadt@ otto@ OK


# 1.18 29-Aug-2005 otto

Remove spurious call to isgraph() that sneaked in in rev 1.16.
ok millert@ deraadt@


# 1.17 28-Aug-2005 millert

Fix the VIS_GLOB checks added in rev 1.16
Add missing casts to u_char so 0xff is treated the same on machines
with signed and unsigned chars.
OK deraadt@ espie@


# 1.16 09-Aug-2005 millert

Add VIS_GLOB to escape special characters used by shell-style globbing.
From Solar Designer based on changes in FreeBSD. OK deraadt@


# 1.15 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.14 25-Mar-2005 otto

deregister (and deauto!). ok millert@ marco@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.13 18-May-2004 jfb

ansify function definitions and zap some `register'

ok millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.12 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.11 14-May-2003 pjanzen

sync vis() behaviour when VIS_SAFE to man page: don't do anything if isgraph()
is true, even if the character isn't 7-bit.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 01-Jul-2002 deraadt

need string.h


# 1.9 01-Jul-2002 pjanzen

Fix strnvis(): don't truncate unnecessarily, set the return value correctly
if we had to truncate, and don't NUL-terminate if size == 0.


Revision tags: OPENBSD_3_1_BASE
# 1.8 19-Feb-2002 millert

We live in an ANSI C world. Remove lots of gratuitous #ifdef __STDC__ cruft.


Revision tags: OPENBSD_3_0_BASE
# 1.7 13-Aug-2001 millert

Explicitly NUL terminate dst in strvis() and strvisx() in case
we are passes an empty string. vis() and strnvis() were already OK.
Based on patch by wilfried@openbsd.org


Revision tags: OPENBSD_2_9_BASE
# 1.6 21-Nov-2000 millert

Add strnvis(3) -- a length-bounded version of strvis(3) with a return
value similar to snprintf(3) and strlcpy(3).


Revision tags: OPENBSD_2_8_BASE
# 1.5 19-Jul-2000 deraadt

off-by-one calculation error; getcwd() would return NULL if the buffer was
the needed length + terminating byte + 1; that 1 is not needed; assar


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE
# 1.4 25-Jul-1997 mickey

#if __STDC__ --> #ifdef __STDC__


# 1.3 09-Jul-1997 millert

Clean up some -Wall complaints.


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE
# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision