diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-12-21 14:22:22 +0000 |
---|---|---|
committer | Sam Thursfield <Sam Thursfield> | 2013-01-03 11:32:53 +0000 |
commit | c2693d6d08db26825688ddca5de6eb8a4b7cde4a (patch) | |
tree | 10611dcf065b1893421b83a9de53cf6feb83a048 /m4/ungetc.m4 | |
parent | 861325a84f231a2a2da307b53ef5ff527d67e876 (diff) | |
download | m4-c2693d6d08db26825688ddca5de6eb8a4b7cde4a.tar.gz |
Commit files from tarball
Diffstat (limited to 'm4/ungetc.m4')
-rw-r--r-- | m4/ungetc.m4 | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/m4/ungetc.m4 b/m4/ungetc.m4 new file mode 100644 index 00000000..749f6bd5 --- /dev/null +++ b/m4/ungetc.m4 @@ -0,0 +1,36 @@ +# ungetc.m4 serial 2 +dnl Copyright (C) 2009-2011 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + + AC_CACHE_CHECK([whether ungetc works on arbitrary bytes], + [gl_cv_func_ungetc_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include <stdio.h> + ]], [FILE *f; + if (!(f = fopen ("conftest.tmp", "w+"))) return 1; + if (fputs ("abc", f) < 0) return 2; + rewind (f); + if (fgetc (f) != 'a') return 3; + if (fgetc (f) != 'b') return 4; + if (ungetc ('d', f) != 'd') return 5; + if (ftell (f) != 1) return 6; + if (fgetc (f) != 'd') return 7; + if (ftell (f) != 2) return 8; + if (fseek (f, 0, SEEK_CUR) != 0) return 9; + if (ftell (f) != 2) return 10; + if (fgetc (f) != 'c') return 11; + fclose (f); remove ("conftest.tmp");])], + [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no], + [gl_cv_func_ungetc_works='guessing no']) + ]) + if test "$gl_cv_func_ungetc_works" != yes; then + AC_DEFINE([FUNC_UNGETC_BROKEN], [1], + [Define to 1 if ungetc is broken when used on arbitrary bytes.]) + fi +]) |