[USETUP] Some fixes/improvements suggested by Thomas (1/2).

- isspace('\0') returns FALSE anyways so no need to separately test for a NULL character;
- The (str/wcs)toul function cannot return a NULL pointer from its second paramter;
- VersionInfo32_FindChild(): the third argument is indeed a number of characters (not bytes),
  so rename the parameter to make this fact clear. The function is however correctly used within this module.

svn path=/branches/setup_improvements/; revision=74629
This commit is contained in:
Hermès Bélusca-Maïto 2017-05-22 17:55:16 +02:00
parent 5a6050902b
commit 3074ad7159
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 4 additions and 5 deletions

View file

@ -142,7 +142,7 @@ ArcGetNextTokenA(
KeyValue = strtoul(p, (PSTR*)&p, 10); KeyValue = strtoul(p, (PSTR*)&p, 10);
/* Skip any trailing whitespace */ /* Skip any trailing whitespace */
while (*p && isspace(*p)) ++p; while (isspace(*p)) ++p;
/* The token must terminate with ')' */ /* The token must terminate with ')' */
if (*p != ')') if (*p != ')')
@ -202,10 +202,9 @@ ArcGetNextTokenU(
*/ */
// KeyValue = _wtoi(p); // KeyValue = _wtoi(p);
KeyValue = wcstoul(p, (PWSTR*)&p, 10); KeyValue = wcstoul(p, (PWSTR*)&p, 10);
ASSERT(p);
/* Skip any trailing whitespace */ /* Skip any trailing whitespace */
while (*p && iswspace(*p)) ++p; while (iswspace(*p)) ++p;
/* The token must terminate with ')' */ /* The token must terminate with ')' */
if (*p != L')') if (*p != L')')

View file

@ -104,13 +104,13 @@ static PCVS_VERSION_INFO_STRUCT32
VersionInfo32_FindChild( VersionInfo32_FindChild(
IN PCVS_VERSION_INFO_STRUCT32 info, IN PCVS_VERSION_INFO_STRUCT32 info,
IN PCWSTR szKey, IN PCWSTR szKey,
IN UINT cbKey) IN UINT cchKey)
{ {
PCVS_VERSION_INFO_STRUCT32 child = VersionInfo32_Children(info); PCVS_VERSION_INFO_STRUCT32 child = VersionInfo32_Children(info);
while ((ULONG_PTR)child < (ULONG_PTR)info + info->wLength) while ((ULONG_PTR)child < (ULONG_PTR)info + info->wLength)
{ {
if (!_wcsnicmp(child->szKey, szKey, cbKey) && !child->szKey[cbKey]) if (!_wcsnicmp(child->szKey, szKey, cchKey) && !child->szKey[cchKey])
return child; return child;
if (child->wLength == 0) return NULL; if (child->wLength == 0) return NULL;