aboutsummaryrefslogtreecommitdiffstats
path: root/src/conf.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-10-06 08:54:43 +0000
committerEric Wong <normalperson@yhbt.net>2006-10-06 08:54:43 +0000
commite3222d807a6178e0a4a5254b8443c3432b663efb (patch)
tree9e404aedec15a6154b5f7ed891b7465181c91f9e /src/conf.c
parent1a51bfb84a9d3eb6c1ae891403ab237ee24a3b12 (diff)
downloadmpd-e3222d807a6178e0a4a5254b8443c3432b663efb.tar.gz
mpd-e3222d807a6178e0a4a5254b8443c3432b663efb.tar.xz
mpd-e3222d807a6178e0a4a5254b8443c3432b663efb.zip
Revert buffer2array() behavior back to tried and true 0.11.x version
Warren's fix in r4872 made phpMp work again, but also broke the unit tests completely (they work in this version). The version in 0.12.0 is far too buggy (it was from mpd-ke, what do you expect?). This one passes all the unit tests that the mpd-ke one passed, and should also work with phpMp when used with PHP magic quotes. This also means we can search on 100 (or more) tags at once, so no more arbitrary limits other than system memory. To run the unit tests, just do this: gcc -o t -DUNIT_TEST=1 src/buffer2array.c && ./t && echo OK git-svn-id: https://svn.musicpd.org/mpd/trunk@4874 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/conf.c')
-rw-r--r--src/conf.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/conf.c b/src/conf.c
index 0b3e0df5f..dc45ed2b9 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -41,7 +41,6 @@
#define CONF_REPEATABLE_MASK 0x01
#define CONF_BLOCK_MASK 0x02
-#define CONF_LINE_TOKEN_MAX 3
typedef struct _configEntry {
unsigned char mask;
@@ -194,16 +193,15 @@ static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string)
{
ConfigParam *ret = newConfigParam(NULL, *count);
+ char **array;
int i;
int numberOfArgs;
int argsMinusComment;
while (myFgets(string, MAX_STRING_SIZE, fp)) {
- char *array[CONF_LINE_TOKEN_MAX] = { NULL };
-
(*count)++;
- numberOfArgs = buffer2array(string, array, CONF_LINE_TOKEN_MAX);
+ numberOfArgs = buffer2array(string, &array);
for (i = 0; i < numberOfArgs; i++) {
if (array[i][0] == CONF_COMMENT)
@@ -213,11 +211,13 @@ static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string)
argsMinusComment = i;
if (0 == argsMinusComment) {
+ freeArgArray(array, numberOfArgs);
continue;
}
if (1 == argsMinusComment &&
0 == strcmp(array[0], CONF_BLOCK_END)) {
+ freeArgArray(array, numberOfArgs);
break;
}
@@ -238,6 +238,8 @@ static ConfigParam *readConfigBlock(FILE * fp, int *count, char *string)
}
addBlockParam(ret, array[0], array[1], *count);
+
+ freeArgArray(array, numberOfArgs);
}
return ret;
@@ -254,6 +256,7 @@ void readConf(char *file)
ConfigEntry *entry;
void *voidPtr;
ConfigParam *param;
+ char **array;
if (!(fp = fopen(file, "r"))) {
ERROR("problems opening file %s for reading: %s\n", file,
@@ -262,10 +265,9 @@ void readConf(char *file)
}
while (myFgets(string, MAX_STRING_SIZE, fp)) {
- char *array[CONF_LINE_TOKEN_MAX] = { NULL };
count++;
- numberOfArgs = buffer2array(string, array, CONF_LINE_TOKEN_MAX);
+ numberOfArgs = buffer2array(string, &array);
for (i = 0; i < numberOfArgs; i++) {
if (array[i][0] == CONF_COMMENT)
@@ -275,6 +277,7 @@ void readConf(char *file)
argsMinusComment = i;
if (0 == argsMinusComment) {
+ freeArgArray(array, numberOfArgs);
continue;
}
@@ -313,6 +316,8 @@ void readConf(char *file)
param = newConfigParam(array[1], count);
insertInListWithoutKey(entry->configParamList, param);
+
+ freeArgArray(array, numberOfArgs);
}
fclose(fp);
}