Moved 16-bit string functions to user16.c and kbd16.c.
This commit is contained in:
parent
7ea69cc7ea
commit
89b0f3ae6e
|
@ -85,6 +85,23 @@ VOID WINAPI KEYBOARD_Disable(VOID)
|
|||
pKeyStateTable = NULL;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiToOem (KEYBOARD.5)
|
||||
*/
|
||||
INT16 WINAPI AnsiToOem16( LPCSTR s, LPSTR d )
|
||||
{
|
||||
CharToOemA( s, d );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* OemToAnsi (KEYBOARD.6)
|
||||
*/
|
||||
INT16 WINAPI OemToAnsi16( LPCSTR s, LPSTR d )
|
||||
{
|
||||
OemToCharA( s, d );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* SetSpeed (KEYBOARD.7)
|
||||
|
@ -153,6 +170,22 @@ INT16 WINAPI GetKeyNameText16(LONG lParam, LPSTR lpBuffer, INT16 nSize)
|
|||
return GetKeyNameTextA( lParam, lpBuffer, nSize );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiToOemBuff (KEYBOARD.134)
|
||||
*/
|
||||
void WINAPI AnsiToOemBuff16( LPCSTR s, LPSTR d, UINT16 len )
|
||||
{
|
||||
if (len != 0) CharToOemBuffA( s, d, len );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* OemToAnsiBuff (KEYBOARD.135)
|
||||
*/
|
||||
void WINAPI OemToAnsiBuff16( LPCSTR s, LPSTR d, UINT16 len )
|
||||
{
|
||||
if (len != 0) OemToCharBuffA( s, d, len );
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* ToAscii (KEYBOARD.4)
|
||||
*
|
||||
|
|
311
dlls/user/lstr.c
311
dlls/user/lstr.c
|
@ -31,13 +31,11 @@
|
|||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "winerror.h"
|
||||
|
||||
#include "wine/exception.h"
|
||||
#include "wine/unicode.h"
|
||||
#include "wine/winbase16.h"
|
||||
#include "wine/winuser16.h"
|
||||
|
||||
#include "excpt.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
@ -53,123 +51,6 @@ static WINE_EXCEPTION_FILTER(page_fault)
|
|||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiToOem (KEYBOARD.5)
|
||||
*/
|
||||
INT16 WINAPI AnsiToOem16( LPCSTR s, LPSTR d )
|
||||
{
|
||||
CharToOemA( s, d );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* OemToAnsi (KEYBOARD.6)
|
||||
*/
|
||||
INT16 WINAPI OemToAnsi16( LPCSTR s, LPSTR d )
|
||||
{
|
||||
OemToCharA( s, d );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiToOemBuff (KEYBOARD.134)
|
||||
*/
|
||||
void WINAPI AnsiToOemBuff16( LPCSTR s, LPSTR d, UINT16 len )
|
||||
{
|
||||
if (len != 0) CharToOemBuffA( s, d, len );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* OemToAnsiBuff (KEYBOARD.135)
|
||||
*/
|
||||
void WINAPI OemToAnsiBuff16( LPCSTR s, LPSTR d, UINT16 len )
|
||||
{
|
||||
if (len != 0) OemToCharBuffA( s, d, len );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* lstrcmp (USER.430)
|
||||
*/
|
||||
INT16 WINAPI lstrcmp16( LPCSTR str1, LPCSTR str2 )
|
||||
{
|
||||
return (INT16)strcmp( str1, str2 );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiUpper (USER.431)
|
||||
*/
|
||||
SEGPTR WINAPI AnsiUpper16( SEGPTR strOrChar )
|
||||
{
|
||||
/* uppercase only one char if strOrChar < 0x10000 */
|
||||
if (HIWORD(strOrChar))
|
||||
{
|
||||
CharUpperA( MapSL(strOrChar) );
|
||||
return strOrChar;
|
||||
}
|
||||
else return (SEGPTR)CharUpperA( (LPSTR)strOrChar );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiLower (USER.432)
|
||||
*/
|
||||
SEGPTR WINAPI AnsiLower16( SEGPTR strOrChar )
|
||||
{
|
||||
/* lowercase only one char if strOrChar < 0x10000 */
|
||||
if (HIWORD(strOrChar))
|
||||
{
|
||||
CharLowerA( MapSL(strOrChar) );
|
||||
return strOrChar;
|
||||
}
|
||||
else return (SEGPTR)CharLowerA( (LPSTR)strOrChar );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiUpperBuff (USER.437)
|
||||
*/
|
||||
UINT16 WINAPI AnsiUpperBuff16( LPSTR str, UINT16 len )
|
||||
{
|
||||
CharUpperBuffA( str, len ? len : 65536 );
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiLowerBuff (USER.438)
|
||||
*/
|
||||
UINT16 WINAPI AnsiLowerBuff16( LPSTR str, UINT16 len )
|
||||
{
|
||||
CharLowerBuffA( str, len ? len : 65536 );
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiNext (USER.472)
|
||||
*/
|
||||
SEGPTR WINAPI AnsiNext16(SEGPTR current)
|
||||
{
|
||||
char *ptr = MapSL(current);
|
||||
return current + (CharNextA(ptr) - ptr);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiPrev (USER.473)
|
||||
*/
|
||||
SEGPTR WINAPI AnsiPrev16( LPCSTR start, SEGPTR current )
|
||||
{
|
||||
char *ptr = MapSL(current);
|
||||
return current - (ptr - CharPrevA( start, ptr ));
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CharNextA (USER32.@)
|
||||
*/
|
||||
|
@ -585,193 +466,3 @@ BOOL WINAPI IsCharAlphaW(WCHAR x)
|
|||
{
|
||||
return (get_char_typeW(x) & C1_ALPHA) != 0;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* FormatMessage (USER.606)
|
||||
*/
|
||||
DWORD WINAPI FormatMessage16(
|
||||
DWORD dwFlags,
|
||||
SEGPTR lpSource, /* [in] NOTE: not always a valid pointer */
|
||||
WORD dwMessageId,
|
||||
WORD dwLanguageId,
|
||||
LPSTR lpBuffer, /* [out] NOTE: *((HLOCAL16*)) for FORMAT_MESSAGE_ALLOCATE_BUFFER*/
|
||||
WORD nSize,
|
||||
LPDWORD args /* [in] NOTE: va_list *args */
|
||||
) {
|
||||
#ifdef __i386__
|
||||
/* This implementation is completely dependent on the format of the va_list on x86 CPUs */
|
||||
LPSTR target,t;
|
||||
DWORD talloced;
|
||||
LPSTR from,f;
|
||||
DWORD width = dwFlags & FORMAT_MESSAGE_MAX_WIDTH_MASK;
|
||||
BOOL eos = FALSE;
|
||||
LPSTR allocstring = NULL;
|
||||
|
||||
TRACE("(0x%lx,%lx,%d,0x%x,%p,%d,%p)\n",
|
||||
dwFlags,lpSource,dwMessageId,dwLanguageId,lpBuffer,nSize,args);
|
||||
if ((dwFlags & FORMAT_MESSAGE_FROM_SYSTEM)
|
||||
&& (dwFlags & FORMAT_MESSAGE_FROM_HMODULE)) return 0;
|
||||
if ((dwFlags & FORMAT_MESSAGE_FROM_STRING)
|
||||
&&((dwFlags & FORMAT_MESSAGE_FROM_SYSTEM)
|
||||
|| (dwFlags & FORMAT_MESSAGE_FROM_HMODULE))) return 0;
|
||||
|
||||
if (width && width != FORMAT_MESSAGE_MAX_WIDTH_MASK)
|
||||
FIXME("line wrapping (%lu) not supported.\n", width);
|
||||
from = NULL;
|
||||
if (dwFlags & FORMAT_MESSAGE_FROM_STRING)
|
||||
{
|
||||
char *source = MapSL(lpSource);
|
||||
from = HeapAlloc( GetProcessHeap(), 0, strlen(source)+1 );
|
||||
strcpy( from, source );
|
||||
}
|
||||
else if (dwFlags & FORMAT_MESSAGE_FROM_SYSTEM) {
|
||||
from = HeapAlloc( GetProcessHeap(),0,200 );
|
||||
sprintf(from,"Systemmessage, messageid = 0x%08x\n",dwMessageId);
|
||||
}
|
||||
else if (dwFlags & FORMAT_MESSAGE_FROM_HMODULE) {
|
||||
INT16 bufsize;
|
||||
HINSTANCE16 hinst16 = ((HINSTANCE16)lpSource & 0xffff);
|
||||
|
||||
dwMessageId &= 0xFFFF;
|
||||
bufsize=LoadString16(hinst16,dwMessageId,NULL,0);
|
||||
if (bufsize) {
|
||||
from = HeapAlloc( GetProcessHeap(), 0, bufsize +1);
|
||||
LoadString16(hinst16,dwMessageId,from,bufsize+1);
|
||||
}
|
||||
}
|
||||
target = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 100);
|
||||
t = target;
|
||||
talloced= 100;
|
||||
|
||||
#define ADD_TO_T(c) \
|
||||
*t++=c;\
|
||||
if (t-target == talloced) {\
|
||||
target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
|
||||
t = target+talloced;\
|
||||
talloced*=2;\
|
||||
}
|
||||
|
||||
if (from) {
|
||||
f=from;
|
||||
while (*f && !eos) {
|
||||
if (*f=='%') {
|
||||
int insertnr;
|
||||
char *fmtstr,*x,*lastf;
|
||||
DWORD *argliststart;
|
||||
|
||||
fmtstr = NULL;
|
||||
lastf = f;
|
||||
f++;
|
||||
if (!*f) {
|
||||
ADD_TO_T('%');
|
||||
continue;
|
||||
}
|
||||
switch (*f) {
|
||||
case '1':case '2':case '3':case '4':case '5':
|
||||
case '6':case '7':case '8':case '9':
|
||||
insertnr=*f-'0';
|
||||
switch (f[1]) {
|
||||
case '0':case '1':case '2':case '3':
|
||||
case '4':case '5':case '6':case '7':
|
||||
case '8':case '9':
|
||||
f++;
|
||||
insertnr=insertnr*10+*f-'0';
|
||||
f++;
|
||||
break;
|
||||
default:
|
||||
f++;
|
||||
break;
|
||||
}
|
||||
if (*f=='!') {
|
||||
f++;
|
||||
if (NULL!=(x=strchr(f,'!'))) {
|
||||
*x='\0';
|
||||
fmtstr=HeapAlloc(GetProcessHeap(),0,strlen(f)+2);
|
||||
sprintf(fmtstr,"%%%s",f);
|
||||
f=x+1;
|
||||
} else {
|
||||
fmtstr=HeapAlloc(GetProcessHeap(),0,strlen(f)+2);
|
||||
sprintf(fmtstr,"%%%s",f);
|
||||
f+=strlen(f); /*at \0*/
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!args) break;
|
||||
fmtstr=HeapAlloc( GetProcessHeap(), 0, 3 );
|
||||
strcpy( fmtstr, "%s" );
|
||||
}
|
||||
if (args) {
|
||||
int ret;
|
||||
int sz;
|
||||
LPSTR b = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sz = 100);
|
||||
|
||||
argliststart=args+insertnr-1;
|
||||
|
||||
/* CMF - This makes a BIG assumption about va_list */
|
||||
while ((ret = vsnprintf(b, sz, fmtstr, (va_list) argliststart) < 0) || (ret >= sz)) {
|
||||
sz = (ret == -1 ? sz + 100 : ret + 1);
|
||||
b = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, b, sz);
|
||||
}
|
||||
for (x=b; *x; x++) ADD_TO_T(*x);
|
||||
HeapFree(GetProcessHeap(), 0, b);
|
||||
} else {
|
||||
/* NULL args - copy formatstr
|
||||
* (probably wrong)
|
||||
*/
|
||||
while ((lastf<f)&&(*lastf)) {
|
||||
ADD_TO_T(*lastf++);
|
||||
}
|
||||
}
|
||||
HeapFree(GetProcessHeap(),0,fmtstr);
|
||||
break;
|
||||
case '0': /* Just stop processing format string */
|
||||
eos = TRUE;
|
||||
f++;
|
||||
break;
|
||||
case 'n': /* 16 bit version just outputs 'n' */
|
||||
default:
|
||||
ADD_TO_T(*f++);
|
||||
break;
|
||||
}
|
||||
} else { /* '\n' or '\r' gets mapped to "\r\n" */
|
||||
if(*f == '\n' || *f == '\r') {
|
||||
if (width == 0) {
|
||||
ADD_TO_T('\r');
|
||||
ADD_TO_T('\n');
|
||||
if(*f++ == '\r' && *f == '\n')
|
||||
f++;
|
||||
}
|
||||
} else {
|
||||
ADD_TO_T(*f++);
|
||||
}
|
||||
}
|
||||
}
|
||||
*t='\0';
|
||||
}
|
||||
talloced = strlen(target)+1;
|
||||
if (nSize && talloced<nSize) {
|
||||
target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,nSize);
|
||||
}
|
||||
TRACE("-- %s\n",debugstr_a(target));
|
||||
if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) {
|
||||
/* nSize is the MINIMUM size */
|
||||
HLOCAL16 h = LocalAlloc16(LPTR,talloced);
|
||||
SEGPTR ptr = LocalLock16(h);
|
||||
allocstring = MapSL( ptr );
|
||||
memcpy( allocstring,target,talloced);
|
||||
LocalUnlock16( h );
|
||||
*((HLOCAL16*)lpBuffer) = h;
|
||||
} else
|
||||
lstrcpynA(lpBuffer,target,nSize);
|
||||
HeapFree(GetProcessHeap(),0,target);
|
||||
HeapFree(GetProcessHeap(),0,from);
|
||||
return (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) ?
|
||||
strlen(allocstring):
|
||||
strlen(lpBuffer);
|
||||
#else
|
||||
return 0;
|
||||
#endif /* __i386__ */
|
||||
}
|
||||
#undef ADD_TO_T
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "wine/winuser16.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
@ -1167,6 +1170,65 @@ BOOL16 WINAPI SetMenuItemBitmaps16( HMENU16 hMenu, UINT16 nPos, UINT16 wFlags,
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* lstrcmp (USER.430)
|
||||
*/
|
||||
INT16 WINAPI lstrcmp16( LPCSTR str1, LPCSTR str2 )
|
||||
{
|
||||
return strcmp( str1, str2 );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiUpper (USER.431)
|
||||
*/
|
||||
SEGPTR WINAPI AnsiUpper16( SEGPTR strOrChar )
|
||||
{
|
||||
/* uppercase only one char if strOrChar < 0x10000 */
|
||||
if (HIWORD(strOrChar))
|
||||
{
|
||||
CharUpperA( MapSL(strOrChar) );
|
||||
return strOrChar;
|
||||
}
|
||||
else return (SEGPTR)CharUpperA( (LPSTR)strOrChar );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiLower (USER.432)
|
||||
*/
|
||||
SEGPTR WINAPI AnsiLower16( SEGPTR strOrChar )
|
||||
{
|
||||
/* lowercase only one char if strOrChar < 0x10000 */
|
||||
if (HIWORD(strOrChar))
|
||||
{
|
||||
CharLowerA( MapSL(strOrChar) );
|
||||
return strOrChar;
|
||||
}
|
||||
else return (SEGPTR)CharLowerA( (LPSTR)strOrChar );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiUpperBuff (USER.437)
|
||||
*/
|
||||
UINT16 WINAPI AnsiUpperBuff16( LPSTR str, UINT16 len )
|
||||
{
|
||||
CharUpperBuffA( str, len ? len : 65536 );
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiLowerBuff (USER.438)
|
||||
*/
|
||||
UINT16 WINAPI AnsiLowerBuff16( LPSTR str, UINT16 len )
|
||||
{
|
||||
CharLowerBuffA( str, len ? len : 65536 );
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* InsertMenuItem (USER.441)
|
||||
*
|
||||
|
@ -1432,6 +1494,216 @@ void WINAPI DrawFocusRect16( HDC16 hdc, const RECT16* rc )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiNext (USER.472)
|
||||
*/
|
||||
SEGPTR WINAPI AnsiNext16(SEGPTR current)
|
||||
{
|
||||
char *ptr = MapSL(current);
|
||||
return current + (CharNextA(ptr) - ptr);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* AnsiPrev (USER.473)
|
||||
*/
|
||||
SEGPTR WINAPI AnsiPrev16( LPCSTR start, SEGPTR current )
|
||||
{
|
||||
char *ptr = MapSL(current);
|
||||
return current - (ptr - CharPrevA( start, ptr ));
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* FormatMessage (USER.606)
|
||||
*/
|
||||
DWORD WINAPI FormatMessage16(
|
||||
DWORD dwFlags,
|
||||
SEGPTR lpSource, /* [in] NOTE: not always a valid pointer */
|
||||
WORD dwMessageId,
|
||||
WORD dwLanguageId,
|
||||
LPSTR lpBuffer, /* [out] NOTE: *((HLOCAL16*)) for FORMAT_MESSAGE_ALLOCATE_BUFFER*/
|
||||
WORD nSize,
|
||||
LPDWORD args ) /* [in] NOTE: va_list *args */
|
||||
{
|
||||
#ifdef __i386__
|
||||
/* This implementation is completely dependent on the format of the va_list on x86 CPUs */
|
||||
LPSTR target,t;
|
||||
DWORD talloced;
|
||||
LPSTR from,f;
|
||||
DWORD width = dwFlags & FORMAT_MESSAGE_MAX_WIDTH_MASK;
|
||||
BOOL eos = FALSE;
|
||||
LPSTR allocstring = NULL;
|
||||
|
||||
TRACE("(0x%lx,%lx,%d,0x%x,%p,%d,%p)\n",
|
||||
dwFlags,lpSource,dwMessageId,dwLanguageId,lpBuffer,nSize,args);
|
||||
if ((dwFlags & FORMAT_MESSAGE_FROM_SYSTEM)
|
||||
&& (dwFlags & FORMAT_MESSAGE_FROM_HMODULE)) return 0;
|
||||
if ((dwFlags & FORMAT_MESSAGE_FROM_STRING)
|
||||
&&((dwFlags & FORMAT_MESSAGE_FROM_SYSTEM)
|
||||
|| (dwFlags & FORMAT_MESSAGE_FROM_HMODULE))) return 0;
|
||||
|
||||
if (width && width != FORMAT_MESSAGE_MAX_WIDTH_MASK)
|
||||
FIXME("line wrapping (%lu) not supported.\n", width);
|
||||
from = NULL;
|
||||
if (dwFlags & FORMAT_MESSAGE_FROM_STRING)
|
||||
{
|
||||
char *source = MapSL(lpSource);
|
||||
from = HeapAlloc( GetProcessHeap(), 0, strlen(source)+1 );
|
||||
strcpy( from, source );
|
||||
}
|
||||
else if (dwFlags & FORMAT_MESSAGE_FROM_SYSTEM) {
|
||||
from = HeapAlloc( GetProcessHeap(),0,200 );
|
||||
sprintf(from,"Systemmessage, messageid = 0x%08x\n",dwMessageId);
|
||||
}
|
||||
else if (dwFlags & FORMAT_MESSAGE_FROM_HMODULE) {
|
||||
INT16 bufsize;
|
||||
HINSTANCE16 hinst16 = ((HINSTANCE16)lpSource & 0xffff);
|
||||
|
||||
dwMessageId &= 0xFFFF;
|
||||
bufsize=LoadString16(hinst16,dwMessageId,NULL,0);
|
||||
if (bufsize) {
|
||||
from = HeapAlloc( GetProcessHeap(), 0, bufsize +1);
|
||||
LoadString16(hinst16,dwMessageId,from,bufsize+1);
|
||||
}
|
||||
}
|
||||
target = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 100);
|
||||
t = target;
|
||||
talloced= 100;
|
||||
|
||||
#define ADD_TO_T(c) \
|
||||
*t++=c;\
|
||||
if (t-target == talloced) {\
|
||||
target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
|
||||
t = target+talloced;\
|
||||
talloced*=2;\
|
||||
}
|
||||
|
||||
if (from) {
|
||||
f=from;
|
||||
while (*f && !eos) {
|
||||
if (*f=='%') {
|
||||
int insertnr;
|
||||
char *fmtstr,*x,*lastf;
|
||||
DWORD *argliststart;
|
||||
|
||||
fmtstr = NULL;
|
||||
lastf = f;
|
||||
f++;
|
||||
if (!*f) {
|
||||
ADD_TO_T('%');
|
||||
continue;
|
||||
}
|
||||
switch (*f) {
|
||||
case '1':case '2':case '3':case '4':case '5':
|
||||
case '6':case '7':case '8':case '9':
|
||||
insertnr=*f-'0';
|
||||
switch (f[1]) {
|
||||
case '0':case '1':case '2':case '3':
|
||||
case '4':case '5':case '6':case '7':
|
||||
case '8':case '9':
|
||||
f++;
|
||||
insertnr=insertnr*10+*f-'0';
|
||||
f++;
|
||||
break;
|
||||
default:
|
||||
f++;
|
||||
break;
|
||||
}
|
||||
if (*f=='!') {
|
||||
f++;
|
||||
if (NULL!=(x=strchr(f,'!'))) {
|
||||
*x='\0';
|
||||
fmtstr=HeapAlloc(GetProcessHeap(),0,strlen(f)+2);
|
||||
sprintf(fmtstr,"%%%s",f);
|
||||
f=x+1;
|
||||
} else {
|
||||
fmtstr=HeapAlloc(GetProcessHeap(),0,strlen(f)+2);
|
||||
sprintf(fmtstr,"%%%s",f);
|
||||
f+=strlen(f); /*at \0*/
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!args) break;
|
||||
fmtstr=HeapAlloc( GetProcessHeap(), 0, 3 );
|
||||
strcpy( fmtstr, "%s" );
|
||||
}
|
||||
if (args) {
|
||||
int ret;
|
||||
int sz;
|
||||
LPSTR b = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sz = 100);
|
||||
|
||||
argliststart=args+insertnr-1;
|
||||
|
||||
/* CMF - This makes a BIG assumption about va_list */
|
||||
while ((ret = vsnprintf(b, sz, fmtstr, (va_list) argliststart) < 0) || (ret >= sz)) {
|
||||
sz = (ret == -1 ? sz + 100 : ret + 1);
|
||||
b = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, b, sz);
|
||||
}
|
||||
for (x=b; *x; x++) ADD_TO_T(*x);
|
||||
HeapFree(GetProcessHeap(), 0, b);
|
||||
} else {
|
||||
/* NULL args - copy formatstr
|
||||
* (probably wrong)
|
||||
*/
|
||||
while ((lastf<f)&&(*lastf)) {
|
||||
ADD_TO_T(*lastf++);
|
||||
}
|
||||
}
|
||||
HeapFree(GetProcessHeap(),0,fmtstr);
|
||||
break;
|
||||
case '0': /* Just stop processing format string */
|
||||
eos = TRUE;
|
||||
f++;
|
||||
break;
|
||||
case 'n': /* 16 bit version just outputs 'n' */
|
||||
default:
|
||||
ADD_TO_T(*f++);
|
||||
break;
|
||||
}
|
||||
} else { /* '\n' or '\r' gets mapped to "\r\n" */
|
||||
if(*f == '\n' || *f == '\r') {
|
||||
if (width == 0) {
|
||||
ADD_TO_T('\r');
|
||||
ADD_TO_T('\n');
|
||||
if(*f++ == '\r' && *f == '\n')
|
||||
f++;
|
||||
}
|
||||
} else {
|
||||
ADD_TO_T(*f++);
|
||||
}
|
||||
}
|
||||
}
|
||||
*t='\0';
|
||||
}
|
||||
talloced = strlen(target)+1;
|
||||
if (nSize && talloced<nSize) {
|
||||
target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,nSize);
|
||||
}
|
||||
TRACE("-- %s\n",debugstr_a(target));
|
||||
if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) {
|
||||
/* nSize is the MINIMUM size */
|
||||
HLOCAL16 h = LocalAlloc16(LPTR,talloced);
|
||||
SEGPTR ptr = LocalLock16(h);
|
||||
allocstring = MapSL( ptr );
|
||||
memcpy( allocstring,target,talloced);
|
||||
LocalUnlock16( h );
|
||||
*((HLOCAL16*)lpBuffer) = h;
|
||||
} else
|
||||
lstrcpynA(lpBuffer,target,nSize);
|
||||
HeapFree(GetProcessHeap(),0,target);
|
||||
HeapFree(GetProcessHeap(),0,from);
|
||||
return (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) ?
|
||||
strlen(allocstring):
|
||||
strlen(lpBuffer);
|
||||
#else
|
||||
return 0;
|
||||
#endif /* __i386__ */
|
||||
}
|
||||
#undef ADD_TO_T
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* ChangeDisplaySettings (USER.620)
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue