From 70ba7316bd332dd7b16aec1d4bf51aff0451c1b3 Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 29 Apr 2024 09:44:45 -0400 Subject: [PATCH] cwLex.h/cpp: test() now returns an rc_t. --- cwLex.cpp | 9 ++++++--- cwLex.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cwLex.cpp b/cwLex.cpp index 5eca99b..2333b17 100644 --- a/cwLex.cpp +++ b/cwLex.cpp @@ -853,7 +853,7 @@ namespace cw //) //( - void test() + rc_t test() { rc_t rc = kOkRC; unsigned tid = kInvalidId; @@ -872,8 +872,8 @@ namespace cw // initialize a lexer with a buffer of text if((rc = lex::create(h,buf,strlen(buf), kReturnSpaceLexFl | kReturnCommentsLexFl)) != kOkRC ) { - cwLogError(rc,"Lexer initialization failed."); - return; + rc = cwLogError(rc,"Lexer initialization failed."); + goto errLabel; } // register some additional recoginizers @@ -913,9 +913,12 @@ namespace cw } + errLabel: // finalize the lexer lex::destroy(h); + + return rc; } } } diff --git a/cwLex.h b/cwLex.h index 2f25b77..c77aafd 100644 --- a/cwLex.h +++ b/cwLex.h @@ -129,7 +129,7 @@ namespace cw const char* idToLabel( handle_t h, unsigned typeId ); // Lexer testing stub. - void test( ); + rc_t test( ); } }