GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_string_compare.c Lines: 9 9 100.0 %
Date: 2024-12-05 08:52:37 Branches: 8 8 100.0 %

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

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