Skip to content

Commit e829556

Browse files
committed
massive coding style fixes.
1 parent d931db4 commit e829556

File tree

87 files changed

+1298
-693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1298
-693
lines changed

src/api/ngx_http_lua_api.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
#ifndef NGX_HTTP_LUA_API_H
2-
#define NGX_HTTP_LUA_API_H
1+
2+
/*
3+
* Copyright (C) Yichun Zhang (agentzh)
4+
*/
5+
6+
7+
#ifndef _NGX_HTTP_LUA_API_H_INCLUDED_
8+
#define _NGX_HTTP_LUA_API_H_INCLUDED_
39

410

511
#include <nginx.h>
@@ -36,5 +42,6 @@ ngx_int_t ngx_http_lua_shared_dict_get(ngx_shm_zone_t *shm_zone,
3642
ngx_shm_zone_t *ngx_http_lua_find_zone(u_char *name_data, size_t name_len);
3743

3844

39-
#endif /* NGX_HTTP_LUA_API_H */
45+
#endif /* _NGX_HTTP_LUA_API_H_INCLUDED_ */
4046

47+
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

src/ddebug.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
/* vim:set ft=c ts=4 sw=4 et fdm=marker: */
21

3-
#ifndef DDEBUG_H
4-
#define DDEBUG_H
2+
/*
3+
* Copyright (C) Yichun Zhang (agentzh)
4+
*/
5+
6+
7+
#ifndef _DDEBUG_H_INCLUDED_
8+
#define _DDEBUG_H_INCLUDED_
9+
510

611
#include <nginx.h>
712
#include <ngx_core.h>
813

14+
915
#if defined(DDEBUG) && (DDEBUG)
1016

1117
# if (NGX_HAVE_VARIADIC_MACROS)
@@ -70,5 +76,7 @@ static void dd(const char *fmt, ...) {
7076

7177
#endif
7278

73-
#endif /* DDEBUG_H */
7479

80+
#endif /* _DDEBUG_H_INCLUDED_ */
81+
82+
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

src/ngx_http_lua_accessby.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
/* vim:set ft=c ts=4 sw=4 et fdm=marker: */
1+
2+
/*
3+
* Copyright (C) Xiaozhe Wang (chaoslawful)
4+
* Copyright (C) Yichun Zhang (agentzh)
5+
*/
6+
27

38
#ifndef DDEBUG
49
#define DDEBUG 0
510
#endif
611
#include "ddebug.h"
712

13+
814
#include <nginx.h>
915
#include "ngx_http_lua_accessby.h"
1016
#include "ngx_http_lua_util.h"
@@ -44,7 +50,7 @@ ngx_http_lua_access_handler(ngx_http_request_t *r)
4450
last_ph = &ph[cur_ph->next - 2];
4551

4652
dd("ph cur: %d, ph next: %d", (int) r->phase_handler,
47-
(int) (cur_ph->next - 2));
53+
(int) (cur_ph->next - 2));
4854

4955
#if 0
5056
if (cur_ph == last_ph) {
@@ -111,7 +117,7 @@ ngx_http_lua_access_handler(ngx_http_request_t *r)
111117
r->request_body_in_clean_file = 1;
112118

113119
rc = ngx_http_read_client_request_body(r,
114-
ngx_http_lua_generic_phase_post_read);
120+
ngx_http_lua_generic_phase_post_read);
115121

116122
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
117123
#if (nginx_version < 1002006) || \
@@ -149,8 +155,10 @@ ngx_http_lua_access_handler_inline(ngx_http_request_t *r)
149155

150156
/* load Lua inline script (w/ cache) sp = 1 */
151157
rc = ngx_http_lua_cache_loadbuffer(L, llcf->access_src.value.data,
152-
llcf->access_src.value.len, llcf->access_src_key,
153-
"access_by_lua", &err, llcf->enable_code_cache ? 1 : 0);
158+
llcf->access_src.value.len,
159+
llcf->access_src_key,
160+
"access_by_lua", &err,
161+
llcf->enable_code_cache ? 1 : 0);
154162

