X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=test%2Fparsecsv.c;h=f0c2a1ac55fb9a41355a49853c4a82c7b3a31f32;hb=f35d39f9adca67471b72f3e47398855d51481f87;hp=f0a8a1a18103681e209986cb10de3e69cc114ffe;hpb=c7d8a4c93c59999481f91333ebdebde830575dbf;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/test/parsecsv.c b/test/parsecsv.c index f0a8a1a1..f0c2a1ac 100644 --- a/test/parsecsv.c +++ b/test/parsecsv.c @@ -1,7 +1,7 @@ /* $Id: parsecsv.c $ This file is part of the HandBrake source code. - Homepage: . + Homepage: . It may be used under the terms of the GNU General Public License. */ #include @@ -12,11 +12,11 @@ #define is_newline(_x) ( (_x) == 13 || \ (_x) == 11 || \ (_x) == 10 ) - + #define is_white(_x) ( (_x) == '\t' || \ (_x) == ' ' || \ - is_newline(_x) ) - + is_newline(_x) ) + #define is_sep(_x) ( (_x) == ',' ) #define is_esc(_x) ( (_x) == '\\' ) @@ -38,18 +38,18 @@ hb_csv_file_t *hb_open_csv_file( const char *filepath ) { hb_csv_file_t *file = NULL; FILE * fileref; - + if( filepath == NULL ) { return file; } - + fileref = fopen( filepath, "r" ); if( fileref == NULL ) { return file; } - + file = malloc( sizeof( hb_csv_file_t ) ); file->fileref = fileref; file->eof = 0; @@ -59,13 +59,13 @@ hb_csv_file_t *hb_open_csv_file( const char *filepath ) return file; } -void hb_close_csv_file( hb_csv_file_t *file ) +void hb_close_csv_file( hb_csv_file_t *file ) { if( file == NULL ) { return; } - + fclose( file->fileref ); free( file ); } @@ -81,12 +81,12 @@ hb_csv_cell_t *hb_read_next_cell( hb_csv_file_t *file ) { return cell; } - + if( file->eof ) { return cell; } - + cell = malloc( sizeof( hb_csv_cell_t ) ); cell->cell_row = file->curr_row; cell->cell_col = file->curr_col; @@ -113,12 +113,12 @@ hb_csv_cell_t *hb_read_next_cell( hb_csv_file_t *file ) } } } - + if( c == CSV_CHAR_EOF ) { file->eof = 1; } - + /* Terminate the cell text */ cell->cell_text[index] = '\0'; hb_trim_end( cell->cell_text ); @@ -131,7 +131,7 @@ void hb_dispose_cell( hb_csv_cell_t *cell ) { return; } - + free( cell ); } @@ -139,15 +139,14 @@ void hb_dispose_cell( hb_csv_cell_t *cell ) static uint16_t hb_parse_character( hb_csv_file_t * file ) { int byte; - uint16_t c; - int read_result; + uint16_t c = 0; int need_char = 1; - + if( file == NULL ) { return CSV_CHAR_ERROR; } - + while( need_char ) { byte = fgetc( file->fileref ); @@ -159,7 +158,7 @@ static uint16_t hb_parse_character( hb_csv_file_t * file ) { return CSV_CHAR_ERROR; } - + if( file->parse_state == CSV_PARSE_SEEK && is_white(byte) ) { continue; @@ -194,7 +193,7 @@ static uint16_t hb_parse_character( hb_csv_file_t * file ) c = (uint16_t)byte; } } - + return c; } @@ -206,9 +205,9 @@ static void hb_trim_end( char *text ) } int i = strlen(text) - 1; - + for( i = strlen(text) - 1; i >= 0 && is_white(text[i]) ; i-- ) { text[i] = '\0'; } -} \ No newline at end of file +}