Commit | Line | Data |
---|---|---|
0dcd613f AC |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
3 | Copyright 2001, 2004 Free Software Foundation, Inc. | |
4 | ||
5 | Contributed by Red Hat, originally written by Jim Blandy. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 | ||
21 | Please email any bugs, comments, and/or additions to this file to: | |
22 | bug-gdb@gnu.org */ | |
dea97812 KB |
23 | |
24 | #include <stdio.h> | |
7b2953d9 | 25 | #include <stdlib.h> |
7cf03d44 | 26 | #include <string.h> |
dea97812 KB |
27 | |
28 | ||
29 | /* X_string is a null-terminated string in the X charset whose | |
30 | elements are as follows. X should be the name the `set charset' | |
31 | command uses for the character set, in lower-case, with any | |
32 | non-identifier characters replaced with underscores. Where a | |
33 | character set doesn't have the given character, the string should | |
34 | contain the character 'x'. | |
35 | ||
36 | [0] --- the `alert' character, '\a' | |
37 | [1] --- the `backspace' character, '\b' | |
0dcd613f AC |
38 | [2] --- the `form feed' character, '\f' |
39 | [3] --- the `line feed' character, '\n' | |
40 | [4] --- the `carriage return' character, '\r' | |
41 | [5] --- the `horizontal tab' character, '\t' | |
42 | [6] --- the `vertical tab' character, '\v' | |
43 | [7 .. 32] --- the uppercase letters A-Z | |
44 | [33 .. 58] --- the lowercase letters a-z | |
45 | [59 .. 68] --- the digits 0-9 | |
46 | [69] --- the `cent' character | |
47 | [70] --- a control character with no defined backslash escape | |
dea97812 KB |
48 | |
49 | Feel free to extend these as you like. */ | |
50 | ||
0dcd613f | 51 | #define NUM_CHARS (71) |
dea97812 KB |
52 | |
53 | char ascii_string[NUM_CHARS]; | |
54 | char iso_8859_1_string[NUM_CHARS]; | |
55 | char ebcdic_us_string[NUM_CHARS]; | |
56 | char ibm1047_string[NUM_CHARS]; | |
57 | ||
58 | ||
59 | void | |
60 | init_string (char string[], | |
61 | char x, | |
0dcd613f | 62 | char alert, char backspace, char form_feed, |
dea97812 KB |
63 | char line_feed, char carriage_return, char horizontal_tab, |
64 | char vertical_tab, char cent, char misc_ctrl) | |
65 | { | |
66 | memset (string, x, NUM_CHARS); | |
67 | string[0] = alert; | |
68 | string[1] = backspace; | |
0dcd613f AC |
69 | string[2] = form_feed; |
70 | string[3] = line_feed; | |
71 | string[4] = carriage_return; | |
72 | string[5] = horizontal_tab; | |
73 | string[6] = vertical_tab; | |
74 | string[69] = cent; | |
75 | string[70] = misc_ctrl; | |
dea97812 KB |
76 | } |
77 | ||
78 | ||
79 | void | |
80 | fill_run (char string[], int start, int len, int first) | |
81 | { | |
82 | int i; | |
83 | ||
84 | for (i = 0; i < len; i++) | |
85 | string[start + i] = first + i; | |
86 | } | |
87 | ||
88 | ||
89 | int main () | |
90 | { | |
91 | #ifdef usestubs | |
92 | set_debug_traps(); | |
93 | breakpoint(); | |
94 | #endif | |
95 | (void) malloc (1); | |
96 | /* Initialize ascii_string. */ | |
97 | init_string (ascii_string, | |
98 | 120, | |
0dcd613f | 99 | 7, 8, 12, |
dea97812 KB |
100 | 10, 13, 9, |
101 | 11, 120, 17); | |
0dcd613f AC |
102 | fill_run (ascii_string, 7, 26, 65); |
103 | fill_run (ascii_string, 33, 26, 97); | |
104 | fill_run (ascii_string, 59, 10, 48); | |
dea97812 KB |
105 | |
106 | /* Initialize iso_8859_1_string. */ | |
107 | init_string (iso_8859_1_string, | |
108 | 120, | |
0dcd613f | 109 | 7, 8, 12, |
dea97812 KB |
110 | 10, 13, 9, |
111 | 11, 162, 17); | |
0dcd613f AC |
112 | fill_run (iso_8859_1_string, 7, 26, 65); |
113 | fill_run (iso_8859_1_string, 33, 26, 97); | |
114 | fill_run (iso_8859_1_string, 59, 10, 48); | |
dea97812 KB |
115 | |
116 | /* Initialize ebcdic_us_string. */ | |
117 | init_string (ebcdic_us_string, | |
118 | 167, | |
0dcd613f | 119 | 47, 22, 12, |
dea97812 KB |
120 | 37, 13, 5, |
121 | 11, 74, 17); | |
122 | /* In EBCDIC, the upper-case letters are broken into three separate runs. */ | |
0dcd613f AC |
123 | fill_run (ebcdic_us_string, 7, 9, 193); |
124 | fill_run (ebcdic_us_string, 16, 9, 209); | |
125 | fill_run (ebcdic_us_string, 25, 8, 226); | |
dea97812 | 126 | /* The lower-case letters are, too. */ |
0dcd613f AC |
127 | fill_run (ebcdic_us_string, 33, 9, 129); |
128 | fill_run (ebcdic_us_string, 42, 9, 145); | |
129 | fill_run (ebcdic_us_string, 51, 8, 162); | |
dea97812 | 130 | /* The digits, at least, are contiguous. */ |
0dcd613f | 131 | fill_run (ebcdic_us_string, 59, 10, 240); |
dea97812 KB |
132 | |
133 | /* Initialize ibm1047_string. */ | |
134 | init_string (ibm1047_string, | |
135 | 167, | |
0dcd613f | 136 | 47, 22, 12, |
dea97812 KB |
137 | 37, 13, 5, |
138 | 11, 74, 17); | |
139 | /* In EBCDIC, the upper-case letters are broken into three separate runs. */ | |
0dcd613f AC |
140 | fill_run (ibm1047_string, 7, 9, 193); |
141 | fill_run (ibm1047_string, 16, 9, 209); | |
142 | fill_run (ibm1047_string, 25, 8, 226); | |
dea97812 | 143 | /* The lower-case letters are, too. */ |
0dcd613f AC |
144 | fill_run (ibm1047_string, 33, 9, 129); |
145 | fill_run (ibm1047_string, 42, 9, 145); | |
146 | fill_run (ibm1047_string, 51, 8, 162); | |
dea97812 | 147 | /* The digits, at least, are contiguous. */ |
0dcd613f | 148 | fill_run (ibm1047_string, 59, 10, 240); |
dea97812 KB |
149 | |
150 | puts ("All set!"); /* all strings initialized */ | |
151 | } |