summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2018-12-16 18:51:29 +0100
committerSlávek Banko <slavek.banko@axis.cz>2018-12-17 17:53:06 +0100
commita729c2c36c1144a5ea64ca297244d3e31703a8cd (patch)
tree4bfb39b9ad941f4dd1f8722b1f65b86a80fd0f0d
parentc55c4a99a336a4286ea42406688928f4f266be06 (diff)
downloadkrename-a729c2c36c1144a5ea64ca297244d3e31703a8cd.tar.gz
krename-a729c2c36c1144a5ea64ca297244d3e31703a8cd.zip
Fix inifinite loop while parsing subdirs.
Improved clarity of the original while loop. Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit 82824eab47a7c7a4be97d29f3674d560cb0164c2)
-rw-r--r--krename/batchrenamer.cpp8
-rw-r--r--krename/krenameimpl.cpp12
2 files changed, 13 insertions, 7 deletions
diff --git a/krename/batchrenamer.cpp b/krename/batchrenamer.cpp
index 371a0da..98b2ef4 100644
--- a/krename/batchrenamer.cpp
+++ b/krename/batchrenamer.cpp
@@ -839,8 +839,11 @@ void BatchRenamer::parseSubdirs( data* f )
// create the missing subdir now
int i = 0;
- TQString d = "";
- while (!(d = dirs.section("/", i, i, TQString::SectionSkipEmpty)).isEmpty()) { // asignment here!
+ TQString d = TQString::null;
+ for (d = dirs.section("/", i, i, TQString::SectionSkipEmpty);
+ !d.isEmpty();
+ i++, d = dirs.section("/", i, i, TQString::SectionSkipEmpty))
+ {
KURL url = f->dst.url;
// it is important to unescape here
// to support dirnames containing "&" or
@@ -852,7 +855,6 @@ void BatchRenamer::parseSubdirs( data* f )
f->dst.url.addPath( d );
f->dst.directory.append( d + "/" );
- i++;
}
}
}
diff --git a/krename/krenameimpl.cpp b/krename/krenameimpl.cpp
index 1835fd1..e62c81c 100644
--- a/krename/krenameimpl.cpp
+++ b/krename/krenameimpl.cpp
@@ -1171,14 +1171,18 @@ bool KRenameImpl::setupBatchRenamer( BatchRenamer* b, bool preview )
int i = 0;
TQString d = "/";
- while (!(d += url.section( "/", i, i, TQString::SectionSkipEmpty)).isEmpty()) { // asignment here!
- if (!TDEIO::NetAccess::exists(d, false, parent) && !TDEIO::NetAccess::mkdir(d, parent, -1))
+ TQString ds = TQString::null;
+ for (ds = url.section("/", i, i, TQString::SectionSkipEmpty);
+ !ds.isEmpty();
+ i++, d.append("/"), ds = url.section("/", i, i, TQString::SectionSkipEmpty))
+ {
+ d += ds;
+ if (!TDEIO::NetAccess::exists(d, false, parent) &&
+ !TDEIO::NetAccess::mkdir(d, parent, -1))
{
tqDebug( "Can't create %s", d.latin1() );
break;
}
- d.append( "/" );
- i++;
}
}