From 5a02356a3a123e85fd5a4342a042346a43c11e56 Mon Sep 17 00:00:00 2001 From: guy <guy@c028cbd2-c16b-5b4b-a496-9718f37d4682> Date: Thu, 14 Dec 1995 13:16:48 +0000 Subject: [PATCH] Migliorato decoder che ora funziona anche per codici nulli git-svn-id: svn://10.65.10.50/trunk@2288 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/saldacon.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/cg/saldacon.cpp b/cg/saldacon.cpp index 81616b4c4..d0226140e 100755 --- a/cg/saldacon.cpp +++ b/cg/saldacon.cpp @@ -238,15 +238,24 @@ TDecoder::~TDecoder() } const TString& TDecoder::decode(const char* code) -{ +{ + if (code == NULL) + code = ""; + TObject* obj = objptr(code); if (obj == NULL) - { - _file->setkey(1); - _file->put(_if, code); - const int err = _file->read(); - CHECKS(err == NOERR, "Can't decode ", code); - obj = new TString(_file->get(_of)); + { + int err = ~NOERR; + if (*code) + { + _file->setkey(1); + _file->put(_if, code); + err = _file->read(); + } + if (err == NOERR) + obj = new TString(_file->get(_of)); // Found + else + obj = new TString(1); // Not found add(code, obj); } const TString& s = (const TString&)*obj;