155163
if (rc != NGX_OK) {
156164
if (err == NULL) {
@@ -197,7 +205,7 @@ ngx_http_lua_access_handler_file(ngx_http_request_t *r)
197205

198206
/* load Lua script file (w/ cache) sp = 1 */
199207
rc = ngx_http_lua_cache_loadfile(L, script_path, llcf->access_src_key,
200-
&err, llcf->enable_code_cache ? 1 : 0);
208+
&err, llcf->enable_code_cache ? 1 : 0);
201209

202210
if (rc != NGX_OK) {
203211
if (err == NULL) {
@@ -331,3 +339,4 @@ ngx_http_lua_access_by_chunk(lua_State *L, ngx_http_request_t *r)
331339
return NGX_DECLINED;
332340
}
333341

342+
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

src/ngx_http_lua_accessby.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
/* vim:set ft=c ts=4 sw=4 et fdm=marker: */
21

3-
#ifndef NGX_HTTP_LUA_ACCESSBY_H
4-
#define NGX_HTTP_LUA_ACCESSBY_H
2+
/*
3+
* Copyright (C) Xiaozhe Wang (chaoslawful)
4+
* Copyright (C) Yichun Zhang (agentzh)
5+
*/
6+
7+
8+
#ifndef _NGX_HTTP_LUA_ACCESSBY_H_INCLUDED_
9+
#define _NGX_HTTP_LUA_ACCESSBY_H_INCLUDED_
510

611

712
#include "ngx_http_lua_common.h"
@@ -12,5 +17,6 @@ ngx_int_t ngx_http_lua_access_handler_inline(ngx_http_request_t *r);
1217
ngx_int_t ngx_http_lua_access_handler_file(ngx_http_request_t *r);
1318

1419

15-
#endif /* NGX_HTTP_LUA_ACCESSBY_H */
20+
#endif /* _NGX_HTTP_LUA_ACCESSBY_H_INCLUDED_ */
1621

22+
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

src/ngx_http_lua_api.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
/* vim:set ft=c ts=4 sw=4 et fdm=marker: */
1+
2+
/*
3+
* Copyright (C) Yichun Zhang (agentzh)
4+
*/
5+
26

37
#include "ddebug.h"
48

@@ -77,3 +81,4 @@ ngx_http_lua_add_package_preload(ngx_conf_t *cf, const char *package,
7781
return NGX_OK;
7882
}
7983

84+
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

src/ngx_http_lua_args.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
2+
/*
3+
* Copyright (C) Xiaozhe Wang (chaoslawful)
4+
* Copyright (C) Yichun Zhang (agentzh)
5+
*/
6+
7+
18
#ifndef DDEBUG
29
#define DDEBUG 0
310
#endif
411
#include "ddebug.h"
512

13+
614
#include "ngx_http_lua_args.h"
715
#include "ngx_http_lua_util.h"
816

@@ -22,7 +30,7 @@ ngx_http_lua_ngx_req_set_uri_args(lua_State *L) {
2230

2331
if (lua_gettop(L) != 1) {
2432
return luaL_error(L, "expecting 1 argument but seen %d",
25-
lua_gettop(L));
33+
lua_gettop(L));
2634
}
2735

2836
lua_pushlightuserdata(L, &ngx_http_lua_request_key);
@@ -58,7 +66,7 @@ ngx_http_lua_ngx_req_set_uri_args(lua_State *L) {
5866

5967
default:
6068
msg = lua_pushfstring(L, "string, number, or table expected, "
61-
"but got %s", luaL_typename(L, 2));
69+
"but got %s", luaL_typename(L, 2));
6270
return luaL_argerror(L, 1, msg);
6371
}
6472

@@ -170,7 +178,7 @@ ngx_http_lua_ngx_req_get_post_args(lua_State *L)
170178

171179
if (r->request_body == NULL) {
172180
return luaL_error(L, "no request body found; "
173-
"maybe you should turn on lua_need_request_body?");
181+
"maybe you should turn on lua_need_request_body?");
174182
}
175183

