From add0bcc4c9191cb8980d0b6935ca5d51a9928d82 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 30 Nov 2009 21:24:21 +0000 Subject: Trim trailing space & reduce space+tab. --- src/libsputext/Makefile.am | 2 +- src/libsputext/demux_sputext.c | 270 +++++++++++++++++----------------- src/libsputext/xine_sputext_decoder.c | 190 ++++++++++++------------ 3 files changed, 231 insertions(+), 231 deletions(-) (limited to 'src/libsputext') diff --git a/src/libsputext/Makefile.am b/src/libsputext/Makefile.am index 62258933d..ad6c1b776 100644 --- a/src/libsputext/Makefile.am +++ b/src/libsputext/Makefile.am @@ -9,6 +9,6 @@ xineplug_dmx_sputext_la_SOURCES = demux_sputext.c xineplug_dmx_sputext_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) xineplug_dmx_sputext_la_CFLAGS = $(VISIBILITY_FLAG) -xineplug_decode_sputext_la_SOURCES = xine_sputext_decoder.c +xineplug_decode_sputext_la_SOURCES = xine_sputext_decoder.c xineplug_decode_sputext_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) xineplug_decode_sputext_la_CFLAGS = $(VISIBILITY_FLAG) diff --git a/src/libsputext/demux_sputext.c b/src/libsputext/demux_sputext.c index 198c30498..b0e1299d9 100644 --- a/src/libsputext/demux_sputext.c +++ b/src/libsputext/demux_sputext.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -67,7 +67,7 @@ typedef struct { long start; /* csecs */ long end; /* csecs */ - + char *text[SUB_MAX_TEXT]; } subtitle_t; @@ -84,10 +84,10 @@ typedef struct { char buf[SUB_BUFSIZE]; off_t buflen; - float mpsub_position; + float mpsub_position; - int uses_time; - int errs; + int uses_time; + int errs; subtitle_t *subtitles; int num; /* number of subtitle structs */ int cur; /* current subtitle */ @@ -117,8 +117,8 @@ typedef struct demux_sputext_class_s { #define FORMAT_RT 5 #define FORMAT_SSA 6 /* Sub Station Alpha */ #define FORMAT_PJS 7 -#define FORMAT_MPSUB 8 -#define FORMAT_AQTITLE 9 +#define FORMAT_MPSUB 8 +#define FORMAT_AQTITLE 9 #define FORMAT_JACOBSUB 10 #define FORMAT_SUBVIEWER2 11 #define FORMAT_SUBRIP09 12 @@ -137,7 +137,7 @@ static inline void trail_space(char *s) { } while(*copy); } size_t i = strlen(s) - 1; - while (i > 0 && isspace(s[i])) + while (i > 0 && isspace(s[i])) s[i--] = '\0'; } @@ -146,24 +146,24 @@ static inline void trail_space(char *s) { */ static char *read_line_from_input(demux_sputext_t *this, char *line, off_t len) { off_t nread = 0; - + if ((len - this->buflen) > 512 && len < SUB_BUFSIZE) { - if((nread = this->input->read(this->input, + if((nread = this->input->read(this->input, &this->buf[this->buflen], len - this->buflen)) < 0) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "read failed.\n"); return NULL; } } - + this->buflen += nread; this->buf[this->buflen] = '\0'; char *s = strchr(this->buf, '\n'); if (line && (s || this->buflen)) { - + size_t linelen = s ? (s - this->buf) + 1 : this->buflen; - + memcpy(line, this->buf, linelen); line[linelen] = '\0'; @@ -187,14 +187,14 @@ static subtitle_t *sub_read_line_sami(demux_sputext_t *this, subtitle_t *current current->lines = current->start = 0; current->end = -1; int state = 0; - + /* read the first line */ if (!s) if (!(s = read_line_from_input(this, line, LINE_LEN))) return 0; - + do { switch (state) { - + case 0: /* find "START=" */ s = strstr (s, "Start="); if (s) { @@ -202,15 +202,15 @@ static subtitle_t *sub_read_line_sami(demux_sputext_t *this, subtitle_t *current state = 1; continue; } break; - + case 1: /* find "" */ if ((s = strchr (s, '>'))) { s++; state = 3; p = text; continue; } break; - + case 3: /* get all text until '<' appears */ if (*s == '\0') { break; } else if (*s == '<') { state = 4; } @@ -224,7 +224,7 @@ static subtitle_t *sub_read_line_sami(demux_sputext_t *this, subtitle_t *current } else *p++ = *s++; continue; - + case 4: /* get current->end or skip */ { char *q = strstr (s, "Start="); @@ -241,13 +241,13 @@ static subtitle_t *sub_read_line_sami(demux_sputext_t *this, subtitle_t *current if (s) { s++; state = 3; continue; } break; } - + /* read next line */ - if (state != 99 && !(s = read_line_from_input (this, line, LINE_LEN))) + if (state != 99 && !(s = read_line_from_input (this, line, LINE_LEN))) return 0; - + } while (state != 99); - + return current; } @@ -255,16 +255,16 @@ static subtitle_t *sub_read_line_sami(demux_sputext_t *this, subtitle_t *current static char *sub_readtext(char *source, char **dest) { size_t len=0; char *p=source; - + while ( !eol(*p) && *p!= '|' ) { p++,len++; } - + *dest = strndup(source, len); - + while (*p=='\r' || *p=='\n' || *p=='|') p++; - + if (*p) return p; /* not-last text field */ else return NULL; /* last text field */ } @@ -273,39 +273,39 @@ static subtitle_t *sub_read_line_microdvd(demux_sputext_t *this, subtitle_t *cur char line[LINE_LEN + 1]; char line2[LINE_LEN + 1]; - + memset (current, 0, sizeof(subtitle_t)); - + current->end=-1; do { if (!read_line_from_input (this, line, LINE_LEN)) return NULL; } while ((sscanf (line, "{%ld}{}%" LINE_LEN_QUOT "[^\r\n]", &(current->start), line2) !=2) && (sscanf (line, "{%ld}{%ld}%" LINE_LEN_QUOT "[^\r\n]", &(current->start), &(current->end),line2) !=3) ); - + char *p=line2; - + char *next=p; size_t i=0; while ((next =sub_readtext (next, &(current->text[i])))) { if (current->text[i]==ERR) return ERR; i++; - if (i>=SUB_MAX_TEXT) { + if (i>=SUB_MAX_TEXT) { xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "Too many lines in a subtitle\n"); current->lines=i; return current; } } current->lines= ++i; - + return current; } static subtitle_t *sub_read_line_subviewer(demux_sputext_t *this, subtitle_t *current) { char line[LINE_LEN + 1]; - + memset (current, 0, sizeof(subtitle_t)); - + while (1) { if (!read_line_from_input(this, line, LINE_LEN)) return NULL; @@ -322,7 +322,7 @@ static subtitle_t *sub_read_line_subviewer(demux_sputext_t *this, subtitle_t *cu if (!read_line_from_input(this, line, LINE_LEN)) return NULL; - + char *p = line, *q = line; for (current->lines=1; current->lines <= SUB_MAX_TEXT; current->lines++) { size_t len; @@ -410,9 +410,9 @@ static subtitle_t *sub_read_line_subrip(demux_sputext_t *this,subtitle_t *curren static subtitle_t *sub_read_line_vplayer(demux_sputext_t *this,subtitle_t *current) { char line[LINE_LEN + 1]; - + memset (current, 0, sizeof(subtitle_t)); - + while (!current->text[0]) { if( this->next_line[0] == '\0' ) { /* if the buffer is empty.... */ if( !read_line_from_input(this, line, LINE_LEN) ) return NULL; @@ -437,27 +437,27 @@ static subtitle_t *sub_read_line_vplayer(demux_sputext_t *this,subtitle_t *curre current->end = b1*360000+b2*6000+b3*100; } - if ((current->end - current->start) > LINE_LEN) + if ((current->end - current->start) > LINE_LEN) current->end = current->start + LINE_LEN; /* not too long though. */ /* teraz czas na wkopiowanie stringu */ char *p=line; /* finds the body of the subtitle_t */ { int i; - for (i=0; i<3; i++){ + for (i=0; i<3; i++){ char *p2=strchr( p, ':'); if( p2 == NULL ) break; p=p2+1; } } - + char *next=p; int i=0; while( (next = sub_readtext( next, &(current->text[i]))) ) { - if (current->text[i]==ERR) + if (current->text[i]==ERR) return ERR; i++; - if (i>=SUB_MAX_TEXT) { + if (i>=SUB_MAX_TEXT) { xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "Too many lines in a subtitle\n"); current->lines=i; return current; @@ -470,12 +470,12 @@ static subtitle_t *sub_read_line_vplayer(demux_sputext_t *this,subtitle_t *curre static subtitle_t *sub_read_line_rt(demux_sputext_t *this,subtitle_t *current) { /* - * TODO: This format uses quite rich (sub/super)set of xhtml + * TODO: This format uses quite rich (sub/super)set of xhtml * I couldn't check it since DTD is not included. - * WARNING: full XML parses can be required for proper parsing + * WARNING: full XML parses can be required for proper parsing */ memset (current, 0, sizeof(subtitle_t)); - + while (!current->text[0]) { char line[LINE_LEN + 1]; if (!read_line_from_input(this, line, LINE_LEN)) return NULL; @@ -488,20 +488,20 @@ static subtitle_t *sub_read_line_rt(demux_sputext_t *this,subtitle_t *current) { { int a1,a2,a3,a4,b1,b2,b3,b4,len,plen; if ((len=sscanf (line, "