summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-05-30 18:08:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-05-30 18:08:31 -0700
commit2364f7d445f7fd21695c0c651b1b80a581602980 (patch)
treec9e356ae8595260e7a589bed8e23a3626df4906f /configure
parent1f54ad5cc1d384d0818a6bf6cec20a95ecc5a5ae (diff)
downloadtxr-2364f7d445f7fd21695c0c651b1b80a581602980.tar.gz
txr-2364f7d445f7fd21695c0c651b1b80a581602980.tar.bz2
txr-2364f7d445f7fd21695c0c651b1b80a581602980.zip
streams: maintain integer format string detector.
* configure: provide LONGLONG_TYPE and INTPTR_TYPE macros in config.h that expand to a string literal capturing the original tokens of the type that was probed. * stream.c (struct fmt): Removed size member, replaced with type string. We can match format strings to the textual type, which will work even if we cannot compile that type. So that is to say, for instance the "%I64d" entry in the table is associated with "int64", whereas an expression like sizeof (int64) won't compile where that type doesn't exist. (fmt_tab): Replace sizes with type names. Also fix an issue: %llx was replicated in three rows of the table. (detect_format_string): Determine the textual type of cnum. It is a typedef for intptr_t, and the new INPTR_TYPE macro gives the tokens that were used to typedef intptr_t. If INTPTR_TYPE happens to be "longlong_t", we use LONGLONG_TYPE in its place. Then using the determined type, we can search the table for an appropriate entry: one which matches the type and whose conversion specifier works. Also, we now test all four conversion specifiers rather than assuming that if the decimal one is okay, the others work. Plus, if a working format string is not found, we now abort.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure2
1 files changed, 2 insertions, 0 deletions
diff --git a/configure b/configure
index 57c66094..f22de6b9 100755
--- a/configure
+++ b/configure
@@ -1205,6 +1205,7 @@ done
if [ -n "$longlong" ] ; then
printf '"%s"\n' "$longlong"
printf "#define HAVE_LONGLONG_T 1\n" >> config.h
+ printf "#define LONGLONG_TYPE \"%s\"\n" "$longlong" >> config.h
printf "typedef $longlong longlong_t;\n" >> config.h
else
printf "none\n"
@@ -1411,6 +1412,7 @@ fi
printf '"%s"\n' "$intptr"
printf "typedef $intptr int_ptr_t;\n" >> config.h
printf "typedef unsigned $intptr uint_ptr_t;\n" >> config.h
+printf "#define INTPTR_TYPE \"%s\"\n" "$intptr" >> config.h
intptr_max_expr="((((convert(int_ptr_t, 1) << $((SIZEOF_PTR * SIZEOF_BYTE - 2))) - 1) << 1) + 1)"
printf "#define INT_PTR_MAX %s\n" "$intptr_max_expr" >> config.h
printf "#define INT_PTR_MIN (-INT_PTR_MAX-1)\n" >> config.h