22 * Encoding names and routines for work with it. All
33 * in this file is shared bedween FE and BE.
44 *
5- * $Id: encnames.c,v 1.1 2001/09/0703:32:11 ishii Exp $
5+ * $Id: encnames.c,v 1.2 2001/09/0715:01:45 momjian Exp $
66 */
77#ifdef FRONTEND
88#include "postgres_fe.h"
2222#include "mb/pg_wchar.h"
2323#include <ctype.h>
2424
25- /*
26- * Debug
27- */
28- /* #define DEBUG_ENCODING */
29- #ifdef DEBUG_ENCODING
30- #ifdef FRONTEND
31- #define encdebug (_format ,_a ...)fprintf(stderr, _format, ##_a)
32- #else
33- #define encdebug (_format ,_a ...)elog(NOTICE, _format, ##_a)
34- #endif
35- #else
36- #define encdebug (_format ,_a ...)
37- #endif
38-
3925/* ----------
40- * All encoding names, sorted: *** A L P H A B E T I C ***
26+ * All encoding names, sorted: *** A L P H A B E T I C ***
4127 *
4228 * All names must be without irrelevan chars, search routines use
4329 * isalnum() chars only. It means ISO-8859-1, iso_8859-1 and Iso8859_1
4430 * are always converted to 'iso88591'. All must be lower case.
4531 *
46- * The table doesn't contain 'cs' aliases (like csISOLatin1). It's needful?
32+ * The table doesn't contain 'cs' aliases (like csISOLatin1). It's needful?
4733 *
4834 * Karel Zak, Aug 2001
4935 * ----------
50- */
36+ */
5137pg_encname pg_encname_tbl []=
5238{
5339{"alt" ,PG_ALT },/* IBM866 */
5440{"big5" ,PG_BIG5 },/* Big5; Chinese for Taiwan Multi-byte set */
55- {"euccn" ,PG_EUC_CN },/* EUC-CN; ??? */
41+ {"euccn" ,PG_EUC_CN },/* EUC-CN; ??? */
5642{"eucjp" ,PG_EUC_JP },/* EUC-JP; Extended UNIX Code Fixed Width for Japanese, stdandard OSF */
5743{"euckr" ,PG_EUC_KR },/* EUC-KR; RFC1557,Choi */
5844{"euctw" ,PG_EUC_TW },/* EUC-TW; ??? */
@@ -88,7 +74,7 @@ unsigned int pg_encname_tbl_sz = \
8874sizeof (pg_encname_tbl ) /sizeof (pg_encname_tbl [0 ])- 1 ;
8975
9076/* ----------
91- * WARNING: sorted by pg_enc enum (pg_wchar.h)!
77+ * WARNING: sorted by pg_enc enum (pg_wchar.h)!
9278 * ----------
9379 */
9480pg_enc2name pg_enc2name_tbl []=
@@ -179,7 +165,7 @@ pg_char_to_encname_struct(const char *name)
179165* key ;
180166
181167if (name == NULL || * name == '\0' )
182- return NULL ;
168+ return NULL ;
183169
184170if (strlen (name )> NAMEDATALEN )
185171{
@@ -192,13 +178,11 @@ pg_char_to_encname_struct(const char *name)
192178}
193179key = clean_encoding_name ((char * )name ,buff );
194180
195- encdebug ("Name: %s" ,key );
196-
197181while (last >=base )
198- {
182+ {
199183position = base + ((last - base ) >>1 );
200184result = key [0 ]- position -> name [0 ];
201-
185+
202186if (result == 0 )
203187{
204188result = strcmp (key ,position -> name );
@@ -210,8 +194,6 @@ pg_char_to_encname_struct(const char *name)
210194else
211195base = position + 1 ;
212196}
213-
214- encdebug ("UNKNOWN! encoding" );
215197return NULL ;
216198}
217199
@@ -244,7 +226,7 @@ pg_encoding_to_char(int encoding)
244226{
245227if (PG_VALID_ENCODING (encoding ))
246228{
247- pg_enc2name * p = & pg_enc2name_tbl [encoding ];
229+ pg_enc2name * p = & pg_enc2name_tbl [encoding ];
248230Assert (encoding == p -> encoding );
249231return p -> name ;
250232}