Overview
Comment: | Do not require snprintf to return expected length |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c5beed7277961ba3e919ef82956f4dab |
User & Date: | js on 2020-05-16 16:46:42 |
Other Links: | manifest | tags |
Context
2020-05-16
| ||
17:17 | Don't use %I on Windows check-in: ecca609079 user: js tags: trunk | |
16:46 | Do not require snprintf to return expected length check-in: c5beed7277 user: js tags: trunk | |
2020-05-10
| ||
15:33 | Fix building with --disable-sockets on Windows check-in: efbb4a8eb4 user: js tags: trunk | |
Changes
Modified configure.ac from [a657be6730] to [d6072003ac].
︙ | ︙ | |||
36 37 38 39 40 41 42 | OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" LDFLAGS="$LDFLAGS $flags" enable_shared="no" enable_threads="no" enable_sockets="no" enable_files="no" | < < | 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 | OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" LDFLAGS="$LDFLAGS $flags" enable_shared="no" enable_threads="no" enable_sockets="no" enable_files="no" ;; m68k-*-amigaos*) AS_IF([test x"$OBJCFLAGS" = x""], [ OBJCFLAGS="-O0" ]) OBJCFLAGS="$OBJCFLAGS -noixemul" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -noixemul" CPPFLAGS="$CPPFLAGS -D__NO_NET_API" LDFLAGS="$LDFLAGS -noixemul" enable_files="yes" # Required for reading ENV: enable_shared="no" supports_amiga_lib="yes" AS_IF([test x"$enable_amiga_lib" != x"no"], [ AC_SUBST(OBJFWRT_AMIGA_LIB, objfwrt68k.library) AC_SUBST(SFDC_TARGET, m68k-amigaos) AC_SUBST(SFD_FILE, amigaos3.sfd) AC_SUBST(SFDC_INLINE_H, inline.h) dnl For 68000, GCC emits calls to helper functions that |
︙ | ︙ | |||
826 827 828 829 830 831 832 833 | esac AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm") AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex") AC_CHECK_FUNC(asprintf, [ case "$host" in *-psp-*) | > > > > > | < < < < < < < < < < < < < < < < < < | < < < < < | 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 | esac AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm") AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex") AC_CHECK_FUNC(asprintf, [ case "$host" in *-*-mingw*) dnl asprintf from MinGW is broken on older Windows dnl versions have_asprintf="no" ;; *-psp-*) dnl asprintf is broken on the PSP have_asprintf="no" ;; *) have_asprintf="yes" AC_DEFINE(HAVE_ASPRINTF, 1, [Whether we have asprintf()]) ;; esac ], [ have_asprintf="no" ]) AC_ARG_ENABLE(unicode-tables, AS_HELP_STRING([--disable-unicode-tables], [Disable Unicode tables])) AS_IF([test x"$enable_unicode_tables" != x"no"], [ AC_DEFINE(OF_HAVE_UNICODE_TABLES, 1, [Whether to build with Unicode tables]) AC_SUBST(UNICODE_M, "unicode.m") |
︙ | ︙ |
Modified src/of_asprintf.m from [0f7da4996c] to [36d94b6a4d].
︙ | ︙ | |||
95 96 97 98 99 100 101 | } #endif #ifndef HAVE_ASPRINTF static int vasprintf(char **string, const char *format, va_list arguments) { | | | > > > > > > | | | > > > > > > > > > > > > > > > > > > > > | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | } #endif #ifndef HAVE_ASPRINTF static int vasprintf(char **string, const char *format, va_list arguments) { int expectedLength, length; va_list argumentsCopy; va_copy(argumentsCopy, arguments); expectedLength = vsnprintf(NULL, 0, format, argumentsCopy); if (expectedLength == -1) /* * We have no way to know how large it is. Let's try 64 KB and * hope. */ expectedLength = 65535; if ((*string = malloc((size_t)expectedLength + 1)) == NULL) return -1; length = vsnprintf(*string, (size_t)expectedLength + 1, format, arguments); if (length == -1 || length > expectedLength) { free(*string); *string = NULL; return -1; } /* * In case we could not determine the size, resize to the actual size * needed, but ignore any failure to do so. */ if (length < expectedLength) { char *resized; if ((resized = realloc(*string, length + 1)) != NULL) *string = resized; } return length; } static int asprintf(char **string, const char *format, ...) { int ret; va_list arguments; |
︙ | ︙ | |||
547 548 549 550 551 552 553 554 555 556 557 558 559 560 | va_arg(ctx->arguments, long double)); break; default: return false; } #ifndef HAVE_ASPRINTF_L /* * If there's no asprintf_l, we have no other choice than to * use this ugly hack to replace the locale's decimal point * back to ".". */ point = [OFLocale decimalPoint]; | > > > | 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | va_arg(ctx->arguments, long double)); break; default: return false; } #ifndef HAVE_ASPRINTF_L if (tmpLen == -1) return false; /* * If there's no asprintf_l, we have no other choice than to * use this ugly hack to replace the locale's decimal point * back to ".". */ point = [OFLocale decimalPoint]; |
︙ | ︙ |