From 5b64150cdf0dfd6e068cdf27c5ea857c2d967d15 Mon Sep 17 00:00:00 2001 From: aidanfnv Date: Mon, 11 Aug 2025 11:54:47 -0700 Subject: 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 Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/slang/slang-options.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source') 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); -- cgit v1.2.3