void __os2_finddata_cvt( FF_BUFFER *ffb, struct _finddata_t *fileinfo ) #endif #endif /******************************************************************************/ { /*** Handle the timestamps ***/ fileinfo->time_create = _d2ttime( TODDATE( ffb->fdateCreation ), TODTIME( ffb->ftimeCreation ) ); fileinfo->time_access = _d2ttime( TODDATE( ffb->fdateLastAccess ), TODTIME( ffb->ftimeLastAccess ) ); fileinfo->time_write = _d2ttime( TODDATE( ffb->fdateLastWrite ), TODTIME( ffb->ftimeLastWrite ) ); #if defined( __INT64__ ) && !defined( _M_I86 ) if( _FILEAPI64() ) { #endif fileinfo->attrib = ffb->attrFile; fileinfo->size = ffb->cbFile; #ifdef __WIDECHAR__ mbstowcs( fileinfo->name, ffb->achName, _mbslen( ffb->achName ) + 1 ); #else strcpy( fileinfo->name, ffb->achName ); #endif #if defined( __INT64__ ) && !defined( _M_I86 ) } else { fileinfo->attrib = ((FF_BUFFER_32 *)ffb)->attrFile; fileinfo->size = ((FF_BUFFER_32 *)ffb)->cbFile; #ifdef __WIDECHAR__ mbstowcs( fileinfo->name, ((FF_BUFFER_32 *)ffb)->achName, _mbslen( ((FF_BUFFER_32 *)ffb)->achName ) + 1 ); #else strcpy( fileinfo->name, ((FF_BUFFER_32 *)ffb)->achName ); #endif } #endif }
CString MeaXMLParser::Encode(const CString& src) { CString encStr; #ifdef _UNICODE for (int i = 0; i < src.GetLength(); i++) { TCHAR ch = src.GetAt(i); switch(ch) { case _T('&'): encStr += _T("&"); break; case _T('<'): encStr += _T("<"); break; case _T('>'): encStr += _T(">"); break; case _T('\''): encStr += _T("'"); break; case _T('\"'): encStr += _T("""); break; default: encStr += ch; break; } } #else const unsigned char *str = reinterpret_cast<const unsigned char*>(static_cast<LPCTSTR>(src)); const unsigned char *sptr; int len = _mbslen(str); int i; for (i = 0, sptr = str; i < len; i++, sptr = _mbsinc(sptr)) { switch(*sptr) { case _T('&'): encStr += _T("&"); break; case _T('<'): encStr += _T("<"); break; case _T('>'): encStr += _T(">"); break; case _T('\''): encStr += _T("'"); break; case _T('\"'): encStr += _T("""); break; default: encStr += *sptr; break; } } #endif return encStr; }
_WCRTLINK size_t _wstrftime_ms( CHAR_TYPE *s, size_t maxsize, const char *format, const struct tm *timeptr ) { wchar_t *auto_buf; int length; length = _mbslen( (unsigned char *)format ) + 1; auto_buf = (wchar_t *)alloca( length * CHARSIZE ); mbstowcs( auto_buf, format, length ); return( wcsftime( s, maxsize, auto_buf, timeptr ) ); }
/* * @implemented */ unsigned char * _mbsdup(const unsigned char *_s) { unsigned char *rv; if (_s == 0) return 0; rv = (unsigned char *)malloc(_mbslen(_s) + 1); if (rv == 0) return 0; _mbscpy(rv, _s); return rv; }
static HMODULE LoadLibraryMB(const char* path) { #ifdef _UNICODE int len = _mbslen((const unsigned char*)path); int siz = MultiByteToWideChar(0,0, path,len, NULL,0); TCHAR* apath = (TCHAR*)HMD_ALLOCA((siz+1) * sizeof(TCHAR)); MultiByteToWideChar(0,0, path,len, apath,siz); return AfxLoadLibrary(apath); #else return AfxLoadLibrary(path); #endif }
LPSTR CMemPool::GetDuplicateStringA(LPCSTR szSrc) { assert(szSrc); DWORD dwBytes = (_mbslen((const unsigned char*)szSrc) + 1) * sizeof(CHAR); LPSTR pString = (LPSTR)GetAlignedMemory(dwBytes, sizeof(CHAR)); if (pString) { _mbscpy_s((unsigned char*)pString, dwBytes, (const unsigned char*)szSrc); } return pString; }
_WCRTLINK CHAR_TYPE *__F_NAME(getcwd,_wgetcwd)( CHAR_TYPE *buf, size_t size ) /***************************************************************************/ { int len; #ifdef __WIDECHAR__ char cwd[MB_CUR_MAX * _MAX_PATH]; /* multi-byte chars */ #else char cwd[_MAX_PATH]; /* single-byte chars */ #endif __null_check( buf, 1 ); if( __getdcwd( &cwd[3], 0 ) ) { _RWD_errno = ENOENT; /* noent? */ return( NULL ); } /* get current drive and insert into cwd[0] */ cwd[0] = TinyGetCurrDrive() + 'A'; cwd[1] = ':'; cwd[2] = '\\'; #ifdef __WIDECHAR__ len = _mbslen( (unsigned char *)cwd ) + 1; #else len = strlen( cwd ) + 1; #endif if( buf == NULL ) { if( (buf = lib_malloc( max( size, len ) * CHARSIZE )) == NULL ) { _RWD_errno = ENOMEM; return( NULL ); } size = len; } /*** Copy the pathname into a buffer and quit ***/ #ifdef __WIDECHAR__ if( mbstowcs( buf, cwd, size ) == -1 ) { return( NULL ); } return( buf ); #else return( strncpy( buf, cwd, size ) ); #endif }
DWORD __lib_GetCurrentDirectoryW( DWORD nBufferLength, LPWSTR lpBuffer ) /**********************************************************************/ { if( WIN32_IS_NT ) { /* NT */ return( GetCurrentDirectoryW( nBufferLength, lpBuffer ) ); } else { /* Win95 or Win32s */ char * mbBuffer; BOOL osrc; size_t cvt; size_t len; /*** Allocate some memory ***/ len = _MAX_PATH*MB_CUR_MAX + 1; mbBuffer = lib_malloc( len ); if( mbBuffer == NULL ) { return( FALSE ); } /*** Call the OS ***/ osrc = GetCurrentDirectoryA( len, mbBuffer ); if( osrc == 0 ) { lib_free( mbBuffer ); return( 0 ); } /*** If buffer too small, return required size ***/ if( _mbslen( mbBuffer ) + 1 > nBufferLength ) { lib_free( mbBuffer ); return( osrc ); } /*** Convert returned info ***/ cvt = mbstowcs( lpBuffer, mbBuffer, nBufferLength ); if( cvt == (size_t)-1 ) { lib_free( mbBuffer ); return( 0 ); } return( osrc ); } }
utf8_t& operator=(const utf8_t & s){ delete [] buffer; unsigned length = _mbslen((unsigned char const *)s.buffer); buffer = new char[length + 1](); memcpy(buffer, s.buffer, length + 1); }
utf8_t(const utf8_t & s){ unsigned length = _mbslen((unsigned char const *)s.buffer); buffer = new char[length + 1](); memcpy(buffer, s.buffer, length + 1); }
int if_up(char *devname) { /* Get network adapter status from WMI using COM */ DWORD ifStatus = 0; HRESULT hres; IWbemLocator *locator=NULL; IWbemServices *services=NULL; IEnumWbemClassObject *results=NULL; BSTR resource=SysAllocString(L"ROOT\\CIMV2"); BSTR language=SysAllocString(L"WQL"); LPWSTR query_h=L"SELECT NetConnectionStatus FROM Win32_NetworkAdapter " L"WHERE NetConnectionID = "; size_t len=_mbslen(devname); size_t cont=0; /* Count how many single single quotes(') in devname for escap */ /* single quotes(') in WQL query string */ char *pc=devname; for(; pc=(char *)_mbschr(pc,'\''); pc++) { cont++; } /* Need to add two single quotes(') at begin and after devname */ WCHAR query_str[len+cont+wcslen(query_h)+3]; wcscpy(query_str,query_h); /* Add start single quote(') to query string before append devname */ wcscat(query_str,L"'"); WCHAR connid[len+1]; mbstowcs(connid,devname,len+1); WCHAR *pw, *qw=connid; for(pw=connid; pw=wcschr(pw, L'\''); pw++) { /* Escape single quotes(') in devname */ wcsncat(query_str,qw,pw-qw); wcscat(query_str,L"\\"); qw=pw; } wcscat(query_str,qw); /* Append terminal single quote(') to query string */ wcscat(query_str,L"'"); BSTR query=SysAllocString(query_str); // initialize COM hres=CoInitializeEx(0, COINIT_MULTITHREADED); if (FAILED(hres)) { log_warn("Failed to initialize COM library:0x%x\n", hres); goto cleanup; } hres=CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL); if (FAILED(hres)) { log_warn("Failed to initialize security:0x%x\n",hres); CoUninitialize(); goto cleanup; } // connect to WMI hres=CoCreateInstance(&CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (LPVOID *) &locator); if (FAILED(hres)) { log_warn("Failed to create IWbemLocator object:0x%x\n",hres); CoUninitialize(); goto cleanup; } hres=locator->lpVtbl->ConnectServer(locator, resource, NULL, NULL, NULL, 0, NULL, NULL, &services); if (FAILED(hres)) { log_warn("Could not connect:0x%x\n",hres); locator->lpVtbl->Release(locator); CoUninitialize(); goto cleanup; } // issue a WMI query hres=services->lpVtbl->ExecQuery(services, language, query, WBEM_FLAG_BIDIRECTIONAL, NULL, &results); if (FAILED(hres)) { log_warn("Query for processes failed:0x%x\n",hres); services->lpVtbl->Release(services); locator->lpVtbl->Release(locator); CoUninitialize(); goto cleanup; } // list the query results else { IWbemClassObject *result = NULL; ULONG returnedCount = 0; // enumerate the retrieved objects while((results->lpVtbl->Next(results, WBEM_INFINITE, 1, &result, &returnedCount)) == S_OK) { VARIANT status; // obtain the desired properties of the next result result->lpVtbl->Get(result, L"NetConnectionStatus", 0, &status, 0, 0); // release the current result object result->lpVtbl->Release(result); if(status.intVal==2) { ifStatus=-1; break; } } } // release WMI COM interfaces results->lpVtbl->Release(results); services->lpVtbl->Release(services); locator->lpVtbl->Release(locator); // unwind everything else we've allocated CoUninitialize(); cleanup: SysFreeString(query); SysFreeString(language); SysFreeString(resource); return ifStatus; }
// _wsetenv and setenv are implemented this way so that each can call the // other without having the other call it, which would call the other, and // so on, making bad things happen. This inter-calling is necessary to keep // the wide and MBCS environments consistent. _WCRTLINK int __F_NAME(setenv,_wsetenv)( const CHAR_TYPE *name, const CHAR_TYPE *newvalue, int overwrite ) { #if !defined( __UNIX__ ) && !defined( __RDOS__ ) && !defined( __RDOSDEV__ ) #ifdef __WIDECHAR__ char *otherName; char *otherNewval; const size_t charsize = sizeof( wchar_t ); const size_t fact = MB_CUR_MAX; #else wchar_t *otherName; wchar_t *otherNewval; const size_t charsize = MB_CUR_MAX; const size_t fact = 1; #endif size_t otherNameLen; size_t otherNewvalLen; #endif int rc; if( name == NULL || *name == NULLCHAR || __F_NAME(strchr,wcschr)( name, STRING( '=' ) ) != NULL ) { _RWD_errno = EINVAL; return( -1 ); } /*** Ensure variable is deleted if newvalue == "" ***/ #ifndef __UNIX__ if( (newvalue != NULL) && (*newvalue == NULLCHAR) ) { if( overwrite || (__F_NAME(getenv,_wgetenv)( name ) == NULL) ) { newvalue = NULL; } } #endif #ifdef __NT__ /*** Update the process environment if using Win32 ***/ if( overwrite || __F_NAME(getenv,_wgetenv)( name ) == NULL ) { if( __lib_SetEnvironmentVariable( name, newvalue ) == FALSE ) { return( -1 ); } } #elif defined( __RDOS__ ) /*** Update the process environment if using RDOS ***/ if( overwrite || __F_NAME(getenv,_wgetenv)( name ) == NULL ) { int handle; handle = RdosOpenProcessEnv(); RdosDeleteEnvVar( handle, name ); if( *newvalue != NULLCHAR ) RdosAddEnvVar( handle, name, newvalue ); RdosCloseEnv( handle ); } #elif defined( __RDOSDEV__ ) /*** Update the process environment if using RDOSDEV ***/ if( overwrite || __F_NAME(getenv,_wgetenv)( name ) == NULL ) { int handle; handle = RdosOpenSysEnv(); RdosDeleteEnvVar( handle, name ); if( *newvalue != NULLCHAR ) RdosAddEnvVar( handle, name, newvalue ); RdosCloseEnv( handle ); } #endif /*** Update the (__WIDECHAR__ ? wide : MBCS) environment ***/ #ifdef __WIDECHAR__ if( _RWD_wenviron == NULL ) { __create_wide_environment(); } #endif rc = __F_NAME(__setenv,__wsetenv)( name, newvalue, overwrite ); if( rc == -1 ) { return( -1 ); } #if !defined( __UNIX__ ) && !defined( __RDOS__ ) && !defined( __RDOSDEV__ ) /*** Update the other environment ***/ #ifndef __WIDECHAR__ if( _RWD_wenviron == NULL ) { return( 0 ); // _wenviron uninitialized } #endif #ifdef __WIDECHAR__ otherNameLen = wcslen( name ) + 1; #else otherNameLen = _mbslen( (unsigned char *)name ) + 1; #endif otherName = lib_malloc( otherNameLen * charsize ); if( otherName == NULL ) { _RWD_errno = ENOMEM; return( -1 ); } if( newvalue != NULL ) { #ifdef __WIDECHAR__ otherNewvalLen = wcslen( newvalue ) + 1; #else otherNewvalLen = _mbslen( (unsigned char *)newvalue ) + 1; #endif otherNewval = lib_malloc( otherNewvalLen * charsize ); if( otherNewval == NULL ) { lib_free( otherName ); _RWD_errno = ENOMEM; return( -1 ); } } else { otherNewval = NULL; } rc = __F_NAME(mbstowcs,wcstombs)( otherName, name, otherNameLen * fact ); if( rc != -1 ) { if( otherNewval != NULL ) { rc = __F_NAME(mbstowcs,wcstombs)( otherNewval, newvalue, otherNewvalLen * fact ); } if( rc != -1 ) { rc = __F_NAME(__wsetenv,__setenv)( otherName, otherNewval, overwrite ); } } lib_free( otherName ); lib_free( otherNewval ); if( rc == -1 ) { return( -1 ); } #endif return( 0 ); }
static void test_mbcp(void) { int mb_orig_max = *p__mb_cur_max; int curr_mbcp = _getmbcp(); unsigned char *mbstring = (unsigned char *)"\xb0\xb1\xb2 \xb3\xb4 \xb5"; /* incorrect string */ unsigned char *mbstring2 = (unsigned char *)"\xb0\xb1\xb2\xb3Q\xb4\xb5"; /* correct string */ unsigned char *mbsonlylead = (unsigned char *)"\xb0\0\xb1\xb2 \xb3"; unsigned char buf[16]; int step; /* _mbtype tests */ /* An SBCS codepage test. The ctype of characters on e.g. CP1252 or CP1250 differs slightly * between versions of Windows. Also Windows 9x seems to ignore the codepage and always uses * CP1252 (or the ACP?) so we test only a few ASCII characters */ _setmbcp(1252); expect_eq(p_mbctype[10], 0, char, "%x"); expect_eq(p_mbctype[50], 0, char, "%x"); expect_eq(p_mbctype[66], _SBUP, char, "%x"); expect_eq(p_mbctype[100], _SBLOW, char, "%x"); expect_eq(p_mbctype[128], 0, char, "%x"); _setmbcp(1250); expect_eq(p_mbctype[10], 0, char, "%x"); expect_eq(p_mbctype[50], 0, char, "%x"); expect_eq(p_mbctype[66], _SBUP, char, "%x"); expect_eq(p_mbctype[100], _SBLOW, char, "%x"); expect_eq(p_mbctype[128], 0, char, "%x"); /* double byte code pages */ test_codepage(932); test_codepage(936); test_codepage(949); test_codepage(950); _setmbcp(936); ok(*p__mb_cur_max == mb_orig_max, "__mb_cur_max shouldn't be updated (is %d != %d)\n", *p__mb_cur_max, mb_orig_max); ok(_ismbblead('\354'), "\354 should be a lead byte\n"); ok(_ismbblead(' ') == FALSE, "' ' should not be a lead byte\n"); ok(_ismbblead(0x1234b0), "0x1234b0 should not be a lead byte\n"); ok(_ismbblead(0x123420) == FALSE, "0x123420 should not be a lead byte\n"); ok(_ismbbtrail('\xb0'), "\xa0 should be a trail byte\n"); ok(_ismbbtrail(' ') == FALSE, "' ' should not be a trail byte\n"); /* _ismbslead */ expect_eq(_ismbslead(mbstring, &mbstring[0]), -1, int, "%d"); expect_eq(_ismbslead(mbstring, &mbstring[1]), FALSE, int, "%d"); expect_eq(_ismbslead(mbstring, &mbstring[2]), -1, int, "%d"); expect_eq(_ismbslead(mbstring, &mbstring[3]), FALSE, int, "%d"); expect_eq(_ismbslead(mbstring, &mbstring[4]), -1, int, "%d"); expect_eq(_ismbslead(mbstring, &mbstring[5]), FALSE, int, "%d"); expect_eq(_ismbslead(mbstring, &mbstring[6]), FALSE, int, "%d"); expect_eq(_ismbslead(mbstring, &mbstring[7]), -1, int, "%d"); expect_eq(_ismbslead(mbstring, &mbstring[8]), FALSE, int, "%d"); expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[0]), -1, int, "%d"); expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[1]), FALSE, int, "%d"); expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[2]), FALSE, int, "%d"); expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d"); /* _ismbstrail */ expect_eq(_ismbstrail(mbstring, &mbstring[0]), FALSE, int, "%d"); expect_eq(_ismbstrail(mbstring, &mbstring[1]), -1, int, "%d"); expect_eq(_ismbstrail(mbstring, &mbstring[2]), FALSE, int, "%d"); expect_eq(_ismbstrail(mbstring, &mbstring[3]), -1, int, "%d"); expect_eq(_ismbstrail(mbstring, &mbstring[4]), FALSE, int, "%d"); expect_eq(_ismbstrail(mbstring, &mbstring[5]), -1, int, "%d"); expect_eq(_ismbstrail(mbstring, &mbstring[6]), FALSE, int, "%d"); expect_eq(_ismbstrail(mbstring, &mbstring[7]), FALSE, int, "%d"); expect_eq(_ismbstrail(mbstring, &mbstring[8]), -1, int, "%d"); expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[0]), FALSE, int, "%d"); expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[1]), -1, int, "%d"); expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[2]), FALSE, int, "%d"); expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[3]), FALSE, int, "%d"); expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[4]), FALSE, int, "%d"); expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d"); /* _mbsbtype */ expect_eq(_mbsbtype(mbstring, 0), _MBC_LEAD, int, "%d"); expect_eq(_mbsbtype(mbstring, 1), _MBC_TRAIL, int, "%d"); expect_eq(_mbsbtype(mbstring, 2), _MBC_LEAD, int, "%d"); expect_eq(_mbsbtype(mbstring, 3), _MBC_ILLEGAL, int, "%d"); expect_eq(_mbsbtype(mbstring, 4), _MBC_LEAD, int, "%d"); expect_eq(_mbsbtype(mbstring, 5), _MBC_TRAIL, int, "%d"); expect_eq(_mbsbtype(mbstring, 6), _MBC_SINGLE, int, "%d"); expect_eq(_mbsbtype(mbstring, 7), _MBC_LEAD, int, "%d"); expect_eq(_mbsbtype(mbstring, 8), _MBC_ILLEGAL, int, "%d"); expect_eq(_mbsbtype(mbsonlylead, 0), _MBC_LEAD, int, "%d"); expect_eq(_mbsbtype(mbsonlylead, 1), _MBC_ILLEGAL, int, "%d"); expect_eq(_mbsbtype(mbsonlylead, 2), _MBC_ILLEGAL, int, "%d"); expect_eq(_mbsbtype(mbsonlylead, 3), _MBC_ILLEGAL, int, "%d"); expect_eq(_mbsbtype(mbsonlylead, 4), _MBC_ILLEGAL, int, "%d"); expect_eq(_mbsbtype(mbsonlylead, 5), _MBC_ILLEGAL, int, "%d"); /* _mbsnextc */ expect_eq(_mbsnextc(mbstring), 0xb0b1, int, "%x"); expect_eq(_mbsnextc(&mbstring[2]), 0xb220, int, "%x"); /* lead + invalid tail */ expect_eq(_mbsnextc(&mbstring[3]), 0x20, int, "%x"); /* single char */ /* _mbclen/_mbslen */ expect_eq(_mbclen(mbstring), 2, int, "%d"); expect_eq(_mbclen(&mbstring[2]), 2, int, "%d"); expect_eq(_mbclen(&mbstring[3]), 1, int, "%d"); expect_eq(_mbslen(mbstring2), 4, int, "%d"); expect_eq(_mbslen(mbsonlylead), 0, int, "%d"); /* lead + NUL not counted as character */ expect_eq(_mbslen(mbstring), 4, int, "%d"); /* lead + invalid trail counted */ /* _mbccpy/_mbsncpy */ memset(buf, 0xff, sizeof(buf)); _mbccpy(buf, mbstring); expect_bin(buf, "\xb0\xb1\xff", 3); memset(buf, 0xff, sizeof(buf)); _mbsncpy(buf, mbstring, 1); expect_bin(buf, "\xb0\xb1\xff", 3); memset(buf, 0xff, sizeof(buf)); _mbsncpy(buf, mbstring, 2); expect_bin(buf, "\xb0\xb1\xb2 \xff", 5); memset(buf, 0xff, sizeof(buf)); _mbsncpy(buf, mbstring, 3); expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4\xff", 7); memset(buf, 0xff, sizeof(buf)); _mbsncpy(buf, mbstring, 4); expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4 \xff", 8); memset(buf, 0xff, sizeof(buf)); _mbsncpy(buf, mbstring, 5); expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4 \0\0\xff", 10); memset(buf, 0xff, sizeof(buf)); _mbsncpy(buf, mbsonlylead, 6); expect_bin(buf, "\0\0\0\0\0\0\0\xff", 8); memset(buf, 0xff, sizeof(buf)); _mbsnbcpy(buf, mbstring2, 2); expect_bin(buf, "\xb0\xb1\xff", 3); _mbsnbcpy(buf, mbstring2, 3); expect_bin(buf, "\xb0\xb1\0\xff", 4); _mbsnbcpy(buf, mbstring2, 4); expect_bin(buf, "\xb0\xb1\xb2\xb3\xff", 5); memset(buf, 0xff, sizeof(buf)); _mbsnbcpy(buf, mbsonlylead, 5); expect_bin(buf, "\0\0\0\0\0\xff", 6); /* _mbsinc/mbsdec */ step = _mbsinc(mbstring) - mbstring; ok(step == 2, "_mbsinc adds %d (exp. 2)\n", step); step = _mbsinc(&mbstring[2]) - &mbstring[2]; /* lead + invalid tail */ ok(step == 2, "_mbsinc adds %d (exp. 2)\n", step); step = _mbsninc(mbsonlylead, 1) - mbsonlylead; ok(step == 0, "_mbsninc adds %d (exp. 0)\n", step); step = _mbsninc(mbsonlylead, 2) - mbsonlylead; /* lead + NUL byte + lead + char */ ok(step == 0, "_mbsninc adds %d (exp. 0)\n", step); step = _mbsninc(mbstring2, 0) - mbstring2; ok(step == 0, "_mbsninc adds %d (exp. 2)\n", step); step = _mbsninc(mbstring2, 1) - mbstring2; ok(step == 2, "_mbsninc adds %d (exp. 2)\n", step); step = _mbsninc(mbstring2, 2) - mbstring2; ok(step == 4, "_mbsninc adds %d (exp. 4)\n", step); step = _mbsninc(mbstring2, 3) - mbstring2; ok(step == 5, "_mbsninc adds %d (exp. 5)\n", step); step = _mbsninc(mbstring2, 4) - mbstring2; ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step); step = _mbsninc(mbstring2, 5) - mbstring2; ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step); step = _mbsninc(mbstring2, 17) - mbstring2; ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step); /* functions that depend on locale codepage, not mbcp. * we hope the current locale to be SBCS because setlocale(LC_ALL, ".1252") seems not to work yet * (as of Wine 0.9.43) */ if (*p__mb_cur_max == 1) { expect_eq(mblen((char *)mbstring, 3), 1, int, "%x"); expect_eq(_mbstrlen((char *)mbstring2), 7, int, "%d"); }