diff options
author | Grigori Goronzy <greg@chown.ath.cx> | 2015-09-07 11:40:54 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@chown.ath.cx> | 2015-09-07 11:40:54 +0200 |
commit | a2f12d6f79bfdc6bc7c1cb6ddd3a42c97ab2de4f (patch) | |
tree | 2600406db3d71a17d4389f34ba4bf66f7c098247 /libass/ass_utils.c | |
parent | 23de9995103c16ceceba19cae87e328be12fa8e4 (diff) | |
parent | 0268c64b8ec7bef9287a212759152bf7d15e64d8 (diff) | |
download | libass-a2f12d6f79bfdc6bc7c1cb6ddd3a42c97ab2de4f.tar.bz2 libass-a2f12d6f79bfdc6bc7c1cb6ddd3a42c97ab2de4f.tar.xz |
Merge branch 'fonts'
Diffstat (limited to 'libass/ass_utils.c')
-rw-r--r-- | libass/ass_utils.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c index 94edf805..1c0ebdd0 100644 --- a/libass/ass_utils.c +++ b/libass/ass_utils.c @@ -24,7 +24,7 @@ #include <stdint.h> #include <inttypes.h> #include <strings.h> -#include <limits.h> +#include <ctype.h> #include "ass_library.h" #include "ass.h" @@ -326,7 +326,7 @@ int parse_ycbcr_matrix(char *str) return YCBCR_UNKNOWN; } -void ass_msg(ASS_Library *priv, int lvl, char *fmt, ...) +void ass_msg(ASS_Library *priv, int lvl, const char *fmt, ...) { va_list va; va_start(va, fmt); @@ -334,6 +334,28 @@ void ass_msg(ASS_Library *priv, int lvl, char *fmt, ...) va_end(va); } +/** + * Return a string with spaces trimmed at start and end. + * \param str input string + * \return output string, can be released with free() + */ +char *strdup_trimmed(const char *str) +{ + int left = 0; + int right = strlen(str) - 1; + char *out = NULL; + + while (isspace(str[left])) left++; + while (right > left && isspace(str[right])) right--; + + out = calloc(1, right-left+2); + + if (out) + memcpy(out, str + left, right-left+1); + + return out; +} + unsigned ass_utf8_get_char(char **str) { uint8_t *strp = (uint8_t *) * str; |