summaryrefslogtreecommitdiffstats
path: root/libass/ass_utils.c
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2014-05-17 22:39:33 +0100
committerOleg Oshmyan <chortos@inbox.lv>2014-06-06 15:08:16 +0100
commit722fc526e33df96994bd38f4ae7853d20d2e2544 (patch)
tree10d9900b4417da5b09fc8c9f12d21e9fb842dfc7 /libass/ass_utils.c
parent03c66c1dfd283f955d43b63e20ffa5a2f4dce9a8 (diff)
downloadlibass-722fc526e33df96994bd38f4ae7853d20d2e2544.tar.bz2
libass-722fc526e33df96994bd38f4ae7853d20d2e2544.tar.xz
Move (r)skip_spaces to ass_utils
Diffstat (limited to 'libass/ass_utils.c')
-rw-r--r--libass/ass_utils.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c
index 5140506..58ee96d 100644
--- a/libass/ass_utils.c
+++ b/libass/ass_utils.c
@@ -89,6 +89,22 @@ void ass_aligned_free(void *ptr)
free(*((void **)ptr - 1));
}
+void skip_spaces(char **str)
+{
+ char *p = *str;
+ while ((*p == ' ') || (*p == '\t'))
+ ++p;
+ *str = p;
+}
+
+void rskip_spaces(char **str, char *limit)
+{
+ char *p = *str;
+ while ((p > limit) && ((p[-1] == ' ') || (p[-1] == '\t')))
+ --p;
+ *str = p;
+}
+
int mystrtoi(char **p, int *res)
{
double temp_res;
@@ -177,8 +193,7 @@ int strtocolor(ASS_Library *library, char **q, uint32_t *res, int hex)
// Return a boolean value for a string
char parse_bool(char *str)
{
- while (*str == ' ' || *str == '\t')
- str++;
+ skip_spaces(&str);
if (!strncasecmp(str, "yes", 3))
return 1;
else if (strtol(str, NULL, 10) > 0)
@@ -188,14 +203,12 @@ char parse_bool(char *str)
int parse_ycbcr_matrix(char *str)
{
- while (*str == ' ' || *str == '\t')
- str++;
+ skip_spaces(&str);
if (*str == '\0')
return YCBCR_DEFAULT;
char *end = str + strlen(str);
- while (end[-1] == ' ' || end[-1] == '\t')
- end--;
+ rskip_spaces(&end, str);
// Trim a local copy of the input that we know is safe to
// modify. The buffer is larger than any valid string + NUL,