Mercurial > mplayer.hg
changeset 3701:a33d0351630e
bzero() -> memset()
malloc()+strcpy() -> strdup()
trail_space() slightly changed
author | pl |
---|---|
date | Mon, 24 Dec 2001 10:39:28 +0000 |
parents | 91f801a94a59 |
children | e16996f5497d |
files | subreader.c |
diffstat | 1 files changed, 15 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/subreader.c Mon Dec 24 10:35:43 2001 +0000 +++ b/subreader.c Mon Dec 24 10:39:28 2001 +0000 @@ -15,7 +15,7 @@ #include "config.h" #include "subreader.h" -#define ERR (void *)-1 +#define ERR ((void *) -1) #ifdef USE_ICONV #ifdef __FreeBSD__ @@ -39,13 +39,15 @@ /* Use the SUB_* constant defined in the header file */ int sub_format=SUB_INVALID; -int eol(char p) { +static int eol(char p) { return (p=='\r' || p=='\n' || p=='\0'); } -static inline void trail_space(char *s) { - int i; - while (isspace(*s)) strcpy(s, s + 1); +/* Remove leading and trailing space */ +static void trail_space(char *s) { + int i = 0; + while (isspace(*s)) ++i; + if (i) strcpy(s, s + i); i = strlen(s) - 1; while (i > 0 && isspace(s[i])) s[i--] = '\0'; } @@ -165,7 +167,7 @@ char *p, *next; int i; - bzero (current, sizeof(subtitle)); + memset(current, 0, sizeof(subtitle)); do { if (!fgets (line, LINE_LEN, fd)) return NULL; @@ -190,7 +192,7 @@ char *p=NULL, *q=NULL; int len; - bzero (current, sizeof(subtitle)); + memset(current, 0, sizeof(subtitle)); while (1) { if (!fgets (line, LINE_LEN, fd)) return NULL; @@ -221,7 +223,7 @@ char *p=NULL; int i,len; - bzero (current, sizeof(subtitle)); + memset(current, '\0', sizeof(subtitle)); while (!current->text[0]) { if (!fgets (line, LINE_LEN, fd)) return NULL; @@ -254,7 +256,7 @@ char *p=NULL, *next; int i,len,len2,plen; - bzero (current, sizeof(subtitle)); + memset(current, '\0', sizeof(subtitle)); while (!current->text[0]) { if (!fgets (line, LINE_LEN, fd)) return NULL; @@ -306,7 +308,7 @@ char *p=NULL,*next=NULL; int i,len,plen; - bzero (current, sizeof(subtitle)); + memset(current, '\0', sizeof(subtitle)); while (!current->text[0]) { if (!fgets (line, LINE_LEN, fd)) return NULL; @@ -374,8 +376,7 @@ } - current->text[num]=(char *) malloc(strlen(line2)+1); - strcpy(current->text[num],line2); + current->text[num]=strdup(line2); return current; } @@ -384,7 +385,7 @@ char line[LINE_LEN+1]; char text[LINE_LEN+1]; - bzero (current, sizeof(subtitle)); + memset(current, '\0', sizeof(subtitle)); if (!fgets (line, LINE_LEN, fd)) return NULL; @@ -438,7 +439,7 @@ subtitle *sub_read_line_aqt(FILE *fd,subtitle *current) { char line[LINE_LEN+1]; - bzero (current, sizeof(subtitle)); + memset(current, '\0', sizeof(subtitle)); while (1) { // try to locate next subtitle