blob: 20f0d320c292968731f7b87bea305d51c5bc7aeb [file] [log] [blame]
Igor Sysoev48fef662004-02-24 17:31:46 +00001
2echo $ngx_n "checking for $ngx_type printf() format ..." $ngx_c
3echo >> $NGX_ERR
4echo "checking for $ngx_type printf() format" >> $NGX_ERR
5
6ngx_fmt=no
7comma=
8fmtX=
9
10for fmt in $ngx_formats
11do
12
13 cat << END > $NGX_AUTOTEST.c
14
15int main() {
Igor Sysoevc0247302004-06-27 18:01:57 +000016 printf("$fmt", ($ngx_type) $ngx_max_value);
Igor Sysoev48fef662004-02-24 17:31:46 +000017 return 0;
18}
19
20END
21
22 eval "$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c \
23 >> $NGX_ERR 2>&1"
24
Igor Sysoevc0247302004-06-27 18:01:57 +000025 max_value=`echo $ngx_max_value | sed -e "s/L*\$//"`
Igor Sysoev48fef662004-02-24 17:31:46 +000026
27 if [ -x $NGX_AUTOTEST ]; then
Igor Sysoevc0247302004-06-27 18:01:57 +000028 if [ "`$NGX_AUTOTEST`" = $max_value ]; then
Igor Sysoev48fef662004-02-24 17:31:46 +000029 ngx_fmt=$fmt
30 fi
31 fi
32
33 rm $NGX_AUTOTEST*
34
35 if [ $ngx_fmt != no ]; then
36 break
37 fi
38
39 fmtX=`echo $fmt | sed -e "s/d/X/"`
40
41 echo $ngx_n "$comma \"${fmtX}\" is not appropriate" $ngx_c
42 comma=","
43done
44
45
46if [ $ngx_fmt = no ]; then
47 echo "$0: error: printf() $ngx_type format not found"
48 exit 1
49fi
50
Igor Sysoev71e9fa02004-02-24 19:34:46 +000051
Igor Sysoevc0247302004-06-27 18:01:57 +000052if [ $ngx_ptr_size = 4 ]; then
53 fmtX="%0`expr 2 \* $ngx_ptr_size`"
Igor Sysoev71e9fa02004-02-24 19:34:46 +000054else
Igor Sysoev14dab452004-02-25 15:46:57 +000055 fmtX="%"
Igor Sysoev71e9fa02004-02-24 19:34:46 +000056fi
57
Igor Sysoev48fef662004-02-24 17:31:46 +000058ngx_fmt=`echo $ngx_fmt | sed -e "s/d/X/" -e "s/^%/$fmtX/"`
59
60echo "$comma \"${ngx_fmt}\" used"
61
Igor Sysoev71e9fa02004-02-24 19:34:46 +000062
Igor Sysoev48fef662004-02-24 17:31:46 +000063cat << END >> $NGX_AUTO_CONFIG_H
64
65#ifndef $ngx_fmt_name
66#define $ngx_fmt_name "$ngx_fmt"
67#endif
68
69END