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