Skip to content

Use Nginx core function in ngx_http_lua_rebase_path #835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

Someguynamedpie
Copy link

Using the Nginx core function for pathing. Had to cast away volatility but it shouldn't be an issue.

I release my changes into the public domain.

For better support for absolute/relative path detection.
Also cast away the volatility, nothing should blow up in theory since the fullname function is cheap.
@agentzh
Copy link
Member

agentzh commented Aug 9, 2016

@Someguynamedpie Thanks for your patch. But will you fix the coding style of your changes to be strictly aligned up with the rest of the code base? Many thanks!

if (dst == NULL) {

nsrc.len = len;
nsrc.data = ngx_palloc(pool, len+1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ngx_palloc may return NULL and we should handle this case.

@agentzh
Copy link
Member

agentzh commented Aug 9, 2016

@Someguynamedpie It's recommended to always run the ngx-releng tool to check your code:

https://github.com/openresty/nginx-devel-utils/blob/master/ngx-releng

The errors found by ngx-releng against your branch on my side are as follows:

src/ngx_http_lua_util.c
376:
379:
382:
385:
388:
391:
src/ngx_http_lua_util.c
389:    if(ngx_get_full_name(pool, (ngx_str_t*)&ngx_cycle->prefix, &nsrc))
not check NULL: src/ngx_http_lua_util.c: line 383:     nsrc.data = ngx_palloc(pool, len+1);
    if (!nsrc.data)

src/ngx_http_lua_util.c:
variable name should align with the previous line
375:     u_char *optr;
found unnecessary tail space
376:
found unnecessary tail space
379:
need space before +
381:     nsrc.data = ngx_palloc(pool, len+1);
need space after +
381:     nsrc.data = ngx_palloc(pool, len+1);
found unnecessary tail space
382:
found unnecessary tail space
385:
found unnecessary tail space
388:
need space before *
389:     if(ngx_get_full_name(pool, (ngx_str_t*)&ngx_cycle->prefix, &nsrc))
found unnecessary tail space
391:

@Someguynamedpie
Copy link
Author

Apologies, wasn't aware there were tools to encourage following the coding style. Most of the style issues are actually because I made the mistake of copying it from the terminal haha. I'll work on cleaning it up tonight.

@agentzh
Copy link
Member

agentzh commented Aug 10, 2016

@Someguynamedpie Thanks for your patience and help!

agentzh added a commit that referenced this pull request Aug 12, 2016
…X systems like Win32. thanks Someguynamedpie for the report and the original patch in #835.
@agentzh
Copy link
Member

agentzh commented Aug 12, 2016

@Someguynamedpie Well, I've just rewrote your patch and committed it to git master. Please let me know if it works for you on Win32.

@agentzh agentzh closed this Aug 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants