Skip to content

Commit 9a0a84c

Browse files
author
Ishimoto Shinobu
committed
use openbsd vis
Signed-off-by: Ishimoto Shinobu <[email protected]>
1 parent d1136d5 commit 9a0a84c

File tree

2 files changed

+198
-714
lines changed

2 files changed

+198
-714
lines changed

include/vis.h

+25-52
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
/* $NetBSD: vis.h,v 1.25 2017/04/23 01:57:36 christos Exp $ */
1+
/* $OpenBSD: vis.h,v 1.15 2015/07/20 01:52:27 millert Exp $ */
2+
/* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */
23

34
/*-
4-
* Copyright (c) 1990, 1993
5-
* The Regents of the University of California. All rights reserved.
5+
* Copyright (c) 1990 The Regents of the University of California.
6+
* All rights reserved.
67
*
78
* Redistribution and use in source and binary forms, with or without
89
* modification, are permitted provided that the following conditions
@@ -28,46 +29,35 @@
2829
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2930
* SUCH DAMAGE.
3031
*
31-
* @(#)vis.h 8.1 (Berkeley) 6/2/93
32+
* @(#)vis.h 5.9 (Berkeley) 4/3/91
3233
*/
3334

3435
#ifndef _VIS_H_
3536
#define _VIS_H_
3637

37-
#include <bsd.h>
38-
#include <sys/types.h>
39-
4038
/*
4139
* to select alternate encoding format
4240
*/
43-
#define VIS_OCTAL 0x0001 /* use octal \ddd format */
44-
#define VIS_CSTYLE 0x0002 /* use \[nrft0..] where appropiate */
41+
#define VIS_OCTAL 0x01 /* use octal \ddd format */
42+
#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropriate */
4543

4644
/*
4745
* to alter set of characters encoded (default is to encode all
4846
* non-graphic except space, tab, and newline).
4947
*/
50-
#define VIS_SP 0x0004 /* also encode space */
51-
#define VIS_TAB 0x0008 /* also encode tab */
52-
#define VIS_NL 0x0010 /* also encode newline */
48+
#define VIS_SP 0x04 /* also encode space */
49+
#define VIS_TAB 0x08 /* also encode tab */
50+
#define VIS_NL 0x10 /* also encode newline */
5351
#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
54-
#define VIS_SAFE 0x0020 /* only encode "unsafe" characters */
55-
#define VIS_DQ 0x8000 /* also encode double quotes */
52+
#define VIS_SAFE 0x20 /* only encode "unsafe" characters */
53+
#define VIS_DQ 0x200 /* backslash-escape double quotes */
54+
#define VIS_ALL 0x400 /* encode all characters */
5655

5756
/*
5857
* other
5958
*/
60-
#define VIS_NOSLASH 0x0040 /* inhibit printing '\' */
61-
#define VIS_HTTP1808 0x0080 /* http-style escape % hex hex */
62-
#define VIS_HTTPSTYLE 0x0080 /* http-style escape % hex hex */
63-
#define VIS_MIMESTYLE 0x0100 /* mime-style escape = HEX HEX */
64-
#define VIS_HTTP1866 0x0200 /* http-style &#num; or &string; */
65-
#define VIS_NOESCAPE 0x0400 /* don't decode `\' */
66-
#define _VIS_END 0x0800 /* for unvis */
67-
#define VIS_GLOB 0x1000 /* encode glob(3) magic characters */
68-
#define VIS_SHELL 0x2000 /* encode shell special characters [not glob] */
69-
#define VIS_META (VIS_WHITE | VIS_GLOB | VIS_SHELL)
70-
#define VIS_NOLOCALE 0x4000 /* encode using the C locale */
59+
#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
60+
#define VIS_GLOB 0x100 /* encode glob(3) magics and '#' */
7161

7262
/*
7363
* unvis return codes
@@ -81,40 +71,23 @@
8171
/*
8272
* unvis flags
8373
*/
84-
#define UNVIS_END _VIS_END /* no more characters */
74+
#define UNVIS_END 1 /* no more characters */
75+
76+
#include <bsd.h>
8577

8678
__BEGIN_DECLS
8779
char *vis(char *, int, int, int);
88-
char *nvis(char *, size_t, int, int, int);
89-
90-
char *svis(char *, int, int, int, const char *);
91-
char *snvis(char *, size_t, int, int, int, const char *);
92-
9380
int strvis(char *, const char *, int);
9481
int stravis(char **, const char *, int);
95-
int strnvis(char *, size_t, const char *, int);
96-
97-
int strsvis(char *, const char *, int, const char *);
98-
int strsnvis(char *, size_t, const char *, int, const char *);
99-
100-
int strvisx(char *, const char *, size_t, int);
101-
int strnvisx(char *, size_t, const char *, size_t, int);
102-
int strenvisx(char *, size_t, const char *, size_t, int, int *);
103-
104-
int strsvisx(char *, const char *, size_t, int, const char *);
105-
int strsnvisx(char *, size_t, const char *, size_t, int, const char *);
106-
int strsenvisx(char *, size_t, const char *, size_t , int, const char *,
107-
int *);
108-
82+
int strnvis(char *, const char *, size_t, int)
83+
__attribute__ ((__bounded__(__string__,1,3)));
84+
int strvisx(char *, const char *, size_t, int)
85+
__attribute__ ((__bounded__(__string__,1,3)));
10986
int strunvis(char *, const char *);
110-
int strnunvis(char *, size_t, const char *);
111-
112-
int strunvisx(char *, const char *, int);
113-
int strnunvisx(char *, size_t, const char *, int);
87+
int unvis(char *, char, int *, int);
88+
ssize_t strnunvis(char *, const char *, size_t)
89+
__attribute__ ((__bounded__(__string__,1,3)));
11490

115-
#ifndef __LIBC12_SOURCE__
116-
int unvis(char *, int, int *, int);
117-
#endif
11891
__END_DECLS
11992

12093
#endif /* !_VIS_H_ */

0 commit comments

Comments
 (0)