Deleted Added
full compact
conv.c (1591) conv.c (87203)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD: head/usr.bin/hexdump/conv.c 87203 2001-12-02 12:09:41Z markm $
32 */
33
34#ifndef lint
34 */
35
36#ifndef lint
35static char sccsid[] = "@(#)conv.c 8.1 (Berkeley) 6/6/93";
37static const char sccsid[] = "@(#)conv.c 8.1 (Berkeley) 6/6/93";
36#endif /* not lint */
37
38#include <sys/types.h>
39
40#include <stdio.h>
41#include <ctype.h>
42#include "hexdump.h"
43
44void
45conv_c(pr, p)
46 PR *pr;
47 u_char *p;
48{
49 extern int deprecated;
50 char buf[10], *str;
38#endif /* not lint */
39
40#include <sys/types.h>
41
42#include <stdio.h>
43#include <ctype.h>
44#include "hexdump.h"
45
46void
47conv_c(pr, p)
48 PR *pr;
49 u_char *p;
50{
51 extern int deprecated;
52 char buf[10], *str;
53 static char nul[] = "\\0";
54 static char alarm[] = "\\a";
55 static char backspace[] = "\\b";
56 static char formfeed[] = "\\f";
57 static char newline[] = "\\n";
58 static char carriageret[] = "\\r";
59 static char verticaltab[] = "\\v";
60 static char tab[] = "\\t";
51
52 switch(*p) {
53 case '\0':
61
62 switch(*p) {
63 case '\0':
54 str = "\\0";
64 str = nul;
55 goto strpr;
56 /* case '\a': */
57 case '\007':
58 if (deprecated) /* od didn't know about \a */
59 break;
65 goto strpr;
66 /* case '\a': */
67 case '\007':
68 if (deprecated) /* od didn't know about \a */
69 break;
60 str = "\\a";
70 str = alarm;
61 goto strpr;
62 case '\b':
71 goto strpr;
72 case '\b':
63 str = "\\b";
73 str = backspace;
64 goto strpr;
65 case '\f':
74 goto strpr;
75 case '\f':
66 str = "\\f";
76 str = formfeed;
67 goto strpr;
68 case '\n':
77 goto strpr;
78 case '\n':
69 str = "\\n";
79 str = newline;
70 goto strpr;
71 case '\r':
80 goto strpr;
81 case '\r':
72 str = "\\r";
82 str = carriageret;
73 goto strpr;
74 case '\t':
83 goto strpr;
84 case '\t':
75 str = "\\t";
85 str = tab;
76 goto strpr;
77 case '\v':
78 if (deprecated)
79 break;
86 goto strpr;
87 case '\v':
88 if (deprecated)
89 break;
80 str = "\\v";
90 str = verticaltab;
81 goto strpr;
82 default:
83 break;
84 }
85 if (isprint(*p)) {
86 *pr->cchar = 'c';
87 (void)printf(pr->fmt, *p);
88 } else {

--- 4 unchanged lines hidden (view full) ---

93}
94
95void
96conv_u(pr, p)
97 PR *pr;
98 u_char *p;
99{
100 extern int deprecated;
91 goto strpr;
92 default:
93 break;
94 }
95 if (isprint(*p)) {
96 *pr->cchar = 'c';
97 (void)printf(pr->fmt, *p);
98 } else {

--- 4 unchanged lines hidden (view full) ---

103}
104
105void
106conv_u(pr, p)
107 PR *pr;
108 u_char *p;
109{
110 extern int deprecated;
101 static char *list[] = {
111 static const char *list[] = {
102 "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
103 "bs", "ht", "lf", "vt", "ff", "cr", "so", "si",
104 "dle", "dcl", "dc2", "dc3", "dc4", "nak", "syn", "etb",
105 "can", "em", "sub", "esc", "fs", "gs", "rs", "us",
106 };
107
108 /* od used nl, not lf */
109 if (*p <= 0x1f) {

--- 19 unchanged lines hidden ---
112 "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
113 "bs", "ht", "lf", "vt", "ff", "cr", "so", "si",
114 "dle", "dcl", "dc2", "dc3", "dc4", "nak", "syn", "etb",
115 "can", "em", "sub", "esc", "fs", "gs", "rs", "us",
116 };
117
118 /* od used nl, not lf */
119 if (*p <= 0x1f) {

--- 19 unchanged lines hidden ---