Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 935a283

Browse files
committed
Use goto instead of an if around the options parsing
1 parent 084f6ab commit 935a283

File tree

1 file changed

+100
-101
lines changed

1 file changed

+100
-101
lines changed

‎sapi/cgi/cgi_main.c‎

Lines changed: 100 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,112 +2268,111 @@ consult the installation file that came with this distribution, or visit \n\
22682268
init_request_info(request);
22692269

22702270
if (!cgi && !fastcgi) {
2271-
if (behavior != PHP_MODE_LINT) {
2272-
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
2273-
switch (c) {
2274-
2275-
case 'a': /* interactive mode */
2276-
printf("Interactive mode enabled\n\n");
2277-
fflush(stdout);
2278-
break;
2279-
2280-
case 'C': /* don't chdir to the script directory */
2281-
SG(options) |= SAPI_OPTION_NO_CHDIR;
2282-
break;
2283-
2284-
case 'e': /* enable extended info output */
2285-
CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
2286-
break;
2287-
2288-
case 'f': /* parse file */
2289-
if (script_file) {
2290-
efree(script_file);
2291-
}
2292-
script_file = estrdup(php_optarg);
2293-
no_headers = 1;
2294-
break;
2271+
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
2272+
switch (c) {
22952273

2296-
case 'i': /* php info & quit */
2297-
if (script_file) {
2298-
efree(script_file);
2299-
}
2300-
if (php_request_startup() == FAILURE) {
2301-
SG(server_context) = NULL;
2302-
php_module_shutdown();
2303-
free(bindpath);
2304-
return FAILURE;
2305-
}
2306-
if (no_headers) {
2307-
SG(headers_sent) = 1;
2308-
SG(request_info).no_headers = 1;
2309-
}
2310-
php_print_info(0xFFFFFFFF);
2311-
php_request_shutdown((void *) 0);
2312-
fcgi_shutdown();
2313-
exit_status = 0;
2314-
goto out;
2315-
2316-
case 'l': /* syntax check mode */
2317-
no_headers = 1;
2318-
behavior = PHP_MODE_LINT;
2319-
break;
2320-
2321-
case 'm': /* list compiled in modules */
2322-
if (script_file) {
2323-
efree(script_file);
2324-
}
2325-
SG(headers_sent) = 1;
2326-
php_printf("[PHP Modules]\n");
2327-
print_modules();
2328-
php_printf("\n[Zend Modules]\n");
2329-
print_extensions();
2330-
php_printf("\n");
2331-
php_output_end_all();
2332-
fcgi_shutdown();
2333-
exit_status = 0;
2334-
goto out;
2335-
2336-
case 'q': /* do not generate HTTP headers */
2337-
no_headers = 1;
2338-
break;
2339-
2340-
case 'v': /* show php version & quit */
2341-
if (script_file) {
2342-
efree(script_file);
2343-
}
2344-
no_headers = 1;
2345-
if (php_request_startup() == FAILURE) {
2346-
SG(server_context) = NULL;
2347-
php_module_shutdown();
2348-
free(bindpath);
2349-
return FAILURE;
2350-
}
2274+
case 'a': /* interactive mode */
2275+
printf("Interactive mode enabled\n\n");
2276+
fflush(stdout);
2277+
break;
2278+
2279+
case 'C': /* don't chdir to the script directory */
2280+
SG(options) |= SAPI_OPTION_NO_CHDIR;
2281+
break;
2282+
2283+
case 'e': /* enable extended info output */
2284+
CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
2285+
break;
2286+
2287+
case 'f': /* parse file */
2288+
if (script_file) {
2289+
efree(script_file);
2290+
}
2291+
script_file = estrdup(php_optarg);
2292+
no_headers = 1;
2293+
break;
2294+
2295+
case 'i': /* php info & quit */
2296+
if (script_file) {
2297+
efree(script_file);
2298+
}
2299+
if (php_request_startup() == FAILURE) {
2300+
SG(server_context) = NULL;
2301+
php_module_shutdown();
2302+
free(bindpath);
2303+
return FAILURE;
2304+
}
2305+
if (no_headers) {
23512306
SG(headers_sent) = 1;
23522307
SG(request_info).no_headers = 1;
2353-
#if ZEND_DEBUG
2354-
php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
2355-
#else
2356-
php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
2357-
#endif
2358-
php_request_shutdown((void *) 0);
2359-
fcgi_shutdown();
2360-
exit_status = 0;
2361-
goto out;
2362-
2363-
case 'w':
2364-
behavior = PHP_MODE_STRIP;
2365-
break;
2366-
2367-
case 'z': /* load extension file */
2368-
zend_load_extension(php_optarg);
2369-
break;
2370-
2371-
default:
2372-
break;
2373-
}
2308+
}
2309+
php_print_info(0xFFFFFFFF);
2310+
php_request_shutdown((void *) 0);
2311+
fcgi_shutdown();
2312+
exit_status = 0;
2313+
goto out;
2314+
2315+
case 'l': /* syntax check mode */
2316+
no_headers = 1;
2317+
behavior = PHP_MODE_LINT;
2318+
break;
2319+
2320+
case 'm': /* list compiled in modules */
2321+
if (script_file) {
2322+
efree(script_file);
2323+
}
2324+
SG(headers_sent) = 1;
2325+
php_printf("[PHP Modules]\n");
2326+
print_modules();
2327+
php_printf("\n[Zend Modules]\n");
2328+
print_extensions();
2329+
php_printf("\n");
2330+
php_output_end_all();
2331+
fcgi_shutdown();
2332+
exit_status = 0;
2333+
goto out;
2334+
2335+
case 'q': /* do not generate HTTP headers */
2336+
no_headers = 1;
2337+
break;
2338+
2339+
case 'v': /* show php version & quit */
2340+
if (script_file) {
2341+
efree(script_file);
2342+
}
2343+
no_headers = 1;
2344+
if (php_request_startup() == FAILURE) {
2345+
SG(server_context) = NULL;
2346+
php_module_shutdown();
2347+
free(bindpath);
2348+
return FAILURE;
2349+
}
2350+
SG(headers_sent) = 1;
2351+
SG(request_info).no_headers = 1;
2352+
#if ZEND_DEBUG
2353+
php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
2354+
#else
2355+
php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
2356+
#endif
2357+
php_request_shutdown((void *) 0);
2358+
fcgi_shutdown();
2359+
exit_status = 0;
2360+
goto out;
2361+
2362+
case 'w':
2363+
behavior = PHP_MODE_STRIP;
2364+
break;
2365+
2366+
case 'z': /* load extension file */
2367+
zend_load_extension(php_optarg);
2368+
break;
2369+
2370+
default:
2371+
break;
23742372
}
23752373
}
23762374

2375+
do_repeat:
23772376
if (script_file) {
23782377
/* override path_translated if -f on command line */
23792378
if (SG(request_info).path_translated) efree(SG(request_info).path_translated);
@@ -2585,7 +2584,7 @@ consult the installation file that came with this distribution, or visit \n\
25852584
if (behavior == PHP_MODE_LINT && argc - 1 > php_optind) {
25862585
php_optind++;
25872586
script_file = NULL;
2588-
continue;
2587+
goto do_repeat;
25892588
}
25902589
break;
25912590
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /