summaryrefslogtreecommitdiffstats
path: root/src/modules/objects/class_file.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2026-02-21 11:03:45 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2026-02-22 20:26:55 +0900
commit16d42ec4616a84b046cd71f805a009b792a93ec9 (patch)
tree1522d1dd06ecd32e6c61d142b88d4b4814b83950 /src/modules/objects/class_file.cpp
parenta09cecfffd5151adfc50e343c821ed8ebdd1ab87 (diff)
downloadkvirc-16d42ec4616a84b046cd71f805a009b792a93ec9.tar.gz
kvirc-16d42ec4616a84b046cd71f805a009b792a93ec9.zip
Fix conversion of TQString to const char* (modules)
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'src/modules/objects/class_file.cpp')
-rw-r--r--src/modules/objects/class_file.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/modules/objects/class_file.cpp b/src/modules/objects/class_file.cpp
index 9195f117..98198cd4 100644
--- a/src/modules/objects/class_file.cpp
+++ b/src/modules/objects/class_file.cpp
@@ -296,8 +296,14 @@ bool KviKvsObject_file::functionputch(KviKvsObjectFunctionCall *c)
if (m_pFile)
{
if (szChar.length()>1)c->warning(__tr2qs("Argument to long, using only first char"));
- const char *ch=szChar;
- if (m_pFile->putch(ch[0])<0) c->warning(__tr2qs("Write error occured !"));
+ // FIXME: putch() argument shouldn't be passed via TQString.
+ char ch = szChar[0].latin1();
+ if (!ch && !szChar[0].isNull())
+ {
+ c->warning(__tr2qs("Can't properly handle non-latin-1 characters."));
+ ch = '?';
+ }
+ if (m_pFile->putch(ch)<0) c->warning(__tr2qs("Write error occurred!"));
}
return true;
@@ -328,8 +334,14 @@ bool KviKvsObject_file::functionunGetch(KviKvsObjectFunctionCall *c)
else
{
if (szChar.length()>1) c->warning(__tr2qs("Argument to long, using only first char"));
- const char *ch=szChar;
- if (m_pFile->ungetch(ch[0])<0) c->warning(__tr2qs("An error occured !"));// c->error ?
+ // FIXME: ungetch() argument shouldn't be passed via TQString.
+ char ch = szChar[0].latin1();
+ if (!ch && !szChar[0].isNull())
+ {
+ c->warning(__tr2qs("Can't properly handle non-latin-1 characters."));
+ ch = '?';
+ }
+ if (m_pFile->ungetch(ch)<0) c->warning(__tr2qs("An error occurred!"));
}
return true;
}
@@ -365,8 +377,7 @@ bool KviKvsObject_file::functionwriteBlock(KviKvsObjectFunctionCall *c)
if (!m_pFile) return true;
if(!m_pFile->isOpen())
c->warning(__tr("File is not open !"));
- const char *block=szBlock;
- int rlen = m_pFile->writeBlock(block, uLen);
+ int rlen = m_pFile->writeBlock(szBlock.utf8().data(), uLen);
c->returnValue()->setInteger(rlen);
m_pFile->flush();
return true;