allow condensed command lines options
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 0f8e272..3c6aab8 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -185,8 +185,8 @@
static ngx_uint_t ngx_show_version;
static ngx_uint_t ngx_show_configure;
-static char *ngx_conf_file;
-static char *ngx_conf_params;
+static u_char *ngx_conf_file;
+static u_char *ngx_conf_params;
#if (NGX_WIN32)
static char *ngx_signal;
#endif
@@ -598,72 +598,98 @@
static ngx_int_t
ngx_get_options(int argc, char *const *argv)
{
- ngx_int_t i;
+ u_char *p;
+ ngx_int_t i;
for (i = 1; i < argc; i++) {
- if (argv[i][0] != '-') {
+
+ p = (u_char *) argv[i];
+
+ if (*p++ != '-') {
ngx_log_stderr("invalid option: \"%s\"", argv[i]);
return NGX_ERROR;
}
- switch (argv[i][1]) {
+ while (*p) {
- case 'v':
- ngx_show_version = 1;
- break;
+ switch (*p++) {
- case 'V':
- ngx_show_version = 1;
- ngx_show_configure = 1;
- break;
-
- case 't':
- ngx_test_config = 1;
- break;
-
- case 'c':
- if (argv[++i]) {
- ngx_conf_file = argv[i];
+ case 'v':
+ ngx_show_version = 1;
break;
- }
- ngx_log_stderr("the option \"-c\" requires file name");
- return NGX_ERROR;
-
- case 'g':
- if (argv[++i]) {
- ngx_conf_params = argv[i];
+ case 'V':
+ ngx_show_version = 1;
+ ngx_show_configure = 1;
break;
- }
- ngx_log_stderr("the option \"-g\" requires parameter");
- return NGX_ERROR;
+ case 't':
+ ngx_test_config = 1;
+ break;
+
+ case 'c':
+ if (*p) {
+ ngx_conf_file = p;
+ goto next;
+ }
+
+ if (argv[++i]) {
+ ngx_conf_file = (u_char *) argv[i];
+ goto next;
+ }
+
+ ngx_log_stderr("the option \"-c\" requires file name");
+ return NGX_ERROR;
+
+ case 'g':
+ if (*p) {
+ ngx_conf_params = p;
+ goto next;
+ }
+
+ if (argv[++i]) {
+ ngx_conf_params = (u_char *) argv[i];
+ goto next;
+ }
+
+ ngx_log_stderr("the option \"-g\" requires parameter");
+ return NGX_ERROR;
#if (NGX_WIN32)
- case 's':
- if (argv[++i] == NULL) {
- ngx_log_stderr("the option \"-s\" requires parameter");
+ case 's':
+ if (*p) {
+ ngx_signal = (char *) p;
+
+ } else if (argv[++i]) {
+ ngx_signal = argv[i];
+
+ } else {
+ ngx_log_stderr("the option \"-s\" requires parameter");
+ return NGX_ERROR;
+ }
+
+ if (ngx_strcmp(ngx_signal, "stop") == 0
+ || ngx_strcmp(ngx_signal, "quit") == 0
+ || ngx_strcmp(ngx_signal, "reopen") == 0
+ || ngx_strcmp(ngx_signal, "reload") == 0)
+ {
+ ngx_process = NGX_PROCESS_SIGNALLER;
+ goto next;
+ }
+
+ ngx_log_stderr("invalid option: \"-s %s\"", ngx_signal);
return NGX_ERROR;
- }
-
- if (ngx_strcmp(argv[i], "stop") == 0
- || ngx_strcmp(argv[i], "quit") == 0
- || ngx_strcmp(argv[i], "reopen") == 0
- || ngx_strcmp(argv[i], "reload") == 0)
- {
- ngx_process = NGX_PROCESS_SIGNALLER;
- ngx_signal = argv[i];
- break;
- }
-
- ngx_log_stderr("invalid option: \"-s %s\"", argv[i]);
- return NGX_ERROR;
#endif
- default:
- ngx_log_stderr("invalid option: \"%s\"", argv[i]);
- return NGX_ERROR;
+ default:
+ ngx_log_stderr("invalid option: \"%c\"", *(p - 1));
+ return NGX_ERROR;
+ }
}
+
+ next:
+
+ continue;
}
return NGX_OK;
@@ -717,7 +743,7 @@
{
if (ngx_conf_file) {
cycle->conf_file.len = ngx_strlen(ngx_conf_file);
- cycle->conf_file.data = (u_char *) ngx_conf_file;
+ cycle->conf_file.data = ngx_conf_file;
} else {
cycle->conf_file.len = sizeof(NGX_CONF_PATH) - 1;
@@ -725,8 +751,8 @@
}
if (ngx_conf_params) {
- cycle->conf_param.data = (u_char *) ngx_conf_params;
cycle->conf_param.len = ngx_strlen(ngx_conf_params);
+ cycle->conf_param.data = ngx_conf_params;
}
if (ngx_test_config) {