@@ -730,7 +730,7 @@ void phar_parse_metadata_lazy(const char *buffer, phar_metadata_tracker *tracker
730
730
* This is used by phar_open_from_filename to process the manifest, but can be called
731
731
* directly.
732
732
*/
733
- static int phar_parse_pharfile (php_stream * fp , char * fname , size_t fname_len , char * alias , size_t alias_len , zend_long halt_offset , phar_archive_data * * pphar , uint32_t compression , char * * error ) /* {{{ */
733
+ static zend_result phar_parse_pharfile (php_stream * fp , char * fname , size_t fname_len , char * alias , size_t alias_len , zend_long halt_offset , phar_archive_data * * pphar , uint32_t compression , char * * error ) /* {{{ */
734
734
{
735
735
char b32 [4 ], * buffer , * endbuffer , * savebuf ;
736
736
phar_archive_data * mydata = NULL ;
@@ -1806,7 +1806,7 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l
1806
1806
* if not, check to see if its dirname() exists (i.e. "/path/to") and is a directory
1807
1807
* succeed if we are creating the file, otherwise fail.
1808
1808
*/
1809
- static int phar_analyze_path (const char * fname , const char * ext , size_t ext_len , int for_create ) /* {{{ */
1809
+ static zend_result phar_analyze_path (const char * fname , const char * ext , size_t ext_len , int for_create ) /* {{{ */
1810
1810
{
1811
1811
php_stream_statbuf ssb ;
1812
1812
char * realpath ;
@@ -1911,7 +1911,7 @@ static int phar_analyze_path(const char *fname, const char *ext, size_t ext_len,
1911
1911
/* }}} */
1912
1912
1913
1913
/* check for ".phar" in extension */
1914
- static int phar_check_str (const char * fname , const char * ext_str , size_t ext_len , int executable , int for_create ) /* {{{ */
1914
+ static zend_result phar_check_str (const char * fname , const char * ext_str , size_t ext_len , int executable , int for_create ) /* {{{ */
1915
1915
{
1916
1916
const char * pos ;
1917
1917
@@ -2057,6 +2057,7 @@ zend_result phar_detect_phar_fname_ext(const char *filename, size_t filename_len
2057
2057
}
2058
2058
}
2059
2059
2060
+ // TODO Use some sort of loop here instead of a goto
2060
2061
pos = memchr (filename + 1 , '.' , filename_len );
2061
2062
next_extension :
2062
2063
if (!pos ) {
@@ -2078,30 +2079,23 @@ zend_result phar_detect_phar_fname_ext(const char *filename, size_t filename_len
2078
2079
* ext_len = strlen (pos );
2079
2080
2080
2081
/* file extension must contain "phar" */
2081
- switch (phar_check_str (filename , * ext_str , * ext_len , executable , for_create )) {
2082
- case SUCCESS :
2083
- return SUCCESS ;
2084
- case FAILURE :
2085
- /* we are at the end of the string, so we fail */
2086
- return FAILURE ;
2087
- }
2082
+ return phar_check_str (filename , * ext_str , * ext_len , executable , for_create );
2088
2083
}
2089
2084
2090
2085
/* we've found an extension that ends at a directory separator */
2091
2086
* ext_str = pos ;
2092
2087
* ext_len = slash - pos ;
2093
2088
2094
- switch (phar_check_str (filename , * ext_str , * ext_len , executable , for_create )) {
2095
- case SUCCESS :
2096
- return SUCCESS ;
2097
- case FAILURE :
2098
- /* look for more extensions */
2099
- pos = strchr (pos + 1 , '.' );
2100
- if (pos ) {
2101
- * ext_str = NULL ;
2102
- * ext_len = 0 ;
2103
- }
2104
- goto next_extension ;
2089
+ if (phar_check_str (filename , * ext_str , * ext_len , executable , for_create ) == SUCCESS ) {
2090
+ return SUCCESS ;
2091
+ }
2092
+
2093
+ /* look for more extensions */
2094
+ pos = strchr (pos + 1 , '.' );
2095
+ if (pos ) {
2096
+ * ext_str = NULL ;
2097
+ * ext_len = 0 ;
2098
+ goto next_extension ;
2105
2099
}
2106
2100
2107
2101
return FAILURE ;
0 commit comments