X-Git-Url: https://git.draconx.ca/gitweb/dxcommon.git/blobdiff_plain/9efff8c7a48509fabab57631f5c64c669183dee0..27f6a9c3d4663286f1bec753fbd035ab1a6eb5de:/m4/getline.m4
diff --git a/m4/getline.m4 b/m4/getline.m4
new file mode 100644
index 0000000..8356a62
--- /dev/null
+++ b/m4/getline.m4
@@ -0,0 +1,31 @@
+# Copyright © 2024 Nick Bowler
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+# DX_CHECK_GETLINE
+#
+# Check whether or not the getline function is available. If it is, the macro
+# HAVE_GETLINE is defined to 1 and the cache variable dx_cv_have_getline is set
+# to "yes". Otherwise, dx_cv_have_getline is set to "no".
+AC_DEFUN([DX_CHECK_GETLINE],
+[AC_CACHE_CHECK([for getline], [dx_cv_have_getline],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include
+], [ssize_t (*x)() = getline;
+char *p = 0;
+size_t n = 0;
+return getline(&p, &n, stdin);
+])], [dx_cv_have_getline=yes], [dx_cv_have_getline=no])])
+AS_CASE([$dx_cv_have_getline], [yes],
+ [AC_DEFINE([HAVE_GETLINE], [1],
+ [Define to 1 if the getline function is available.])])])