Skip to content

Commit 1f26f75

Browse files
committed
comskip: fix C89 compatibility — move loop variable declarations before for statements
1 parent 2ab5c72 commit 1f26f75

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

comskip.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,12 @@ void add_cc_text(long start_frame, long end_frame, const char *text)
410410
cc_text[cc_text_count].text_len = strnlen(text, sizeof(cc_text[cc_text_count].text) - 1);
411411
strncpy((char*)cc_text[cc_text_count].text, text, sizeof(cc_text[cc_text_count].text) - 1);
412412
cc_text[cc_text_count].text[sizeof(cc_text[cc_text_count].text) - 1] = '\0';
413-
// Replace newlines with spaces so the log stays line-oriented.
414-
for (unsigned char *p = cc_text[cc_text_count].text; *p; p++)
415-
if (*p == '\n' || *p == '\r') *p = ' ';
413+
{
414+
// Replace newlines with spaces so the log stays line-oriented.
415+
unsigned char *p;
416+
for (p = cc_text[cc_text_count].text; *p; p++)
417+
if (*p == '\n' || *p == '\r') *p = ' ';
418+
}
416419
cc_text_count++;
417420
}
418421

mpeg2dec.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,17 +648,19 @@ void subtitle_packet_process(VideoState *is, AVPacket *packet)
648648
long sub_frame = (long)(sub_pts * is->fps);
649649

650650
if (sub.num_rects > 0) {
651-
for (unsigned i = 0; i < sub.num_rects; i++) {
651+
unsigned i;
652+
for (i = 0; i < sub.num_rects; i++) {
652653
const char *text = NULL;
653654
if (sub.rects[i]->text) {
654655
text = sub.rects[i]->text;
655656
} else if (sub.rects[i]->type == SUBTITLE_ASS && sub.rects[i]->ass) {
656657
// FFmpeg's ff_ass_get_dialog produces:
657658
// readorder,layer,style,speaker,marginL,marginR,marginV,,text
658659
// The text field follows the 8th comma.
659-
text = sub.rects[i]->ass;
660+
const char *p;
660661
int commas = 0;
661-
for (const char *p = text; *p; p++) {
662+
text = sub.rects[i]->ass;
663+
for (p = text; *p; p++) {
662664
if (*p == ',') {
663665
commas++;
664666
if (commas == 8) { text = p + 1; break; }

0 commit comments

Comments
 (0)