mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
16
apps/misc.c
16
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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 == '-')
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue