26
26
27
27
PG_MODULE_MAGIC ;
28
28
29
+ #ifdef USE_ASSERT_CHECKING
30
+ #define ISN_DEBUG 1
31
+ #else
32
+ #define ISN_DEBUG 0
33
+ #endif
34
+
29
35
#define MAXEAN13LEN 18
30
36
31
37
enum isn_type
@@ -36,7 +42,6 @@ enum isn_type
36
42
static const char * const isn_names [] = {"EAN13/UPC/ISxN" , "EAN13/UPC/ISxN" , "EAN13" , "ISBN" , "ISMN" , "ISSN" , "UPC" };
37
43
38
44
static bool g_weak = false;
39
- static bool g_initialized = false;
40
45
41
46
42
47
/***********************************************************************
@@ -56,7 +61,7 @@ static bool g_initialized = false;
56
61
/*
57
62
* Check if the table and its index is correct (just for debugging)
58
63
*/
59
- #ifdef ISN_DEBUG
64
+ pg_attribute_unused ()
60
65
static bool
61
66
check_table (const char * (* TABLE )[2 ], const unsigned TABLE_index [10 ][2 ])
62
67
{
@@ -68,7 +73,6 @@ check_table(const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
68
73
y = -1 ,
69
74
i = 0 ,
70
75
j ,
71
- cnt = 0 ,
72
76
init = 0 ;
73
77
74
78
if (TABLE == NULL || TABLE_index == NULL )
@@ -131,7 +135,6 @@ check_table(const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
131
135
elog (DEBUG1 , "index %d is invalid" , j );
132
136
return false;
133
137
}
134
- #endif /* ISN_DEBUG */
135
138
136
139
/*----------------------------------------------------------
137
140
* Formatting and conversion routines.
@@ -922,22 +925,24 @@ string2ean(const char *str, bool errorOK, ean13 *result,
922
925
* Exported routines.
923
926
*---------------------------------------------------------*/
924
927
928
+ void _PG_init (void );
929
+
925
930
void
926
- initialize (void )
931
+ _PG_init (void )
927
932
{
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
+ }
941
946
}
942
947
943
948
/* isn_out
0 commit comments