+2016-05-12 Keith Marshall <keithmarshall@users.sourceforge.net>
+
+ Resolve some strnlen() implementation issues.
+
+ * mingwex/strnlen.s (__mingw_strnlen) [!NUL]: Correct termination
+ logic; should have used jnz, not jz, to skip endpoint adjustment on
+ scanning past a terminal NUL character code.
+
+ * include/string.h [_POSIX_C_SOURCE >= 200809L] (strnlen): Do not
+ #define it, as this breaks GCC compilation; use __CRT_ALIAS instead,
+ with __JMPSTUB__ referencing via "oldname" libraries.
+
+ * Makefile.in (jmpstub_awk_script, libimpl_awk_script): Adapt to
+ facilitate assignment of __JMPSTUB__ and __LIBIMPL__ references to
+ libraries other than libmingwex.a
+ (strnlen.jmpstub.$OBJEXT): Assign it to all "moldname" libraries prior
+ to libmoldname80.a, in addition to libcoldname.a, as specified by the
+ __JMPSTUB__ assignment within <string.h>
+
2016-05-03 Keith Marshall <keithmarshall@users.sourceforge.net>
Enforce consistent specification of package version.
$(foreach name,coldname $(all_moldname),lib$(name).a): $(addsuffix .$(OBJEXT), \
isascii iscsym iscsymf toascii)
+# Selected versions of the oldname libraries also provide a
+# convenient vehicle for delivery of stubs, emulating functions
+# which appear in later MSVCRT versions, and which we also wish
+# to support in conjunction with earlier versions.
+#
+$(foreach name,moldname $(addprefix moldname,70 71),lib$(name).a) \
+$(foreach name,moldname $(addprefix moldname,70 71),lib$(name)d.a): \
+ strnlen.jmpstub.$(OBJEXT)
+
coldname.def: %.def: ${mingwrt_srcdir}/moldname.def.in
$(CC) -C -E -P -D__FILENAME__=$@ -D__CRTDLL__ -xc-header $< > $@
fmt = "\nlib%s.a: %s\n%s: jmpstub.sx\n\t$$(COMPILE.sx) %s -o $$@ $$^\n"; \
} \
/__JMPSTUB(__)? *[(].*FUNCTION/ { \
- LIB = "mingwex"; \
FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
+ LIB = match( $$0, ".*[ ,(:]LIB *= *"symbol, altlib ) ? altlib[1] : "mingwex"; \
OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".jmpstub.$$(OBJEXT)"; \
OBJNAME_CFLAGS = "-D FUNCTION="FUNCTION; \
if( match( $$0, ".*[ ,(:]REMAPPED *= *"symbol, alias ) ) \
fmt = "\nlib%s.a: %s\n%s.libimpl: %s\n"; \
} \
/__LIBIMPL(__)? *[(].*FUNCTION/ { \
- LIB = "mingwex"; \
FUNCTION = gensub( ".*[ ,(:]FUNCTION *= *"symbol".*", "\\1", 1 ); \
+ LIB = match( $$0, ".*[ ,(:]LIB *= *"symbol, altlib ) ? altlib[1] : "mingwex"; \
OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".libimpl.$$(OBJEXT)"; \
printf fmt, LIB, OBJNAME, FUNCTION, FILENAME; \
} \
* the GCC breakage noted above. (Note that we implement strnlen() with
* the alternative external name, __mingw_strnlen() in libmingwex.a, to
* avoid possible link time collision with MSVCR80.DLL's implementation,
- * then map this to strnlen() via a preprocessor define, so that users
- * may use it conventionally, (including taking its address); this may
- * interfere with C++ namespace qualification, but since strnlen() is
- * not a standard C++ function, we do not anticipate any consequent
- * usage issues).
+ * then map this to strnlen() via a __CRT_ALIAS, with stubs designated
+ * for linking from within the appropriate oldname libraries.
*/
-#define strnlen __mingw_strnlen
extern size_t __mingw_strnlen (const char *, size_t);
+__JMPSTUB__(( LIB=coldname; FUNCTION=strnlen ))
+__CRT_ALIAS size_t strnlen (const char *__text, size_t __maxlen)
+{ return __mingw_strnlen (__text, __maxlen); }
+
#endif /* _POSIX_C_SOURCE >= 200809L */
#undef __STRING_H_SOURCED__
movl %edx, %edi /* using this as the scan pointer ... */
repne scasb /* as required by this CPU scan */
mov %edi, %eax /* note where we stopped ... */
- jz .L3 /* but if we found NUL, we've overrun ... */
- decl %eax /* so we need to adjust one byte backward */
+ jnz .L3 /* no NUL found; count is complete ... */
+ decl %eax /* NUL found and counted; discount it */
.L3:
sub %edx, %eax /* compute effective count to return */
.L4: