@@ -410,6 +410,52 @@ static void php_load_zend_extension_cb(void *arg) { }
410
410
#endif
411
411
/* }}} */
412
412
413
+ /* {{{ get_env_location
414
+ */
415
+ static char * get_env_location (const char * envname )
416
+ {
417
+ char * env_location = getenv (envname );
418
+ #ifdef PHP_WIN32
419
+ char phprc_path [MAXPATHLEN ];
420
+ #endif
421
+
422
+ #ifdef PHP_WIN32
423
+ if (!env_location ) {
424
+ char dummybuf ;
425
+ int size ;
426
+
427
+ SetLastError (0 );
428
+
429
+ /*If the given buffer is not large enough to hold the data, the return value is
430
+ the buffer size, in characters, required to hold the string and its terminating
431
+ null character. We use this return value to alloc the final buffer. */
432
+ size = GetEnvironmentVariableA (envname , & dummybuf , 0 );
433
+ if (GetLastError () == ERROR_ENVVAR_NOT_FOUND ) {
434
+ /* The environment variable doesn't exist. */
435
+ env_location = "" ;
436
+ } else {
437
+ if (size == 0 ) {
438
+ env_location = "" ;
439
+ } else {
440
+ size = GetEnvironmentVariableA (envname , phprc_path , size );
441
+ if (size == 0 ) {
442
+ env_location = "" ;
443
+ } else {
444
+ env_location = phprc_path ;
445
+ }
446
+ }
447
+ }
448
+ }
449
+ #else
450
+ if (!env_location ) {
451
+ env_location = "" ;
452
+ }
453
+ #endif
454
+
455
+ return env_location ;
456
+ }
457
+ /* }}} */
458
+
413
459
/* {{{ append_ini_path
414
460
*/
415
461
static void append_ini_path (char * php_ini_search_path , int search_path_size , char * path )
@@ -455,50 +501,14 @@ int php_init_config(void)
455
501
} else if (!sapi_module .php_ini_ignore ) {
456
502
int search_path_size ;
457
503
char * default_location ;
458
- char * env_location ;
504
+ char * env_location = get_env_location ( "PHPRC" ) ;
459
505
#ifdef PHP_WIN32
460
506
char * reg_location ;
461
- char phprc_path [MAXPATHLEN ];
462
507
#endif
463
508
464
- env_location = getenv ("PHPRC" );
465
-
466
- #ifdef PHP_WIN32
467
- if (!env_location ) {
468
- char dummybuf ;
469
- int size ;
470
-
471
- SetLastError (0 );
472
-
473
- /*If the given buffer is not large enough to hold the data, the return value is
474
- the buffer size, in characters, required to hold the string and its terminating
475
- null character. We use this return value to alloc the final buffer. */
476
- size = GetEnvironmentVariableA ("PHPRC" , & dummybuf , 0 );
477
- if (GetLastError () == ERROR_ENVVAR_NOT_FOUND ) {
478
- /* The environment variable doesn't exist. */
479
- env_location = "" ;
480
- } else {
481
- if (size == 0 ) {
482
- env_location = "" ;
483
- } else {
484
- size = GetEnvironmentVariableA ("PHPRC" , phprc_path , size );
485
- if (size == 0 ) {
486
- env_location = "" ;
487
- } else {
488
- env_location = phprc_path ;
489
- }
490
- }
491
- }
492
- }
493
- #else
494
- if (!env_location ) {
495
- env_location = "" ;
496
- }
497
- #endif
498
509
/*
499
510
* Prepare search path
500
511
*/
501
-
502
512
search_path_size = MAXPATHLEN * 4 + (int )strlen (env_location ) + 3 + 1 ;
503
513
php_ini_search_path = (char * ) emalloc (search_path_size );
504
514
free_ini_search_path = 1 ;
0 commit comments