]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/utypes.c
ICU-6.2.22.tar.gz
[apple/icu.git] / icuSources / common / utypes.c
1 /*
2 ******************************************************************************
3 *
4 * Copyright (C) 1997-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 ******************************************************************************
8 *
9 * FILE NAME : utypes.c (previously putil.c)
10 *
11 * Date Name Description
12 * 10/07/2004 grhoten split from putil.c
13 ******************************************************************************
14 */
15
16 #include "unicode/utypes.h"
17
18 /* u_errorName() ------------------------------------------------------------ */
19
20 static const char * const
21 _uErrorInfoName[U_ERROR_WARNING_LIMIT-U_ERROR_WARNING_START]={
22 "U_USING_FALLBACK_WARNING",
23 "U_USING_DEFAULT_WARNING",
24 "U_SAFECLONE_ALLOCATED_WARNING",
25 "U_STATE_OLD_WARNING",
26 "U_STRING_NOT_TERMINATED_WARNING",
27 "U_SORT_KEY_TOO_SHORT_WARNING",
28 "U_AMBIGUOUS_ALIAS_WARNING",
29 "U_DIFFERENT_UCA_VERSION"
30 };
31
32 static const char * const
33 _uTransErrorName[U_PARSE_ERROR_LIMIT - U_PARSE_ERROR_START]={
34 "U_BAD_VARIABLE_DEFINITION",
35 "U_MALFORMED_RULE",
36 "U_MALFORMED_SET",
37 "U_MALFORMED_SYMBOL_REFERENCE",
38 "U_MALFORMED_UNICODE_ESCAPE",
39 "U_MALFORMED_VARIABLE_DEFINITION",
40 "U_MALFORMED_VARIABLE_REFERENCE",
41 "U_MISMATCHED_SEGMENT_DELIMITERS",
42 "U_MISPLACED_ANCHOR_START",
43 "U_MISPLACED_CURSOR_OFFSET",
44 "U_MISPLACED_QUANTIFIER",
45 "U_MISSING_OPERATOR",
46 "U_MISSING_SEGMENT_CLOSE",
47 "U_MULTIPLE_ANTE_CONTEXTS",
48 "U_MULTIPLE_CURSORS",
49 "U_MULTIPLE_POST_CONTEXTS",
50 "U_TRAILING_BACKSLASH",
51 "U_UNDEFINED_SEGMENT_REFERENCE",
52 "U_UNDEFINED_VARIABLE",
53 "U_UNQUOTED_SPECIAL",
54 "U_UNTERMINATED_QUOTE",
55 "U_RULE_MASK_ERROR",
56 "U_MISPLACED_COMPOUND_FILTER",
57 "U_MULTIPLE_COMPOUND_FILTERS",
58 "U_INVALID_RBT_SYNTAX",
59 "U_INVALID_PROPERTY_PATTERN",
60 "U_MALFORMED_PRAGMA",
61 "U_UNCLOSED_SEGMENT",
62 "U_ILLEGAL_CHAR_IN_SEGMENT",
63 "U_VARIABLE_RANGE_EXHAUSTED",
64 "U_VARIABLE_RANGE_OVERLAP",
65 "U_ILLEGAL_CHARACTER",
66 "U_INTERNAL_TRANSLITERATOR_ERROR",
67 "U_INVALID_ID",
68 "U_INVALID_FUNCTION"
69 };
70
71 static const char * const
72 _uErrorName[U_STANDARD_ERROR_LIMIT]={
73 "U_ZERO_ERROR",
74
75 "U_ILLEGAL_ARGUMENT_ERROR",
76 "U_MISSING_RESOURCE_ERROR",
77 "U_INVALID_FORMAT_ERROR",
78 "U_FILE_ACCESS_ERROR",
79 "U_INTERNAL_PROGRAM_ERROR",
80 "U_MESSAGE_PARSE_ERROR",
81 "U_MEMORY_ALLOCATION_ERROR",
82 "U_INDEX_OUTOFBOUNDS_ERROR",
83 "U_PARSE_ERROR",
84 "U_INVALID_CHAR_FOUND",
85 "U_TRUNCATED_CHAR_FOUND",
86 "U_ILLEGAL_CHAR_FOUND",
87 "U_INVALID_TABLE_FORMAT",
88 "U_INVALID_TABLE_FILE",
89 "U_BUFFER_OVERFLOW_ERROR",
90 "U_UNSUPPORTED_ERROR",
91 "U_RESOURCE_TYPE_MISMATCH",
92 "U_ILLEGAL_ESCAPE_SEQUENCE",
93 "U_UNSUPPORTED_ESCAPE_SEQUENCE",
94 "U_NO_SPACE_AVAILABLE",
95 "U_CE_NOT_FOUND_ERROR",
96 "U_PRIMARY_TOO_LONG_ERROR",
97 "U_STATE_TOO_OLD_ERROR",
98 "U_TOO_MANY_ALIASES_ERROR",
99 "U_ENUM_OUT_OF_SYNC_ERROR",
100 "U_INVARIANT_CONVERSION_ERROR",
101 "U_INVALID_STATE_ERROR",
102 "U_COLLATOR_VERSION_MISMATCH",
103 "U_USELESS_COLLATOR_ERROR"
104 };
105 static const char * const
106 _uFmtErrorName[U_FMT_PARSE_ERROR_LIMIT - U_FMT_PARSE_ERROR_START] = {
107 "U_UNEXPECTED_TOKEN",
108 "U_MULTIPLE_DECIMAL_SEPARATORS",
109 "U_MULTIPLE_EXPONENTIAL_SYMBOLS",
110 "U_MALFORMED_EXPONENTIAL_PATTERN",
111 "U_MULTIPLE_PERCENT_SYMBOLS",
112 "U_MULTIPLE_PERMILL_SYMBOLS",
113 "U_MULTIPLE_PAD_SPECIFIERS",
114 "U_PATTERN_SYNTAX_ERROR",
115 "U_ILLEGAL_PAD_POSITION",
116 "U_UNMATCHED_BRACES",
117 "U_UNSUPPORTED_PROPERTY",
118 "U_UNSUPPORTED_ATTRIBUTE"
119 };
120
121 static const char * const
122 _uBrkErrorName[U_BRK_ERROR_LIMIT - U_BRK_ERROR_START] = {
123 "U_BRK_ERROR_START",
124 "U_BRK_INTERNAL_ERROR",
125 "U_BRK_HEX_DIGITS_EXPECTED",
126 "U_BRK_SEMICOLON_EXPECTED",
127 "U_BRK_RULE_SYNTAX",
128 "U_BRK_UNCLOSED_SET",
129 "U_BRK_ASSIGN_ERROR",
130 "U_BRK_VARIABLE_REDFINITION",
131 "U_BRK_MISMATCHED_PAREN",
132 "U_BRK_NEW_LINE_IN_QUOTED_STRING",
133 "U_BRK_UNDEFINED_VARIABLE",
134 "U_BRK_INIT_ERROR",
135 "U_BRK_RULE_EMPTY_SET",
136 "U_BRK_UNRECOGNIZED_OPTION",
137 "U_BRK_MALFORMED_RULE_TAG"
138 };
139
140 static const char * const
141 _uRegexErrorName[U_REGEX_ERROR_LIMIT - U_REGEX_ERROR_START] = {
142 "U_REGEX_ERROR_START",
143 "U_REGEX_INTERNAL_ERROR",
144 "U_REGEX_RULE_SYNTAX",
145 "U_REGEX_INVALID_STATE",
146 "U_REGEX_BAD_ESCAPE_SEQUENCE",
147 "U_REGEX_PROPERTY_SYNTAX",
148 "U_REGEX_UNIMPLEMENTED",
149 "U_REGEX_MISMATCHED_PAREN",
150 "U_REGEX_NUMBER_TOO_BIG",
151 "U_REGEX_BAD_INTERVAL",
152 "U_REGEX_MAX_LT_MIN",
153 "U_REGEX_INVALID_BACK_REF",
154 "U_REGEX_INVALID_FLAG",
155 "U_REGEX_LOOK_BEHIND_LIMIT",
156 "U_REGEX_SET_CONTAINS_STRING"
157 };
158
159 static const char * const
160 _uIDNAErrorName[U_IDNA_ERROR_LIMIT - U_IDNA_ERROR_START] = {
161 "U_IDNA_ERROR_START",
162 "U_IDNA_PROHIBITED_ERROR",
163 "U_IDNA_UNASSIGNED_ERROR",
164 "U_IDNA_CHECK_BIDI_ERROR",
165 "U_IDNA_STD3_ASCII_RULES_ERROR",
166 "U_IDNA_ACE_PREFIX_ERROR",
167 "U_IDNA_VERIFICATION_ERROR",
168 "U_IDNA_LABEL_TOO_LONG_ERROR"
169 };
170
171 U_CAPI const char * U_EXPORT2
172 u_errorName(UErrorCode code) {
173 if(U_ZERO_ERROR <= code && code < U_STANDARD_ERROR_LIMIT) {
174 return _uErrorName[code];
175 } else if(U_ERROR_WARNING_START <= code && code < U_ERROR_WARNING_LIMIT) {
176 return _uErrorInfoName[code - U_ERROR_WARNING_START];
177 } else if(U_PARSE_ERROR_START <= code && code < U_PARSE_ERROR_LIMIT){
178 return _uTransErrorName[code - U_PARSE_ERROR_START];
179 } else if(U_FMT_PARSE_ERROR_START <= code && code < U_FMT_PARSE_ERROR_LIMIT){
180 return _uFmtErrorName[code - U_FMT_PARSE_ERROR_START];
181 } else if (U_BRK_ERROR_START <= code && code < U_BRK_ERROR_LIMIT){
182 return _uBrkErrorName[code - U_BRK_ERROR_START];
183 } else if (U_REGEX_ERROR_START <= code && code < U_REGEX_ERROR_LIMIT) {
184 return _uRegexErrorName[code - U_REGEX_ERROR_START];
185 } else if( U_IDNA_ERROR_START <= code && code <= U_IDNA_ERROR_LIMIT) {
186 return _uIDNAErrorName[code - U_IDNA_ERROR_START];
187 } else {
188 return "[BOGUS UErrorCode]";
189 }
190 }
191
192 /*
193 * Hey, Emacs, please set the following:
194 *
195 * Local Variables:
196 * indent-tabs-mode: nil
197 * End:
198 *
199 */