Skip to content

Commit ee584d1

Browse files
committed
Use typedef for function pointer in scanf
1 parent 7343e8e commit ee584d1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ext/standard/scanf.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ typedef struct CharSet {
106106
} *ranges;
107107
} CharSet;
108108

109+
typedef zend_long (*int_string_formater)(const char*, char**, int);
110+
109111
/*
110112
* Declarations for functions used only in this file.
111113
*/
@@ -583,7 +585,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
583585
int base = 0;
584586
int underflow = 0;
585587
size_t width;
586-
zend_long (*fn)(const char*, char**, int) = NULL;
588+
int_string_formater fn = NULL;
587589
char *ch, sch;
588590
int flags;
589591
char buf[64]; /* Temporary buffer to hold scanned number
@@ -740,29 +742,29 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
740742
case 'D':
741743
op = 'i';
742744
base = 10;
743-
fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR;
745+
fn = (int_string_formater)ZEND_STRTOL_PTR;
744746
break;
745747
case 'i':
746748
op = 'i';
747749
base = 0;
748-
fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR;
750+
fn = (int_string_formater)ZEND_STRTOL_PTR;
749751
break;
750752
case 'o':
751753
op = 'i';
752754
base = 8;
753-
fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR;
755+
fn = (int_string_formater)ZEND_STRTOL_PTR;
754756
break;
755757
case 'x':
756758
case 'X':
757759
op = 'i';
758760
base = 16;
759-
fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR;
761+
fn = (int_string_formater)ZEND_STRTOL_PTR;
760762
break;
761763
case 'u':
762764
op = 'i';
763765
base = 10;
764766
flags |= SCAN_UNSIGNED;
765-
fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOUL_PTR;
767+
fn = (int_string_formater)ZEND_STRTOUL_PTR;
766768
break;
767769

768770
case 'f':

0 commit comments

Comments
 (0)