2626
2727PG_MODULE_MAGIC ;
2828
29+ #ifdef USE_ASSERT_CHECKING
30+ #define ISN_DEBUG 1
31+ #else
32+ #define ISN_DEBUG 0
33+ #endif
34+
2935#define MAXEAN13LEN 18
3036
3137enum isn_type
@@ -36,7 +42,6 @@ enum isn_type
3642static const char * const isn_names [] = {"EAN13/UPC/ISxN" , "EAN13/UPC/ISxN" , "EAN13" , "ISBN" , "ISMN" , "ISSN" , "UPC" };
3743
3844static bool g_weak = false;
39- static bool g_initialized = false;
4045
4146
4247/***********************************************************************
@@ -56,7 +61,7 @@ static bool g_initialized = false;
5661/*
5762 * Check if the table and its index is correct (just for debugging)
5863 */
59- #ifdef ISN_DEBUG
64+ pg_attribute_unused ()
6065static bool
6166check_table (const char * (* TABLE )[2 ], const unsigned TABLE_index [10 ][2 ])
6267{
@@ -68,7 +73,6 @@ check_table(const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
6873 y = -1 ,
6974 i = 0 ,
7075 j ,
71- cnt = 0 ,
7276 init = 0 ;
7377
7478 if (TABLE == NULL || TABLE_index == NULL )
@@ -131,7 +135,6 @@ check_table(const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
131135 elog (DEBUG1 , "index %d is invalid" , j );
132136 return false;
133137}
134- #endif /* ISN_DEBUG */
135138
136139/*----------------------------------------------------------
137140 * Formatting and conversion routines.
@@ -922,22 +925,24 @@ string2ean(const char *str, bool errorOK, ean13 *result,
922925 * Exported routines.
923926 *---------------------------------------------------------*/
924927
928+ void _PG_init (void );
929+
925930void
926- initialize (void )
931+ _PG_init (void )
927932{
928- #ifdef ISN_DEBUG
929- if (! check_table ( EAN13 , EAN13_index ))
930- elog ( LOG , "EAN13 failed check" );
931- if (! check_table ( ISBN , ISBN_index ))
932- elog ( LOG , "ISBN failed check" );
933- if (! check_table ( ISMN , ISMN_index ))
934- elog ( LOG , "ISMN failed check" );
935- if (! check_table ( ISSN , ISSN_index ))
936- elog ( LOG , "ISSN failed check" );
937- if (! check_table ( UPC , UPC_index ))
938- elog ( LOG , "UPC failed check" );
939- #endif
940- g_initialized = true;
933+ if ( ISN_DEBUG )
934+ {
935+ if (! check_table ( EAN13_range , EAN13_index ))
936+ elog ( ERROR , "EAN13 failed check" );
937+ if (! check_table ( ISBN_range , ISBN_index ))
938+ elog ( ERROR , "ISBN failed check" );
939+ if (! check_table ( ISMN_range , ISMN_index ))
940+ elog ( ERROR , "ISMN failed check" );
941+ if (! check_table ( ISSN_range , ISSN_index ))
942+ elog ( ERROR , "ISSN failed check" );
943+ if (! check_table ( UPC_range , UPC_index ))
944+ elog ( ERROR , "UPC failed check" );
945+ }
941946}
942947
943948/* isn_out
0 commit comments