1 |
24 |
jeremybenn |
/* This testcase is part of GDB, the GNU debugger.
|
2 |
|
|
|
3 |
|
|
Copyright 2001, 2004, 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>.
|
19 |
|
|
|
20 |
|
|
Please email any bugs, comments, and/or additions to this file to:
|
21 |
|
|
bug-gdb@gnu.org */
|
22 |
|
|
|
23 |
|
|
#include <stdio.h>
|
24 |
|
|
#include <stdlib.h>
|
25 |
|
|
#include <string.h>
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
/* X_string is a null-terminated string in the X charset whose
|
29 |
|
|
elements are as follows. X should be the name the `set charset'
|
30 |
|
|
command uses for the character set, in lower-case, with any
|
31 |
|
|
non-identifier characters replaced with underscores. Where a
|
32 |
|
|
character set doesn't have the given character, the string should
|
33 |
|
|
contain the character 'x'.
|
34 |
|
|
|
35 |
|
|
[0] --- the `alert' character, '\a'
|
36 |
|
|
[1] --- the `backspace' character, '\b'
|
37 |
|
|
[2] --- the `form feed' character, '\f'
|
38 |
|
|
[3] --- the `line feed' character, '\n'
|
39 |
|
|
[4] --- the `carriage return' character, '\r'
|
40 |
|
|
[5] --- the `horizontal tab' character, '\t'
|
41 |
|
|
[6] --- the `vertical tab' character, '\v'
|
42 |
|
|
[7 .. 32] --- the uppercase letters A-Z
|
43 |
|
|
[33 .. 58] --- the lowercase letters a-z
|
44 |
|
|
[59 .. 68] --- the digits 0-9
|
45 |
|
|
[69] --- the `cent' character
|
46 |
|
|
[70] --- a control character with no defined backslash escape
|
47 |
|
|
|
48 |
|
|
Feel free to extend these as you like. */
|
49 |
|
|
|
50 |
|
|
#define NUM_CHARS (71)
|
51 |
|
|
|
52 |
|
|
char ascii_string[NUM_CHARS];
|
53 |
|
|
char iso_8859_1_string[NUM_CHARS];
|
54 |
|
|
char ebcdic_us_string[NUM_CHARS];
|
55 |
|
|
char ibm1047_string[NUM_CHARS];
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
void
|
59 |
|
|
init_string (char string[],
|
60 |
|
|
char x,
|
61 |
|
|
char alert, char backspace, char form_feed,
|
62 |
|
|
char line_feed, char carriage_return, char horizontal_tab,
|
63 |
|
|
char vertical_tab, char cent, char misc_ctrl)
|
64 |
|
|
{
|
65 |
|
|
memset (string, x, NUM_CHARS);
|
66 |
|
|
string[0] = alert;
|
67 |
|
|
string[1] = backspace;
|
68 |
|
|
string[2] = form_feed;
|
69 |
|
|
string[3] = line_feed;
|
70 |
|
|
string[4] = carriage_return;
|
71 |
|
|
string[5] = horizontal_tab;
|
72 |
|
|
string[6] = vertical_tab;
|
73 |
|
|
string[69] = cent;
|
74 |
|
|
string[70] = misc_ctrl;
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
void
|
79 |
|
|
fill_run (char string[], int start, int len, int first)
|
80 |
|
|
{
|
81 |
|
|
int i;
|
82 |
|
|
|
83 |
|
|
for (i = 0; i < len; i++)
|
84 |
|
|
string[start + i] = first + i;
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
int main ()
|
89 |
|
|
{
|
90 |
|
|
#ifdef usestubs
|
91 |
|
|
set_debug_traps();
|
92 |
|
|
breakpoint();
|
93 |
|
|
#endif
|
94 |
|
|
(void) malloc (1);
|
95 |
|
|
/* Initialize ascii_string. */
|
96 |
|
|
init_string (ascii_string,
|
97 |
|
|
120,
|
98 |
|
|
7, 8, 12,
|
99 |
|
|
10, 13, 9,
|
100 |
|
|
11, 120, 17);
|
101 |
|
|
fill_run (ascii_string, 7, 26, 65);
|
102 |
|
|
fill_run (ascii_string, 33, 26, 97);
|
103 |
|
|
fill_run (ascii_string, 59, 10, 48);
|
104 |
|
|
|
105 |
|
|
/* Initialize iso_8859_1_string. */
|
106 |
|
|
init_string (iso_8859_1_string,
|
107 |
|
|
120,
|
108 |
|
|
7, 8, 12,
|
109 |
|
|
10, 13, 9,
|
110 |
|
|
11, 162, 17);
|
111 |
|
|
fill_run (iso_8859_1_string, 7, 26, 65);
|
112 |
|
|
fill_run (iso_8859_1_string, 33, 26, 97);
|
113 |
|
|
fill_run (iso_8859_1_string, 59, 10, 48);
|
114 |
|
|
|
115 |
|
|
/* Initialize ebcdic_us_string. */
|
116 |
|
|
init_string (ebcdic_us_string,
|
117 |
|
|
167,
|
118 |
|
|
47, 22, 12,
|
119 |
|
|
37, 13, 5,
|
120 |
|
|
11, 74, 17);
|
121 |
|
|
/* In EBCDIC, the upper-case letters are broken into three separate runs. */
|
122 |
|
|
fill_run (ebcdic_us_string, 7, 9, 193);
|
123 |
|
|
fill_run (ebcdic_us_string, 16, 9, 209);
|
124 |
|
|
fill_run (ebcdic_us_string, 25, 8, 226);
|
125 |
|
|
/* The lower-case letters are, too. */
|
126 |
|
|
fill_run (ebcdic_us_string, 33, 9, 129);
|
127 |
|
|
fill_run (ebcdic_us_string, 42, 9, 145);
|
128 |
|
|
fill_run (ebcdic_us_string, 51, 8, 162);
|
129 |
|
|
/* The digits, at least, are contiguous. */
|
130 |
|
|
fill_run (ebcdic_us_string, 59, 10, 240);
|
131 |
|
|
|
132 |
|
|
/* Initialize ibm1047_string. */
|
133 |
|
|
init_string (ibm1047_string,
|
134 |
|
|
167,
|
135 |
|
|
47, 22, 12,
|
136 |
|
|
37, 13, 5,
|
137 |
|
|
11, 74, 17);
|
138 |
|
|
/* In EBCDIC, the upper-case letters are broken into three separate runs. */
|
139 |
|
|
fill_run (ibm1047_string, 7, 9, 193);
|
140 |
|
|
fill_run (ibm1047_string, 16, 9, 209);
|
141 |
|
|
fill_run (ibm1047_string, 25, 8, 226);
|
142 |
|
|
/* The lower-case letters are, too. */
|
143 |
|
|
fill_run (ibm1047_string, 33, 9, 129);
|
144 |
|
|
fill_run (ibm1047_string, 42, 9, 145);
|
145 |
|
|
fill_run (ibm1047_string, 51, 8, 162);
|
146 |
|
|
/* The digits, at least, are contiguous. */
|
147 |
|
|
fill_run (ibm1047_string, 59, 10, 240);
|
148 |
|
|
|
149 |
|
|
puts ("All set!"); /* all strings initialized */
|
150 |
|
|
}
|