176184
if (r->request_body->temp_file) {
@@ -240,7 +248,7 @@ ngx_http_lua_parse_args(ngx_http_request_t *r, lua_State *L, u_char *buf,
240248
src = q; dst = q;
241249

242250
ngx_http_lua_unescape_uri(&dst, &src, p - q,
243-
NGX_UNESCAPE_URI_COMPONENT);
251+
NGX_UNESCAPE_URI_COMPONENT);
244252

245253
dd("pushing key %.*s", (int) (dst - q), q);
246254

@@ -258,7 +266,7 @@ ngx_http_lua_parse_args(ngx_http_request_t *r, lua_State *L, u_char *buf,
258266
src = q; dst = q;
259267

260268
ngx_http_lua_unescape_uri(&dst, &src, p - q,
261-
NGX_UNESCAPE_URI_COMPONENT);
269+
NGX_UNESCAPE_URI_COMPONENT);
262270

263271
dd("pushing key or value %.*s", (int) (dst - q), q);
264272

@@ -296,7 +304,7 @@ ngx_http_lua_parse_args(ngx_http_request_t *r, lua_State *L, u_char *buf,
296304

297305
if (max > 0 && ++count == max) {
298306
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
299-
"lua hit query args limit %d", max);
307+
"lua hit query args limit %d", max);
300308

301309
return 1;
302310
}
@@ -310,7 +318,7 @@ ngx_http_lua_parse_args(ngx_http_request_t *r, lua_State *L, u_char *buf,
310318
src = q; dst = q;
311319

312320
ngx_http_lua_unescape_uri(&dst, &src, p - q,
313-
NGX_UNESCAPE_URI_COMPONENT);
321+
NGX_UNESCAPE_URI_COMPONENT);
314322

315323
dd("pushing key or value %.*s", (int) (dst - q), q);
316324

@@ -361,3 +369,4 @@ ngx_http_lua_inject_req_args_api(lua_State *L)
361369
lua_setfield(L, -2, "get_post_args");
362370
}
363371

372+
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

src/ngx_http_lua_bodyfilterby.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
/* vim:set ft=c ts=4 sw=4 et fdm=marker: */
1+
2+
/*
3+
* Copyright (C) Xiaozhe Wang (chaoslawful)
4+
* Copyright (C) Yichun Zhang (agentzh)
5+
*/
6+
27

38
#ifndef DDEBUG
49
#define DDEBUG 0
510
#endif
611
#include "ddebug.h"
712

13+
814
#include "ngx_http_lua_bodyfilterby.h"
915
#include "ngx_http_lua_exception.h"
1016
#include "ngx_http_lua_util.h"
@@ -22,9 +28,7 @@
2228

2329

2430
static void ngx_http_lua_body_filter_by_lua_env(lua_State *L,
25-
ngx_http_request_t *r, ngx_chain_t *in);
26-
27-
31+
ngx_http_request_t *r, ngx_chain_t *in);
2832
static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
2933

3034

@@ -163,16 +167,18 @@ ngx_http_lua_body_filter_inline(ngx_http_request_t *r, ngx_chain_t *in)
163167

164168
/* load Lua inline script (w/ cache) sp = 1 */
165169
rc = ngx_http_lua_cache_loadbuffer(L, llcf->body_filter_src.value.data,
166-
llcf->body_filter_src.value.len, llcf->body_filter_src_key,
167-
"body_filter_by_lua", &err, llcf->enable_code_cache ? 1 : 0);
170+
llcf->body_filter_src.value.len,
171+
llcf->body_filter_src_key,
172+
"body_filter_by_lua", &err,
173+
llcf->enable_code_cache ? 1 : 0);
168174

