Commit Graph

19 Commits

Author SHA1 Message Date
Alejandro Colomar
952bcc50bf Fixed #define style.
We had a mix of styles for declaring function-like macros:

Style A:
 #define                    \
 foo()                      \
     do {                   \
         ...                \
     } while (0)

Style B:
 #define foo()              \
     do {                   \
         ...                \
     } while (0)

We had a similar number of occurences of each style:

 $ grep -rnI '^\w*(.*\\' | wc -l
 244
 $ grep -rn 'define.*(.*)' | wc -l
 239

(Those regexes aren't perfect, but a very decent approximation.)

Real examples:

 $ find src -type f | xargs sed -n '/^nxt_double_is_zero/,/^$/p'
 nxt_double_is_zero(f)                                                         \
     (fabs(f) <= FLT_EPSILON)

 $ find src -type f | xargs sed -n '/define nxt_http_field_set/,/^$/p'
 #define nxt_http_field_set(_field, _name, _value)                             \
     do {                                                                      \
         (_field)->name_length = nxt_length(_name);                            \
         (_field)->value_length = nxt_length(_value);                          \
         (_field)->name = (u_char *) _name;                                    \
         (_field)->value = (u_char *) _value;                                  \
     } while (0)

I'd like to standardize on a single style for them, and IMO,
having the identifier in the same line as #define is a better
option for the following reasons:

- Programmers are used to `#define foo() ...` (readability).
- One less line of code.
- The program for finding them is really simple (see below).

 function grep_ngx_func()
 {
     if (($# != 1)); then
         >&2 echo "Usage: ${FUNCNAME[0]} <func>";
         return 1;
     fi;

     find src -type f \
     | grep '\.[ch]$' \
     | xargs grep -l "$1" \
     | sort \
     | xargs pcregrep -Mn "(?s)^\$[\w\s*]+?^$1\(.*?^}";

     find src -type f \
     | grep '\.[ch]$' \
     | xargs grep -l "$1" \
     | sort \
     | xargs pcregrep -Mn "(?s)define $1\(.*?^$" \
     | sed -E '1s/^[^:]+:[0-9]+:/&\n\n/';
 }

 $ grep_ngx_func
 Usage: grep_ngx_func <func>

 $ grep_ngx_func nxt_http_field_set
 src/nxt_http.h:98:

 #define nxt_http_field_set(_field, _name, _value)                             \
     do {                                                                      \
         (_field)->name_length = nxt_length(_name);                            \
         (_field)->value_length = nxt_length(_value);                          \
         (_field)->name = (u_char *) _name;                                    \
         (_field)->value = (u_char *) _value;                                  \
     } while (0)

 $ grep_ngx_func nxt_sprintf
 src/nxt_sprintf.c:56:

 u_char * nxt_cdecl
 nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
 {
     u_char   *p;
     va_list  args;

     va_start(args, fmt);
     p = nxt_vsprintf(buf, end, fmt, args);
     va_end(args);

     return p;
 }

................
Scripted change:
................

$ find src -type f \
  | grep '\.[ch]$' \
  | xargs sed -i '/define *\\$/{N;s/ *\\\n/ /;s/        //}'
2022-05-03 12:11:14 +02:00
Valentin Bartenev
7bf6253941 Custom implementation of Base64 decoding function.
Compared to the previous implementation based on OpenSSL, the new implementation
has these advantages:

 1. Strict and reliable detection of invalid strings, including strings with
    less than 4 bytes of garbage at the end;

 2. Allows to use Base64 strings without '=' padding.
2021-10-26 15:43:44 +03:00
Tiago Natel de Moura
4ad8c5b898 Isolation: mount tmpfs by default. 2020-08-20 15:44:29 +01:00
Valentin Bartenev
d0de6df839 Fixed global constant declaration (appeared in 9af10e099d09).
This fixes building with GCC 10, which is default to -fno-common.
See: https://gcc.gnu.org/gcc-10/porting_to.html
2020-05-15 21:32:07 +03:00
Axel Duch
ee1e248f4b Router: decode uri and args. 2020-05-14 12:29:06 +02:00
Valentin Bartenev
68c6b67ffc Configuration: support for rational numbers. 2020-03-30 19:37:58 +03:00
Valentin Bartenev
35d6f84426 Added nxt_is_complex_uri_encoded()/nxt_encode_complex_uri(). 2020-03-27 17:22:52 +03:00
Igor Sysoev
ec0d5c928e Changed nxt_memcasecmp() interface to avoid casts. 2019-10-10 19:37:40 +03:00
Valentin Bartenev
08a8d1510d Basic support for serving static files. 2019-09-19 02:47:09 +03:00
Valentin Bartenev
64be8717bd Configuration: added ability to access object members with slashes.
Now URI encoding can be used to escape "/" in the request path:

  GET /config/listeners/unix:%2Fpath%2Fto%2Fsocket/
2019-09-16 20:17:42 +03:00
Igor Sysoev
95c9bba33b Introduced nxt_memcpy_upcase(). 2019-02-26 19:48:44 +03:00
Igor Sysoev
606eda045b Removed '\r' and '\n' artifact macros. 2018-06-25 16:56:45 +03:00
Valentin Bartenev
1a52d876f7 Introduced nxt_length() macro. 2018-06-25 16:51:47 +03:00
Valentin Bartenev
096562c0b1 Improved applications versions handling. 2017-10-05 16:46:18 +03:00
Igor Sysoev
949548da29 The new module configuration interface.
Configuration and building example:

  ./configure
  ./configure python
  ./configure php
  ./configure go
  make all

or

  ./configure
  make nginext
  ./configure python
  make python
  ./configure php
  make php
  ./configure go
  make go

Modules configuration options and building examples:

  ./configure python --module=python2 --config=python2.7-config
  make python2

  ./configure php --module=php7 --config=php7.0-config
                  --lib-path=/usr/local/php7.0
  make php7

  ./configure go --go=go1.6 --go-path=${HOME}/go1.6
  make go1.6
2017-08-17 21:47:19 +03:00
Valentin Bartenev
2dd8048bf9 Renamed nxt_str_copy() to nxt_str_cstrz(). 2017-08-16 15:43:02 +03:00
Igor Sysoev
f888a5310c Using new memory pool implementation. 2017-06-20 19:49:17 +03:00
Igor Sysoev
6e67bee0f4 nxt_str_t changes. 2017-02-01 19:20:07 +03:00
Igor Sysoev
16cbf3c076 Initial version. 2017-01-17 20:00:00 +03:00