// ==============================================================================================
-static void skip_spaces(char **str)
-{
- char *p = *str;
- while ((*p == ' ') || (*p == '\t'))
- ++p;
- *str = p;
-}
-
-static void rskip_spaces(char **str, char *limit)
-{
- char *p = *str;
- while ((p >= limit) && ((*p == ' ') || (*p == '\t')))
- --p;
- *str = p;
-}
-
/**
* \brief Set up default style
* \param style style to edit to defaults
*p = '\0';
*str = p + 1; // ',' found, str will point to the next char (beginning of the next token)
}
- --p; // end of current token
- rskip_spaces(&p, start);
- if (p < start)
- p = start; // empty token
- else
- ++p; // the first space character, or '\0'
+ rskip_spaces(&p, start); // end of current token: the first space character, or '\0'
*p = '\0';
return start;
}
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;
// 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)
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,
void *ass_aligned_alloc(size_t alignment, size_t size);
void ass_aligned_free(void *ptr);
+void skip_spaces(char **str);
+void rskip_spaces(char **str, char *limit);
int mystrtoi(char **p, int *res);
int mystrtoll(char **p, long long *res);
int mystrtou32(char **p, int base, uint32_t *res);