Re: [nginx] Improved code readablity.
Got it, thanks for your reply :) On Thu, Mar 8, 2018 at 1:13 PM, Ruslan Ermilov <r...@nginx.com> wrote: > On Thu, Mar 08, 2018 at 08:42:06AM +0800, Junwang Zhao wrote: >> I'm a little bit confused why the diffs are equal to each other, >> ASAICS, the changed code removed the effect of 'flags'? >> >> Can you explain a little bit since I just began to read the code base :) > > "flags | ~NGX_HTTP_VAR_WEAK" would either evaluate to "all bits set" > or "all bits set except NGX_HTTP_VAR_WEAK" if this bit is not set in > "flags". > >> 2018-03-07 23:29 GMT+08:00 Ruslan Ermilov <r...@nginx.com>: >> > details: http://hg.nginx.org/nginx/rev/0b1eb40de6da >> > branches: >> > changeset: 7226:0b1eb40de6da >> > user: Ruslan Ermilov <r...@nginx.com> >> > date: Wed Mar 07 18:28:12 2018 +0300 >> > description: >> > Improved code readablity. >> > >> > No functional changes. >> > >> > diffstat: >> > >> > src/http/ngx_http_variables.c | 8 ++-- >> > src/stream/ngx_stream_variables.c | 8 ++-- >> > 2 files changed, 12 insertions(+), 4 deletions(-) >> > >> > diffs (50 lines): >> > >> > diff -r e80930e5e422 -r 0b1eb40de6da src/http/ngx_http_variables.c >> > --- a/src/http/ngx_http_variables.c Mon Mar 05 21:35:13 2018 +0300 >> > +++ b/src/http/ngx_http_variables.c Wed Mar 07 18:28:12 2018 +0300 >> > @@ -429,7 +429,9 @@ ngx_http_add_variable(ngx_conf_t *cf, ng >> > return NULL; >> > } >> > >> > -v->flags &= flags | ~NGX_HTTP_VAR_WEAK; >> > +if (!(flags & NGX_HTTP_VAR_WEAK)) { >> > +v->flags &= ~NGX_HTTP_VAR_WEAK; >> > +} >> > >> > return v; >> > } >> > @@ -494,7 +496,9 @@ ngx_http_add_prefix_variable(ngx_conf_t >> > return NULL; >> > } >> > >> > -v->flags &= flags | ~NGX_HTTP_VAR_WEAK; >> > +if (!(flags & NGX_HTTP_VAR_WEAK)) { >> > +v->flags &= ~NGX_HTTP_VAR_WEAK; >> > +} >> > >> > return v; >> > } >> > diff -r e80930e5e422 -r 0b1eb40de6da src/stream/ngx_stream_variables.c >> > --- a/src/stream/ngx_stream_variables.c Mon Mar 05 21:35:13 2018 +0300 >> > +++ b/src/stream/ngx_stream_variables.c Wed Mar 07 18:28:12 2018 +0300 >> > @@ -161,7 +161,9 @@ ngx_stream_add_variable(ngx_conf_t *cf, >> > return NULL; >> > } >> > >> > -v->flags &= flags | ~NGX_STREAM_VAR_WEAK; >> > +if (!(flags & NGX_STREAM_VAR_WEAK)) { >> > +v->flags &= ~NGX_STREAM_VAR_WEAK; >> > +} >> > >> > return v; >> > } >> > @@ -227,7 +229,9 @@ ngx_stream_add_prefix_variable(ngx_conf_ >> > return NULL; >> > } >> > >> > -v->flags &= flags | ~NGX_STREAM_VAR_WEAK; >> > +if (!(flags & NGX_STREAM_VAR_WEAK)) { >> > +v->flags &= ~NGX_STREAM_VAR_WEAK; >> > +} >> > >> > return v; >> > } >> > ___ >> > nginx-devel mailing list >> > nginx-devel@nginx.org >> > http://mailman.nginx.org/mailman/listinfo/nginx-devel >> ___ >> nginx-devel mailing list >> nginx-devel@nginx.org >> http://mailman.nginx.org/mailman/listinfo/nginx-devel >> > > -- > Ruslan Ermilov > Assume stupidity not malice > ___ > nginx-devel mailing list > nginx-devel@nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
Re: [nginx] Improved code readablity.
I'm a little bit confused why the diffs are equal to each other, ASAICS, the changed code removed the effect of 'flags'? Can you explain a little bit since I just began to read the code base :) 2018-03-07 23:29 GMT+08:00 Ruslan Ermilov: > details: http://hg.nginx.org/nginx/rev/0b1eb40de6da > branches: > changeset: 7226:0b1eb40de6da > user: Ruslan Ermilov > date: Wed Mar 07 18:28:12 2018 +0300 > description: > Improved code readablity. > > No functional changes. > > diffstat: > > src/http/ngx_http_variables.c | 8 ++-- > src/stream/ngx_stream_variables.c | 8 ++-- > 2 files changed, 12 insertions(+), 4 deletions(-) > > diffs (50 lines): > > diff -r e80930e5e422 -r 0b1eb40de6da src/http/ngx_http_variables.c > --- a/src/http/ngx_http_variables.c Mon Mar 05 21:35:13 2018 +0300 > +++ b/src/http/ngx_http_variables.c Wed Mar 07 18:28:12 2018 +0300 > @@ -429,7 +429,9 @@ ngx_http_add_variable(ngx_conf_t *cf, ng > return NULL; > } > > -v->flags &= flags | ~NGX_HTTP_VAR_WEAK; > +if (!(flags & NGX_HTTP_VAR_WEAK)) { > +v->flags &= ~NGX_HTTP_VAR_WEAK; > +} > > return v; > } > @@ -494,7 +496,9 @@ ngx_http_add_prefix_variable(ngx_conf_t > return NULL; > } > > -v->flags &= flags | ~NGX_HTTP_VAR_WEAK; > +if (!(flags & NGX_HTTP_VAR_WEAK)) { > +v->flags &= ~NGX_HTTP_VAR_WEAK; > +} > > return v; > } > diff -r e80930e5e422 -r 0b1eb40de6da src/stream/ngx_stream_variables.c > --- a/src/stream/ngx_stream_variables.c Mon Mar 05 21:35:13 2018 +0300 > +++ b/src/stream/ngx_stream_variables.c Wed Mar 07 18:28:12 2018 +0300 > @@ -161,7 +161,9 @@ ngx_stream_add_variable(ngx_conf_t *cf, > return NULL; > } > > -v->flags &= flags | ~NGX_STREAM_VAR_WEAK; > +if (!(flags & NGX_STREAM_VAR_WEAK)) { > +v->flags &= ~NGX_STREAM_VAR_WEAK; > +} > > return v; > } > @@ -227,7 +229,9 @@ ngx_stream_add_prefix_variable(ngx_conf_ > return NULL; > } > > -v->flags &= flags | ~NGX_STREAM_VAR_WEAK; > +if (!(flags & NGX_STREAM_VAR_WEAK)) { > +v->flags &= ~NGX_STREAM_VAR_WEAK; > +} > > return v; > } > ___ > nginx-devel mailing list > nginx-devel@nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
Re: [nginx] enhance options
LGTM On Sun, Feb 4, 2018 at 8:49 PM, 洪志道wrote: > Hi! > > Maybe it's better to keep the options more complete, and consider the > follow operation as a mistake. > > /usr/local/nginx/sbin/nginx - > > hg diff > diff -r cbf59d483c9c src/core/nginx.c > --- a/src/core/nginx.c Tue Jan 16 13:52:03 2018 +0300 > +++ b/src/core/nginx.c Sun Feb 04 07:41:36 2018 -0500 > @@ -753,7 +753,12 @@ > return NGX_ERROR; > } > > -while (*p) { > +do { > + > +if (*p == '\0') { > +ngx_log_stderr(0, "missing option: \"%s\"", argv[i]); > +return NGX_ERROR; > +} > > switch (*p++) { > > @@ -855,7 +860,8 @@ > ngx_log_stderr(0, "invalid option: \"%c\"", *(p - 1)); > return NGX_ERROR; > } > -} > + > +} while (*p); > > next: > > Thanks. > > ___ > nginx-devel mailing list > nginx-devel@nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx-devel > ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel