4 * Copyright 1993 Yngvi Sigurjonsson (yngvi@hafro.is)
5 * Copyright 1996 Marcus Meissner
19 # define iswalnum(c) isalnum(c)
20 # define iswalpha(c) isalpha(c)
21 # define iswupper(c) isupper(c)
22 # define iswlower(c) islower(c)
23 #endif /* HAVE_WCTYPE_H */
29 #include "wine/winbase16.h"
30 #include "wine/winuser16.h"
35 #include "stackframe.h"
37 #include "debugtools.h"
39 DEFAULT_DEBUG_CHANNEL(resource
);
41 extern const WORD OLE2NLS_CT_CType3_LUT
[]; /* FIXME: does not belong here */
44 /* Funny to divide them between user and kernel. */
46 /* be careful: always use functions from wctype.h if character > 255 */
49 * Unicode case conversion routines ... these should be used where
50 * toupper/tolower are used for ASCII.
53 /* FIXME: should probably get rid of wctype.h altogether */
56 /***********************************************************************
59 WCHAR
towupper(WCHAR code
)
61 const WCHAR
* ptr
= uprtable
[HIBYTE(code
)];
62 return ptr
? ptr
[LOBYTE(code
)] : code
;
65 /***********************************************************************
68 WCHAR
towlower(WCHAR code
)
70 const WCHAR
* ptr
= lwrtable
[HIBYTE(code
)];
71 return ptr
? ptr
[LOBYTE(code
)] : code
;
73 #endif /* HAVE_WCTYPE_H */
75 /***********************************************************************
76 * IsCharAlpha (USER.433)
78 BOOL16 WINAPI
IsCharAlpha16(CHAR ch
)
80 return isalpha(ch
); /* This is probably not right for NLS */
83 /***********************************************************************
84 * IsCharAlphaNumeric (USER.434)
86 BOOL16 WINAPI
IsCharAlphaNumeric16(CHAR ch
)
91 /***********************************************************************
92 * IsCharUpper (USER.435)
94 BOOL16 WINAPI
IsCharUpper16(CHAR ch
)
99 /***********************************************************************
100 * IsCharLower (USER.436)
102 BOOL16 WINAPI
IsCharLower16(CHAR ch
)
107 /***********************************************************************
108 * AnsiUpper16 (USER.431)
110 SEGPTR WINAPI
AnsiUpper16( SEGPTR strOrChar
)
112 /* I am not sure if the locale stuff works with toupper, but then again
113 I am not sure if the Linux libc locale stuffs works at all */
115 /* uppercase only one char if strOrChar < 0x10000 */
116 if (HIWORD(strOrChar
))
119 for (s
= PTR_SEG_TO_LIN(strOrChar
); *s
; s
++) *s
= toupper(*s
);
122 else return toupper((char)strOrChar
);
126 /***********************************************************************
127 * AnsiUpperBuff16 (USER.437)
129 UINT16 WINAPI
AnsiUpperBuff16( LPSTR str
, UINT16 len
)
131 UINT count
= len
? len
: 65536;
132 for (; count
; count
--, str
++) *str
= toupper(*str
);
136 /***********************************************************************
137 * AnsiLower16 (USER.432)
139 SEGPTR WINAPI
AnsiLower16( SEGPTR strOrChar
)
141 /* I am not sure if the locale stuff works with toupper, but then again
142 I am not sure if the Linux libc locale stuffs works at all */
144 /* lowercase only one char if strOrChar < 0x10000 */
145 if (HIWORD(strOrChar
))
148 for (s
= PTR_SEG_TO_LIN( strOrChar
); *s
; s
++) *s
= tolower( *s
);
151 else return tolower((char)strOrChar
);
155 /***********************************************************************
156 * AnsiLowerBuff16 (USER.438)
158 UINT16 WINAPI
AnsiLowerBuff16( LPSTR str
, UINT16 len
)
160 UINT count
= len
? len
: 65536;
161 for (; count
; count
--, str
++) *str
= tolower(*str
);
166 /***********************************************************************
167 * AnsiNext16 (USER.472)
169 SEGPTR WINAPI
AnsiNext16(SEGPTR current
)
171 return (*(char *)PTR_SEG_TO_LIN(current
)) ? current
+ 1 : current
;
175 /***********************************************************************
176 * AnsiPrev16 (USER.473)
178 SEGPTR WINAPI
AnsiPrev16( SEGPTR start
, SEGPTR current
)
180 return (current
== start
) ? start
: current
- 1;
184 /***********************************************************************
185 * CharNextA (USER32.29)
187 LPSTR WINAPI
CharNextA( LPCSTR ptr
)
189 if (!*ptr
) return (LPSTR
)ptr
;
190 if (IsDBCSLeadByte( *ptr
) && (*(ptr
+1) != 0) ) return (LPSTR
)(ptr
+ 2);
191 return (LPSTR
)(ptr
+ 1);
195 /***********************************************************************
196 * CharNextExA (USER32.30)
198 LPSTR WINAPI
CharNextExA( WORD codepage
, LPCSTR ptr
, DWORD flags
)
200 if (!*ptr
) return (LPSTR
)ptr
;
201 if (IsDBCSLeadByteEx( codepage
, *ptr
) && (*(ptr
+1) != 0) ) return (LPSTR
)(ptr
+ 2);
202 return (LPSTR
)(ptr
+ 1);
206 /***********************************************************************
207 * CharNextExW (USER32.31)
209 LPWSTR WINAPI
CharNextExW(WORD codepage
,LPCWSTR x
,DWORD flags
)
211 /* FIXME: add DBCS / codepage stuff */
212 if (*x
) return (LPWSTR
)(x
+1);
213 else return (LPWSTR
)x
;
216 /***********************************************************************
217 * CharNextW (USER32.32)
219 LPWSTR WINAPI
CharNextW(LPCWSTR x
)
221 if (*x
) return (LPWSTR
)(x
+1);
222 else return (LPWSTR
)x
;
225 /***********************************************************************
226 * CharPrevA (USER32.33)
228 LPSTR WINAPI
CharPrevA( LPCSTR start
, LPCSTR ptr
)
230 while (*start
&& (start
< ptr
))
232 LPCSTR next
= CharNextA( start
);
233 if (next
>= ptr
) break;
240 /***********************************************************************
241 * CharPrevExA (USER32.34)
243 LPSTR WINAPI
CharPrevExA( WORD codepage
, LPCSTR start
, LPCSTR ptr
, DWORD flags
)
245 while (*start
&& (start
< ptr
))
247 LPCSTR next
= CharNextExA( codepage
, start
, flags
);
248 if (next
> ptr
) break;
255 /***********************************************************************
256 * CharPrevExW (USER32.35)
258 LPWSTR WINAPI
CharPrevExW(WORD codepage
,LPCWSTR start
,LPCWSTR x
,DWORD flags
)
260 /* FIXME: add DBCS / codepage stuff */
261 if (x
>start
) return (LPWSTR
)(x
-1);
262 else return (LPWSTR
)x
;
265 /***********************************************************************
266 * CharPrevW (USER32.36)
268 LPWSTR WINAPI
CharPrevW(LPCWSTR start
,LPCWSTR x
)
270 if (x
>start
) return (LPWSTR
)(x
-1);
271 else return (LPWSTR
)x
;
274 /***********************************************************************
275 * CharLowerA (USER32.25)
276 * FIXME: handle current locale
278 LPSTR WINAPI
CharLowerA(LPSTR x
)
292 else return (LPSTR
)tolower((char)(int)x
);
295 /***********************************************************************
296 * CharLowerBuffA (USER32.26)
297 * FIXME: handle current locale
299 DWORD WINAPI
CharLowerBuffA(LPSTR x
,DWORD buflen
)
303 if (!x
) return 0; /* YES */
304 while (*x
&& (buflen
--))
313 /***********************************************************************
314 * CharLowerBuffW (USER32.27)
315 * FIXME: handle current locale
317 DWORD WINAPI
CharLowerBuffW(LPWSTR x
,DWORD buflen
)
321 if (!x
) return 0; /* YES */
322 while (*x
&& (buflen
--))
331 /***********************************************************************
332 * CharLowerW (USER32.28)
333 * FIXME: handle current locale
335 LPWSTR WINAPI
CharLowerW(LPWSTR x
)
347 else return (LPWSTR
)((UINT
)towlower(LOWORD(x
)));
350 /***********************************************************************
351 * CharUpperA (USER32.41)
352 * FIXME: handle current locale
354 LPSTR WINAPI
CharUpperA(LPSTR x
)
366 return (LPSTR
)toupper((char)(int)x
);
369 /***********************************************************************
370 * CharUpperBuffA (USER32.42)
371 * FIXME: handle current locale
373 DWORD WINAPI
CharUpperBuffA(LPSTR x
,DWORD buflen
)
377 if (!x
) return 0; /* YES */
378 while (*x
&& (buflen
--))
387 /***********************************************************************
388 * CharUpperBuffW (USER32.43)
389 * FIXME: handle current locale
391 DWORD WINAPI
CharUpperBuffW(LPWSTR x
,DWORD buflen
)
395 if (!x
) return 0; /* YES */
396 while (*x
&& (buflen
--))
405 /***********************************************************************
406 * CharUpperW (USER32.44)
407 * FIXME: handle current locale
409 LPWSTR WINAPI
CharUpperW(LPWSTR x
)
421 else return (LPWSTR
)((UINT
)towupper(LOWORD(x
)));
424 /***********************************************************************
425 * IsCharAlphaA (USER32.331)
426 * FIXME: handle current locale
428 BOOL WINAPI
IsCharAlphaA(CHAR x
)
430 return (OLE2NLS_CT_CType3_LUT
[(unsigned char)x
] & C3_ALPHA
);
433 /***********************************************************************
434 * IsCharAlphaNumericA (USER32.332)
435 * FIXME: handle current locale
437 BOOL WINAPI
IsCharAlphaNumericA(CHAR x
)
439 return IsCharAlphaA(x
) || isdigit(x
) ;
442 /***********************************************************************
443 * IsCharAlphaNumericW (USER32.333)
444 * FIXME: handle current locale
446 BOOL WINAPI
IsCharAlphaNumericW(WCHAR x
)
451 /***********************************************************************
452 * IsCharAlphaW (USER32.334)
453 * FIXME: handle current locale
455 BOOL WINAPI
IsCharAlphaW(WCHAR x
)
460 /***********************************************************************
461 * IsCharLowerA (USER32.335)
462 * FIXME: handle current locale
464 BOOL WINAPI
IsCharLowerA(CHAR x
)
469 /***********************************************************************
470 * IsCharLowerW (USER32.336)
471 * FIXME: handle current locale
473 BOOL WINAPI
IsCharLowerW(WCHAR x
)
478 /***********************************************************************
479 * IsCharUpperA (USER32.337)
480 * FIXME: handle current locale
482 BOOL WINAPI
IsCharUpperA(CHAR x
)
487 /***********************************************************************
488 * IsCharUpperW (USER32.338)
489 * FIXME: handle current locale
491 BOOL WINAPI
IsCharUpperW(WCHAR x
)
496 /***********************************************************************
497 * FormatMessage16 (USER.606)
499 DWORD WINAPI
FormatMessage16(
501 SEGPTR lpSource
, /*not always a valid pointer*/
504 LPSTR lpBuffer
, /* *((HLOCAL16*)) for FORMAT_MESSAGE_ALLOCATE_BUFFER*/
506 LPDWORD args
/* va_list *args */
509 /* This implementation is completely dependant on the format of the va_list on x86 CPUs */
513 DWORD width
= dwFlags
& FORMAT_MESSAGE_MAX_WIDTH_MASK
;
515 LPSTR allocstring
= NULL
;
517 TRACE("(0x%lx,%lx,%d,0x%x,%p,%d,%p)\n",
518 dwFlags
,lpSource
,dwMessageId
,dwLanguageId
,lpBuffer
,nSize
,args
);
520 FIXME("line wrapping not supported.\n");
522 if (dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
523 from
= HEAP_strdupA( GetProcessHeap(), 0, PTR_SEG_TO_LIN(lpSource
));
524 if (dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
) {
525 from
= HeapAlloc( GetProcessHeap(),0,200 );
526 sprintf(from
,"Systemmessage, messageid = 0x%08x\n",dwMessageId
);
528 if (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
) {
530 HINSTANCE16 hinst16
= ((HMODULE
)lpSource
& 0xffff);
532 dwMessageId
&= 0xFFFF;
533 bufsize
=LoadString16(hinst16
,dwMessageId
,NULL
,0);
535 from
= HeapAlloc( GetProcessHeap(), 0, bufsize
+1);
536 LoadString16(hinst16
,dwMessageId
,from
,bufsize
+1);
539 target
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 100);
543 #define ADD_TO_T(c) \
545 if (t-target == talloced) {\
546 target = (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
547 t = target+talloced;\
556 char *fmtstr
,*sprintfbuf
,*x
,*lastf
;
567 case '1':case '2':case '3':case '4':case '5':
568 case '6':case '7':case '8':case '9':
571 case '0':case '1':case '2':case '3':
572 case '4':case '5':case '6':case '7':
575 insertnr
=insertnr
*10+*f
-'0';
584 if (NULL
!=(x
=strchr(f
,'!'))) {
586 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
587 sprintf(fmtstr
,"%%%s",f
);
590 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
));
591 sprintf(fmtstr
,"%%%s",f
);
592 f
+=strlen(f
); /*at \0*/
598 fmtstr
=HEAP_strdupA(GetProcessHeap(),0,"%s");
600 argliststart
=args
+insertnr
-1;
601 if (fmtstr
[strlen(fmtstr
)-1]=='s')
602 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,
603 strlen(PTR_SEG_TO_LIN(argliststart
[0]))+1);
605 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,100);
607 /* CMF - This makes a BIG assumption about va_list */
608 wvsprintf16(sprintfbuf
, fmtstr
, (va_list) argliststart
);
613 HeapFree(GetProcessHeap(),0,sprintfbuf
);
615 /* NULL args - copy formatstr
618 while ((lastf
<f
)&&(*lastf
)) {
622 HeapFree(GetProcessHeap(),0,fmtstr
);
624 case '0': /* Just stop processing format string */
628 case 'n': /* 16 bit version just outputs 'n' */
633 } else { /* '\n' or '\r' gets mapped to "\r\n" */
634 if(*f
== '\n' || *f
== '\r') {
637 if(*f
++ == '\r' && *f
== '\n')
646 talloced
= strlen(target
)+1;
647 if (nSize
&& talloced
<nSize
) {
648 target
= (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,target
,nSize
);
650 TRACE("-- %s\n",debugstr_a(target
));
651 if (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) {
652 /* nSize is the MINIMUM size */
653 *((HLOCAL16
*)lpBuffer
)= LocalAlloc16(LPTR
,talloced
);
654 allocstring
=PTR_SEG_OFF_TO_LIN(CURRENT_DS
,*((HLOCAL16
*)lpBuffer
));
655 memcpy( allocstring
,target
,talloced
);
657 lstrcpynA(lpBuffer
,target
,nSize
);
658 HeapFree(GetProcessHeap(),0,target
);
659 if (from
) HeapFree(GetProcessHeap(),0,from
);
660 return (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) ?
665 #endif /* __i386__ */
669 /***********************************************************************
670 * FormatMessageA (KERNEL32.138)
671 * FIXME: missing wrap,FROM_SYSTEM message-loading,
673 DWORD WINAPI
FormatMessageA(
680 LPDWORD args
/* va_list *args */
683 /* This implementation is completely dependant on the format of the va_list on x86 CPUs */
687 DWORD width
= dwFlags
& FORMAT_MESSAGE_MAX_WIDTH_MASK
;
690 TRACE("(0x%lx,%p,%ld,0x%lx,%p,%ld,%p)\n",
691 dwFlags
,lpSource
,dwMessageId
,dwLanguageId
,lpBuffer
,nSize
,args
);
693 FIXME("line wrapping not supported.\n");
695 if (dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
696 from
= HEAP_strdupA( GetProcessHeap(), 0, (LPSTR
)lpSource
);
697 if (dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
) {
698 from
= HeapAlloc( GetProcessHeap(),0,200 );
699 sprintf(from
,"Systemmessage, messageid = 0x%08lx\n",dwMessageId
);
701 if (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
) {
704 dwMessageId
&= 0xFFFF;
705 bufsize
=LoadMessageA((HMODULE
)lpSource
,dwMessageId
,dwLanguageId
,NULL
,100);
707 from
= HeapAlloc( GetProcessHeap(), 0, bufsize
+ 1 );
708 LoadMessageA((HMODULE
)lpSource
,dwMessageId
,dwLanguageId
,from
,bufsize
+1);
711 target
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 100);
715 #define ADD_TO_T(c) \
717 if (t-target == talloced) {\
718 target = (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
719 t = target+talloced;\
728 char *fmtstr
,*sprintfbuf
,*x
,*lastf
;
739 case '1':case '2':case '3':case '4':case '5':
740 case '6':case '7':case '8':case '9':
743 case '0':case '1':case '2':case '3':
744 case '4':case '5':case '6':case '7':
747 insertnr
=insertnr
*10+*f
-'0';
756 if (NULL
!=(x
=strchr(f
,'!'))) {
758 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
759 sprintf(fmtstr
,"%%%s",f
);
762 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
));
763 sprintf(fmtstr
,"%%%s",f
);
764 f
+=strlen(f
); /*at \0*/
770 fmtstr
=HEAP_strdupA(GetProcessHeap(),0,"%s");
772 if (dwFlags
& FORMAT_MESSAGE_ARGUMENT_ARRAY
)
773 argliststart
=args
+insertnr
-1;
775 argliststart
=(*(DWORD
**)args
)+insertnr
-1;
777 if (fmtstr
[strlen(fmtstr
)-1]=='s' && argliststart
[0])
778 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,strlen((LPSTR
)argliststart
[0])+1);
780 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,100);
782 /* CMF - This makes a BIG assumption about va_list */
783 wvsprintfA(sprintfbuf
, fmtstr
, (va_list) argliststart
);
788 HeapFree(GetProcessHeap(),0,sprintfbuf
);
790 /* NULL args - copy formatstr
793 while ((lastf
<f
)&&(*lastf
)) {
797 HeapFree(GetProcessHeap(),0,fmtstr
);
812 } else { /* '\n' or '\r' gets mapped to "\r\n" */
813 if(*f
== '\n' || *f
== '\r') {
816 if(*f
++ == '\r' && *f
== '\n')
825 talloced
= strlen(target
)+1;
826 if (nSize
&& talloced
<nSize
) {
827 target
= (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,target
,nSize
);
829 TRACE("-- %s\n",debugstr_a(target
));
830 if (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) {
831 /* nSize is the MINIMUM size */
832 *((LPVOID
*)lpBuffer
) = (LPVOID
)LocalAlloc(GMEM_ZEROINIT
,talloced
);
833 memcpy(*(LPSTR
*)lpBuffer
,target
,talloced
);
835 lstrcpynA(lpBuffer
,target
,nSize
);
837 HeapFree(GetProcessHeap(),0,target
);
838 if (from
) HeapFree(GetProcessHeap(),0,from
);
839 return (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) ?
840 strlen(*(LPSTR
*)lpBuffer
):
844 #endif /* __i386__ */
849 /***********************************************************************
850 * FormatMessageW (KERNEL32.138)
852 DWORD WINAPI
FormatMessageW(
859 LPDWORD args
/* va_list *args */
862 /* This implementation is completely dependant on the format of the va_list on x86 CPUs */
866 DWORD width
= dwFlags
& FORMAT_MESSAGE_MAX_WIDTH_MASK
;
869 TRACE("(0x%lx,%p,%ld,0x%lx,%p,%ld,%p)\n",
870 dwFlags
,lpSource
,dwMessageId
,dwLanguageId
,lpBuffer
,nSize
,args
);
872 FIXME("line wrapping not supported.\n");
874 if (dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
875 from
= HEAP_strdupWtoA(GetProcessHeap(),0,(LPWSTR
)lpSource
);
876 if (dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
) {
877 /* gather information from system message tables ... */
878 from
= HeapAlloc( GetProcessHeap(),0,200 );
879 sprintf(from
,"Systemmessage, messageid = 0x%08lx\n",dwMessageId
);
881 if (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
) {
884 dwMessageId
&= 0xFFFF;
885 bufsize
=LoadMessageA((HMODULE
)lpSource
,dwMessageId
,dwLanguageId
,NULL
,100);
888 from
= HeapAlloc( GetProcessHeap(), 0, bufsize
+ 1 );
889 LoadMessageA((HMODULE
)lpSource
,dwMessageId
,dwLanguageId
,from
,bufsize
+1);
892 target
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 100 );
896 #define ADD_TO_T(c) \
898 if (t-target == talloced) {\
899 target = (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
900 t = target+talloced;\
909 char *fmtstr
,*sprintfbuf
,*x
;
919 case '1':case '2':case '3':case '4':case '5':
920 case '6':case '7':case '8':case '9':
923 case '0':case '1':case '2':case '3':
924 case '4':case '5':case '6':case '7':
927 insertnr
=insertnr
*10+*f
-'0';
936 if (NULL
!=(x
=strchr(f
,'!')))
939 fmtstr
=HeapAlloc( GetProcessHeap(), 0, strlen(f
)+2);
940 sprintf(fmtstr
,"%%%s",f
);
943 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
));
944 sprintf(fmtstr
,"%%%s",f
);
945 f
+=strlen(f
); /*at \0*/
951 fmtstr
=HEAP_strdupA( GetProcessHeap(),0,"%s");
952 if (dwFlags
& FORMAT_MESSAGE_ARGUMENT_ARRAY
)
953 argliststart
=args
+insertnr
-1;
955 argliststart
=(*(DWORD
**)args
)+insertnr
-1;
957 if (fmtstr
[strlen(fmtstr
)-1]=='s' && argliststart
[0]) {
960 xarr
[0]=(DWORD
)HEAP_strdupWtoA(GetProcessHeap(),0,(LPWSTR
)(*(argliststart
+0)));
961 /* possible invalid pointers */
962 xarr
[1]=*(argliststart
+1);
963 xarr
[2]=*(argliststart
+2);
964 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,lstrlenW((LPWSTR
)argliststart
[0])*2+1);
966 /* CMF - This makes a BIG assumption about va_list */
967 vsprintf(sprintfbuf
, fmtstr
, (va_list) xarr
);
969 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,100);
971 /* CMF - This makes a BIG assumption about va_list */
972 wvsprintfA(sprintfbuf
, fmtstr
, (va_list) argliststart
);
978 HeapFree(GetProcessHeap(),0,sprintfbuf
);
979 HeapFree(GetProcessHeap(),0,fmtstr
);
994 } else { /* '\n' or '\r' gets mapped to "\r\n" */
995 if(*f
== '\n' || *f
== '\r') {
998 if(*f
++ == '\r' && *f
== '\n')
1007 talloced
= strlen(target
)+1;
1008 if (nSize
&& talloced
<nSize
)
1009 target
= (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,target
,nSize
);
1010 if (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) {
1011 /* nSize is the MINIMUM size */
1012 *((LPVOID
*)lpBuffer
) = (LPVOID
)LocalAlloc(GMEM_ZEROINIT
,talloced
*2+2);
1013 lstrcpynAtoW(*(LPWSTR
*)lpBuffer
,target
,talloced
);
1015 lstrcpynAtoW(lpBuffer
,target
,nSize
);
1016 HeapFree(GetProcessHeap(),0,target
);
1017 if (from
) HeapFree(GetProcessHeap(),0,from
);
1018 return (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) ?
1019 lstrlenW(*(LPWSTR
*)lpBuffer
):
1023 #endif /* __i386__ */