169175
if (rc != NGX_OK) {
170176
if (err == NULL) {
171177
err = "unknown error";
172178
}
173179

174180
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
175-
"Failed to load Lua inlined code: %s", err);
181+
"Failed to load Lua inlined code: %s", err);
176182

177183
return NGX_HTTP_INTERNAL_SERVER_ERROR;
178184
}
@@ -204,12 +210,13 @@ ngx_http_lua_body_filter_file(ngx_http_request_t *r, ngx_chain_t *in)
204210

205211
/* Eval nginx variables in code path string first */
206212
if (ngx_http_complex_value(r, &llcf->body_filter_src, &eval_src)
207-
!= NGX_OK) {
213+
!= NGX_OK)
214+
{
208215
return NGX_ERROR;
209216
}
210217

211218
script_path = ngx_http_lua_rebase_path(r->pool, eval_src.data,
212-
eval_src.len);
219+
eval_src.len);
213220

214221
if (script_path == NULL) {
215222
return NGX_ERROR;
@@ -220,7 +227,8 @@ ngx_http_lua_body_filter_file(ngx_http_request_t *r, ngx_chain_t *in)
220227

221228
/* load Lua script file (w/ cache) sp = 1 */
222229
rc = ngx_http_lua_cache_loadfile(L, script_path,
223-
llcf->body_filter_src_key, &err, llcf->enable_code_cache ? 1 : 0);
230+
llcf->body_filter_src_key, &err,
231+
llcf->enable_code_cache ? 1 : 0);
224232

225233
if (rc != NGX_OK) {
226234
if (err == NULL) {
@@ -672,3 +680,4 @@ ngx_http_lua_body_filter_param_set(lua_State *L, ngx_http_request_t *r,
672680
return 0;
673681
}
674682

683+
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

src/ngx_http_lua_bodyfilterby.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
/* vim:set ft=c ts=4 sw=4 et fdm=marker: */
21

3-
#ifndef NGX_HTTP_LUA_BODYFILTERBY_H
4-
#define NGX_HTTP_LUA_BODYFILTERBY_H
2+
/*
3+
* Copyright (C) Yichun Zhang (agentzh)
4+
*/
5+
6+
7+
#ifndef _NGX_HTTP_LUA_BODYFILTERBY_H_INCLUDED_
8+
#define _NGX_HTTP_LUA_BODYFILTERBY_H_INCLUDED_
59

610

711
#include "ngx_http_lua_common.h"
@@ -11,21 +15,17 @@ extern ngx_http_output_body_filter_pt ngx_http_lua_next_filter_body_filter;
1115

1216

1317
ngx_int_t ngx_http_lua_body_filter_init(void);
14-
1518
ngx_int_t ngx_http_lua_body_filter_by_chunk(lua_State *L,
16-
ngx_http_request_t *r, ngx_chain_t *in);
17-
19+
ngx_http_request_t *r, ngx_chain_t *in);
1820
ngx_int_t ngx_http_lua_body_filter_inline(ngx_http_request_t *r,
19-
ngx_chain_t *in);
20-
21+
ngx_chain_t *in);
2122
ngx_int_t ngx_http_lua_body_filter_file(ngx_http_request_t *r,
22-
ngx_chain_t *in);
23-
23+
ngx_chain_t *in);
2424
int ngx_http_lua_body_filter_param_get(lua_State *L);
25-
2625
int ngx_http_lua_body_filter_param_set(lua_State *L, ngx_http_request_t *r,
27-
ngx_http_lua_ctx_t *ctx);
26+
ngx_http_lua_ctx_t *ctx);
2827

2928

30-
#endif /* NGX_HTTP_LUA_BODYFILTERBY_H */
29+
#endif /* _NGX_HTTP_LUA_BODYFILTERBY_H_INCLUDED_ */
3130

31+
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

0 commit comments

Comments
 (0)