35
35
#define lobits (addr ) \
36
36
((unsigned long)(((addr)->e<<24) | ((addr)->f<<16) | ((addr)->g<<8) | ((addr)->h)))
37
37
38
- static unsigned char hex2_to_uchar (const char * str , const char * ptr );
38
+ static unsigned char hex2_to_uchar (const unsigned char * str , const unsigned char * ptr );
39
39
40
- static const char hexlookup [128 ] = {
40
+ static const signed char hexlookup [128 ] = {
41
41
-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
42
42
-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
43
43
-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
@@ -58,16 +58,16 @@ static const char hexlookup[128] = {
58
58
* the entire string, which is used only for error reporting.
59
59
*/
60
60
static inline unsigned char
61
- hex2_to_uchar (const char * ptr , const char * str )
61
+ hex2_to_uchar (const unsigned char * ptr , const unsigned char * str )
62
62
{
63
63
unsigned char ret = 0 ;
64
- char lookup ;
64
+ signed char lookup ;
65
65
66
66
/* Handle the first character */
67
- if (* ptr < 0 )
67
+ if (* ptr > 127 )
68
68
goto invalid_input ;
69
69
70
- lookup = hexlookup [( unsigned char ) * ptr ];
70
+ lookup = hexlookup [* ptr ];
71
71
if (lookup < 0 )
72
72
goto invalid_input ;
73
73
@@ -76,10 +76,10 @@ hex2_to_uchar(const char *ptr, const char *str)
76
76
/* Move to the second character */
77
77
ptr ++ ;
78
78
79
- if (* ptr < 0 )
79
+ if (* ptr > 127 )
80
80
goto invalid_input ;
81
81
82
- lookup = hexlookup [( unsigned char ) * ptr ];
82
+ lookup = hexlookup [* ptr ];
83
83
if (lookup < 0 )
84
84
goto invalid_input ;
85
85
@@ -103,8 +103,8 @@ hex2_to_uchar(const char *ptr, const char *str)
103
103
Datum
104
104
macaddr8_in (PG_FUNCTION_ARGS )
105
105
{
106
- const char * str = PG_GETARG_CSTRING (0 );
107
- const char * ptr = str ;
106
+ const unsigned char * str = ( unsigned char * ) PG_GETARG_CSTRING (0 );
107
+ const unsigned char * ptr = str ;
108
108
macaddr8 * result ;
109
109
unsigned char a = 0 ,
110
110
b = 0 ,
@@ -115,10 +115,10 @@ macaddr8_in(PG_FUNCTION_ARGS)
115
115
g = 0 ,
116
116
h = 0 ;
117
117
int count = 0 ;
118
- char spacer = '\0' ;
118
+ unsigned char spacer = '\0' ;
119
119
120
120
/* skip leading spaces */
121
- while (* ptr && isspace (( unsigned char ) * ptr ))
121
+ while (* ptr && isspace (* ptr ))
122
122
ptr ++ ;
123
123
124
124
/* digits must always come in pairs */
@@ -191,9 +191,9 @@ macaddr8_in(PG_FUNCTION_ARGS)
191
191
/* allow trailing whitespace after if we have 6 or 8 bytes */
192
192
if (count == 6 || count == 8 )
193
193
{
194
- if (isspace (( unsigned char ) * ptr ))
194
+ if (isspace (* ptr ))
195
195
{
196
- while (* ++ ptr && isspace (( unsigned char ) * ptr ));
196
+ while (* ++ ptr && isspace (* ptr ));
197
197
198
198
/* If we found a space and then non-space, it's invalid */
199
199
if (* ptr )
0 commit comments