Skip to content

Commit 695ce10

Browse files
author
Mikachu2333
authored
Add xy_streql_ic (#242)
* add xy_streql_ic * fix format * only target use it
1 parent c36be5f commit 695ce10

2 files changed

Lines changed: 34 additions & 7 deletions

File tree

lib/xy.h

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@
33
* SPDX-License-Identifier: MIT
44
* -------------------------------------------------------------
55
* Lib Name : xy.h
6-
* Lib Authors : Aoran Zeng <ccmywish@qq.com>
7-
* | Heng Guo <2085471348@qq.com>
8-
* Contributors : juzeon <skyjuzheng@gmail.com>
6+
* Lib Authors : Aoran Zeng <ccmywish@qq.com>
7+
* | Heng Guo <2085471348@qq.com>
8+
* Contributors : juzeon <skyjuzheng@gmail.com>
9+
* | Mikachu2333 <mikachu.23333@zohomail.com>
910
* |
1011
* Created On : <2023-08-28>
11-
* Last Modified : <2025-07-19>
12+
* Last Modified : <2025-08-07>
1213
*
1314
* xy: 襄阳、咸阳
14-
* Corss-Platform C11 utilities for CLI applications in mixed flavor (mostly Ruby)
15+
* Corss-Platform C11 utilities for CLI applications in mixed
16+
* flavor (mostly Ruby)
1517
* ------------------------------------------------------------*/
1618

1719
#ifndef XY_H
1820
#define XY_H
1921

20-
#define _XY_Version "v0.1.5.2-2025/07/19"
22+
#define _XY_Version "v0.1.5.3-2025/08/07"
2123
#define _XY_Maintain_URL "https://github.com/RubyMetric/chsrc/blob/dev/lib/xy.h"
2224
#define _XY_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc/blob/dev/lib/xy.h"
2325

@@ -377,6 +379,31 @@ xy_streql (const char *str1, const char *str2)
377379
return strcmp (str1, str2) == 0 ? true : false;
378380
}
379381

382+
static bool
383+
xy_streql_ic(const char *str1, const char *str2)
384+
{
385+
if (NULL == str1 || NULL == str2)
386+
{
387+
return false;
388+
}
389+
390+
size_t len1 = strlen(str1);
391+
size_t len2 = strlen(str2);
392+
if (len1 != len2)
393+
{
394+
return false;
395+
}
396+
397+
for (size_t i = 0; i < len1; i++)
398+
{
399+
if (tolower(str1[i]) != tolower(str2[i]))
400+
{
401+
return false;
402+
}
403+
}
404+
return true;
405+
}
406+
380407
static char *
381408
xy_str_to_quietcmd (const char *cmd)
382409
{

src/chsrc-main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ iterate_targets_ (const char ***array, size_t size, const char *input, const cha
402402
alias = target[k];
403403
while (NULL!=alias)
404404
{
405-
if (xy_streql (input, alias))
405+
if (xy_streql_ic (input, alias))
406406
{
407407
matched = 1; break;
408408
}

0 commit comments

Comments
 (0)