@@ -410,6 +410,20 @@ static void php_load_zend_extension_cb(void *arg) { }
410
410
#endif
411
411
/* }}} */
412
412
413
+ /* {{{ append_ini_path
414
+ */
415
+ static void append_ini_path (char * php_ini_search_path , int search_path_size , char * path )
416
+ {
417
+ static const char paths_separator [] = { ZEND_PATHS_SEPARATOR , 0 };
418
+
419
+ if (* php_ini_search_path ) {
420
+ strlcat (php_ini_search_path , paths_separator , search_path_size );
421
+ }
422
+
423
+ strlcat (php_ini_search_path , path , search_path_size );
424
+ }
425
+ /* }}} */
426
+
413
427
/* {{{ php_init_config
414
428
*/
415
429
int php_init_config (void )
@@ -442,7 +456,6 @@ int php_init_config(void)
442
456
int search_path_size ;
443
457
char * default_location ;
444
458
char * env_location ;
445
- static const char paths_separator [] = { ZEND_PATHS_SEPARATOR , 0 };
446
459
#ifdef PHP_WIN32
447
460
char * reg_location ;
448
461
char phprc_path [MAXPATHLEN ];
@@ -501,20 +514,14 @@ int php_init_config(void)
501
514
/* Add registry location */
502
515
reg_location = GetIniPathFromRegistry ();
503
516
if (reg_location != NULL ) {
504
- if (* php_ini_search_path ) {
505
- strlcat (php_ini_search_path , paths_separator , search_path_size );
506
- }
507
- strlcat (php_ini_search_path , reg_location , search_path_size );
517
+ append_ini_path (php_ini_search_path , search_path_size , reg_location );
508
518
efree (reg_location );
509
519
}
510
520
#endif
511
521
512
522
/* Add cwd (not with CLI) */
513
523
if (!sapi_module .php_ini_ignore_cwd ) {
514
- if (* php_ini_search_path ) {
515
- strlcat (php_ini_search_path , paths_separator , search_path_size );
516
- }
517
- strlcat (php_ini_search_path , "." , search_path_size );
524
+ append_ini_path (php_ini_search_path , search_path_size , "." );
518
525
}
519
526
520
527
if (PG (php_binary )) {
@@ -526,10 +533,8 @@ int php_init_config(void)
526
533
if (separator_location && separator_location != binary_location ) {
527
534
* (separator_location ) = 0 ;
528
535
}
529
- if (* php_ini_search_path ) {
530
- strlcat (php_ini_search_path , paths_separator , search_path_size );
531
- }
532
- strlcat (php_ini_search_path , binary_location , search_path_size );
536
+ append_ini_path (php_ini_search_path , search_path_size , binary_location );
537
+
533
538
efree (binary_location );
534
539
}
535
540
@@ -538,29 +543,20 @@ int php_init_config(void)
538
543
default_location = (char * ) emalloc (MAXPATHLEN + 1 );
539
544
540
545
if (0 < GetWindowsDirectory (default_location , MAXPATHLEN )) {
541
- if (* php_ini_search_path ) {
542
- strlcat (php_ini_search_path , paths_separator , search_path_size );
543
- }
544
- strlcat (php_ini_search_path , default_location , search_path_size );
546
+ append_ini_path (php_ini_search_path , search_path_size , default_location );
545
547
}
546
548
547
549
/* For people running under terminal services, GetWindowsDirectory will
548
550
* return their personal Windows directory, so lets add the system
549
551
* windows directory too */
550
552
if (0 < GetSystemWindowsDirectory (default_location , MAXPATHLEN )) {
551
- if (* php_ini_search_path ) {
552
- strlcat (php_ini_search_path , paths_separator , search_path_size );
553
- }
554
- strlcat (php_ini_search_path , default_location , search_path_size );
553
+ append_ini_path (php_ini_search_path , search_path_size , default_location );
555
554
}
556
555
efree (default_location );
557
556
558
557
#else
559
558
default_location = PHP_CONFIG_FILE_PATH ;
560
- if (* php_ini_search_path ) {
561
- strlcat (php_ini_search_path , paths_separator , search_path_size );
562
- }
563
- strlcat (php_ini_search_path , default_location , search_path_size );
559
+ append_ini_path (php_ini_search_path , search_path_size , default_location );
564
560
#endif
565
561
}
566
562
0 commit comments