GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_string_compare.c Lines: 9 9 100.0 %
Date: 2026-03-06 19:21:09 Branches: 8 8 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Utility (Utility)                                                   */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_utility.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_utility_string_compare                          PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function compares two strings character by character.          */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    string_1                              String to be compared         */
48
/*    string_2                              Another string to be compared */
49
/*    count                                 number of bytes to compare    */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    [GX_TRUE | GX_FALSE]                  [equal | not equal]           */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    None                                                                */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    GUIX Internal Code                                                  */
62
/*                                                                        */
63
/**************************************************************************/
64
1597
GX_BOOL _gx_utility_string_compare(GX_CONST GX_STRING *string_1, GX_CONST GX_STRING *string_2, UINT count)
65
{
66
1597
UINT index = 0;
67
68

1597
    if ((string_1 -> gx_string_length < count) || (string_2 -> gx_string_length < count))
69
    {
70
        /* Not equal.*/
71
2
        return GX_FALSE;
72
    }
73
74
9267
    while (index < count)
75
    {
76
7747
        if (string_1 -> gx_string_ptr[index] != string_2 -> gx_string_ptr[index])
77
        {
78
            /* Not equal. */
79
75
            return GX_FALSE;
80
        }
81
82
7672
        index++;
83
    }
84
85
    /* Equal. */
86
1520
    return GX_TRUE;
87
}
88