# HG changeset patch # User mosu # Date 1061802748 0 # Node ID 7cb48ef05b023ef14783adab87ce612ed145a4e9 # Parent 665fd8af2db71c7e02a7195989fbc9ead2a31af2 Support for case insensitive string matching in SAMI subtitle files. Patch by Bruno Lecointre. diff -r 665fd8af2db7 -r 7cb48ef05b02 subreader.c --- a/subreader.c Mon Aug 25 09:08:06 2003 +0000 +++ b/subreader.c Mon Aug 25 09:12:28 2003 +0000 @@ -74,6 +74,20 @@ while (i > 0 && isspace(s[i])) s[i--] = '\0'; } +static char *stristr(const char *haystack, const char *needle) { + int len = 0; + const char *p = haystack; + + if (!(haystack && needle)) return NULL; + + len=strlen(needle); + while (*p != '\0') { + if (strncasecmp(p, needle, len) == 0) return (char*)p; + p++; + } + + return NULL; +} subtitle *sub_read_line_sami(FILE *fd, subtitle *current) { static char line[LINE_LEN+1]; @@ -92,11 +106,11 @@ switch (state) { case 0: /* find "START=" or "Slacktime:" */ - slacktime_s = strstr (s, "Slacktime:"); + slacktime_s = stristr (s, "Slacktime:"); if (slacktime_s) sub_slacktime = strtol (slacktime_s+10, NULL, 0) / 10; - s = strstr (s, "Start="); + s = stristr (s, "Start="); if (s) { current->start = strtol (s + 6, &s, 0) / 10; state = 1; continue; @@ -104,7 +118,7 @@ break; case 1: /* find "" */ @@ -131,7 +145,7 @@ continue; case 4: /* get current->end or skip */ - q = strstr (s, "Start="); + q = stristr (s, "Start="); if (q) { current->end = strtol (q + 6, &q, 0) / 10 - 1; *p = '\0'; trail_space (text);