summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2015-05-03 01:10:09 +0200
committerDirk Engling <erdgeist@erdgeist.org>2015-05-03 01:10:09 +0200
commit8916a3d9824e1b53e4a739e0f9b60258809bd7ce (patch)
tree06152a97fdbb5353b8b302820a996264e56d49a8
parentd39ece3df4db11af68a9798171d48c23c8b25d2f (diff)
Do not copy redundant data to continuation rows
-rw-r--r--src/export/extract_version_1.c24
1 files changed, 17 insertions, 7 deletions
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 )
73 { 73 {
74 end = strchr( e, '\n' ); 74 end = strchr( e, '\n' );
75 if( !end ) { 75 if( !end ) {
76 fprintf( stderr, "Unexpected end of line in city: %s", g_state.ort ); 76 fprintf( stderr, "Unexpected end of line in city: %s\n", g_state.ort );
77 /* fprintf( stderr, "Failing String, (%d of %d entries, column %d): ###%s\n", entry, num_entries, column, entries ); */ 77 /* fprintf( stderr, "Failing String, (%d of %d entries, column %d): ###%s\n", entry, num_entries, column, entries ); */
78 if( !column ) 78 if( !column )
79 return; 79 return;
@@ -92,10 +92,21 @@ static void split_to_files( uint8_t *entries, int num_entries )
92 e = end; 92 e = end;
93 } 93 }
94 94
95 /* mimic flags from telefonbuch v3 */ 95 *( g_state.outbuf[0] + g_state.outfill[0]++ ) = '0';
96 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; 96
97 memcpy( g_state.outbuf[12] + g_state.outfill[12], g_state.ort, g_state.ort_len ); g_state.outfill[12] += g_state.ort_len; 97 if( entry )
98 memcpy( g_state.outbuf[13] + g_state.outfill[13], g_state.zip, g_state.zip_len ); g_state.outfill[13] += g_state.zip_len; 98 {
99 /* mimic flags from telefonbuch v4 */
100 *( g_state.outbuf[0] + g_state.outfill[0]++ ) = '2';
101 memcpy( g_state.outbuf[12] + g_state.outfill[12], g_state.ort, g_state.ort_len ); g_state.outfill[12] += g_state.ort_len;
102 memcpy( g_state.outbuf[13] + g_state.outfill[13], g_state.zip, g_state.zip_len ); g_state.outfill[13] += g_state.zip_len;
103 }
104 else
105 *( g_state.outbuf[0] + g_state.outfill[0]++ ) = num_entries > 1 ? '1' : '0';
106
107 *( g_state.outbuf[0 ] + g_state.outfill[0 ]++ ) = '\n';
108 *( g_state.outbuf[12] + g_state.outfill[12]++ ) = '\n';
109 *( g_state.outbuf[13] + g_state.outfill[13]++ ) = '\n';
99 if( !end ) 110 if( !end )
100 return; 111 return;
101 } 112 }
@@ -162,11 +173,10 @@ static void act_on_file( uint8_t *file )
162 173
163 for(i=0; ort[i]; ++i ) 174 for(i=0; ort[i]; ++i )
164 g_state.ort[i] = (char)cp437_to_iso8859_1_table[(uint8_t)((uint8_t*)ort)[i]]; 175 g_state.ort[i] = (char)cp437_to_iso8859_1_table[(uint8_t)((uint8_t*)ort)[i]];
165 g_state.ort[i++] = '\n';
166 g_state.ort[i] = 0; 176 g_state.ort[i] = 0;
167 g_state.ort_len = i; 177 g_state.ort_len = i;
168 178
169 g_state.zip_len = snprintf( g_state.zip, sizeof(g_state.zip), "%s\n", zip ); 179 g_state.zip_len = snprintf( g_state.zip, sizeof(g_state.zip), "%s", zip );
170 g_state.vorwahl = vorwahl; 180 g_state.vorwahl = vorwahl;
171 181
172 /* printf( "Working on a %04d page and %06d records file, city: %4s %-32s with prefix %s\n", num_pages, num_records, zip, ort, vorwahl ); */ 182 /* printf( "Working on a %04d page and %06d records file, city: %4s %-32s with prefix %s\n", num_pages, num_records, zip, ort, vorwahl ); */