mirror of
https://github.com/reactos/reactos.git
synced 2025-07-05 00:11:22 +00:00
- RosGetTimeFormat(): replace "if (!cchTime) ; else ..." by "if (cchTime)" and adjust comment
- Kohn Emil Dan <emild@cs.technion.ac.il>: 1) RosGetTimeFormat() has a small bug. The last statement should be return nPos; and not return cchTime; 2) GetTimeFormatA() is not implemented. I have written an implementation for it, which calls GetTimeFormatW(), and converts the string parameters back and forth. (committed with adjustments for correct error handling) svn path=/trunk/; revision=9092
This commit is contained in:
parent
03124cf16a
commit
a46eec6cea
1 changed files with 78 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: lang.c,v 1.12 2004/01/28 23:03:59 gdalsnes Exp $
|
/* $Id: lang.c,v 1.13 2004/04/12 10:19:43 mf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT : ReactOS user mode libraries
|
* PROJECT : ReactOS user mode libraries
|
||||||
|
@ -1235,18 +1235,20 @@ INT RosGetTimeFormat(LCID Locale, DWORD dwFlags, CONST SYSTEMTIME *lpTime, LPCWS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cchTime)
|
/* Are we not only counting? */
|
||||||
/* We are counting */;
|
if (cchTime)
|
||||||
else if (nPos >= cchTime)
|
{
|
||||||
|
if (nPos >= cchTime)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lpTimeStr[nPos] = '\0';
|
lpTimeStr[nPos] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
nPos++;
|
nPos++;
|
||||||
return cchTime;
|
return nPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1302,7 +1304,7 @@ GetTimeFormatW (
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
STDCALL
|
STDCALL
|
||||||
|
@ -1314,8 +1316,73 @@ GetTimeFormatA (
|
||||||
LPSTR lpTimeStr,
|
LPSTR lpTimeStr,
|
||||||
int cchTime
|
int cchTime
|
||||||
)
|
)
|
||||||
{ return sizeof(lpTimeStr);
|
{
|
||||||
|
LPWSTR lpFormatU = NULL;
|
||||||
|
LPWSTR lpTimeStrU;
|
||||||
|
int numCharsU;
|
||||||
|
int retVal;
|
||||||
|
|
||||||
|
if (lpFormat != NULL) {
|
||||||
|
/* First just determine the number of necessary bytes
|
||||||
|
for the unicode string */
|
||||||
|
int numBytes = MultiByteToWideChar(CP_ACP,
|
||||||
|
MB_ERR_INVALID_CHARS,
|
||||||
|
lpFormat,
|
||||||
|
-1,
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
|
||||||
|
/* Try really hard not to fail due to format problems
|
||||||
|
If there are any problems with the format pass NULL
|
||||||
|
to GetTimeFormatW() */
|
||||||
|
if (numBytes > 0) {
|
||||||
|
lpFormatU = HeapAlloc(GetProcessHeap(),0,numBytes);
|
||||||
|
|
||||||
|
if (lpFormatU != NULL)
|
||||||
|
MultiByteToWideChar(CP_ACP,
|
||||||
|
0,
|
||||||
|
lpFormat,
|
||||||
|
-1,
|
||||||
|
lpFormatU,
|
||||||
|
numBytes);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Just get the number of characters needed to store the
|
||||||
|
Unicode output */
|
||||||
|
numCharsU = GetTimeFormatW(Locale,dwFlags,lpTime,lpFormatU,NULL,0);
|
||||||
|
|
||||||
|
if (numCharsU == 0) {
|
||||||
|
if (lpFormatU != NULL)
|
||||||
|
HeapFree(GetProcessHeap(),0,lpFormatU);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
lpTimeStrU = HeapAlloc(GetProcessHeap(),0,numCharsU*sizeof(WCHAR));
|
||||||
|
if (lpTimeStrU == NULL) {
|
||||||
|
if (lpFormatU != NULL)
|
||||||
|
HeapFree(GetProcessHeap(),0,lpFormatU);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetTimeFormatW(Locale,dwFlags,lpTime,lpFormatU,lpTimeStrU,numCharsU))
|
||||||
|
/* Convert the output string to ANSI */
|
||||||
|
retVal = WideCharToMultiByte(CP_ACP,
|
||||||
|
0,
|
||||||
|
lpTimeStrU,
|
||||||
|
numCharsU,
|
||||||
|
lpTimeStr,
|
||||||
|
cchTime,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(),0,lpTimeStrU);
|
||||||
|
if (lpFormatU != NULL)
|
||||||
|
HeapFree(GetProcessHeap(),0,lpFormatU);
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _OLE2NLS_IN_BUILD_
|
#ifndef _OLE2NLS_IN_BUILD_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue