summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Golubev <fatzer2@gmail.com>2025-07-28 22:18:21 +0300
committerAlexander Golubev <fatzer2@gmail.com>2025-08-08 06:43:58 +0300
commit42420798a77520d3b9126361f089cd620922d5d0 (patch)
tree8614f767ad9ca58c5f8141f4092f02cb81dbcf4c
parent3a0b3976b5f2b8c3e72d06c4e703b3fc6fd9ffea (diff)
downloadk3b-42420798a77520d3b9126361f089cd620922d5d0.tar.gz
k3b-42420798a77520d3b9126361f089cd620922d5d0.zip
Fix discovery of sox binary
Closes: https://mirror.git.trinitydesktop.org/gitea/TDE/k3b/issues/58 Signed-off-by: Alexander Golubev <fatzer2@gmail.com> (cherry picked from commit 3067884e745c79639ec82ae7520caf19c6963b66)
-rw-r--r--plugins/encoder/sox/k3bsoxencoder.cpp43
1 files changed, 15 insertions, 28 deletions
diff --git a/plugins/encoder/sox/k3bsoxencoder.cpp b/plugins/encoder/sox/k3bsoxencoder.cpp
index 631a9b9..1cc7c3a 100644
--- a/plugins/encoder/sox/k3bsoxencoder.cpp
+++ b/plugins/encoder/sox/k3bsoxencoder.cpp
@@ -34,6 +34,7 @@
#include <tqcombobox.h>
#include <tqcheckbox.h>
#include <tqlayout.h>
+#include <tqregexp.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -65,47 +66,33 @@ class K3bSoxProgram : public K3bExternalProgram
if( !TQFile::exists( path ) )
return false;
- K3bExternalBin* bin = 0;
-
// probe version
TDEProcess vp;
K3bProcessOutputCollector out( &vp );
vp << path << "-h";
if( vp.start( TDEProcess::Block, TDEProcess::AllOutput ) ) {
- int pos = out.output().find( "sox: SoX Version" );
- if ( pos < 0 )
- pos = out.output().find( "sox: SoX v" ); // newer sox versions
- int endPos = out.output().find( "\n", pos );
- if( pos > 0 && endPos > 0 ) {
- pos += 17;
- bin = new K3bExternalBin( this );
+ TQRegExp versionRe ("sox: +(SoX )?(Version |v)([^\\n]+)");
+ // Should match:
+ // * sox: Version 12.2.3
+ // * sox: SoX Version 12.18.1
+ // * sox: SoX v14.0.0
+ // * sox: SoX v14.4.0
+ int pos = versionRe.search( out.output() );
+ if( pos > 0 ) {
+ TQString version = versionRe.cap(3);
+
+ K3bExternalBin* bin = new K3bExternalBin( this );
+
bin->path = path;
- bin->version = out.output().mid( pos, endPos-pos );
+ bin->version = version;
addBin( bin );
return true;
}
- else {
- pos = out.output().find( "sox: Version" );
- endPos = out.output().find( "\n", pos );
- if( pos > 0 && endPos > 0 ) {
- pos += 13;
- bin = new K3bExternalBin( this );
- bin->path = path;
- bin->version = out.output().mid( pos, endPos-pos );
-
- addBin( bin );
-
- return true;
- }
- else
- return false;
- }
}
- else
- return false;
+ return false;
}
};