Mercurial > hg > nginx
comparison src/core/ngx_string.c @ 1773:d85879105d35
%*s format
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 24 Dec 2007 17:05:16 +0000 |
parents | ec63069aeb78 |
children | 8382d94ba6ae |
comparison
equal
deleted
inserted
replaced
1772:25c93614e6b9 | 1773:d85879105d35 |
---|---|
61 * %r rlim_t | 61 * %r rlim_t |
62 * %p void * | 62 * %p void * |
63 * %V ngx_str_t * | 63 * %V ngx_str_t * |
64 * %v ngx_variable_value_t * | 64 * %v ngx_variable_value_t * |
65 * %s null-terminated string | 65 * %s null-terminated string |
66 * %*s length and string | |
66 * %Z '\0' | 67 * %Z '\0' |
67 * %N '\n' | 68 * %N '\n' |
68 * %c char | 69 * %c char |
69 * %% % | 70 * %% % |
70 * | 71 * |
110 /* | 111 /* |
111 * really we need temp[NGX_INT64_LEN] only, | 112 * really we need temp[NGX_INT64_LEN] only, |
112 * but icc issues the warning | 113 * but icc issues the warning |
113 */ | 114 */ |
114 int d; | 115 int d; |
115 size_t len; | 116 size_t len, slen; |
116 uint32_t ui32; | 117 uint32_t ui32; |
117 int64_t i64; | 118 int64_t i64; |
118 uint64_t ui64; | 119 uint64_t ui64; |
119 ngx_msec_t ms; | 120 ngx_msec_t ms; |
120 ngx_uint_t width, sign, hexadecimal, max_width; | 121 ngx_uint_t width, sign, hexadecimal, max_width; |
144 zero = (u_char) ((*++fmt == '0') ? '0' : ' '); | 145 zero = (u_char) ((*++fmt == '0') ? '0' : ' '); |
145 width = 0; | 146 width = 0; |
146 sign = 1; | 147 sign = 1; |
147 hexadecimal = 0; | 148 hexadecimal = 0; |
148 max_width = 0; | 149 max_width = 0; |
150 slen = 0; | |
149 | 151 |
150 p = temp + NGX_INT64_LEN; | 152 p = temp + NGX_INT64_LEN; |
151 | 153 |
152 while (*fmt >= '0' && *fmt <= '9') { | 154 while (*fmt >= '0' && *fmt <= '9') { |
153 width = width * 10 + *fmt++ - '0'; | 155 width = width * 10 + *fmt++ - '0'; |
177 hexadecimal = 1; | 179 hexadecimal = 1; |
178 sign = 0; | 180 sign = 0; |
179 fmt++; | 181 fmt++; |
180 continue; | 182 continue; |
181 | 183 |
184 case '*': | |
185 slen = va_arg(args, u_int); | |
186 fmt++; | |
187 continue; | |
188 | |
182 default: | 189 default: |
183 break; | 190 break; |
184 } | 191 } |
185 | 192 |
186 break; | 193 break; |
212 continue; | 219 continue; |
213 | 220 |
214 case 's': | 221 case 's': |
215 p = va_arg(args, u_char *); | 222 p = va_arg(args, u_char *); |
216 | 223 |
217 while (*p && buf < last) { | 224 if (slen == 0) { |
218 *buf++ = *p++; | 225 while (*p && buf < last) { |
219 } | 226 *buf++ = *p++; |
227 } | |
228 | |
229 } else { | |
230 buf = ngx_cpymem(buf, p, slen); | |
231 } | |
232 | |
220 fmt++; | 233 fmt++; |
221 | 234 |
222 continue; | 235 continue; |
223 | 236 |
224 case 'O': | 237 case 'O': |