From 8916a3d9824e1b53e4a739e0f9b60258809bd7ce Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sun, 3 May 2015 01:10:09 +0200 Subject: Do not copy redundant data to continuation rows --- src/export/extract_version_1.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/export/extract_version_1.c b/src/export/extract_version_1.c index c138784..f5a75b8 100644 --- a/src/export/extract_version_1.c +++ b/src/export/extract_version_1.c @@ -73,7 +73,7 @@ static void split_to_files( uint8_t *entries, int num_entries ) { end = strchr( e, '\n' ); if( !end ) { - fprintf( stderr, "Unexpected end of line in city: %s", g_state.ort ); + fprintf( stderr, "Unexpected end of line in city: %s\n", g_state.ort ); /* fprintf( stderr, "Failing String, (%d of %d entries, column %d): ###%s\n", entry, num_entries, column, entries ); */ if( !column ) return; @@ -92,10 +92,21 @@ static void split_to_files( uint8_t *entries, int num_entries ) e = end; } - /* mimic flags from telefonbuch v3 */ - memcpy( g_state.outbuf[0 ] + g_state.outfill[0 ], entry ? "02\n" : ( num_entries > 1 ? "01\n" : "00\n" ), 3 ); g_state.outfill[0] += 3; - memcpy( g_state.outbuf[12] + g_state.outfill[12], g_state.ort, g_state.ort_len ); g_state.outfill[12] += g_state.ort_len; - memcpy( g_state.outbuf[13] + g_state.outfill[13], g_state.zip, g_state.zip_len ); g_state.outfill[13] += g_state.zip_len; + *( g_state.outbuf[0] + g_state.outfill[0]++ ) = '0'; + + if( entry ) + { + /* mimic flags from telefonbuch v4 */ + *( g_state.outbuf[0] + g_state.outfill[0]++ ) = '2'; + memcpy( g_state.outbuf[12] + g_state.outfill[12], g_state.ort, g_state.ort_len ); g_state.outfill[12] += g_state.ort_len; + memcpy( g_state.outbuf[13] + g_state.outfill[13], g_state.zip, g_state.zip_len ); g_state.outfill[13] += g_state.zip_len; + } + else + *( g_state.outbuf[0] + g_state.outfill[0]++ ) = num_entries > 1 ? '1' : '0'; + + *( g_state.outbuf[0 ] + g_state.outfill[0 ]++ ) = '\n'; + *( g_state.outbuf[12] + g_state.outfill[12]++ ) = '\n'; + *( g_state.outbuf[13] + g_state.outfill[13]++ ) = '\n'; if( !end ) return; } @@ -162,11 +173,10 @@ static void act_on_file( uint8_t *file ) for(i=0; ort[i]; ++i ) g_state.ort[i] = (char)cp437_to_iso8859_1_table[(uint8_t)((uint8_t*)ort)[i]]; - g_state.ort[i++] = '\n'; g_state.ort[i] = 0; g_state.ort_len = i; - g_state.zip_len = snprintf( g_state.zip, sizeof(g_state.zip), "%s\n", zip ); + g_state.zip_len = snprintf( g_state.zip, sizeof(g_state.zip), "%s", zip ); g_state.vorwahl = vorwahl; /* printf( "Working on a %04d page and %06d records file, city: %4s %-32s with prefix %s\n", num_pages, num_records, zip, ort, vorwahl ); */ -- cgit v1.2.3