|
From: Julian S. <js...@ac...> - 2012-03-26 18:07:48
|
Dmitry,
Do you have some examples of the false errors that this solves?
It would be good to see some examples.
> And i have questions:
> 1. Will such addition be accepted? Or there are caveats with WCHAR
> functions?
Depends on correctness, lack of bad side effects, and presence of
test cases. Especially the last one; memcheck/tests/str_tester.c
is the right place to add them.
> 2. Is mc_replace_strmem.c the correct file for such addition?
Yes
> 3. Will it be correct to use 20360 20370 20380 and 20390 for
> wcscmp/wscncmp/wsclen/wcsnlen?
> Comment in mc_replace_strmem.c say
> -- begin --
> Assignment of behavioural equivalence class tags: 2NNNP is intended
> to be reserved for Memcheck. Current usage:
>
> 20010 STRRCHR
> ...skip...
> 20350 STRCASESTR
> -- end --
Yes fine. Just don't re-use any existing numbers.
> Naive implementation for wcscmp() works under Fedora16/x64/gcc-4.6.3 (at
> least it looks so :) )
>
> #include <wchar.h>
> #define WCSCMP(soname, fnname) \
> int VG_REPLACE_FUNCTION_EZU(20360,soname,fnname) \
> ( const wchar_t* s1, const wchar_t* s2 ); \
> int VG_REPLACE_FUNCTION_EZU(20360,soname,fnname) \
> ( const wchar_t* s1, const wchar_t* s2 ) \
> { \
> register wchar_t c1; \
> register wchar_t c2; \
> while (True) { \
> c1 = *(wchar_t *)s1; \
> c2 = *(wchar_t *)s2; \
> if (c1 != c2) break; \
> if (c1 == 0) break; \
> s1++; s2++; \
> } \
> if ((wchar_t)c1 < (wchar_t)c2) return -1; \
> if ((wchar_t)c1 > (wchar_t)c2) return 1; \
> return 0; \
> }
>
> #if defined(VGO_linux)
> WCSCMP(VG_Z_LIBC_SONAME, wcscmp)
> WCSCMP(VG_Z_LIBC_SONAME, __GI_wcscmp)
> #elif defined(VGO_darwin)
> // WCSCMP(VG_Z_LIBC_SONAME, wcscmp)
> #endif
Looks OK. It's just a clone of strcmp, yes?
Do wide character comparisons involve locale stuff? That has
caused problems in the past. Or are they locale independent?
J
|