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 WCHAR
towupper(WCHAR code
)
58 const WCHAR
* ptr
= uprtable
[HIBYTE(code
)];
59 return ptr
? ptr
[LOBYTE(code
)] : code
;
62 WCHAR
towlower(WCHAR code
)
64 const WCHAR
* ptr
= lwrtable
[HIBYTE(code
)];
65 return ptr
? ptr
[LOBYTE(code
)] : code
;
67 #endif /* HAVE_WCTYPE_H */
69 /***********************************************************************
70 * IsCharAlpha (USER.433)
72 BOOL16 WINAPI
IsCharAlpha16(CHAR ch
)
74 return isalpha(ch
); /* This is probably not right for NLS */
77 /***********************************************************************
78 * IsCharAlphanumeric (USER.434)
80 BOOL16 WINAPI
IsCharAlphaNumeric16(CHAR ch
)
85 /***********************************************************************
86 * IsCharUpper (USER.435)
88 BOOL16 WINAPI
IsCharUpper16(CHAR ch
)
93 /***********************************************************************
94 * IsCharLower (USER.436)
96 BOOL16 WINAPI
IsCharLower16(CHAR ch
)
101 /***********************************************************************
102 * AnsiUpper16 (USER.431)
104 SEGPTR WINAPI
AnsiUpper16( SEGPTR strOrChar
)
106 /* I am not sure if the locale stuff works with toupper, but then again
107 I am not sure if the Linux libc locale stuffs works at all */
109 /* uppercase only one char if strOrChar < 0x10000 */
110 if (HIWORD(strOrChar
))
113 for (s
= PTR_SEG_TO_LIN(strOrChar
); *s
; s
++) *s
= toupper(*s
);
116 else return toupper((char)strOrChar
);
120 /***********************************************************************
121 * AnsiUpperBuff16 (USER.437)
123 UINT16 WINAPI
AnsiUpperBuff16( LPSTR str
, UINT16 len
)
125 UINT count
= len
? len
: 65536;
126 for (; count
; count
--, str
++) *str
= toupper(*str
);
130 /***********************************************************************
131 * AnsiLower16 (USER.432)
133 SEGPTR WINAPI
AnsiLower16( SEGPTR strOrChar
)
135 /* I am not sure if the locale stuff works with toupper, but then again
136 I am not sure if the Linux libc locale stuffs works at all */
138 /* lowercase only one char if strOrChar < 0x10000 */
139 if (HIWORD(strOrChar
))
142 for (s
= PTR_SEG_TO_LIN( strOrChar
); *s
; s
++) *s
= tolower( *s
);
145 else return tolower((char)strOrChar
);
149 /***********************************************************************
150 * AnsiLowerBuff16 (USER.438)
152 UINT16 WINAPI
AnsiLowerBuff16( LPSTR str
, UINT16 len
)
154 UINT count
= len
? len
: 65536;
155 for (; count
; count
--, str
++) *str
= tolower(*str
);
160 /***********************************************************************
161 * AnsiNext16 (USER.472)
163 SEGPTR WINAPI
AnsiNext16(SEGPTR current
)
165 return (*(char *)PTR_SEG_TO_LIN(current
)) ? current
+ 1 : current
;
169 /***********************************************************************
170 * AnsiPrev16 (USER.473)
172 SEGPTR WINAPI
AnsiPrev16( SEGPTR start
, SEGPTR current
)
174 return (current
== start
) ? start
: current
- 1;
178 /***********************************************************************
179 * CharNext32A (USER32.29)
181 LPSTR WINAPI
CharNextA( LPCSTR ptr
)
183 if (!*ptr
) return (LPSTR
)ptr
;
184 if (IsDBCSLeadByte( *ptr
) && (*(ptr
+1) != 0) ) return (LPSTR
)(ptr
+ 2);
185 return (LPSTR
)(ptr
+ 1);
189 /***********************************************************************
190 * CharNextEx32A (USER32.30)
192 LPSTR WINAPI
CharNextExA( WORD codepage
, LPCSTR ptr
, DWORD flags
)
194 if (!*ptr
) return (LPSTR
)ptr
;
195 if (IsDBCSLeadByteEx( codepage
, *ptr
) && (*(ptr
+1) != 0) ) return (LPSTR
)(ptr
+ 2);
196 return (LPSTR
)(ptr
+ 1);
200 /***********************************************************************
201 * CharNextExW (USER32.31)
203 LPWSTR WINAPI
CharNextExW(WORD codepage
,LPCWSTR x
,DWORD flags
)
205 /* FIXME: add DBCS / codepage stuff */
206 if (*x
) return (LPWSTR
)(x
+1);
207 else return (LPWSTR
)x
;
210 /***********************************************************************
211 * CharNextW (USER32.32)
213 LPWSTR WINAPI
CharNextW(LPCWSTR x
)
215 if (*x
) return (LPWSTR
)(x
+1);
216 else return (LPWSTR
)x
;
219 /***********************************************************************
220 * CharPrev32A (USER32.33)
222 LPSTR WINAPI
CharPrevA( LPCSTR start
, LPCSTR ptr
)
224 while (*start
&& (start
< ptr
))
226 LPCSTR next
= CharNextA( start
);
227 if (next
>= ptr
) break;
234 /***********************************************************************
235 * CharPrevEx32A (USER32.34)
237 LPSTR WINAPI
CharPrevExA( WORD codepage
, LPCSTR start
, LPCSTR ptr
, DWORD flags
)
239 while (*start
&& (start
< ptr
))
241 LPCSTR next
= CharNextExA( codepage
, start
, flags
);
242 if (next
> ptr
) break;
249 /***********************************************************************
250 * CharPrevExW (USER32.35)
252 LPWSTR WINAPI
CharPrevExW(WORD codepage
,LPCWSTR start
,LPCWSTR x
,DWORD flags
)
254 /* FIXME: add DBCS / codepage stuff */
255 if (x
>start
) return (LPWSTR
)(x
-1);
256 else return (LPWSTR
)x
;
259 /***********************************************************************
260 * CharPrevW (USER32.36)
262 LPWSTR WINAPI
CharPrevW(LPCWSTR start
,LPCWSTR x
)
264 if (x
>start
) return (LPWSTR
)(x
-1);
265 else return (LPWSTR
)x
;
268 /***********************************************************************
269 * CharLowerA (USER32.25)
270 * FIXME: handle current locale
272 LPSTR WINAPI
CharLowerA(LPSTR x
)
286 else return (LPSTR
)tolower((char)(int)x
);
289 /***********************************************************************
290 * CharLowerBuffA (USER32.26)
291 * FIXME: handle current locale
293 DWORD WINAPI
CharLowerBuffA(LPSTR x
,DWORD buflen
)
297 if (!x
) return 0; /* YES */
298 while (*x
&& (buflen
--))
307 /***********************************************************************
308 * CharLowerBuffW (USER32.27)
309 * FIXME: handle current locale
311 DWORD WINAPI
CharLowerBuffW(LPWSTR x
,DWORD buflen
)
315 if (!x
) return 0; /* YES */
316 while (*x
&& (buflen
--))
325 /***********************************************************************
326 * CharLowerW (USER32.28)
327 * FIXME: handle current locale
329 LPWSTR WINAPI
CharLowerW(LPWSTR x
)
341 else return (LPWSTR
)((UINT
)towlower(LOWORD(x
)));
344 /***********************************************************************
345 * CharUpper32A (USER32.41)
346 * FIXME: handle current locale
348 LPSTR WINAPI
CharUpperA(LPSTR x
)
360 return (LPSTR
)toupper((char)(int)x
);
363 /***********************************************************************
364 * CharUpperBuffA (USER32.42)
365 * FIXME: handle current locale
367 DWORD WINAPI
CharUpperBuffA(LPSTR x
,DWORD buflen
)
371 if (!x
) return 0; /* YES */
372 while (*x
&& (buflen
--))
381 /***********************************************************************
382 * CharUpperBuffW (USER32.43)
383 * FIXME: handle current locale
385 DWORD WINAPI
CharUpperBuffW(LPWSTR x
,DWORD buflen
)
389 if (!x
) return 0; /* YES */
390 while (*x
&& (buflen
--))
399 /***********************************************************************
400 * CharUpperW (USER32.44)
401 * FIXME: handle current locale
403 LPWSTR WINAPI
CharUpperW(LPWSTR x
)
415 else return (LPWSTR
)((UINT
)towupper(LOWORD(x
)));
418 /***********************************************************************
419 * IsCharAlphaA (USER32.331)
420 * FIXME: handle current locale
422 BOOL WINAPI
IsCharAlphaA(CHAR x
)
424 return (OLE2NLS_CT_CType3_LUT
[(unsigned char)x
] & C3_ALPHA
);
427 /***********************************************************************
428 * IsCharAlphaNumericA (USER32.332)
429 * FIXME: handle current locale
431 BOOL WINAPI
IsCharAlphaNumericA(CHAR x
)
433 return IsCharAlphaA(x
) || isdigit(x
) ;
436 /***********************************************************************
437 * IsCharAlphaNumericW (USER32.333)
438 * FIXME: handle current locale
440 BOOL WINAPI
IsCharAlphaNumericW(WCHAR x
)
445 /***********************************************************************
446 * IsCharAlphaW (USER32.334)
447 * FIXME: handle current locale
449 BOOL WINAPI
IsCharAlphaW(WCHAR x
)
454 /***********************************************************************
455 * IsCharLower32A (USER32.335)
456 * FIXME: handle current locale
458 BOOL WINAPI
IsCharLowerA(CHAR x
)
463 /***********************************************************************
464 * IsCharLower32W (USER32.336)
465 * FIXME: handle current locale
467 BOOL WINAPI
IsCharLowerW(WCHAR x
)
472 /***********************************************************************
473 * IsCharUpper32A (USER32.337)
474 * FIXME: handle current locale
476 BOOL WINAPI
IsCharUpperA(CHAR x
)
481 /***********************************************************************
482 * IsCharUpper32W (USER32.338)
483 * FIXME: handle current locale
485 BOOL WINAPI
IsCharUpperW(WCHAR x
)
490 /***********************************************************************
491 * FormatMessage16 (USER.606)
493 DWORD WINAPI
FormatMessage16(
495 SEGPTR lpSource
, /*not always a valid pointer*/
498 LPSTR lpBuffer
, /* *((HLOCAL16*)) for FORMAT_MESSAGE_ALLOCATE_BUFFER*/
500 LPDWORD args
/* va_list *args */
503 /* This implementation is completely dependant on the format of the va_list on x86 CPUs */
507 DWORD width
= dwFlags
& FORMAT_MESSAGE_MAX_WIDTH_MASK
;
509 LPSTR allocstring
= NULL
;
511 TRACE("(0x%lx,%lx,%d,0x%x,%p,%d,%p)\n",
512 dwFlags
,lpSource
,dwMessageId
,dwLanguageId
,lpBuffer
,nSize
,args
);
514 FIXME("line wrapping not supported.\n");
516 if (dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
517 from
= HEAP_strdupA( GetProcessHeap(), 0, PTR_SEG_TO_LIN(lpSource
));
518 if (dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
) {
519 from
= HeapAlloc( GetProcessHeap(),0,200 );
520 sprintf(from
,"Systemmessage, messageid = 0x%08x\n",dwMessageId
);
522 if (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
) {
524 HINSTANCE16 hinst16
= ((HMODULE
)lpSource
& 0xffff);
526 dwMessageId
&= 0xFFFF;
527 bufsize
=LoadString16(hinst16
,dwMessageId
,NULL
,0);
529 from
= HeapAlloc( GetProcessHeap(), 0, bufsize
+1);
530 LoadString16(hinst16
,dwMessageId
,from
,bufsize
+1);
533 target
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 100);
537 #define ADD_TO_T(c) \
539 if (t-target == talloced) {\
540 target = (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
541 t = target+talloced;\
550 char *fmtstr
,*sprintfbuf
,*x
,*lastf
;
561 case '1':case '2':case '3':case '4':case '5':
562 case '6':case '7':case '8':case '9':
565 case '0':case '1':case '2':case '3':
566 case '4':case '5':case '6':case '7':
569 insertnr
=insertnr
*10+*f
-'0';
578 if (NULL
!=(x
=strchr(f
,'!'))) {
580 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
581 sprintf(fmtstr
,"%%%s",f
);
584 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
));
585 sprintf(fmtstr
,"%%%s",f
);
586 f
+=strlen(f
); /*at \0*/
592 fmtstr
=HEAP_strdupA(GetProcessHeap(),0,"%s");
594 argliststart
=args
+insertnr
-1;
595 if (fmtstr
[strlen(fmtstr
)-1]=='s')
596 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,
597 strlen(PTR_SEG_TO_LIN(argliststart
[0]))+1);
599 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,100);
601 /* CMF - This makes a BIG assumption about va_list */
602 wvsprintf16(sprintfbuf
, fmtstr
, (va_list) argliststart
);
607 HeapFree(GetProcessHeap(),0,sprintfbuf
);
609 /* NULL args - copy formatstr
612 while ((lastf
<f
)&&(*lastf
)) {
616 HeapFree(GetProcessHeap(),0,fmtstr
);
618 case '0': /* Just stop processing format string */
622 case 'n': /* 16 bit version just outputs 'n' */
627 } else { /* '\n' or '\r' gets mapped to "\r\n" */
628 if(*f
== '\n' || *f
== '\r') {
631 if(*f
++ == '\r' && *f
== '\n')
640 talloced
= strlen(target
)+1;
641 if (nSize
&& talloced
<nSize
) {
642 target
= (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,target
,nSize
);
644 TRACE("-- %s\n",debugstr_a(target
));
645 if (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) {
646 /* nSize is the MINIMUM size */
647 *((HLOCAL16
*)lpBuffer
)= LocalAlloc16(LPTR
,talloced
);
648 allocstring
=PTR_SEG_OFF_TO_LIN(CURRENT_DS
,*((HLOCAL16
*)lpBuffer
));
649 memcpy( allocstring
,target
,talloced
);
651 lstrcpynA(lpBuffer
,target
,nSize
);
652 HeapFree(GetProcessHeap(),0,target
);
653 if (from
) HeapFree(GetProcessHeap(),0,from
);
654 return (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) ?
659 #endif /* __i386__ */
663 /***********************************************************************
664 * FormatMessageA (KERNEL32.138)
665 * FIXME: missing wrap,FROM_SYSTEM message-loading,
667 DWORD WINAPI
FormatMessageA(
674 LPDWORD args
/* va_list *args */
677 /* This implementation is completely dependant on the format of the va_list on x86 CPUs */
681 DWORD width
= dwFlags
& FORMAT_MESSAGE_MAX_WIDTH_MASK
;
684 TRACE("(0x%lx,%p,%ld,0x%lx,%p,%ld,%p)\n",
685 dwFlags
,lpSource
,dwMessageId
,dwLanguageId
,lpBuffer
,nSize
,args
);
687 FIXME("line wrapping not supported.\n");
689 if (dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
690 from
= HEAP_strdupA( GetProcessHeap(), 0, (LPSTR
)lpSource
);
691 if (dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
) {
692 from
= HeapAlloc( GetProcessHeap(),0,200 );
693 sprintf(from
,"Systemmessage, messageid = 0x%08lx\n",dwMessageId
);
695 if (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
) {
698 dwMessageId
&= 0xFFFF;
699 bufsize
=LoadMessageA((HMODULE
)lpSource
,dwMessageId
,dwLanguageId
,NULL
,100);
701 from
= HeapAlloc( GetProcessHeap(), 0, bufsize
+ 1 );
702 LoadMessageA((HMODULE
)lpSource
,dwMessageId
,dwLanguageId
,from
,bufsize
+1);
705 target
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 100);
709 #define ADD_TO_T(c) \
711 if (t-target == talloced) {\
712 target = (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
713 t = target+talloced;\
722 char *fmtstr
,*sprintfbuf
,*x
,*lastf
;
733 case '1':case '2':case '3':case '4':case '5':
734 case '6':case '7':case '8':case '9':
737 case '0':case '1':case '2':case '3':
738 case '4':case '5':case '6':case '7':
741 insertnr
=insertnr
*10+*f
-'0';
750 if (NULL
!=(x
=strchr(f
,'!'))) {
752 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
)+2);
753 sprintf(fmtstr
,"%%%s",f
);
756 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
));
757 sprintf(fmtstr
,"%%%s",f
);
758 f
+=strlen(f
); /*at \0*/
764 fmtstr
=HEAP_strdupA(GetProcessHeap(),0,"%s");
766 if (dwFlags
& FORMAT_MESSAGE_ARGUMENT_ARRAY
)
767 argliststart
=args
+insertnr
-1;
769 argliststart
=(*(DWORD
**)args
)+insertnr
-1;
771 if (fmtstr
[strlen(fmtstr
)-1]=='s' && argliststart
[0])
772 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,strlen((LPSTR
)argliststart
[0])+1);
774 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,100);
776 /* CMF - This makes a BIG assumption about va_list */
777 wvsprintfA(sprintfbuf
, fmtstr
, (va_list) argliststart
);
782 HeapFree(GetProcessHeap(),0,sprintfbuf
);
784 /* NULL args - copy formatstr
787 while ((lastf
<f
)&&(*lastf
)) {
791 HeapFree(GetProcessHeap(),0,fmtstr
);
806 } else { /* '\n' or '\r' gets mapped to "\r\n" */
807 if(*f
== '\n' || *f
== '\r') {
810 if(*f
++ == '\r' && *f
== '\n')
819 talloced
= strlen(target
)+1;
820 if (nSize
&& talloced
<nSize
) {
821 target
= (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,target
,nSize
);
823 TRACE("-- %s\n",debugstr_a(target
));
824 if (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) {
825 /* nSize is the MINIMUM size */
826 *((LPVOID
*)lpBuffer
) = (LPVOID
)LocalAlloc(GMEM_ZEROINIT
,talloced
);
827 memcpy(*(LPSTR
*)lpBuffer
,target
,talloced
);
829 lstrcpynA(lpBuffer
,target
,nSize
);
831 HeapFree(GetProcessHeap(),0,target
);
832 if (from
) HeapFree(GetProcessHeap(),0,from
);
833 return (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) ?
834 strlen(*(LPSTR
*)lpBuffer
):
838 #endif /* __i386__ */
843 /***********************************************************************
844 * FormatMessageW (KERNEL32.138)
846 DWORD WINAPI
FormatMessageW(
853 LPDWORD args
/* va_list *args */
856 /* This implementation is completely dependant on the format of the va_list on x86 CPUs */
860 DWORD width
= dwFlags
& FORMAT_MESSAGE_MAX_WIDTH_MASK
;
863 TRACE("(0x%lx,%p,%ld,0x%lx,%p,%ld,%p)\n",
864 dwFlags
,lpSource
,dwMessageId
,dwLanguageId
,lpBuffer
,nSize
,args
);
866 FIXME("line wrapping not supported.\n");
868 if (dwFlags
& FORMAT_MESSAGE_FROM_STRING
)
869 from
= HEAP_strdupWtoA(GetProcessHeap(),0,(LPWSTR
)lpSource
);
870 if (dwFlags
& FORMAT_MESSAGE_FROM_SYSTEM
) {
871 /* gather information from system message tables ... */
872 from
= HeapAlloc( GetProcessHeap(),0,200 );
873 sprintf(from
,"Systemmessage, messageid = 0x%08lx\n",dwMessageId
);
875 if (dwFlags
& FORMAT_MESSAGE_FROM_HMODULE
) {
878 dwMessageId
&= 0xFFFF;
879 bufsize
=LoadMessageA((HMODULE
)lpSource
,dwMessageId
,dwLanguageId
,NULL
,100);
882 from
= HeapAlloc( GetProcessHeap(), 0, bufsize
+ 1 );
883 LoadMessageA((HMODULE
)lpSource
,dwMessageId
,dwLanguageId
,from
,bufsize
+1);
886 target
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, 100 );
890 #define ADD_TO_T(c) \
892 if (t-target == talloced) {\
893 target = (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2);\
894 t = target+talloced;\
903 char *fmtstr
,*sprintfbuf
,*x
;
913 case '1':case '2':case '3':case '4':case '5':
914 case '6':case '7':case '8':case '9':
917 case '0':case '1':case '2':case '3':
918 case '4':case '5':case '6':case '7':
921 insertnr
=insertnr
*10+*f
-'0';
930 if (NULL
!=(x
=strchr(f
,'!')))
933 fmtstr
=HeapAlloc( GetProcessHeap(), 0, strlen(f
)+2);
934 sprintf(fmtstr
,"%%%s",f
);
937 fmtstr
=HeapAlloc(GetProcessHeap(),0,strlen(f
));
938 sprintf(fmtstr
,"%%%s",f
);
939 f
+=strlen(f
); /*at \0*/
945 fmtstr
=HEAP_strdupA( GetProcessHeap(),0,"%s");
946 if (dwFlags
& FORMAT_MESSAGE_ARGUMENT_ARRAY
)
947 argliststart
=args
+insertnr
-1;
949 argliststart
=(*(DWORD
**)args
)+insertnr
-1;
951 if (fmtstr
[strlen(fmtstr
)-1]=='s' && argliststart
[0]) {
954 xarr
[0]=(DWORD
)HEAP_strdupWtoA(GetProcessHeap(),0,(LPWSTR
)(*(argliststart
+0)));
955 /* possible invalid pointers */
956 xarr
[1]=*(argliststart
+1);
957 xarr
[2]=*(argliststart
+2);
958 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,lstrlenW((LPWSTR
)argliststart
[0])*2+1);
960 /* CMF - This makes a BIG assumption about va_list */
961 vsprintf(sprintfbuf
, fmtstr
, (va_list) xarr
);
963 sprintfbuf
=HeapAlloc(GetProcessHeap(),0,100);
965 /* CMF - This makes a BIG assumption about va_list */
966 wvsprintfA(sprintfbuf
, fmtstr
, (va_list) argliststart
);
972 HeapFree(GetProcessHeap(),0,sprintfbuf
);
973 HeapFree(GetProcessHeap(),0,fmtstr
);
988 } else { /* '\n' or '\r' gets mapped to "\r\n" */
989 if(*f
== '\n' || *f
== '\r') {
992 if(*f
++ == '\r' && *f
== '\n')
1001 talloced
= strlen(target
)+1;
1002 if (nSize
&& talloced
<nSize
)
1003 target
= (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,target
,nSize
);
1004 if (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) {
1005 /* nSize is the MINIMUM size */
1006 *((LPVOID
*)lpBuffer
) = (LPVOID
)LocalAlloc(GMEM_ZEROINIT
,talloced
*2+2);
1007 lstrcpynAtoW(*(LPWSTR
*)lpBuffer
,target
,talloced
);
1009 lstrcpynAtoW(lpBuffer
,target
,nSize
);
1010 HeapFree(GetProcessHeap(),0,target
);
1011 if (from
) HeapFree(GetProcessHeap(),0,from
);
1012 return (dwFlags
& FORMAT_MESSAGE_ALLOCATE_BUFFER
) ?
1013 lstrlenW(*(LPWSTR
*)lpBuffer
):
1017 #endif /* __i386__ */