summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-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;
}
};