diff --git a/m-core.h b/m-core.h index 3584a3f2..52658637 100644 --- a/m-core.h +++ b/m-core.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -44,6 +43,15 @@ # include #endif +/* By default, always use stdarg. Can be turned off in specific environement if needed + by defining M_USE_STDARG to 0 */ +#ifndef M_USE_STDARG +# define M_USE_STDARG 1 +#endif +#if M_USE_STDARG +# include +#endif + /***************************************************************/ /************************ Compiler Macro ***********************/ @@ -2054,6 +2062,8 @@ M_PARSE_DEFAULT_TYPE_DEF(m_core_parse_ldouble, long double, strtold, ) #endif +#if M_USE_STDARG + /* Define the allocation of the temporary string used by M_CSTR Default is 256 bytes (so 255 characters excluding the final null char). It can be overriden by users if needed. @@ -2123,6 +2133,8 @@ m_core_snprintf(char *str, size_t size, const char *format, ...) #endif +#endif // Have stdarg + /************************************************************/ /********************* HASH selection ***********************/ diff --git a/m-string.h b/m-string.h index 4a0b226f..19ac40d5 100644 --- a/m-string.h +++ b/m-string.h @@ -26,11 +26,6 @@ #ifndef MSTARLIB_STRING_H #define MSTARLIB_STRING_H -#include -#include -#include -#include - #include "m-core.h" M_BEGIN_PROTECTED_CODE @@ -909,6 +904,8 @@ string_replace_all (string_t v, const string_t str1, const string_t str2) } } +#if M_USE_STDARG + /* Format in the string the given printf format */ static inline int string_vprintf (string_t v, const char format[], va_list args) @@ -989,6 +986,10 @@ string_cat_printf (string_t v, const char format[], ...) return size; } +#endif // Have stdarg + +#if M_USE_STDIO + /* Get a line/pureline/file from the FILE and store it in the string */ static inline bool string_fgets(string_t v, FILE *f, string_fgets_t arg) @@ -1099,6 +1100,8 @@ string_fputs(FILE *f, const string_t v) return fputs(string_get_cstr(v), f) >= 0; } +#endif // Have stdio + /* Test if the string starts with the given C string */ static inline bool string_start_with_str_p(const string_t v, const char str[]) @@ -1260,6 +1263,8 @@ string_get_str(string_t v, const string_t v2, bool append) STRINGI_CONTRACT (v); } +#if M_USE_STDIO + /* Transform the string 'v2' into a formatted string and output it in the given FILE */ static inline void @@ -1343,6 +1348,8 @@ string_in_str(string_t v, FILE *f) return c == '"'; } +#endif // Have stdio + /* Read the formatted string from the C string and set the converted value in the string 'v'. Return true in case of success