ask whether strstr found the tag, not whether it is positive

strstr returns a pointer into the string or NULL, and these four tests compare
that pointer to 0 with >. Ordering a pointer against a null pointer constant
is not something C++ defines; MSVC allows it, clang rejects it.

The intent is plainly "did this attribute name contain the tag", and the
result is the same either way, since the only pointer these can produce that
is not greater than zero is the null one. != NULL says it directly, and reads
like the strcmp(name, "...") == 0 tests it sits between.

strstr rather than strcmp is deliberate here: the attributes it looks for are
numbered, usAttachment1 through usAttachment4 and usResult1 upwards, so an
exact comparison would not match them. That is unchanged.

Verification:

    grep -rn 'strstr([^)]*)[ \t]*[><]' --include=*.cpp --include=*.h .   # nothing
    ninja -C build parse         # pointer-ordering class gone: 32 -> 28 sites
    ninja -C build -k 0          # Release, four applications, green
    ninja -C build-debug -k 0    # Debug, four applications, green

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marco Antonio J. Costa
2026-07-23 19:29:55 -03:00
committed by majcosta
co-authored by Claude Opus 4.8
parent 1d6ff6be3c
commit 1bf28bc07a
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -46,7 +46,7 @@ attachmentcombomergeStartElementHandle(void *userData, const XML_Char *name, con
else if(pData->curElement == ELEMENT &&
(strcmp(name, "uiIndex") == 0 ||
strcmp(name, "usItem") == 0 ||
strstr(name, "usAttachment") > 0 ||
strstr(name, "usAttachment") != NULL ||
strcmp(name, "usResult") == 0 ))
{
pData->curElement = ELEMENT_PROPERTY;
@@ -104,7 +104,7 @@ attachmentcombomergeEndElementHandle(void *userData, const XML_Char *name)
pData->curElement = ELEMENT;
pData->curAttachmentComboMerge.usItem = (UINT16) atol(pData->szCharData);
}
else if(strstr(name, "usAttachment") > 0)
else if(strstr(name, "usAttachment") != NULL)
{
pData->curElement = ELEMENT;
pData->curAttachmentComboMerge.usAttachment[pData->curAttIndex] = (UINT16) atol(pData->szCharData);
+2 -2
View File
@@ -60,7 +60,7 @@ transformStartElementHandle(void *userData, const XML_Char *name, const XML_Char
}
else if(pData->curElement == ELEMENT &&
(strcmp(name, "usItem") == 0 ||
strstr(name, "usResult") > 0 ||
strstr(name, "usResult") != NULL ||
strcmp(name, "usAPCost") == 0 ||
strcmp(name, "iBPCost") == 0 ||
strcmp(name, "szMenuRowText") == 0 ||
@@ -130,7 +130,7 @@ transformEndElementHandle(void *userData, const XML_Char *name)
}
pData->curTransform.usItem = usItem;
}
else if(strstr(name, "usResult") > 0)
else if(strstr(name, "usResult") != NULL)
{
pData->curElement = ELEMENT;
pData->curTransform.usResult[pData->curResultIndex] = (UINT16) atol(pData->szCharData);