Skip to content

Commit 8ae9922

Browse files
committed
Boolify _php_pgsql_detect_identifier_escape() and rename it
New name is _php_pgsql_identifier_is_escaped()
1 parent 7a1af52 commit 8ae9922

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ext/pgsql/pgsql.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,11 @@ static void _free_result(zend_resource *rsrc)
278278
}
279279
/* }}} */
280280

281-
static int _php_pgsql_detect_identifier_escape(const char *identifier, size_t len) /* {{{ */
281+
static bool _php_pgsql_identifier_is_escaped(const char *identifier, size_t len) /* {{{ */
282282
{
283283
/* Handle edge case. Cannot be a escaped string */
284284
if (len <= 2) {
285-
return FAILURE;
285+
return false;
286286
}
287287
/* Detect double quotes */
288288
if (identifier[0] == '"' && identifier[len-1] == '"') {
@@ -291,14 +291,14 @@ static int _php_pgsql_detect_identifier_escape(const char *identifier, size_t le
291291
/* Detect wrong format of " inside of escaped string */
292292
for (i = 1; i < len-1; i++) {
293293
if (identifier[i] == '"' && (identifier[++i] != '"' || i == len-1)) {
294-
return FAILURE;
294+
return false;
295295
}
296296
}
297297
} else {
298-
return FAILURE;
298+
return false;
299299
}
300300
/* Escaped properly */
301-
return SUCCESS;
301+
return true;
302302
}
303303
/* }}} */
304304

@@ -5201,7 +5201,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
52015201
}
52025202
/* If field is NULL and HAS DEFAULT, should be skipped */
52035203
if (!skip_field) {
5204-
if (_php_pgsql_detect_identifier_escape(ZSTR_VAL(field), ZSTR_LEN(field)) == SUCCESS) {
5204+
if (_php_pgsql_identifier_is_escaped(ZSTR_VAL(field), ZSTR_LEN(field))) {
52055205
zend_hash_update(Z_ARRVAL_P(result), field, &new_val);
52065206
} else {
52075207
char *escaped = PQescapeIdentifier(pg_link, ZSTR_VAL(field), ZSTR_LEN(field));
@@ -5292,7 +5292,7 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
52925292
/* schema.table should be "schema"."table" */
52935293
const char *dot = memchr(table, '.', table_len);
52945294
size_t len = dot ? dot - table : table_len;
5295-
if (_php_pgsql_detect_identifier_escape(table, len) == SUCCESS) {
5295+
if (_php_pgsql_identifier_is_escaped(table, len)) {
52965296
smart_str_appendl(querystr, table, len);
52975297
} else {
52985298
char *escaped = PQescapeIdentifier(pg_link, table, len);
@@ -5303,7 +5303,7 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
53035303
const char *after_dot = dot + 1;
53045304
len = table_len - len - 1;
53055305
/* "schema"."table" format */
5306-
if (_php_pgsql_detect_identifier_escape(after_dot, len) == SUCCESS) {
5306+
if (_php_pgsql_identifier_is_escaped(after_dot, len)) {
53075307
smart_str_appendc(querystr, '.');
53085308
smart_str_appendl(querystr, after_dot, len);
53095309
} else {

0 commit comments

Comments
 (0)