forked from len0rd/rockbox
Small code reuse improvement
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19943 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
eda5ed0624
commit
5a55772201
5 changed files with 17 additions and 30 deletions
|
|
@ -108,15 +108,6 @@ bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path)
|
||||||
return true;
|
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)
|
static char *get_string(const char *line)
|
||||||
{
|
{
|
||||||
char *start, *end;
|
char *start, *end;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include "metadata_common.h"
|
#include "metadata_common.h"
|
||||||
#include "metadata_parsers.h"
|
#include "metadata_parsers.h"
|
||||||
#include "replaygain.h"
|
#include "replaygain.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
/* Skip an ID3v2 tag if it can be found. We assume the tag is located at the
|
/* 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.
|
* 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);
|
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)
|
unsigned long get_itunes_int32(char* value, int count)
|
||||||
{
|
{
|
||||||
static const char hexdigits[] = "0123456789ABCDEF";
|
static const char hexdigits[] = "0123456789ABCDEF";
|
||||||
|
|
@ -191,7 +182,7 @@ unsigned long get_itunes_int32(char* value, int count)
|
||||||
|
|
||||||
while (count-- > 0)
|
while (count-- > 0)
|
||||||
{
|
{
|
||||||
value = skip_space(value);
|
value = skip_whitespace(value);
|
||||||
|
|
||||||
while (*value && !isspace(*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))
|
while (*value && ((c = strchr(hexdigits, toupper(*value))) != NULL))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
16
apps/misc.c
16
apps/misc.c
|
|
@ -605,8 +605,7 @@ bool settings_parseline(char* line, char** name, char** value)
|
||||||
{
|
{
|
||||||
char* ptr;
|
char* ptr;
|
||||||
|
|
||||||
while ( isspace(*line) )
|
line = skip_whitespace(line);
|
||||||
line++;
|
|
||||||
|
|
||||||
if ( *line == '#' )
|
if ( *line == '#' )
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -618,8 +617,7 @@ bool settings_parseline(char* line, char** name, char** value)
|
||||||
*name = line;
|
*name = line;
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
ptr++;
|
ptr++;
|
||||||
while (isspace(*ptr))
|
ptr = skip_whitespace(ptr);
|
||||||
ptr++;
|
|
||||||
*value = ptr;
|
*value = ptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1123,6 +1121,16 @@ char* strrsplt(char* str, int c)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* skip_whitespace(char* const str)
|
||||||
|
{
|
||||||
|
char *s = str;
|
||||||
|
|
||||||
|
while (isspace(*s))
|
||||||
|
s++;
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
/* Test file existence, using dircache of possible */
|
/* Test file existence, using dircache of possible */
|
||||||
bool file_exists(const char *file)
|
bool file_exists(const char *file)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ int hex_to_rgb(const char* hex, int* color);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char* strrsplt(char* str, int c);
|
char* strrsplt(char* str, int c);
|
||||||
|
char* skip_whitespace(char* const str);
|
||||||
bool file_exists(const char *file);
|
bool file_exists(const char *file);
|
||||||
bool dir_exists(const char *path);
|
bool dir_exists(const char *path);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -224,10 +224,7 @@ static long fp_atof(const char* s, int precision)
|
||||||
long sign = 1;
|
long sign = 1;
|
||||||
bool point = false;
|
bool point = false;
|
||||||
|
|
||||||
while ((*s != '\0') && isspace(*s))
|
s = skip_whitespace(s);
|
||||||
{
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*s == '-')
|
if (*s == '-')
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue