cwCommonImpl.h/cpp : Added #include <ccytpe>. Check for null label in labelToId()

This commit is contained in:
kevin 2023-07-25 20:22:44 -04:00
parent 7e6ab875c9
commit 39599e3e2e
2 changed files with 7 additions and 4 deletions

View File

@ -28,9 +28,11 @@ const char* cw::idToLabel( const idLabelPair_t* array, unsigned id, unsigned eol
unsigned cw::labelToId( const idLabelPair_t* array, const char* label, unsigned eolId ) unsigned cw::labelToId( const idLabelPair_t* array, const char* label, unsigned eolId )
{ {
const idLabelPair_t* p = array; const idLabelPair_t* p = array;
for(; p->id != eolId; ++p)
if( std::strcmp(label,p->label) == 0 ) if( label != nullptr )
return p->id; for(; p->id != eolId; ++p)
if( std::strcmp(label,p->label) == 0 )
return p->id;
return eolId; return eolId;
} }

View File

@ -17,6 +17,7 @@
#include <atomic> #include <atomic>
#include <cstdint> #include <cstdint>
#include <cmath> #include <cmath>
#include <cctype>
#include <complex> #include <complex>
#include <type_traits> #include <type_traits>
@ -151,7 +152,7 @@ namespace cw
cwAssert( h.p != nullptr ); cwAssert( h.p != nullptr );
return h.p; return h.p;
} }
typedef struct idLabelPair_str typedef struct idLabelPair_str
{ {
unsigned id; unsigned id;