Open mikkoi opened 5 years ago
Should we?
Diff:
198,203d197 < #ifdef HAVE_ASPRINTF < #undef HAVE_ASPRINTF < #endif /* defined(HAVE_ASPRINTF) */ < #ifdef HAVE_VASPRINTF < #undef HAVE_VASPRINTF < #endif /* defined(HAVE_VASPRINTF) */ 210,215d203 < #ifdef asprintf < #undef asprintf < #endif /* defined(asprintf) */ < #ifdef vasprintf < #undef vasprintf < #endif /* defined(vasprintf) */ 274,275d261 < #define asprintf rpl_asprintf < #define vasprintf rpl_vasprintf 278c264 < #if !HAVE_SNPRINTF || !HAVE_VSNPRINTF || !HAVE_ASPRINTF || !HAVE_VASPRINTF --- > #if !HAVE_SNPRINTF || !HAVE_VSNPRINTF 296,319d281 < #if !HAVE_VASPRINTF < #if HAVE_STDLIB_H < #include <stdlib.h> /* For malloc(3). */ < #endif /* HAVE_STDLIB_H */ < #ifdef VA_COPY < #undef VA_COPY < #endif /* defined(VA_COPY) */ < #ifdef VA_END_COPY < #undef VA_END_COPY < #endif /* defined(VA_END_COPY) */ < #if HAVE_VA_COPY < #define VA_COPY(dest, src) va_copy(dest, src) < #define VA_END_COPY(ap) va_end(ap) < #elif HAVE___VA_COPY < #define VA_COPY(dest, src) __va_copy(dest, src) < #define VA_END_COPY(ap) va_end(ap) < #else < #define VA_COPY(dest, src) (void)mymemcpy(&dest, &src, sizeof(va_list)) < #define VA_END_COPY(ap) /* No-op. */ < #define NEED_MYMEMCPY 1 < static void *mymemcpy(void *, void *, size_t); < #endif /* HAVE_VA_COPY */ < #endif /* !HAVE_VASPRINTF */ < 364c326 < #if HAVE_UINTMAX_T || defined(uintmax_t) --- > #if defined(HAVE_UINTMAX_T) || defined(uintmax_t) 397c359 < #if HAVE_INTMAX_T || defined(intmax_t) --- > #if defined(HAVE_INTMAX_T) || defined(intmax_t) 406c368 < #if HAVE_UINTPTR_T || defined(uintptr_t) --- > #if defined(HAVE_UINTPTR_T) || defined(uintptr_t) 415c377 < #if HAVE_PTRDIFF_T || defined(ptrdiff_t) --- > #if defined(HAVE_PTRDIFF_T) || defined(ptrdiff_t) 482c444 < #define PRINT_C_LLONG 4 --- > /*#define PRINT_C_LLONG 4 */ 536a499 > /* Disabling, as long long is not supported in C90. 537a501 > */ 670c634,635 < if (ch == 'l') { /* It's a long long. */ --- > /* > if (ch == 'l') } 673c638 < } else --- > } else */ 691a657,659 > default: > /* Lenght modifier is invalid */ > break; 709a678 > /* 712a682 > */ 754a725 > /* 757a729 > */ 842c814 < if ((strvalue = va_arg(args, void *)) == NULL) --- > if ((strvalue = (const char *)va_arg(args, void *)) == NULL) 875a848 > /* 879a853 > */ 915a890,892 > default: > /* This is an invalid state, should not get here */ > break; 1009a987,989 > default: > /* Invalid base */ > break; 1472,1502d1451 < #if !HAVE_VASPRINTF < #if NEED_MYMEMCPY < void * < mymemcpy(void *dst, void *src, size_t len) < { < const char *from = src; < char *to = dst; < < /* No need for optimization, we use this only to replace va_copy(3). */ < while (len-- > 0) < *to++ = *from++; < return dst; < } < #endif /* NEED_MYMEMCPY */ < < int < rpl_vasprintf(char **ret, const char *format, va_list ap) < { < size_t size; < int len; < va_list aq; < < VA_COPY(aq, ap); < len = vsnprintf(NULL, 0, format, aq); < VA_END_COPY(aq); < if (len < 0 || (*ret = malloc(size = len + 1)) == NULL) < return -1; < return vsnprintf(*ret, size, format, ap); < } < #endif /* !HAVE_VASPRINTF */ < 1530,1553d1478 < #if !HAVE_ASPRINTF < #if HAVE_STDARG_H < int < rpl_asprintf(char **ret, const char *format, ...) < #else < int < rpl_asprintf(va_alist) va_dcl < #endif /* HAVE_STDARG_H */ < { < #if !HAVE_STDARG_H < char **ret; < char *format; < #endif /* HAVE_STDARG_H */ < va_list ap; < int len; < < VA_START(ap, format); < VA_SHIFT(ap, ret, char **); < VA_SHIFT(ap, format, const char *); < len = vasprintf(ret, format, ap); < va_end(ap); < return len; < } < #endif /* !HAVE_ASPRINTF */ 1556c1481 < #endif /* !HAVE_SNPRINTF || !HAVE_VSNPRINTF || !HAVE_ASPRINTF || [...] */ --- > #endif /* !HAVE_SNPRINTF || !HAVE_VSNPRINTF*/
Probably no harm in doing so. This would not be high priority. Seems like a little cleanup and support for asprint(). I do not think we need that support currently.
Should we?
Diff: