Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit558a6e8

Browse files
committed
revert removal of hex_decode() from ecpg from commitc3826f8
ecpglib on certain platforms can't handle the pg_log_fatal calls fromlibraries. This was reported by the buildfarm. It needs a refactoringand return value change if it is later removed.Backpatch-through: master
1 parentc3826f8 commit558a6e8

File tree

1 file changed

+51
-1
lines changed
  • src/interfaces/ecpg/ecpglib

1 file changed

+51
-1
lines changed

‎src/interfaces/ecpg/ecpglib/data.c

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include<math.h>
77

8-
#include"common/hex_decode.h"
98
#include"ecpgerrno.h"
109
#include"ecpglib.h"
1110
#include"ecpglib_extern.h"
@@ -137,6 +136,57 @@ ecpg_hex_dec_len(unsigned srclen)
137136
returnsrclen >>1;
138137
}
139138

139+
staticinlinechar
140+
get_hex(charc)
141+
{
142+
staticconstint8hexlookup[128]= {
143+
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
144+
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
145+
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
146+
0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,
147+
-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
148+
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
149+
-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
150+
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
151+
};
152+
intres=-1;
153+
154+
if (c>0&&c<127)
155+
res=hexlookup[(unsignedchar)c];
156+
157+
return (char)res;
158+
}
159+
160+
staticunsigned
161+
hex_decode(constchar*src,unsignedlen,char*dst)
162+
{
163+
constchar*s,
164+
*srcend;
165+
charv1,
166+
v2,
167+
*p;
168+
169+
srcend=src+len;
170+
s=src;
171+
p=dst;
172+
while (s<srcend)
173+
{
174+
if (*s==' '||*s=='\n'||*s=='\t'||*s=='\r')
175+
{
176+
s++;
177+
continue;
178+
}
179+
v1=get_hex(*s++) <<4;
180+
if (s >=srcend)
181+
return-1;
182+
183+
v2=get_hex(*s++);
184+
*p++=v1 |v2;
185+
}
186+
187+
returnp-dst;
188+
}
189+
140190
unsigned
141191
ecpg_hex_encode(constchar*src,unsignedlen,char*dst)
142192
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp