@@ -1394,11 +1394,8 @@ int main(int argc, char **argv) /* {{{ */
1394
1394
}
1395
1395
1396
1396
/* set exec if present on command line */
1397
- if (!exec && (argc > php_optind ) && (strcmp (argv [php_optind - 1 ], "--" ) != SUCCESS )) {
1398
- if (strlen (argv [php_optind ])) {
1399
- if (exec ) {
1400
- free (exec );
1401
- }
1397
+ if (argc > php_optind && (strcmp (argv [php_optind - 1 ], "--" ) != SUCCESS )) {
1398
+ if (!exec && strlen (argv [php_optind ])) {
1402
1399
exec = strdup (argv [php_optind ]);
1403
1400
}
1404
1401
php_optind ++ ;
@@ -1529,6 +1526,14 @@ int main(int argc, char **argv) /* {{{ */
1529
1526
1530
1527
PHPDBG_G (sapi_name_ptr ) = sapi_name ;
1531
1528
1529
+ if (exec ) { /* set execution context */
1530
+ PHPDBG_G (exec ) = phpdbg_resolve_path (exec );
1531
+ PHPDBG_G (exec_len ) = PHPDBG_G (exec ) ? strlen (PHPDBG_G (exec )) : 0 ;
1532
+
1533
+ free (exec );
1534
+ exec = NULL ;
1535
+ }
1536
+
1532
1537
php_output_activate ();
1533
1538
php_output_deactivate ();
1534
1539
@@ -1542,7 +1547,7 @@ int main(int argc, char **argv) /* {{{ */
1542
1547
for (i = SG (request_info ).argc ; -- i ;) {
1543
1548
SG (request_info ).argv [i ] = estrdup (argv [php_optind - 1 + i ]);
1544
1549
}
1545
- SG (request_info ).argv [i ] = exec ? estrdup (exec ) : estrdup ("" );
1550
+ SG (request_info ).argv [0 ] = PHPDBG_G ( exec ) ? estrdup (PHPDBG_G ( exec ) ) : estrdup ("" );
1546
1551
1547
1552
php_hash_environment ();
1548
1553
}
@@ -1603,14 +1608,6 @@ int main(int argc, char **argv) /* {{{ */
1603
1608
php_stream_stdio_ops .write = phpdbg_stdiop_write ;
1604
1609
#endif
1605
1610
1606
- if (exec ) { /* set execution context */
1607
- PHPDBG_G (exec ) = phpdbg_resolve_path (exec );
1608
- PHPDBG_G (exec_len ) = PHPDBG_G (exec ) ? strlen (PHPDBG_G (exec )) : 0 ;
1609
-
1610
- free (exec );
1611
- exec = NULL ;
1612
- }
1613
-
1614
1611
if (oplog_file ) { /* open oplog */
1615
1612
PHPDBG_G (oplog ) = fopen (oplog_file , "w+" );
1616
1613
if (!PHPDBG_G (oplog )) {
@@ -1775,7 +1772,7 @@ int main(int argc, char **argv) /* {{{ */
1775
1772
{
1776
1773
int i ;
1777
1774
/* free argv */
1778
- for (i = SG (request_info ).argc ; -- i ;) {
1775
+ for (i = SG (request_info ).argc ; i -- ;) {
1779
1776
efree (SG (request_info ).argv [i ]);
1780
1777
}
1781
1778
efree (SG (request_info ).argv );
@@ -1838,6 +1835,9 @@ int main(int argc, char **argv) /* {{{ */
1838
1835
}
1839
1836
1840
1837
if ((cleaning > 0 || remote ) && !quit_immediately ) {
1838
+ /* reset internal php_getopt state */
1839
+ php_getopt (-1 , argv , OPTIONS , NULL , & php_optind , 0 , 0 );
1840
+
1841
1841
goto phpdbg_main ;
1842
1842
}
1843
1843
0 commit comments