if (quote && (len >= (int)wcslen(value))) buffer[wcslen(buffer)-1] = '\0';
}
-
/* byte-swaps shorts in-place in a buffer. len is in WCHARs */
static __inline void PROFILE_ByteSwapShortBuffer(WCHAR * buffer, int len)
{
shortbuffer[i] = RtlUshortByteSwap(shortbuffer[i]);
}
-
/* writes any necessary encoding marker to the file */
static __inline void PROFILE_WriteMarker(HANDLE hFile, ENCODING encoding)
{
DPRINT("Error %ld reading file\n", GetLastError());
return NULL;
}
-
len = dwFileSize;
*pEncoding = PROFILE_DetectTextEncoding(buffer_base, &len);
/* len is set to the number of bytes in the character marker.
while (szLineStart < szLineEnd && PROFILE_isspaceW(*szLineStart)) szLineStart++;
while ((szLineEnd > szLineStart) && PROFILE_isspaceW(szLineEnd[-1])) szLineEnd--;
- if (szLineStart >= szLineEnd)
- continue;
+ if (szLineStart >= szLineEnd) continue;
if (*szLineStart == '[') /* section start */
{
* If return_values is TRUE, also include the corresponding values.
*/
static INT PROFILE_GetSection( PROFILESECTION *section, LPCWSTR section_name,
- LPWSTR buffer, UINT len, BOOL return_values, BOOL return_noequalkeys )
+ LPWSTR buffer, UINT len, BOOL return_values )
{
PROFILEKEY *key;
- if (!buffer)
- return 0;
+ if(!buffer) return 0;
DPRINT("%S,%p,%u\n", section_name, buffer, len);
if (len <= 2) break;
if (!*key->name) continue; /* Skip empty lines */
if (IS_ENTRY_COMMENT(key->name)) continue; /* Skip comments */
- if (!return_noequalkeys && !return_values && !key->value) continue; /* Skip lines w.o. '=' */
+ if (!return_values && !key->value) continue; /* Skip lines w.o. '=' */
PROFILE_CopyEntry( buffer, key->name, len - 1, 0 );
len -= wcslen(buffer) + 1;
buffer += wcslen(buffer) + 1;
/* no "else" here ! */
if (section && section[0])
{
- INT ret = PROFILE_GetSection(CurProfile->section, section, buffer, len, FALSE, !win32);
+ INT ret = PROFILE_GetSection(CurProfile->section, section, buffer, len, FALSE);
if (!buffer[0]) /* no luck -> def_val */
{
PROFILE_CopyEntry(buffer, def_val, len, TRUE);
filename )))
return def_val;
- if (len+1 == sizeof(buffer)/sizeof(WCHAR))
- DPRINT1("result may be wrong!\n");
-
/* FIXME: if entry can be found but it's empty, then Win16 is
* supposed to return 0 instead of def_val ! Difficult/problematic
* to implement (every other failure also returns zero buffer),
* thus wait until testing framework avail for making sure nothing
* else gets broken that way. */
- if (!buffer[0])
- return (UINT)def_val;
+ if (!buffer[0]) return (UINT)def_val;
RtlInitUnicodeString( &bufferW, buffer );
- RtlUnicodeStringToInteger( &bufferW, 0, &result); // 10
+ RtlUnicodeStringToInteger( &bufferW, 0, &result);
return result;
}
RtlEnterCriticalSection( &PROFILE_CritSect );
if (PROFILE_Open( filename, FALSE ))
- ret = PROFILE_GetSection(CurProfile->section, section, buffer, len, TRUE, FALSE);
+ ret = PROFILE_GetSection(CurProfile->section, section, buffer, len, TRUE);
RtlLeaveCriticalSection( &PROFILE_CritSect );
return 0;
}
- bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ bufferW = HeapAlloc(GetProcessHeap(), 0, len * 2 * sizeof(WCHAR));
if (!bufferW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
else filenameW.Buffer = NULL;
- retW = GetPrivateProfileSectionW(sectionW.Buffer, bufferW, len, filenameW.Buffer);
- if (len > 2)
+ retW = GetPrivateProfileSectionW(sectionW.Buffer, bufferW, len * 2, filenameW.Buffer);
+ if (retW)
{
+ if (retW == len * 2 - 2) retW++; /* overflow */
ret = WideCharToMultiByte(CP_ACP, 0, bufferW, retW + 1, buffer, len, NULL, NULL);
- if (ret > 2)
- ret -= 1;
- else
+ if (!ret || ret == len) /* overflow */
{
- ret = 0;
+ ret = len - 2;
buffer[len-2] = 0;
buffer[len-1] = 0;
}
+ else ret--;
}
else
{
{
if (CurProfile) PROFILE_ReleaseFile(); /* always return FALSE in this case */
}
- }
+ }
else if (PROFILE_Open( filename, TRUE )) {
if (!string) {/* delete the named section*/
ret = PROFILE_SetString(section,NULL,NULL, FALSE);
INT retW, ret = 0;
bufferW = buffer ? HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)) : NULL;
- if (filename)
- RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
- else
- filenameW.Buffer = NULL;
+ if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename);
+ else filenameW.Buffer = NULL;
retW = GetPrivateProfileSectionNamesW(bufferW, size, filenameW.Buffer);
if (retW && size)
}
+
/***********************************************************************
* WritePrivateProfileStructW (KERNEL32.@)
*/
return ret;
}
-
/***********************************************************************
* WritePrivateProfileStructA (KERNEL32.@)
*/