From b292013bdc7ad01357f5d3ee5fbf4990acb63126 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 4 Jun 2018 15:50:34 +0200 Subject: [PATCH 1/2] cntraining: Replace proprietary BOOL8 by standard bool data type Add also "static" attribute to local functions and remove an old comment. Signed-off-by: Stefan Weil --- src/training/cntraining.cpp | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/training/cntraining.cpp b/src/training/cntraining.cpp index e3949edf..55d520a5 100644 --- a/src/training/cntraining.cpp +++ b/src/training/cntraining.cpp @@ -45,21 +45,11 @@ DECLARE_STRING_PARAM_FLAG(D); Private Function Prototypes ----------------------------------------------------------------------------*/ -void WriteNormProtos(const char *Directory, LIST LabeledProtoList, - const FEATURE_DESC_STRUCT *feature_desc); +static void WriteNormProtos(const char *Directory, LIST LabeledProtoList, + const FEATURE_DESC_STRUCT *feature_desc); -/* -PARAMDESC *ConvertToPARAMDESC( - PARAM_DESC* Param_Desc, - int N); -*/ - -void WriteProtos( - FILE *File, - uint16_t N, - LIST ProtoList, - BOOL8 WriteSigProtos, - BOOL8 WriteInsigProtos); +static void WriteProtos(FILE* File, uint16_t N, LIST ProtoList, + bool WriteSigProtos, bool WriteInsigProtos); /*---------------------------------------------------------------------------- Global Data Definitions and Declarations @@ -216,8 +206,8 @@ int main(int argc, char *argv[]) { * @note Exceptions: none * @note History: Fri Aug 18 16:17:06 1989, DSJ, Created. */ -void WriteNormProtos(const char *Directory, LIST LabeledProtoList, - const FEATURE_DESC_STRUCT *feature_desc) { +static void WriteNormProtos(const char *Directory, LIST LabeledProtoList, + const FEATURE_DESC_STRUCT *feature_desc) { FILE *File; STRING Filename; LABELEDLIST LabeledProto; @@ -254,12 +244,9 @@ void WriteNormProtos(const char *Directory, LIST LabeledProtoList, } // WriteNormProtos /*-------------------------------------------------------------------------*/ -void WriteProtos( - FILE *File, - uint16_t N, - LIST ProtoList, - BOOL8 WriteSigProtos, - BOOL8 WriteInsigProtos) + +static void WriteProtos(FILE* File, uint16_t N, LIST ProtoList, + bool WriteSigProtos, bool WriteInsigProtos) { PROTOTYPE *Proto; From 4f3b266efe46fdac4cce737a26d3a87bc45fe54b Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 4 Jun 2018 16:04:57 +0200 Subject: [PATCH 2/2] src/training: Replace more proprietary BOOL8 by standard bool data type Update also callers of the modified functions to use false / true instead of 0 / 1. Signed-off-by: Stefan Weil --- src/training/cntraining.cpp | 6 +++--- src/training/commontraining.cpp | 8 ++++---- src/training/commontraining.h | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/training/cntraining.cpp b/src/training/cntraining.cpp index 55d520a5..236440f4 100644 --- a/src/training/cntraining.cpp +++ b/src/training/cntraining.cpp @@ -164,7 +164,7 @@ int main(int argc, char *argv[]) { Config.MagicSamples = CharSample->SampleCount; while (Config.MinSamples > 0.001) { ProtoList = ClusterSamples(Clusterer, &Config); - if (NumberOfProtos(ProtoList, 1, 0) > 0) { + if (NumberOfProtos(ProtoList, true, false) > 0) { break; } else { Config.MinSamples *= 0.95; @@ -232,8 +232,8 @@ static void WriteNormProtos(const char *Directory, LIST LabeledProtoList, " (%d significant protos" ", %d insignificant protos)\n", LabeledProto->Label, N, - NumberOfProtos(LabeledProto->List, 1, 0), - NumberOfProtos(LabeledProto->List, 0, 1)); + NumberOfProtos(LabeledProto->List, true, false), + NumberOfProtos(LabeledProto->List, false, true)); exit(1); } fprintf(File, "\n%s %d\n", LabeledProto->Label, N); diff --git a/src/training/commontraining.cpp b/src/training/commontraining.cpp index d888850c..6aad7064 100644 --- a/src/training/commontraining.cpp +++ b/src/training/commontraining.cpp @@ -595,8 +595,8 @@ void CleanUpUnusedData( /*------------------------------------------------------------------------*/ LIST RemoveInsignificantProtos( LIST ProtoList, - BOOL8 KeepSigProtos, - BOOL8 KeepInsigProtos, + bool KeepSigProtos, + bool KeepInsigProtos, int N) { @@ -823,8 +823,8 @@ void AddToNormProtosList( } /*---------------------------------------------------------------------------*/ -int NumberOfProtos(LIST ProtoList, BOOL8 CountSigProtos, - BOOL8 CountInsigProtos) { +int NumberOfProtos(LIST ProtoList, bool CountSigProtos, + bool CountInsigProtos) { int N = 0; PROTOTYPE* Proto; diff --git a/src/training/commontraining.h b/src/training/commontraining.h index 492ba93b..95797bb9 100644 --- a/src/training/commontraining.h +++ b/src/training/commontraining.h @@ -142,8 +142,8 @@ CLUSTERER *SetUpForClustering( LIST RemoveInsignificantProtos( LIST ProtoList, - BOOL8 KeepSigProtos, - BOOL8 KeepInsigProtos, + bool KeepSigProtos, + bool KeepInsigProtos, int N); void CleanUpUnusedData( @@ -181,8 +181,8 @@ void AddToNormProtosList( int NumberOfProtos( LIST ProtoList, - BOOL8 CountSigProtos, - BOOL8 CountInsigProtos); + bool CountSigProtos, + bool CountInsigProtos); void allocNormProtos();