From 29a25b9933b32800f58dd73d5d1fc21993071c92 Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Thu, 20 Jul 2006 16:02:40 +0000 Subject: Add mpd-indent.sh Indent the entire tree, hopefully we can keep it indented. git-svn-id: https://svn.musicpd.org/mpd/trunk@4410 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/buffer2array.c | 77 ++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 40 deletions(-) (limited to 'src/buffer2array.c') diff --git a/src/buffer2array.c b/src/buffer2array.c index 0d8170260..4a0751eae 100644 --- a/src/buffer2array.c +++ b/src/buffer2array.c @@ -22,79 +22,74 @@ #include #include -int buffer2array(char * origBuffer, char *** array) { +int buffer2array(char *origBuffer, char ***array) +{ int quotes = 0; int count = 0; int i; int curr; - int * beginArray; - char * buffer = strdup(origBuffer); + int *beginArray; + char *buffer = strdup(origBuffer); int bufferLength = strlen(buffer); - char * markArray = malloc(sizeof(char)*(bufferLength+1)); + char *markArray = malloc(sizeof(char) * (bufferLength + 1)); - for(curr=0;curr0 && buffer[curr-1]!='\\') { - quotes = quotes?0:1; + } else if (buffer[curr] == '\"') { + if (curr > 0 && buffer[curr - 1] != '\\') { + quotes = quotes ? 0 : 1; markArray[curr] = '0'; - } - else { + } else { markArray[curr] = '1'; } - } - else { + } else { markArray[curr] = '1'; } - if(markArray[curr]=='1') { - if(curr>0) { - if(markArray[curr-1]=='0') { + if (markArray[curr] == '1') { + if (curr > 0) { + if (markArray[curr - 1] == '0') { count++; } - } - else { + } else { count++; } } } markArray[bufferLength] = '\0'; - if(!count) { + if (!count) { free(buffer); free(markArray); return count; } - beginArray = malloc(sizeof(int)*count); - (*array) = malloc(sizeof(char *)*count); + beginArray = malloc(sizeof(int) * count); + (*array) = malloc(sizeof(char *) * count); count = 0; - - for(curr=0;curr0) { - if(markArray[curr-1]=='0') { + + for (curr = 0; curr < bufferLength; curr++) { + if (markArray[curr] == '1') { + if (curr > 0) { + if (markArray[curr - 1] == '0') { beginArray[count++] = curr; } - } - else { + } else { beginArray[count++] = curr; } - } - else { + } else { buffer[curr] = '\0'; } } - for(i=0;i