From 8d555a1d7463bcb18a561dafbeabd297e7b721b8 Mon Sep 17 00:00:00 2001 From: Oleg Oshmyan Date: Sat, 15 Jun 2013 22:24:45 +0100 Subject: Parse style names like VSFilter does Trim '*' from the start of style name fields of Style and Dialogue lines and normalize the case of "Default" in the style name field of Dialogue lines. --- libass/ass_utils.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'libass/ass_utils.c') diff --git a/libass/ass_utils.c b/libass/ass_utils.c index ba31261..3dab74c 100644 --- a/libass/ass_utils.c +++ b/libass/ass_utils.c @@ -205,14 +205,20 @@ unsigned ass_utf8_get_char(char **str) * \param track track * \param name style name * \return index in track->styles - * Returnes 0 if no styles found => expects at least 1 style. - * Parsing code always adds "Default" style in the end. + * Returns 0 if no styles found => expects at least 1 style. + * Parsing code always adds "Default" style in the beginning. */ int lookup_style(ASS_Track *track, char *name) { int i; - if (*name == '*') - ++name; // FIXME: what does '*' really mean ? + // '*' seem to mean literally nothing; + // VSFilter removes them as soon as it can + while (*name == '*') + ++name; + // VSFilter then normalizes the case of "Default" + // (only in contexts where this function is called) + if (strcasecmp(name, "Default") == 0) + name = "Default"; for (i = track->n_styles - 1; i >= 0; --i) { if (strcmp(track->styles[i].Name, name) == 0) return i; @@ -221,7 +227,7 @@ int lookup_style(ASS_Track *track, char *name) ass_msg(track->library, MSGL_WARN, "[%p]: Warning: no style named '%s' found, using '%s'", track, name, track->styles[i].Name); - return i; // use the first style + return i; } /** -- cgit v1.2.3