[libimdb-commit] CVS: libimdb/parser imdbParser.c,1.1,1.2
Status: Pre-Alpha
Brought to you by:
jveldhuis
|
From: Jerry V. <jve...@us...> - 2003-08-17 16:41:54
|
Update of /cvsroot/libimdb/libimdb/parser
In directory sc8-pr-cvs1:/tmp/cvs-serv24662
Modified Files:
imdbParser.c
Log Message:
removed some dead code, fixed failure to check malloc failure
Index: imdbParser.c
===================================================================
RCS file: /cvsroot/libimdb/libimdb/parser/imdbParser.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** imdbParser.c 16 Jun 2003 04:18:38 -0000 1.1
--- imdbParser.c 17 Aug 2003 16:41:51 -0000 1.2
***************
*** 391,397 ****
}
! /** @todo - malloc not checked */
!
! static inline void
subLine(struct line_s *line, struct line_s *newline, int start, int length)
{
--- 391,395 ----
}
! static inline int
subLine(struct line_s *line, struct line_s *newline, int start, int length)
{
***************
*** 410,413 ****
--- 408,414 ----
}
newline->buf=malloc(length+1);
+ if ( newline->buf == NULL ) {
+ return(-1);
+ }
newline->used=length;
newline->size=length+1;
***************
*** 415,427 ****
newline->buf[newline->used]='\0';
}
}
! static inline void
splitLine(struct line_s *line, struct line_s *newline, int start)
{
! subLine(line, newline, start, TO_END_OF_LINE);
line->used=start;
line->buf[line->used]='\0';
! //return(start);
}
--- 416,434 ----
newline->buf[newline->used]='\0';
}
+ return(0);
}
! /**
! * @todo not used
! */
! static inline int
splitLine(struct line_s *line, struct line_s *newline, int start)
{
! if ( subLine(line, newline, start, TO_END_OF_LINE) != 0 ) {
! return(-1);
! }
line->used=start;
line->buf[line->used]='\0';
! return(0);
}
***************
*** 480,483 ****
--- 487,495 ----
else {
results->type=isMovie;
+ /*if ( year != NULL ) {
+ char buf[1024];
+ sprintf(buf, "extra qualifier(s) %s %s", year, st);
+ PARE_FORMAT_ERROR_FAILURE(logh, pathname, line.number, buf, int, -1);
+ }*/
year=st;
}
***************
*** 798,802 ****
char *initHeader;
char *initHeaderUL;
- movieStats_t *movieStats;
PAR_ENTER2(logh,
--- 810,813 ----
***************
*** 817,821 ****
/* reset stats */
parser->stats.directorsList.numDirectors=0;
- movieStats=&(parser->stats.directorsList.movies);
break;
case LIST_ACTORS:
--- 828,831 ----
***************
*** 827,831 ****
/* reset stats */
parser->stats.actorsList.numActors=0;
- movieStats=&(parser->stats.actorsList.movies);
break;
case LIST_ACTRESSES:
--- 837,840 ----
***************
*** 837,851 ****
/* reset stats */
parser->stats.actressesList.numActresses=0;
- movieStats=&(parser->stats.actressesList.movies);
break;
default:
abort();
}
- movieStats->numTVMiniSeries=0;
- movieStats->numMovie=0;
- movieStats->numTVSeries=0;
- movieStats->numTVMovie=0;
- movieStats->numVideoMovie=0;
- movieStats->numVideoGame=0;
if ( access(pathname, R_OK) != 0 ) {
--- 846,853 ----
***************
*** 957,965 ****
}
else {
- /*MovieType_e type=isMovie;
- int yearNumber;
- char *year=NULL;
- char *romanNumberalsInYear=NULL;
- */
int billing=-1;
int narrator=0;
--- 959,962 ----
***************
*** 973,977 ****
t--;
}
! subLine(&line, ¤tName, 0, (t-line.buf+1));
}
--- 970,976 ----
t--;
}
! if ( subLine(&line, ¤tName, 0, (t-line.buf+1)) != 0 ) {
! PARE_BAD_MEM_FAILURE(logh, int, -1);
! }
}
***************
*** 1013,1017 ****
gt=lc;
! subLine(&line, &characterName, (lt+1-line.buf), (gt-lt-1));
/*PAR_DEBUG1(logh, "character info:'%s'", characterName.buf);*/
--- 1012,1018 ----
gt=lc;
! if ( subLine(&line, &characterName, (lt+1-line.buf), (gt-lt-1)) != 0 ) {
! PARE_BAD_MEM_FAILURE(logh, int, -1);
! }
/*PAR_DEBUG1(logh, "character info:'%s'", characterName.buf);*/
***************
*** 1030,1034 ****
}
*gt=')';
! subLine(&characterName, &characterNameAka, (aka-characterName.buf), (gt-aka));
/*PAR_DEBUG1(logh, "character aka info:'%s'", characterNameAka.buf);*/
deleteChars(&characterName, (lt-characterName.buf-1), (gt-lt+2));
--- 1031,1037 ----
}
*gt=')';
! if ( subLine(&characterName, &characterNameAka, (aka-characterName.buf), (gt-aka)) != 0 ){
! PARE_BAD_MEM_FAILURE(logh, int, -1);
! }
/*PAR_DEBUG1(logh, "character aka info:'%s'", characterNameAka.buf);*/
deleteChars(&characterName, (lt-characterName.buf-1), (gt-lt+2));
***************
*** 1080,1223 ****
}
- #if 0
- /* whats left is movie and date and type info */
- if ( *(line.buf+line.used-1) == ')' ) {
- char *st=strrchr(line.buf, '(');
- if ( st == NULL ) {
- PARE_FORMAT_ERROR_F(logh, pathname, line.number, "mismatched paren");
- continue;
- }
- else {
- char *c;
- for (c=st-1; isspace(*st) ; c--) {
- /* empty */
- }
- line.used=c-line.buf;
- line.buf[line.used]='\0';
- }
-
- if ( strcmp(st, "(TV)") == 0) {
- type=isTVMovie;
- }
- else if ( strcmp(st, "(mini)") == 0) {
- type=isTVMiniSeries;
- }
- else if ( strcmp(st, "(V)") == 0 ) {
- type=isVideoMovie;
- }
- else if ( strcmp(st, "(VG)") == 0 ) {
- type=isVideoGame;
- }
- else {
- type=isMovie;
- year=st;
- }
- }
- if ( year == NULL ) {
- char *st=strrchr(line.buf, '(');
- if ( st == NULL ) {
- PARE_FORMAT_ERROR_F(logh, pathname, line.number, "missing year");
- continue;
- }
- else {
- char *c;
- for (c=st-1; isspace(*st) ; c--) {
- /* empty */
- }
- line.used=c-line.buf;
- line.buf[line.used]='\0';
- }
- year=st;
- }
-
- /*dumpLine("Post-removal of ending () stuff", &line);*/
-
- /* @todo - pull off ending (year) */
- year++;
- *(year+strlen(year)-1)='\0';
-
- //fprintf(stderr, "year=%s\n", year);
- if ( strlen(year) > 4 ) {
- if ( (romanNumberalsInYear=strrchr(year, '/')) != NULL ) {
- /* remember roman numberals may follow year */
- *romanNumberalsInYear++='\0';
- yearNumber=atoi(year);
- }
- }
- if ( strlen(year) == 4 ) {
- if ( strcmp(year, "????") == 0 ) {
- yearNumber=0;
- }
- else if ( isdigit(year[0]) &&
- isdigit(year[1]) &&
- isdigit(year[2]) &&
- isdigit(year[3]) ) {
- yearNumber=atoi(year);
- }
- else {
- PARE_FORMAT_ERROR_F(logh, pathname, line.number,
- "unable to decode year from entry");
- continue;
- }
- }
- else {
- PARE_FORMAT_ERROR_F(logh, pathname, line.number,
- "unable to decode year from entry");
- continue;
- }
-
- /* remove double quotes from tv show/movies */
- if ( line.buf[0] == '"' && *(line.buf+line.used-1) == '\"' ) {
- /*dumpLine("had leading/ending \"", &line);*/
- deleteChars(&line, 0, 1);
- deleteChars(&line, line.used-1, 1);
- switch(type) {
- case isTVMiniSeries:
- /* leave as is */
- break;
- case isMovie:
- /* switch to tvseries from default */
- type=isTVSeries;
- break;
- case isTVSeries:
- case isTVMovie:
- case isVideoMovie:
- case isVideoGame:
- PARE_FORMAT_ERROR_F(logh, pathname, line.number,
- "movie type %d looks like it also is a tv show ?");
- continue;
- break;
- }
- }
- else {
- if ( type == isTVMiniSeries ) {
- PARE_FORMAT_ERROR_F(logh, pathname, line.number,
- "mini series that doesn't look like it was made for tv ?");
- }
- }
-
- /** add in stats :) */
- switch(type) {
- case isTVMiniSeries:
- movieStats->numTVMiniSeries++;
- break;
- case isMovie:
- movieStats->numMovie++;
- break;
- case isTVSeries:
- movieStats->numTVSeries++;
- break;
- case isTVMovie:
- movieStats->numTVMovie++;
- break;
- case isVideoMovie:
- movieStats->numVideoMovie++;
- break;
- case isVideoGame:
- movieStats->numVideoGame++;
- break;
- }
- #endif
-
//fprintf(stderr, "%d: %s\n", line.number, line.buf);
count++;
--- 1083,1086 ----
***************
*** 1333,1344 ****
PARE_LIST_FILE_MISSING_FINAL_SEPARATOR_FAILURE(logh, pathname, "line starting with '-------'", int, -1);
}
-
- fprintf(stderr, "%d,%d,%d,%d,%d,%d\n",
- movieStats->numTVMiniSeries,
- movieStats->numMovie,
- movieStats->numTVSeries,
- movieStats->numTVMovie,
- movieStats->numVideoMovie,
- movieStats->numVideoGame);
PAR_SUCCESS(logh, int, 0);
--- 1196,1199 ----
|