Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions edslib/fsw/src/edslib_binding_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@
#include <stdint.h>
#include <stddef.h>
#include <setjmp.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <ctype.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>

#include "edslib_id.h"
#include "edslib_datatypedb.h"
Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_database_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_datatypedb_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_datatypedb_constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_datatypedb_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_datatypedb_pack_unpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdint.h>
Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_displaydb_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_displaydb_iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_displaydb_locate.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_displaydb_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
53 changes: 48 additions & 5 deletions edslib/fsw/src/edslib_displaydb_stringconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,56 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <strings.h>
#include <ctype.h>
#include <limits.h>

#include <stdint.h>
#include "edslib_internal.h"


/*----------------------------------------------------------------
*
* EdsLib local helper function
*
*----------------------------------------------------------------*/
static int32_t EdsLib_Internal_StringCompare_IgnoreCase(const char *String1,
const char *String2)
{
uint32_t Index = 0U;
int32_t Result = 0;
int32_t Char1 = 0;
int32_t Char2 = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Char1 and Char2 should be int here as opposed to int32_t (this is the type needed for ctype.h macros)
Also remove init to 0 because its done later from string data (static analysis will complain about this)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good observation, has been adjusted accordingly

while (Result == 0)
{
if (String1[Index] == '\0' || String2[Index] == '\0')
{
Result = String1[Index] - String2[Index];
break;
}

Char1 = (int32_t)String1[Index];
Char2 = (int32_t)String2[Index];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this before the "if" and then compare Char1 and Char2 rather than String1[Index] (more readable, I think)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Has been cleaned up

/* Convert characters to lower case if they're alphabetical */
if (isalpha(Char1))
{
Char1 = tolower(Char1);
}

if (isalpha(Char2))
{
Char2 = tolower(Char2);
}

Result = Char1 - Char2;

++Index;
}

return Result;
}

/*----------------------------------------------------------------
*
* EdsLib internal function
Expand Down Expand Up @@ -419,22 +462,22 @@ int32_t EdsLib_DisplayScalarConv_FromString_Impl(const EdsLib_DataTypeDB_Entry_t
{
/* typically TRUE/FALSE, also accept YES/NO or 0/1 */
const char *EndPtr = SrcString;
if (strcasecmp(SrcString, "true") == 0)
if (EdsLib_Internal_StringCompare_IgnoreCase(SrcString, "true") == 0)
{
EndPtr += 4;
NumberBuffer.Value.UnsignedInteger = 1;
}
else if (strcasecmp(SrcString, "false") == 0)
else if (EdsLib_Internal_StringCompare_IgnoreCase(SrcString, "false") == 0)
{
EndPtr += 4;
NumberBuffer.Value.UnsignedInteger = 0;
}
else if (strcasecmp(SrcString, "yes") == 0)
else if (EdsLib_Internal_StringCompare_IgnoreCase(SrcString, "yes") == 0)
{
EndPtr += 3;
NumberBuffer.Value.UnsignedInteger = 1;
}
else if (strcasecmp(SrcString, "no") == 0)
else if (EdsLib_Internal_StringCompare_IgnoreCase(SrcString, "no") == 0)
{
EndPtr += 2;
NumberBuffer.Value.UnsignedInteger = 0;
Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_global_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_intfdb_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
1 change: 0 additions & 1 deletion edslib/fsw/src/edslib_intfdb_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <ctype.h>

Expand Down
Loading