From 9c2470246f0b067b80d4785e534cf8ea6a6fbe01 Mon Sep 17 00:00:00 2001 From: Jonathan Zak Date: Wed, 31 Jul 2024 15:24:56 -0400 Subject: [PATCH] How is this not working fr --- ile/Makefile | 2 +- ile/src/handler.cpp | 4 ++-- ile/src/manzan.h | 2 +- test_util.cc | 21 ++++++++++----------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/ile/Makefile b/ile/Makefile index 01f952e..14e2283 100644 --- a/ile/Makefile +++ b/ile/Makefile @@ -28,7 +28,7 @@ src/mzversion.h: system "CRTCPPMOD MODULE(${BUILDLIB}/$*) SRCSTMF('$(CURDIR)/$<') OPTION(*EVENTF) SYSIFCOPT(*IFS64IO) DBGVIEW(*SOURCE) TERASPACE(*YES *TSIFC) STGMDL(*SNGLVL) DTAMDL(*p128) DEFINE(DEBUG_ENABLED) OUTPUT(*PRINT)" > $*.log 2>&1 /qsys.lib/${BUILDLIB}.lib/%.module: src/%.sqlc - system "CRTSQLCI OBJ(${BUILDLIB}/$*) SRCSTMF('$(CURDIR)/$^') COMMIT(*NONE) DATFMT(*ISO) TIMFMT(*ISO) DBGVIEW(*SOURCE) CVTCCSID(*JOB) COMPILEOPT('INCDIR(''src'')') SQLPATH(${BUILDLIB}) DFTRDBCOL(${BUILDLIB}) OPTION(*SQL) OUTPUT(*PRINT)" > $*.log 2>&1 + system "CRTSQLCI OBJ(${BUILDLIB}/$*) SRCSTMF('$(CURDIR)/$^') COMMIT(*NONE) DATFMT(*ISO) TIMFMT(*ISO) DBGVIEW(*SOURCE) CVTCCSID(*JOB) COMPILEOPT('INCDIR(''src'')') SQLPATH(${BUILDLIB}) DFTRDBCOL(${BUILDLIB}) OPTION(*SQL)" > $*.log 2>&1 /qsys.lib/${BUILDLIB.lib}: -system "RUNSQL SQL('create schema ${BUILDLIB}') NAMING(*SYS)" diff --git a/ile/src/handler.cpp b/ile/src/handler.cpp index f428bda..ed0cce5 100644 --- a/ile/src/handler.cpp +++ b/ile/src/handler.cpp @@ -90,8 +90,8 @@ int main(int _argc, char **argv) return 0; } - BUFSTRN(watch_option, argv[1], sizeof(argv[1])); - BUFSTRN(session_id, argv[2], sizeof(argv[2])); + BUFSTRN(watch_option, std::string(argv[1]), 10); + BUFSTRN(session_id, std::string(argv[2]), 10); DEBUG("watch program called. Watch option setting is '%s'\n", watch_option.c_str()); publisher_info_set *publishers = conf_get_publisher_info(session_id.c_str()); diff --git a/ile/src/manzan.h b/ile/src/manzan.h index c8b2647..53041b8 100644 --- a/ile/src/manzan.h +++ b/ile/src/manzan.h @@ -12,7 +12,7 @@ } #define BUFSTRN(dest, src, len) \ - std::string dest = src.substr(0, len); \ + std::string dest(src, len); \ { \ size_t lastChar = dest.find_last_not_of(" "); \ if (lastChar != std::string::npos) \ diff --git a/test_util.cc b/test_util.cc index 87ebc70..4597d65 100644 --- a/test_util.cc +++ b/test_util.cc @@ -4,25 +4,24 @@ // Demonstrate some basic assertions. TEST(UTILITY, testBUFSTRN) { - std::string spaceAtEnd = "hello "; - BUFSTRN(trimmed0, spaceAtEnd, sizeof(spaceAtEnd)); + char spaceAtEnd[] = "hello "; + BUFSTRN(trimmed0, spaceAtEnd, strlen(spaceAtEnd)); EXPECT_STREQ(trimmed0.c_str(), "hello"); - - std::string spaceInMiddle = "hello d"; - BUFSTRN(trimmed1, spaceInMiddle, sizeof(spaceInMiddle)); + char spaceInMiddle[] = "hello d"; + BUFSTRN(trimmed1, spaceInMiddle, strlen(spaceInMiddle)); EXPECT_STREQ(trimmed1.c_str(), "hello d"); - std::string spaceAtBeginning = " hello"; - BUFSTRN(trimmed2, spaceAtBeginning, sizeof(spaceAtBeginning)); + char spaceAtBeginning[] = " hello"; + BUFSTRN(trimmed2, spaceAtBeginning, strlen(spaceAtBeginning)); EXPECT_STREQ(trimmed2.c_str(), " hello"); - std::string allSpace = " "; - BUFSTRN(trimmed3, allSpace, sizeof(allSpace)); + char allSpace[] = " "; + BUFSTRN(trimmed3, allSpace, strlen(allSpace)); EXPECT_STREQ(trimmed3.c_str(), ""); - std::string emptyString = ""; - BUFSTRN(trimmed4, emptyString, sizeof(emptyString)); + char emptyString[] = ""; + BUFSTRN(trimmed4, emptyString, strlen(emptyString)); EXPECT_STREQ(trimmed4.c_str(), ""); }