• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

The MinGW.org Windows System Libraries


Commit MetaInfo

Revisão467402e1dab9396c4f21b894dfb2c7374a483542 (tree)
Hora2021-01-27 04:58:39
AutorKeith Marshall <keith@user...>
CommiterKeith Marshall

Mensagem de Log

Avoid proliferation of static snprintf() implementations.

Mudança Sumário

Diff

--- a/mingwrt/ChangeLog
+++ b/mingwrt/ChangeLog
@@ -1,3 +1,18 @@
1+2021-01-26 Keith Marshall <keith@users.osdn.me>
2+
3+ Avoid proliferation of static snprintf() implementations.
4+
5+ * mingwex/dlfcn.c (dlfcn_store_error_message): Do NOT use...
6+ (vsnprintf): ...this static inline function; prefer to call...
7+ (__mingw_vsnprintf): ...this extern implementation, directly.
8+
9+ * mingwex/dlfcn.c (dlfcn_strerror)
10+ * mingwex/setenv.c (__mingw_setenv)
11+ * mingwex/strerror_r.c (strerror_r): Do NOT use...
12+ (snprintf): ...this; it expands to create static clones of...
13+ (__mingw_snprintf): ...this extern implementation; prefer to call it
14+ directly, to avoid code redundancy.
15+
116 2020-08-07 Keith Marshall <keith@users.osdn.me>
217
318 Initialize MSVCRT.DLL's _pgmptr reference.
--- a/mingwrt/mingwex/dlfcn.c
+++ b/mingwrt/mingwex/dlfcn.c
@@ -6,8 +6,8 @@
66 *
77 * $Id$
88 *
9- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
10- * Copyright (C) 2014, MinGW.org Project
9+ * Written by Keith Marshall <keith@users.osdn.me>
10+ * Copyright (C) 2014, 2021, MinGW.org Project
1111 *
1212 *
1313 * Permission is hereby granted, free of charge, to any person obtaining a
@@ -91,12 +91,12 @@ static void dlfcn_store_error_message( const char *fmt, ... )
9191 int msglen;
9292 va_list argv;
9393 va_start( argv, fmt );
94- msglen = 1 + vsnprintf( NULL, 0, fmt, argv );
94+ msglen = 1 + __mingw_vsnprintf( NULL, 0, fmt, argv );
9595 if( (dlfcn_error_pending = realloc( dlfcn_error_message, msglen )) != NULL )
9696 /*
9797 * Store message, only if a buffer was successfully allocated.
9898 */
99- vsnprintf( dlfcn_error_pending, msglen, fmt, argv );
99+ __mingw_vsnprintf( dlfcn_error_pending, msglen, fmt, argv );
100100 dlfcn_error_message = dlfcn_error_pending;
101101 va_end( argv );
102102 }
@@ -132,8 +132,8 @@ static char *dlfcn_strerror( int errcode )
132132 * formatted reference to the unknown error code.
133133 */
134134 char *fmt = "Unknown error %d";
135- char tmp[1 + snprintf( NULL, 0, fmt, errcode )];
136- snprintf( tmp, sizeof( tmp ), fmt, errcode );
135+ char tmp[1 + __mingw_snprintf( NULL, 0, fmt, errcode )];
136+ __mingw_snprintf( tmp, sizeof( tmp ), fmt, errcode );
137137 text = strdup( tmp );
138138 }
139139 /* However we derived it, the error description is now available
--- a/mingwrt/mingwex/setenv.c
+++ b/mingwrt/mingwex/setenv.c
@@ -7,8 +7,8 @@
77 *
88 * $Id$
99 *
10- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
11- * Copyright (C) 2016, MinGW.org Project
10+ * Written by Keith Marshall <keith@users.osdn.me>
11+ * Copyright (C) 2016, 2021, MinGW.org Project
1212 *
1313 *
1414 * Permission is hereby granted, free of charge, to any person obtaining a
@@ -64,8 +64,8 @@ int __mingw_setenv( const char *var, const char *value, int overwrite )
6464 */
6565 const char *fmt = "%s=%s";
6666 const char *val = value ? value : "";
67- char buf[1 + snprintf( NULL, 0, fmt, var, val )];
68- snprintf( buf, sizeof( buf ), fmt, var, val );
67+ char buf[1 + __mingw_snprintf( NULL, 0, fmt, var, val )];
68+ __mingw_snprintf( buf, sizeof( buf ), fmt, var, val );
6969
7070 /* "buf" is now formatted as "var=value", in the form
7171 * required by putenv(), but it exists only within our
--- a/mingwrt/mingwex/strerror_r.c
+++ b/mingwrt/mingwex/strerror_r.c
@@ -5,8 +5,8 @@
55 *
66 * $Id$
77 *
8- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
9- * Copyright (C) 2016, 2017, MinGW.org Project
8+ * Written by Keith Marshall <keith@users.osdn.me>
9+ * Copyright (C) 2016, 2017, 2021, MinGW.org Project
1010 *
1111 *
1212 * Permission is hereby granted, free of charge, to any person obtaining a
@@ -68,13 +68,13 @@ int strerror_r( int errnum, char *buf, size_t len )
6868 * range INT_MAX < errnum <= UINT_MAX, while sys_nerr is expected
6969 * to be less than INT_MAX.
7070 */
71- snprintf( buf, len, "Unknown error: %d", errnum );
71+ __mingw_snprintf( buf, len, "Unknown error: %d", errnum );
7272 return errno = EINVAL;
7373 }
7474 /* errnum appears to be valid; copy the associated message, while
7575 * checking that its entire text is copied...
7676 */
77- if( snprintf( buf, len, "%s", strerror( errnum )) >= len )
77+ if( __mingw_snprintf( buf, len, "%s", strerror( errnum )) >= len )
7878 /*
7979 * ...otherwise, set errno on truncation.
8080 */