@@ -172,7 +172,7 @@ PHPAPI void config_zval_dtor(zval *zvalue)
172
172
zend_string_release_ex (Z_STR_P (zvalue ), 1 );
173
173
}
174
174
}
175
- /* Reset / free active_ini_sectin global */
175
+ /* Reset / free active_ini_section global */
176
176
#define RESET_ACTIVE_INI_HASH () do { \
177
177
active_ini_hash = NULL; \
178
178
is_special_section = 0; \
@@ -395,6 +395,17 @@ static void php_load_zend_extension_cb(void *arg) { }
395
395
#endif
396
396
/* }}} */
397
397
398
+ static void append_ini_path (char * php_ini_search_path , int search_path_size , const char * path )
399
+ {
400
+ static const char paths_separator [] = { ZEND_PATHS_SEPARATOR , 0 };
401
+
402
+ if (* php_ini_search_path ) {
403
+ strlcat (php_ini_search_path , paths_separator , search_path_size );
404
+ }
405
+
406
+ strlcat (php_ini_search_path , path , search_path_size );
407
+ }
408
+
398
409
/* {{{ php_init_config */
399
410
int php_init_config (void )
400
411
{
@@ -424,7 +435,6 @@ int php_init_config(void)
424
435
int search_path_size ;
425
436
char * default_location ;
426
437
char * env_location ;
427
- static const char paths_separator [] = { ZEND_PATHS_SEPARATOR , 0 };
428
438
#ifdef PHP_WIN32
429
439
char * reg_location ;
430
440
char phprc_path [MAXPATHLEN ];
@@ -475,31 +485,22 @@ int php_init_config(void)
475
485
476
486
/* Add environment location */
477
487
if (env_location [0 ]) {
478
- if (* php_ini_search_path ) {
479
- strlcat (php_ini_search_path , paths_separator , search_path_size );
480
- }
481
- strlcat (php_ini_search_path , env_location , search_path_size );
488
+ append_ini_path (php_ini_search_path , search_path_size , env_location );
482
489
php_ini_file_name = env_location ;
483
490
}
484
491
485
492
#ifdef PHP_WIN32
486
493
/* Add registry location */
487
494
reg_location = GetIniPathFromRegistry ();
488
495
if (reg_location != NULL ) {
489
- if (* php_ini_search_path ) {
490
- strlcat (php_ini_search_path , paths_separator , search_path_size );
491
- }
492
- strlcat (php_ini_search_path , reg_location , search_path_size );
496
+ append_ini_path (php_ini_search_path , search_path_size , reg_location );
493
497
efree (reg_location );
494
498
}
495
499
#endif
496
500
497
501
/* Add cwd (not with CLI) */
498
502
if (!sapi_module .php_ini_ignore_cwd ) {
499
- if (* php_ini_search_path ) {
500
- strlcat (php_ini_search_path , paths_separator , search_path_size );
501
- }
502
- strlcat (php_ini_search_path , "." , search_path_size );
503
+ append_ini_path (php_ini_search_path , search_path_size , "." );
503
504
}
504
505
505
506
if (PG (php_binary )) {
@@ -511,10 +512,8 @@ int php_init_config(void)
511
512
if (separator_location && separator_location != binary_location ) {
512
513
* (separator_location ) = 0 ;
513
514
}
514
- if (* php_ini_search_path ) {
515
- strlcat (php_ini_search_path , paths_separator , search_path_size );
516
- }
517
- strlcat (php_ini_search_path , binary_location , search_path_size );
515
+ append_ini_path (php_ini_search_path , search_path_size , binary_location );
516
+
518
517
efree (binary_location );
519
518
}
520
519
@@ -523,29 +522,20 @@ int php_init_config(void)
523
522
default_location = (char * ) emalloc (MAXPATHLEN + 1 );
524
523
525
524
if (0 < GetWindowsDirectory (default_location , MAXPATHLEN )) {
526
- if (* php_ini_search_path ) {
527
- strlcat (php_ini_search_path , paths_separator , search_path_size );
528
- }
529
- strlcat (php_ini_search_path , default_location , search_path_size );
525
+ append_ini_path (php_ini_search_path , search_path_size , default_location );
530
526
}
531
527
532
528
/* For people running under terminal services, GetWindowsDirectory will
533
529
* return their personal Windows directory, so lets add the system
534
530
* windows directory too */
535
531
if (0 < GetSystemWindowsDirectory (default_location , MAXPATHLEN )) {
536
- if (* php_ini_search_path ) {
537
- strlcat (php_ini_search_path , paths_separator , search_path_size );
538
- }
539
- strlcat (php_ini_search_path , default_location , search_path_size );
532
+ append_ini_path (php_ini_search_path , search_path_size , default_location );
540
533
}
541
534
efree (default_location );
542
535
543
536
#else
544
537
default_location = PHP_CONFIG_FILE_PATH ;
545
- if (* php_ini_search_path ) {
546
- strlcat (php_ini_search_path , paths_separator , search_path_size );
547
- }
548
- strlcat (php_ini_search_path , default_location , search_path_size );
538
+ append_ini_path (php_ini_search_path , search_path_size , default_location );
549
539
#endif
550
540
}
551
541
0 commit comments