+2021-01-26 Keith Marshall <keith@users.osdn.me>
+
+ Avoid proliferation of static snprintf() implementations.
+
+ * mingwex/dlfcn.c (dlfcn_store_error_message): Do NOT use...
+ (vsnprintf): ...this static inline function; prefer to call...
+ (__mingw_vsnprintf): ...this extern implementation, directly.
+
+ * mingwex/dlfcn.c (dlfcn_strerror)
+ * mingwex/setenv.c (__mingw_setenv)
+ * mingwex/strerror_r.c (strerror_r): Do NOT use...
+ (snprintf): ...this; it expands to create static clones of...
+ (__mingw_snprintf): ...this extern implementation; prefer to call it
+ directly, to avoid code redundancy.
+
2020-08-07 Keith Marshall <keith@users.osdn.me>
Initialize MSVCRT.DLL's _pgmptr reference.
*
* $Id$
*
- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2014, MinGW.org Project
+ * Written by Keith Marshall <keith@users.osdn.me>
+ * Copyright (C) 2014, 2021, MinGW.org Project
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
int msglen;
va_list argv;
va_start( argv, fmt );
- msglen = 1 + vsnprintf( NULL, 0, fmt, argv );
+ msglen = 1 + __mingw_vsnprintf( NULL, 0, fmt, argv );
if( (dlfcn_error_pending = realloc( dlfcn_error_message, msglen )) != NULL )
/*
* Store message, only if a buffer was successfully allocated.
*/
- vsnprintf( dlfcn_error_pending, msglen, fmt, argv );
+ __mingw_vsnprintf( dlfcn_error_pending, msglen, fmt, argv );
dlfcn_error_message = dlfcn_error_pending;
va_end( argv );
}
* formatted reference to the unknown error code.
*/
char *fmt = "Unknown error %d";
- char tmp[1 + snprintf( NULL, 0, fmt, errcode )];
- snprintf( tmp, sizeof( tmp ), fmt, errcode );
+ char tmp[1 + __mingw_snprintf( NULL, 0, fmt, errcode )];
+ __mingw_snprintf( tmp, sizeof( tmp ), fmt, errcode );
text = strdup( tmp );
}
/* However we derived it, the error description is now available
*
* $Id$
*
- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2016, MinGW.org Project
+ * Written by Keith Marshall <keith@users.osdn.me>
+ * Copyright (C) 2016, 2021, MinGW.org Project
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
*/
const char *fmt = "%s=%s";
const char *val = value ? value : "";
- char buf[1 + snprintf( NULL, 0, fmt, var, val )];
- snprintf( buf, sizeof( buf ), fmt, var, val );
+ char buf[1 + __mingw_snprintf( NULL, 0, fmt, var, val )];
+ __mingw_snprintf( buf, sizeof( buf ), fmt, var, val );
/* "buf" is now formatted as "var=value", in the form
* required by putenv(), but it exists only within our
*
* $Id$
*
- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2016, 2017, MinGW.org Project
+ * Written by Keith Marshall <keith@users.osdn.me>
+ * Copyright (C) 2016, 2017, 2021, MinGW.org Project
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* range INT_MAX < errnum <= UINT_MAX, while sys_nerr is expected
* to be less than INT_MAX.
*/
- snprintf( buf, len, "Unknown error: %d", errnum );
+ __mingw_snprintf( buf, len, "Unknown error: %d", errnum );
return errno = EINVAL;
}
/* errnum appears to be valid; copy the associated message, while
* checking that its entire text is copied...
*/
- if( snprintf( buf, len, "%s", strerror( errnum )) >= len )
+ if( __mingw_snprintf( buf, len, "%s", strerror( errnum )) >= len )
/*
* ...otherwise, set errno on truncation.
*/