summaryrefslogtreecommitdiff
path: root/auto/fmt/ptrfmt
blob: 20f0d320c292968731f7b87bea305d51c5bc7aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

echo $ngx_n "checking for $ngx_type printf() format ..." $ngx_c
echo >> $NGX_ERR
echo "checking for $ngx_type printf() format" >> $NGX_ERR

ngx_fmt=no
comma=
fmtX=

for fmt in $ngx_formats
do

    cat << END > $NGX_AUTOTEST.c

int main() {
    printf("$fmt", ($ngx_type) $ngx_max_value);
    return 0;
}

END

    eval "$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c \
          >> $NGX_ERR 2>&1"

    max_value=`echo $ngx_max_value | sed -e "s/L*\$//"`

    if [ -x $NGX_AUTOTEST ]; then
        if [ "`$NGX_AUTOTEST`" = $max_value ]; then
            ngx_fmt=$fmt
        fi
    fi

    rm $NGX_AUTOTEST*

    if [ $ngx_fmt != no ]; then
        break
    fi

    fmtX=`echo $fmt | sed -e "s/d/X/"`

    echo $ngx_n "$comma \"${fmtX}\" is not appropriate" $ngx_c
    comma=","
done


if [ $ngx_fmt = no ]; then
    echo "$0: error: printf() $ngx_type format not found"
    exit 1
fi


if [ $ngx_ptr_size = 4 ]; then
    fmtX="%0`expr 2 \* $ngx_ptr_size`"
else
    fmtX="%"
fi

ngx_fmt=`echo $ngx_fmt | sed -e "s/d/X/" -e "s/^%/$fmtX/"`

echo "$comma \"${ngx_fmt}\" used"


cat << END >> $NGX_AUTO_CONFIG_H

#ifndef $ngx_fmt_name
#define $ngx_fmt_name  "$ngx_fmt"
#endif

END