util/StringUtil: rename strchug_fast() to StripLeft()
This commit is contained in:
parent
db6db51742
commit
87bcf739ee
@ -60,7 +60,7 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name,
|
||||
}
|
||||
|
||||
*colon++ = 0;
|
||||
value = strchug_fast(colon);
|
||||
value = StripLeft(colon);
|
||||
|
||||
if (strcmp(line, "mtime") == 0)
|
||||
pm.mtime = strtol(value, nullptr, 10);
|
||||
|
@ -94,7 +94,7 @@ song_load(TextFile &file, const char *uri,
|
||||
}
|
||||
|
||||
*colon++ = 0;
|
||||
const char *value = strchug_fast(colon);
|
||||
const char *value = StripLeft(colon);
|
||||
|
||||
TagType type;
|
||||
if ((type = tag_name_parse(line)) != TAG_NUM_OF_ITEM_TYPES) {
|
||||
|
@ -96,7 +96,7 @@ config_read_block(FILE *fp, int *count, char *string, Error &error)
|
||||
}
|
||||
|
||||
(*count)++;
|
||||
line = strchug_fast(line);
|
||||
line = StripLeft(line);
|
||||
if (*line == 0 || *line == CONF_COMMENT)
|
||||
continue;
|
||||
|
||||
@ -104,7 +104,7 @@ config_read_block(FILE *fp, int *count, char *string, Error &error)
|
||||
/* end of this block; return from the function
|
||||
(and from this "while" loop) */
|
||||
|
||||
line = strchug_fast(line + 1);
|
||||
line = StripLeft(line + 1);
|
||||
if (*line != 0 && *line != CONF_COMMENT) {
|
||||
delete ret;
|
||||
error.Format(config_file_domain,
|
||||
@ -155,7 +155,7 @@ ReadConfigFile(ConfigData &config_data, FILE *fp, Error &error)
|
||||
|
||||
count++;
|
||||
|
||||
line = strchug_fast(string);
|
||||
line = StripLeft(string);
|
||||
if (*line == 0 || *line == CONF_COMMENT)
|
||||
continue;
|
||||
|
||||
@ -205,7 +205,7 @@ ReadConfigFile(ConfigData &config_data, FILE *fp, Error &error)
|
||||
return false;
|
||||
}
|
||||
|
||||
line = strchug_fast(tokenizer.Rest() + 1);
|
||||
line = StripLeft(tokenizer.Rest() + 1);
|
||||
if (*line != 0 && *line != CONF_COMMENT) {
|
||||
error.Format(config_file_domain,
|
||||
"line %i: Unknown tokens after '{'",
|
||||
|
@ -142,11 +142,11 @@ RouteFilter::Configure(const config_param ¶m, Error &error) {
|
||||
// A cowardly default, just passthrough stereo
|
||||
const char *routes = param.GetBlockValue("routes", "0>0, 1>1");
|
||||
while (true) {
|
||||
routes = strchug_fast(routes);
|
||||
routes = StripLeft(routes);
|
||||
|
||||
char *endptr;
|
||||
const unsigned source = strtoul(routes, &endptr, 10);
|
||||
endptr = strchug_fast(endptr);
|
||||
endptr = StripLeft(endptr);
|
||||
if (endptr == routes || *endptr != '>') {
|
||||
error.Set(config_domain,
|
||||
"Malformed 'routes' specification");
|
||||
@ -163,10 +163,10 @@ RouteFilter::Configure(const config_param ¶m, Error &error) {
|
||||
if (source >= min_input_channels)
|
||||
min_input_channels = source + 1;
|
||||
|
||||
routes = strchug_fast(endptr + 1);
|
||||
routes = StripLeft(endptr + 1);
|
||||
|
||||
unsigned dest = strtoul(routes, &endptr, 10);
|
||||
endptr = strchug_fast(endptr);
|
||||
endptr = StripLeft(endptr);
|
||||
if (endptr == routes) {
|
||||
error.Set(config_domain,
|
||||
"Malformed 'routes' specification");
|
||||
|
@ -129,7 +129,7 @@ static bool
|
||||
ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir)
|
||||
{
|
||||
// strip leading white space
|
||||
line = strchug_fast(line);
|
||||
line = StripLeft(line);
|
||||
|
||||
// check for end-of-line or comment
|
||||
if (*line == '\0' || *line == '#')
|
||||
@ -141,11 +141,11 @@ ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir)
|
||||
line += strlen(dir_name);
|
||||
|
||||
// strip equals sign and spaces around it
|
||||
line = strchug_fast(line);
|
||||
line = StripLeft(line);
|
||||
if (*line != '=')
|
||||
return false;
|
||||
++line;
|
||||
line = strchug_fast(line);
|
||||
line = StripLeft(line);
|
||||
|
||||
// check if path is quoted
|
||||
bool quoted = false;
|
||||
|
@ -80,7 +80,7 @@ cue_next_quoted(char *p, char **pp)
|
||||
static const char *
|
||||
cue_next_token(char **pp)
|
||||
{
|
||||
char *p = strchug_fast(*pp);
|
||||
char *p = StripLeft(*pp);
|
||||
if (*p == 0)
|
||||
return nullptr;
|
||||
|
||||
@ -90,7 +90,7 @@ cue_next_token(char **pp)
|
||||
static const char *
|
||||
cue_next_value(char **pp)
|
||||
{
|
||||
char *p = strchug_fast(*pp);
|
||||
char *p = StripLeft(*pp);
|
||||
if (*p == 0)
|
||||
return nullptr;
|
||||
|
||||
|
@ -82,7 +82,7 @@ extm3u_parse_tag(const char *line)
|
||||
/* 0 means unknown duration */
|
||||
duration = 0;
|
||||
|
||||
name = strchug_fast(endptr + 1);
|
||||
name = StripLeft(endptr + 1);
|
||||
if (*name == 0 && duration == 0)
|
||||
/* no information available; don't allocate a tag
|
||||
object */
|
||||
@ -116,7 +116,7 @@ ExtM3uPlaylist::NextSong()
|
||||
continue;
|
||||
}
|
||||
|
||||
line_s = strchug_fast(line_s);
|
||||
line_s = StripLeft(line_s);
|
||||
} while (line_s[0] == '#' || *line_s == 0);
|
||||
|
||||
return new DetachedSong(line_s, std::move(tag));
|
||||
|
@ -52,7 +52,7 @@ M3uPlaylist::NextSong()
|
||||
if (line_s == nullptr)
|
||||
return nullptr;
|
||||
|
||||
line_s = strchug_fast(line_s);
|
||||
line_s = StripLeft(line_s);
|
||||
} while (line_s[0] == '#' || *line_s == 0);
|
||||
|
||||
return new DetachedSong(line_s);
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <string.h>
|
||||
|
||||
const char *
|
||||
strchug_fast(const char *p)
|
||||
StripLeft(const char *p)
|
||||
{
|
||||
while (IsWhitespaceNotNull(*p))
|
||||
++p;
|
||||
@ -38,7 +38,7 @@ strchug_fast(const char *p)
|
||||
char *
|
||||
Strip(char *p)
|
||||
{
|
||||
p = strchug_fast(p);
|
||||
p = StripLeft(p);
|
||||
|
||||
size_t length = strlen(p);
|
||||
while (length > 0 && IsWhitespaceNotNull(p[length - 1]))
|
||||
|
@ -27,19 +27,16 @@
|
||||
/**
|
||||
* Returns a pointer to the first non-whitespace character in the
|
||||
* string, or to the end of the string.
|
||||
*
|
||||
* This is a faster version of g_strchug(), because it does not move
|
||||
* data.
|
||||
*/
|
||||
gcc_pure
|
||||
const char *
|
||||
strchug_fast(const char *p);
|
||||
StripLeft(const char *p);
|
||||
|
||||
gcc_pure
|
||||
static inline char *
|
||||
strchug_fast(char *p)
|
||||
StripLeft(char *p)
|
||||
{
|
||||
return const_cast<char *>(strchug_fast((const char *)p));
|
||||
return const_cast<char *>(StripLeft((const char *)p));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ Tokenizer::NextWord(Error &error)
|
||||
/* a whitespace: the word ends here */
|
||||
*input = 0;
|
||||
/* skip all following spaces, too */
|
||||
input = strchug_fast(input + 1);
|
||||
input = StripLeft(input + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ Tokenizer::NextUnquoted(Error &error)
|
||||
/* a whitespace: the word ends here */
|
||||
*input = 0;
|
||||
/* skip all following spaces, too */
|
||||
input = strchug_fast(input + 1);
|
||||
input = StripLeft(input + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ Tokenizer::NextString(Error &error)
|
||||
/* finish the string and return it */
|
||||
|
||||
*dest = 0;
|
||||
input = strchug_fast(input);
|
||||
input = StripLeft(input);
|
||||
return word;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user