From e435b418bad00558d02805889008d983c0a105b5 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Sat, 25 Apr 2009 03:53:59 +0000 Subject: use vector<> in sys_parsercfile svn path=/trunk/; revision=11134 --- desiredata/src/s_path.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'desiredata') diff --git a/desiredata/src/s_path.c b/desiredata/src/s_path.c index 06a37c1a..56c90c35 100644 --- a/desiredata/src/s_path.c +++ b/desiredata/src/s_path.c @@ -21,6 +21,7 @@ #include #include #include +#include extern t_namelist *sys_externlist; t_namelist *sys_searchpath; @@ -247,59 +248,44 @@ gotone: extern "C" int sys_argparse(int argc, char **argv); #define NUMARGS 1000 +#define foreach(ITER,COLL) for(typeof(COLL.begin()) ITER = COLL.begin(); ITER != (COLL).end(); ITER++) extern "C" int sys_parsercfile(char *filename) { - int rcargc; - char* rcargv[NUMARGS]; + std::vector argv; char buf[1000]; char c[MAXPDSTRING]; int retval = 1; /* that's what we will return at the end; for now, let's think it'll be an error */ - /* initialize rc-arg-array so we can safely clean up at the end */ - for (int i=1; i= NUMARGS-1) error("startup file too long; extra args dropped"); - rcargv[i] = 0; - rcargc = i; /* parse the options */ fclose(file); if (sys_verbose) { - if (rcargv) { + if (argv.size()) { post("startup args from RC file:"); - for (i = 1; i < rcargc; i++) post("%s", rcargv[i]); + foreach(a,argv) post("%s",*a); } else post("no RC file arguments found"); } - if (sys_argparse(rcargc-1, rcargv+1)) { + if (sys_argparse(argv.size(),argv.data())) { post("error parsing RC arguments"); goto cleanup; } retval=0; /* we made it without an error */ cleanup: /* prevent memleak */ - for (i=1; i