summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2009-02-08 11:09:55 +0000
committerNils Wallménius <nils@rockbox.org>2009-02-08 11:09:55 +0000
commit5a55772201829dc0055cc8d3022cc475ccbc2643 (patch)
tree65440f5944388c9db3a439df7f37a75e5431709d
parenteda5ed06244abba643e09a775d71542d91691d4d (diff)
downloadrockbox-5a55772201829dc0055cc8d3022cc475ccbc2643.zip
rockbox-5a55772201829dc0055cc8d3022cc475ccbc2643.tar.gz
rockbox-5a55772201829dc0055cc8d3022cc475ccbc2643.tar.bz2
rockbox-5a55772201829dc0055cc8d3022cc475ccbc2643.tar.xz
Small code reuse improvement
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19943 a1c6a512-1295-4272-9138-f99709370657
-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 0a7521b..1acb9af 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)
return true;
}
-static char *skip_whitespace(char* buf)
-{
- char *r = buf;
- while (*r && isspace(*r))
- r++;
- return r;
-}
-
-
static char *get_string(const char *line)
{
char *start, *end;
diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c
index 94ff212..09f0f94 100644
--- a/apps/metadata/metadata_common.c
+++ b/apps/metadata/metadata_common.c
@@ -29,6 +29,7 @@
#include "metadata_common.h"
#include "metadata_parsers.h"
#include "replaygain.h"
+#include "misc.h"
/* Skip an ID3v2 tag if it can be found. We assume the tag is located at the
* 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)
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
-static char* skip_space(char* str)
-{
- while (isspace(*str))
- {
- str++;
- }
-
- return str;
-}
-
unsigned long get_itunes_int32(char* value, int count)
{
static const char hexdigits[] = "0123456789ABCDEF";
@@ -191,7 +182,7 @@ unsigned long get_itunes_int32(char* value, int count)
while (count-- > 0)
{
- value = skip_space(value);
+ value = skip_whitespace(value);
while (*value && !isspace(*value))
{
@@ -199,7 +190,7 @@ unsigned long get_itunes_int32(char* value, int count)
}
}
- value = skip_space(value);
+ value = skip_whitespace(value);
while (*value && ((c = strchr(hexdigits, toupper(*value))) != NULL))
{
diff --git a/apps/misc.c b/apps/misc.c
index 1410d47..6e871ac 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -605,8 +605,7 @@ bool settings_parseline(char* line, char** name, char** value)
{
char* ptr;
- while ( isspace(*line) )
- line++;
+ line = skip_whitespace(line);
if ( *line == '#' )
return false;
@@ -618,8 +617,7 @@ bool settings_parseline(char* line, char** name, char** value)
*name = line;
*ptr = 0;
ptr++;
- while (isspace(*ptr))
- ptr++;
+ ptr = skip_whitespace(ptr);
*value = ptr;
return true;
}
@@ -1123,6 +1121,16 @@ char* strrsplt(char* str, int c)
return s;
}
+char* skip_whitespace(char* const str)
+{
+ char *s = str;
+
+ while (isspace(*s))
+ s++;
+
+ return s;
+}
+
/* Test file existence, using dircache of possible */
bool file_exists(const char *file)
{
diff --git a/apps/misc.h b/apps/misc.h
index 6a6e847..22ae484 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -124,7 +124,7 @@ int hex_to_rgb(const char* hex, int* color);
#endif
char* strrsplt(char* str, int c);
-
+char* skip_whitespace(char* const str);
bool file_exists(const char *file);
bool dir_exists(const char *path);
diff --git a/apps/replaygain.c b/apps/replaygain.c
index e0bfc8e..93bf384 100644
--- a/apps/replaygain.c
+++ b/apps/replaygain.c
@@ -224,10 +224,7 @@ static long fp_atof(const char* s, int precision)
long sign = 1;
bool point = false;
- while ((*s != '\0') && isspace(*s))
- {
- s++;
- }
+ s = skip_whitespace(s);
if (*s == '-')
{