change order
This commit is contained in:
parent
912893e685
commit
26e737a2c8
1 changed files with 47 additions and 44 deletions
|
@ -8,6 +8,9 @@
|
|||
#include <ngx_core.h>
|
||||
|
||||
|
||||
static size_t ngx_sprint_uchar(u_char *text, u_char c, size_t len);
|
||||
|
||||
|
||||
/* AF_INET only */
|
||||
|
||||
in_addr_t
|
||||
|
@ -63,50 +66,6 @@ ngx_inet_addr(u_char *text, size_t len)
|
|||
* than using FreeBSD libc's snprintf().
|
||||
*/
|
||||
|
||||
|
||||
static ngx_inline size_t
|
||||
ngx_sprint_uchar(u_char *text, u_char c, size_t len)
|
||||
{
|
||||
size_t n;
|
||||
ngx_uint_t c1, c2;
|
||||
|
||||
n = 0;
|
||||
|
||||
if (len == n) {
|
||||
return n;
|
||||
}
|
||||
|
||||
c1 = c / 100;
|
||||
|
||||
if (c1) {
|
||||
*text++ = (u_char) (c1 + '0');
|
||||
n++;
|
||||
|
||||
if (len == n) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
c2 = (c % 100) / 10;
|
||||
|
||||
if (c1 || c2) {
|
||||
*text++ = (u_char) (c2 + '0');
|
||||
n++;
|
||||
|
||||
if (len == n) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
c2 = c % 10;
|
||||
|
||||
*text++ = (u_char) (c2 + '0');
|
||||
n++;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
/* AF_INET only */
|
||||
|
||||
size_t
|
||||
|
@ -163,6 +122,7 @@ ngx_sock_ntop(int family, struct sockaddr *sa, u_char *text, size_t len)
|
|||
return n;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
ngx_inet_ntop(int family, void *addr, u_char *text, size_t len)
|
||||
{
|
||||
|
@ -216,6 +176,49 @@ ngx_inet_ntop(int family, void *addr, u_char *text, size_t len)
|
|||
}
|
||||
|
||||
|
||||
static size_t
|
||||
ngx_sprint_uchar(u_char *text, u_char c, size_t len)
|
||||
{
|
||||
size_t n;
|
||||
ngx_uint_t c1, c2;
|
||||
|
||||
n = 0;
|
||||
|
||||
if (len == n) {
|
||||
return n;
|
||||
}
|
||||
|
||||
c1 = c / 100;
|
||||
|
||||
if (c1) {
|
||||
*text++ = (u_char) (c1 + '0');
|
||||
n++;
|
||||
|
||||
if (len == n) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
c2 = (c % 100) / 10;
|
||||
|
||||
if (c1 || c2) {
|
||||
*text++ = (u_char) (c2 + '0');
|
||||
n++;
|
||||
|
||||
if (len == n) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
c2 = c % 10;
|
||||
|
||||
*text++ = (u_char) (c2 + '0');
|
||||
n++;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
/* AF_INET only */
|
||||
|
||||
ngx_int_t
|
||||
|
|
Loading…
Reference in a new issue