summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/cuesheet.c9
-rw-r--r--apps/metadata/metadata_common.c15
-rw-r--r--apps/misc.c16
-rw-r--r--apps/misc.h2
-rw-r--r--apps/replaygain.c5
5 files changed, 17 insertions, 30 deletions
diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index 0a7521bbc5..1acb9af5cf 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -108,15 +108,6 @@ bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path)
108 return true; 108 return true;
109} 109}
110 110
111static char *skip_whitespace(char* buf)
112{
113 char *r = buf;
114 while (*r && isspace(*r))
115 r++;
116 return r;
117}
118
119
120static char *get_string(const char *line) 111static char *get_string(const char *line)
121{ 112{
122 char *start, *end; 113 char *start, *end;
diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c
index 94ff212cea..09f0f94a88 100644
--- a/apps/metadata/metadata_common.c
+++ b/apps/metadata/metadata_common.c
@@ -29,6 +29,7 @@
29#include "metadata_common.h" 29#include "metadata_common.h"
30#include "metadata_parsers.h" 30#include "metadata_parsers.h"
31#include "replaygain.h" 31#include "replaygain.h"
32#include "misc.h"
32 33
33/* Skip an ID3v2 tag if it can be found. We assume the tag is located at the 34/* Skip an ID3v2 tag if it can be found. We assume the tag is located at the
34 * start of the file, which should be true in all cases where we need to skip it. 35 * start of the file, which should be true in all cases where we need to skip it.
@@ -173,16 +174,6 @@ long get_slong(void* buf)
173 return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); 174 return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
174} 175}
175 176
176static char* skip_space(char* str)
177{
178 while (isspace(*str))
179 {
180 str++;
181 }
182
183 return str;
184}
185
186unsigned long get_itunes_int32(char* value, int count) 177unsigned long get_itunes_int32(char* value, int count)
187{ 178{
188 static const char hexdigits[] = "0123456789ABCDEF"; 179 static const char hexdigits[] = "0123456789ABCDEF";
@@ -191,7 +182,7 @@ unsigned long get_itunes_int32(char* value, int count)
191 182
192 while (count-- > 0) 183 while (count-- > 0)
193 { 184 {
194 value = skip_space(value); 185 value = skip_whitespace(value);
195 186
196 while (*value && !isspace(*value)) 187 while (*value && !isspace(*value))
197 { 188 {
@@ -199,7 +190,7 @@ unsigned long get_itunes_int32(char* value, int count)
199 } 190 }
200 } 191 }
201 192
202 value = skip_space(value); 193 value = skip_whitespace(value);
203 194
204 while (*value && ((c = strchr(hexdigits, toupper(*value))) != NULL)) 195 while (*value && ((c = strchr(hexdigits, toupper(*value))) != NULL))
205 { 196 {
diff --git a/apps/misc.c b/apps/misc.c
index 1410d47244..6e871acd3b 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -605,8 +605,7 @@ bool settings_parseline(char* line, char** name, char** value)
605{ 605{
606 char* ptr; 606 char* ptr;
607 607
608 while ( isspace(*line) ) 608 line = skip_whitespace(line);
609 line++;
610 609
611 if ( *line == '#' ) 610 if ( *line == '#' )
612 return false; 611 return false;
@@ -618,8 +617,7 @@ bool settings_parseline(char* line, char** name, char** value)
618 *name = line; 617 *name = line;
619 *ptr = 0; 618 *ptr = 0;
620 ptr++; 619 ptr++;
621 while (isspace(*ptr)) 620 ptr = skip_whitespace(ptr);
622 ptr++;
623 *value = ptr; 621 *value = ptr;
624 return true; 622 return true;
625} 623}
@@ -1123,6 +1121,16 @@ char* strrsplt(char* str, int c)
1123 return s; 1121 return s;
1124} 1122}
1125 1123
1124char* skip_whitespace(char* const str)
1125{
1126 char *s = str;
1127
1128 while (isspace(*s))
1129 s++;
1130
1131 return s;
1132}
1133
1126/* Test file existence, using dircache of possible */ 1134/* Test file existence, using dircache of possible */
1127bool file_exists(const char *file) 1135bool file_exists(const char *file)
1128{ 1136{
diff --git a/apps/misc.h b/apps/misc.h
index 6a6e847a16..22ae4849a4 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -124,7 +124,7 @@ int hex_to_rgb(const char* hex, int* color);
124#endif 124#endif
125 125
126char* strrsplt(char* str, int c); 126char* strrsplt(char* str, int c);
127 127char* skip_whitespace(char* const str);
128bool file_exists(const char *file); 128bool file_exists(const char *file);
129bool dir_exists(const char *path); 129bool dir_exists(const char *path);
130 130
diff --git a/apps/replaygain.c b/apps/replaygain.c
index e0bfc8e64e..93bf384539 100644
--- a/apps/replaygain.c
+++ b/apps/replaygain.c
@@ -224,10 +224,7 @@ static long fp_atof(const char* s, int precision)
224 long sign = 1; 224 long sign = 1;
225 bool point = false; 225 bool point = false;
226 226
227 while ((*s != '\0') && isspace(*s)) 227 s = skip_whitespace(s);
228 {
229 s++;
230 }
231 228
232 if (*s == '-') 229 if (*s == '-')
233 { 230 {