Commit c852bd39 authored by moret's avatar moret
Browse files

Fix JackArgParser (when used with empty strings)

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2669 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 70f56fc7
......@@ -200,7 +200,7 @@ JackLoadableInternalClient::JackLoadableInternalClient(JackServer* server, JackS
jack_error("symbol jack_finish cannot be found in %s", so_name);
throw - 1;
}
fDescriptor = (JackDriverDescFunction)GetJackProc(fHandle, "jack_get_descriptor");
if (!fDescriptor) {
jack_info("No jack_get_descriptor entry-point for %s", so_name);
......
......@@ -322,7 +322,7 @@ namespace Jack
int JackNetMaster::SetProcess ( jack_nframes_t nframes, void* arg )
{
JackNetMaster* master = static_cast<JackNetMaster*> ( arg );
JackNetMaster* master = static_cast<JackNetMaster*> ( arg );
return master->Process();
}
......@@ -629,12 +629,12 @@ extern "C"
{
jack_driver_desc_t *desc;
desc = (jack_driver_desc_t*)calloc(1, sizeof(jack_driver_desc_t));
// TODO
return desc;
}
EXPORT int jack_internal_initialize ( jack_client_t* jack_client, const JSList* params )
{
if ( master_manager )
......@@ -649,11 +649,12 @@ extern "C"
return ( master_manager ) ? 0 : 1;
}
}
EXPORT int jack_initialize ( jack_client_t* jack_client, const char* load_init )
{
const JSList* params = NULL;
// TODO : convert load_init to params
const JSList* params = NULL;
Jack::JackArgParser args(load_init);
const char** argv = args.GetArgv();
return jack_internal_initialize(jack_client, params);
}
......
......@@ -21,7 +21,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "JackConstants.h"
#include "JackMidiPort.h"
#include "JackExports.h"
#include "JackError.h"
#include "JackError.h"
#include "JackTools.h"
#include "JackPlatformNetSocket.h"
#include <string>
......
......@@ -205,9 +205,17 @@ namespace Jack {
}
JackArgParser::JackArgParser(const char* arg) {
jack_log ( "JackArgParser::JackArgParser, arg : '%s'", arg );
fArgc=0;
fNumArgv=0;
fArgString=string(arg);
//if empty string
if (strlen(arg)==0) {
fArgv = NULL;
return;
}
//else parse the arg string
fArgString+=" ";
const size_t arg_len=fArgString.length();
int i=0;
......@@ -226,7 +234,7 @@ namespace Jack {
//no more quotes or spaces, consider the end of the string
if (pos==string::npos)
pos=arg_len;
//if it's a double quote
//if double quote
if (fArgString.at(pos)=='\"') {
//first character : copy the substring
if (pos==start) {
......@@ -242,7 +250,7 @@ namespace Jack {
start=pos;
}
}
//if it's a space
//if space
if (fArgString.at(pos)==' ') {
copy_start=start;
copy_length=pos-copy_start;
......@@ -260,12 +268,16 @@ namespace Jack {
fill_n(fArgv[i],args[i].length()+1,0);
args[i].copy(fArgv[i],args[i].length());
}
//finally count the 'real' options (the ones starting with a '-')
for (i=0; i<fNumArgv; i++)
if (fArgv[i][0]=='-')
fArgc++;
}
JackArgParser::~JackArgParser() {
for (int i=0; i<fNumArgv; i++)
delete[] fArgv[i];
delete[] fArgv;
}
......
......@@ -20,6 +20,8 @@
#ifndef __JackTools__
#define __JackTools__
#include "JackExports.h"
#ifdef WIN32
#include <windows.h>
#else
......@@ -54,7 +56,7 @@ struct JackTools
};
class JackArgParser
class EXPORT JackArgParser
{
private:
std::string fArgString;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment