*** empty log message ***
[gnulib.git] / m4 / off_t-format.m4
1 #serial 1                                                     -*- autoconf -*-
2
3 dnl FIXME
4 AC_DEFUN(jm_SYS_OFF_T_PRINTF_FORMAT,
5 [dnl
6     AC_CHECK_HEADERS(string.h stdlinb.h)
7     AC_CACHE_CHECK([for printf format that works with type off_t],
8                    jm_cv_sys_off_t_printf_format,
9     [
10      for jm_fmt in '' L ll q; do
11        jm_OFF_T_FORMAT="$jm_fmt"
12        export jm_OFF_T_FORMAT
13        AC_TRY_RUN([
14 #        include <sys/types.h>
15 #        include <stdio.h>
16 #        if HAVE_STDLIB_H
17 #         include <stdlib.h>
18 #        endif
19 #        if HAVE_STRING_H
20 #         include <string.h>
21 #        endif
22          int
23          main()
24          {
25            static off_t x[] = {1, 255, 65535, 99999999};
26            char buf[50], fmt[50];
27
28            /* this should be one of these values: "", "L", "ll", "q"  */
29            char *f = getenv ("jm_OFF_T_FORMAT");
30
31            sprintf (fmt, "%%%sd %%%sx %%%sx %%%sd", f, f, f, f);
32            sprintf (buf, fmt, x[0], x[1], x[2], x[3]);
33            exit (strcmp (buf, "1 ff ffff 99999999"));
34          }
35          ], jm_cv_sys_off_t_printf_format=$jm_fmt; break
36          , jm_cv_sys_off_t_printf_format=no dnl The library version does NOT work.
37          , jm_cv_sys_off_t_printf_format=no dnl We're cross compiling.
38        )
39      done
40     ])
41   fi
42
43   if test $am_cv_func_working_getline = no; then
44     AC_LIBOBJ(getline)
45   fi
46 ])