Skip to content

Commit 1c5633c

Browse files
committed
fix indent
1 parent 6b2ecfd commit 1c5633c

File tree

3 files changed

+163
-163
lines changed

3 files changed

+163
-163
lines changed

core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void php_protocolbuffers_format_string(zval *result, pbf *payload TSRMLS_DC)
282282
char *p = 0;
283283
free = 1;
284284

285-
/* Note: this is safe */
285+
/* Note: this is safe */
286286
buffer = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
287287
size = zend_sprintf(buffer, "%f", payload->value.f);
288288

@@ -302,11 +302,11 @@ void php_protocolbuffers_format_string(zval *result, pbf *payload TSRMLS_DC)
302302
}
303303
break;
304304
}
305-
}
305+
}
306306
break;
307307
case TYPE_DOUBLE:{
308308
free = 1;
309-
/* Note: this is safe */
309+
/* Note: this is safe */
310310
buffer = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
311311
size = zend_sprintf(buffer, "%.*G", (int)EG(precision), payload->value.d);
312312
}
@@ -387,7 +387,7 @@ const char* php_protocolbuffers_decode_message(INTERNAL_FUNCTION_PARAMETERS, con
387387
break;
388388
case WIRETYPE_FIXED64:
389389
if (!php_protocolbuffers_process_fixed64(INTERNAL_FUNCTION_PARAM_PASSTHRU, wiretype, tag, container, s, data, hresult)) {
390-
return NULL;
390+
return NULL;
391391
}
392392
data += 8;
393393
break;

core_inl.h

Lines changed: 156 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -3,207 +3,207 @@
33

44
static inline int is_utf8(const char *s, int len)
55
{
6-
int i;
7-
const unsigned char *bytes = (const unsigned char *)s;
8-
9-
if (len < 1) {
10-
/* NOTE: always return 1 when passed string is null */
11-
return 1;
12-
}
13-
14-
for (i = 0; i < len; i++) {
15-
/* ASCII */
16-
if (bytes[0] == 0x09 ||
17-
bytes[0] == 0x0A ||
18-
bytes[0] == 0x0D ||
19-
(bytes[0] >= 0x20 && bytes[0] <= 0x7E)
20-
) {
21-
bytes += 1;
22-
continue;
23-
}
24-
25-
/* non-overlong 2-byte */
26-
if (((i+1) <= len) &&
27-
(bytes[0] >= 0xC2 && bytes[0] <= 0xDF) &&
28-
(bytes[1] >= 0x80 && bytes[1] <= 0xBF)) {
29-
bytes += 2;
30-
i+=1;
31-
continue;
32-
}
33-
34-
/* excluding overlongs */
35-
if (((i+2) <= len) &&
36-
bytes[0] == 0xE0 &&
37-
(bytes[1] >= 0xA0 && bytes[1] <= 0xBF) &&
38-
(bytes[2] >= 0x80 && bytes[2] <= 0xBF)
39-
) {
40-
bytes += 3;
41-
i+=2;
42-
continue;
43-
}
44-
45-
/* straight 3-byte */
46-
if (((i+2) <= len) &&
47-
((bytes[0] >= 0xE1 && bytes[0] <= 0xEC) ||
48-
bytes[0] == 0xEE ||
49-
bytes[0] == 0xEF) &&
50-
(bytes[1] >= 0x80 && bytes[1] <= 0xBF) &&
51-
(bytes[2] >= 0x80 && bytes[2] <= 0xBF)
52-
) {
53-
bytes += 3;
54-
i+=2;
55-
continue;
56-
}
57-
58-
/* excluding surrogates */
59-
if (((i+2) <= len) &&
60-
bytes[0] == 0xED &&
61-
(bytes[1] >= 0x80 && bytes[1] <= 0x9F) &&
62-
(bytes[2] >= 0x80 && bytes[2] <= 0xBF)
63-
) {
64-
bytes += 3;
65-
i+=2;
66-
continue;
67-
}
68-
69-
/* planes 1-3 */
70-
if (((i+3) <= len) &&
71-
bytes[0] == 0xF0 &&
72-
(bytes[1] >= 0x90 && bytes[1] <= 0xBF) &&
73-
(bytes[2] >= 0x80 && bytes[2] <= 0xBF) &&
74-
(bytes[3] >= 0x80 && bytes[3] <= 0xBF)
75-
) {
76-
bytes += 4;
77-
i+=3;
78-
continue;
79-
}
80-
81-
/* planes 4-15 */
82-
if (((i+3) <= len) &&
83-
bytes[0] >= 0xF1 && bytes[0] <= 0xF3 &&
84-
bytes[1] >= 0x80 && bytes[1] <= 0xBF &&
85-
bytes[2] >= 0x80 && bytes[2] <= 0xBF &&
86-
bytes[3] >= 0x80 && bytes[3] <= 0xBF
87-
) {
88-
bytes += 4;
89-
i+=3;
90-
continue;
91-
}
92-
93-
/* plane 16 */
94-
if (((i+3) <= len) &&
95-
bytes[0] == 0xF4 &&
96-
(bytes[1] >= 0x80 && bytes[1] <= 0x8F) &&
97-
(bytes[2] >= 0x80 && bytes[2] <= 0xBF) &&
98-
(bytes[3] >= 0x80 && bytes[3] <= 0xBF)
99-
) {
100-
bytes += 4;
101-
i+=3;
102-
continue;
103-
}
104-
105-
return 0;
106-
}
107-
108-
return 1;
6+
int i;
7+
const unsigned char *bytes = (const unsigned char *)s;
8+
9+
if (len < 1) {
10+
/* NOTE: always return 1 when passed string is null */
11+
return 1;
12+
}
13+
14+
for (i = 0; i < len; i++) {
15+
/* ASCII */
16+
if (bytes[0] == 0x09 ||
17+
bytes[0] == 0x0A ||
18+
bytes[0] == 0x0D ||
19+
(bytes[0] >= 0x20 && bytes[0] <= 0x7E)
20+
) {
21+
bytes += 1;
22+
continue;
23+
}
24+
25+
/* non-overlong 2-byte */
26+
if (((i+1) <= len) &&
27+
(bytes[0] >= 0xC2 && bytes[0] <= 0xDF) &&
28+
(bytes[1] >= 0x80 && bytes[1] <= 0xBF)) {
29+
bytes += 2;
30+
i+=1;
31+
continue;
32+
}
33+
34+
/* excluding overlongs */
35+
if (((i+2) <= len) &&
36+
bytes[0] == 0xE0 &&
37+
(bytes[1] >= 0xA0 && bytes[1] <= 0xBF) &&
38+
(bytes[2] >= 0x80 && bytes[2] <= 0xBF)
39+
) {
40+
bytes += 3;
41+
i+=2;
42+
continue;
43+
}
44+
45+
/* straight 3-byte */
46+
if (((i+2) <= len) &&
47+
((bytes[0] >= 0xE1 && bytes[0] <= 0xEC) ||
48+
bytes[0] == 0xEE ||
49+
bytes[0] == 0xEF) &&
50+
(bytes[1] >= 0x80 && bytes[1] <= 0xBF) &&
51+
(bytes[2] >= 0x80 && bytes[2] <= 0xBF)
52+
) {
53+
bytes += 3;
54+
i+=2;
55+
continue;
56+
}
57+
58+
/* excluding surrogates */
59+
if (((i+2) <= len) &&
60+
bytes[0] == 0xED &&
61+
(bytes[1] >= 0x80 && bytes[1] <= 0x9F) &&
62+
(bytes[2] >= 0x80 && bytes[2] <= 0xBF)
63+
) {
64+
bytes += 3;
65+
i+=2;
66+
continue;
67+
}
68+
69+
/* planes 1-3 */
70+
if (((i+3) <= len) &&
71+
bytes[0] == 0xF0 &&
72+
(bytes[1] >= 0x90 && bytes[1] <= 0xBF) &&
73+
(bytes[2] >= 0x80 && bytes[2] <= 0xBF) &&
74+
(bytes[3] >= 0x80 && bytes[3] <= 0xBF)
75+
) {
76+
bytes += 4;
77+
i+=3;
78+
continue;
79+
}
80+
81+
/* planes 4-15 */
82+
if (((i+3) <= len) &&
83+
bytes[0] >= 0xF1 && bytes[0] <= 0xF3 &&
84+
bytes[1] >= 0x80 && bytes[1] <= 0xBF &&
85+
bytes[2] >= 0x80 && bytes[2] <= 0xBF &&
86+
bytes[3] >= 0x80 && bytes[3] <= 0xBF
87+
) {
88+
bytes += 4;
89+
i+=3;
90+
continue;
91+
}
92+
93+
/* plane 16 */
94+
if (((i+3) <= len) &&
95+
bytes[0] == 0xF4 &&
96+
(bytes[1] >= 0x80 && bytes[1] <= 0x8F) &&
97+
(bytes[2] >= 0x80 && bytes[2] <= 0xBF) &&
98+
(bytes[3] >= 0x80 && bytes[3] <= 0xBF)
99+
) {
100+
bytes += 4;
101+
i+=3;
102+
continue;
103+
}
104+
105+
return 0;
106+
}
107+
108+
return 1;
109109
}
110110

111111

112112
static inline uint32_t zigzag_encode32(int32_t n) {
113-
// Note: the right-shift must be arithmetic
114-
return (n << 1) ^ (n >> 31);
113+
// Note: the right-shift must be arithmetic
114+
return (n << 1) ^ (n >> 31);
115115
}
116116

117117
static inline int32_t zigzag_decode32(uint32_t n) {
118-
return (n >> 1) ^ - (int32_t)(n & 1);
118+
return (n >> 1) ^ - (int32_t)(n & 1);
119119
}
120120

121121
static inline uint64_t zigzag_encode64(int64_t n) {
122-
// Note: the right-shift must be arithmetic
123-
return (n << 1) ^ (n >> 63);
122+
// Note: the right-shift must be arithmetic
123+
return (n << 1) ^ (n >> 63);
124124
}
125125

126126
static inline int64_t zigzag_decode64(uint64_t n) {
127-
return (n >> 1) ^ - (int64_t)(n & 1);
127+
return (n >> 1) ^ - (int64_t)(n & 1);
128128
}
129129

130130
static inline uint64_t encode_double(double value) {
131-
union {
132-
double d;
133-
uint64_t v;
134-
} u;
135-
u.d = value;
131+
union {
132+
double d;
133+
uint64_t v;
134+
} u;
135+
u.d = value;
136136

137-
return u.v;
137+
return u.v;
138138
}
139139

140140
static inline double decode_double(uint64_t value) {
141-
union {
142-
double d;
143-
uint64_t v;
144-
} u;
145-
u.v = value;
141+
union {
142+
double d;
143+
uint64_t v;
144+
} u;
145+
u.v = value;
146146

147-
return u.d;
147+
return u.d;
148148
}
149149

150150
static inline uint32_t encode_float(float value) {
151-
union {
152-
float f;
153-
uint32_t v;
154-
} u;
155-
u.f = value;
151+
union {
152+
float f;
153+
uint32_t v;
154+
} u;
155+
u.f = value;
156156

157-
return u.v;
157+
return u.v;
158158
}
159159

160160
static inline float decode_float(int32_t value) {
161-
union {
162-
float f;
163-
uint32_t v;
164-
} u;
165-
u.v = value;
161+
union {
162+
float f;
163+
uint32_t v;
164+
} u;
165+
u.v = value;
166166

167-
return u.f;
167+
return u.f;
168168
}
169169

170170
static inline int php_protocolbuffers_get_lval_from_hash_by_tag(HashTable *proto, ulong tag, const char *name, size_t name_len TSRMLS_DC)
171171
{
172-
zval **d, **dd;
172+
zval **d, **dd;
173173

174-
if (zend_hash_index_find(proto, tag, (void **)&d) != SUCCESS) {
175-
return 0;
176-
}
174+
if (zend_hash_index_find(proto, tag, (void **)&d) != SUCCESS) {
175+
return 0;
176+
}
177177

178-
if (Z_TYPE_PP(d) != IS_ARRAY) {
179-
return 0;
180-
}
178+
if (Z_TYPE_PP(d) != IS_ARRAY) {
179+
return 0;
180+
}
181181

182-
if (zend_hash_find(Z_ARRVAL_PP(d), (char*)name, name_len, (void **)&dd) == SUCCESS) {
183-
return Z_LVAL_PP(dd);
184-
}
182+
if (zend_hash_find(Z_ARRVAL_PP(d), (char*)name, name_len, (void **)&dd) == SUCCESS) {
183+
return Z_LVAL_PP(dd);
184+
}
185185

186-
return 0;
186+
return 0;
187187
}
188188

189189
static inline int php_protocolbuffers_get_zval_from_hash_by_tag(HashTable *proto, ulong tag, const char *name, size_t name_len, zval **result TSRMLS_DC)
190190
{
191-
zval **d, **dd;
191+
zval **d, **dd;
192192

193-
if (zend_hash_index_find(proto, tag, (void **)&d) != SUCCESS) {
194-
return 0;
195-
}
193+
if (zend_hash_index_find(proto, tag, (void **)&d) != SUCCESS) {
194+
return 0;
195+
}
196196

197-
if (Z_TYPE_PP(d) != IS_ARRAY) {
198-
return 0;
199-
}
197+
if (Z_TYPE_PP(d) != IS_ARRAY) {
198+
return 0;
199+
}
200200

201-
if (zend_hash_find(Z_ARRVAL_PP(d), (char*)name, name_len, (void **)&dd) == SUCCESS) {
202-
*result = *dd;
203-
return 1;
204-
}
201+
if (zend_hash_find(Z_ARRVAL_PP(d), (char*)name, name_len, (void **)&dd) == SUCCESS) {
202+
*result = *dd;
203+
return 1;
204+
}
205205

206-
return 0;
206+
return 0;
207207
}
208208

209209
static inline const char* ReadVarint32FromArray(const char* buffer, uint* value, const char* buffer_end) {

0 commit comments

Comments
 (0)