commit dacb7ad8915c0bda67a0e995dfb0d980b67a134f Author: Daniel Swanson Date: Tue Jun 15 15:42:52 2021 -0500 death to void* diff --git a/apertium/interchunk.cc b/apertium/interchunk.cc index 2549e33..8c722da 100644 --- a/apertium/interchunk.cc +++ b/apertium/interchunk.cc @@ -85,7 +85,7 @@ Interchunk::evalCachedString(xmlNode* element) case ti_get_case_from: if (checkIndex(element, ti.getPos(), lword)) { return StringUtils::copycase(word[ti.getPos()]->chunkPart(attr_items[ti.getContent()]), - evalString((xmlNode*) ti.getPointer())); + evalString(ti.getPointer())); } break; diff --git a/apertium/postchunk.cc b/apertium/postchunk.cc index 922633f..ab2429e 100644 --- a/apertium/postchunk.cc +++ b/apertium/postchunk.cc @@ -94,7 +94,7 @@ Postchunk::evalCachedString(xmlNode* element) case ti_get_case_from: if (checkIndex(element, ti.getPos(), lword)) { return StringUtils::copycase(word[ti.getPos()]->chunkPart(attr_items[ti.getContent()]), - evalString((xmlNode*) ti.getPointer())); + evalString(ti.getPointer())); } break; diff --git a/apertium/transfer.cc b/apertium/transfer.cc index 64aad0d..f439f1c 100644 --- a/apertium/transfer.cc +++ b/apertium/transfer.cc @@ -137,7 +137,7 @@ Transfer::evalCachedString(xmlNode *element) if(!word[ti.getPos()]->source(attr_items[ti.getContent()], ti.getCondition()).empty()) { UString ret; ret += '<'; - ret += UString((UChar*) ti.getPointer()); + ret += ti.getStrval(); ret += '>'; return ret; } else { @@ -151,7 +151,7 @@ Transfer::evalCachedString(xmlNode *element) if(!word[ti.getPos()]->target(attr_items[ti.getContent()], ti.getCondition()).empty()) { UString ret; ret += '<'; - ret += UString((UChar*) ti.getPointer()); + ret += ti.getStrval(); ret += '>'; return ret; } else { @@ -165,7 +165,7 @@ Transfer::evalCachedString(xmlNode *element) if(!word[ti.getPos()]->reference(attr_items[ti.getContent()], ti.getCondition()).empty()) { UString ret; ret += '<'; - ret += UString((UChar*) ti.getPointer()); + ret += ti.getStrval(); ret += '>'; return ret; } else { @@ -232,7 +232,8 @@ void Transfer::processClip(xmlNode* element) { int pos = 0; - xmlChar *side = NULL, *as = NULL; + xmlChar *side = NULL; + UString as; UString part; bool queue = true; @@ -248,17 +249,17 @@ Transfer::processClip(xmlNode* element) queue = false; } } else if(!xmlStrcmp(i->name, (const xmlChar *) "link-to")) { - as = i->children->content; + as = to_ustring((const char*)i->children->content); } } - if(as != NULL) { + if(!as.empty()) { if(!xmlStrcmp(side, (const xmlChar *) "sl")) { - evalStringCache[element] = TransferInstr(ti_linkto_sl, part, pos, (void *) as, queue); + evalStringCache[element] = TransferInstr(ti_linkto_sl, part, pos, NULL, queue, as); } else if(!xmlStrcmp(side, (const xmlChar *) "ref")) { - evalStringCache[element] = TransferInstr(ti_linkto_ref, part, pos, (void *) as, queue); + evalStringCache[element] = TransferInstr(ti_linkto_ref, part, pos, NULL, queue, as); } else { - evalStringCache[element] = TransferInstr(ti_linkto_tl, part, pos, (void *) as, queue); + evalStringCache[element] = TransferInstr(ti_linkto_tl, part, pos, NULL, queue, as); } } else if(!xmlStrcmp(side, (const xmlChar *) "sl")) { evalStringCache[element] = TransferInstr(ti_clip_sl, part, pos, NULL, queue); @@ -1395,8 +1396,8 @@ Transfer::applyWord(UString const &word_str) { case '\\': i++; - ms.step(towlower(word_str[i]), any_char); - break; + ms.step(towlower(word_str[i]), any_char); + break; case '[': if(word_str[i+1] == '[') diff --git a/apertium/transfer_instr.cc b/apertium/transfer_instr.cc index 46f719d..0b2e5c1 100644 --- a/apertium/transfer_instr.cc +++ b/apertium/transfer_instr.cc @@ -25,6 +25,7 @@ TransferInstr::copy(TransferInstr const &o) pos = o.pos; pointer = o.pointer; condition = o.condition; + strval = o.strval; } void @@ -33,13 +34,15 @@ TransferInstr::destroy() } TransferInstr::TransferInstr(TransferInstrType t, UString const &c, - int const p, void *ptr, bool cond) + int const p, xmlNode* ptr, bool cond, + const UString& sv) { type = t; content = c; pos = p; pointer = ptr; condition = cond; + strval = sv; } TransferInstr::~TransferInstr() @@ -81,7 +84,7 @@ TransferInstr::getPos() return pos; } -void * +xmlNode* TransferInstr::getPointer() { return pointer; @@ -92,3 +95,9 @@ TransferInstr::getCondition() { return condition; } + +const UString& +TransferInstr::getStrval() +{ + return strval; +} diff --git a/apertium/transfer_instr.h b/apertium/transfer_instr.h index 92ab858..3d51b28 100644 --- a/apertium/transfer_instr.h +++ b/apertium/transfer_instr.h @@ -17,6 +17,7 @@ #ifndef _TRANSFERINSTR_ #define _TRANSFERINSTR_ +#include #include #include @@ -47,8 +48,9 @@ private: TransferInstrType type; UString content; int pos; - void *pointer; + xmlNode* pointer; bool condition; + UString strval; void copy(TransferInstr const &o); void destroy(); @@ -60,7 +62,7 @@ public: condition(false) {} TransferInstr(TransferInstrType t, UString const &c, int const p, - void *ptr=NULL, bool cond = true); + xmlNode* ptr=NULL, bool cond = true, const UString& sv = ""_u); ~TransferInstr(); TransferInstr(TransferInstr const &o); TransferInstr & operator =(TransferInstr const &o); @@ -69,8 +71,9 @@ public: TransferInstrType getType(); UString const & getContent(); int getPos(); - void * getPointer(); + xmlNode* getPointer(); bool getCondition(); + const UString& getStrval(); }; #endif