diff options
| author | aidanfnv <aidanf@nvidia.com> | 2025-08-11 11:54:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-11 18:54:47 +0000 |
| commit | 5b64150cdf0dfd6e068cdf27c5ea857c2d967d15 (patch) | |
| tree | 3932372950e4524f9e011738b89a15887bf553d8 /source | |
| parent | dcdebc1a76a0a6ffbfd6a5805354f8f679c60202 (diff) | |
Do case-sensitive search for category first in slangc -h (#8142)
Related to #7969
In the slangc help text we have two categories, the option category
`Target` and the values category `target`, where the names only differ
by case. The help parser finds the category in the list by the
case-insensitive name, so `slangc -h Target` and `slangc -h target` will
both print the `Target` help text and never the `target` help text.
This commit replaces the case-insensitive name search with a
case-sensitive one, and then only if the case-sensitive check fails do
we do a case-insensitive search.
That way, if the user uses `Target` they get the `Target` text, for
`target` they get the `target` text. If they use something like
`Capability`, a category that does not exist but whose name is
upper-case of the value category `capability`, they will still get the
help text for `capability` as before as a fallback.
---------
Co-authored-by: slangbot <ellieh+slangbot@nvidia.com>
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-options.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index e777d27bc..b0eb1748d 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -2009,8 +2009,14 @@ SlangResult OptionsParser::_parseHelp(const CommandLineArg& arg) { auto catArg = m_reader.getArgAndAdvance(); - categoryIndex = - m_cmdOptions->findCategoryByCaseInsensitiveName(catArg.value.getUnownedSlice()); + categoryIndex = m_cmdOptions->findCategoryByName(catArg.value.getUnownedSlice()); + + if (categoryIndex < 0) + { + categoryIndex = + m_cmdOptions->findCategoryByCaseInsensitiveName(catArg.value.getUnownedSlice()); + } + if (categoryIndex < 0) { m_sink->diagnose(catArg.loc, Diagnostics::unknownHelpCategory); |
