summaryrefslogtreecommitdiffstats
path: root/libass/ass_utils.c
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2013-06-15 22:02:54 +0100
committerwm4 <wm4@nowhere>2013-06-22 19:07:58 +0200
commit5523d3d5e0ba0fc747b9159d59bf2c57f6a79715 (patch)
treebb83a20c1e727963dfd673d222e33afc3d0bada0 /libass/ass_utils.c
parentb992975a3543e7d539e6a3b568dd6b1f198e9561 (diff)
downloadlibass-5523d3d5e0ba0fc747b9159d59bf2c57f6a79715.tar.bz2
libass-5523d3d5e0ba0fc747b9159d59bf2c57f6a79715.tar.xz
Fix \r style lookup
Make \rSTYLENAME with an invalid STYLENAME fall back to line style rather than to Default. This fixes issue #104.
Diffstat (limited to 'libass/ass_utils.c')
-rw-r--r--libass/ass_utils.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c
index df7c447..ba31261 100644
--- a/libass/ass_utils.c
+++ b/libass/ass_utils.c
@@ -224,6 +224,26 @@ int lookup_style(ASS_Track *track, char *name)
return i; // use the first style
}
+/**
+ * \brief find style by name as in \r
+ * \param track track
+ * \param name style name
+ * \return style in track->styles
+ * Returns NULL if no style has the given name.
+ */
+ASS_Style *lookup_style_strict(ASS_Track *track, char *name)
+{
+ int i;
+ for (i = track->n_styles - 1; i >= 0; --i) {
+ if (strcmp(track->styles[i].Name, name) == 0)
+ return track->styles + i;
+ }
+ ass_msg(track->library, MSGL_WARN,
+ "[%p]: Warning: no style named '%s' found",
+ track, name);
+ return NULL;
+}
+
#ifdef CONFIG_ENCA
void *ass_guess_buffer_cp(ASS_Library *library, unsigned char *buffer,
int buflen, char *preferred_language,