From: Jaakko Heinonen Date: Sun, 10 Jun 2001 10:55:15 +0000 (+0000) Subject: Text filter update X-Git-Tag: upstream/0.6.1~2^2~369 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=c0217523d30a32c86e495066655a5c528f5cc772;p=pkg%2Fabook.git Text filter update --- diff --git a/ChangeLog b/ChangeLog index 8875544..d64af02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ - html export filter creates now valid html documents - ablity to print/export only selected items - new editor commands + - text filter update 0.4.12 - added man page for abookrc (Alan Ford) diff --git a/filter.c b/filter.c index d401bf1..15370fb 100644 --- a/filter.c +++ b/filter.c @@ -1168,6 +1168,71 @@ mutt_alias_export(FILE *out, struct db_enumerator e) * printable export filter */ + +static void +text_write_address_us(FILE *out, int i) { + fprintf(out, "\n%s", database[i][ADDRESS]); + + if (database[i][CITY]) + fprintf(out, "\n%s", database[i][CITY]); + + if (database[i][STATE] || database[i][ZIP]) { + fputc('\n', out); + + if(database[i][STATE]) { + fprintf(out, "%s", database[i][STATE]); + if(database[i][ZIP]) + fputc(' ', out); + } + + if(database[i][ZIP]) + fprintf(out, "%s", database[i][ZIP]); + } + + if (database[i][COUNTRY]) + fprintf(out, "\n%s", database[i][COUNTRY]); +} + + +static void +text_write_address_uk(FILE *out, int i) { + int j; + + for (j = ADDRESS; j <= COUNTRY; j++) + if (database[i][j]) + fprintf(out, "\n%s", database[i][j]); +} + +static void +text_write_address_eu(FILE *out, int i) { + fprintf(out, "\n%s", database[i][ADDRESS]); + + if (database[i][ZIP] || database[i][CITY]) { + fputc('\n', out); + + if(database[i][ZIP]) { + fprintf(out, "%s", database[i][ZIP]); + if(database[i][CITY]) + fputc(' ', out); + } + + if(database[i][CITY]) + fprintf(out, "%s", database[i][CITY]); + /* + fprintf(out, "\n%s %s", + safe_str(database[i][ZIP]), + safe_str(database[i] [CITY])); + */ + } + + + if (database[i][STATE]) + fprintf(out, "\n%s", database[i][STATE]); + + if (database[i][COUNTRY]) + fprintf(out, "\n%s", database[i][COUNTRY]); +} + static int text_export_database(FILE * out, struct db_enumerator e) { @@ -1199,42 +1264,12 @@ text_export_database(FILE * out, struct db_enumerator e) } /* Print address */ if (database[e.item][ADDRESS]) { - if (!safe_strcmp(style, "us")) { /* US like */ - fprintf(out, "\n%s", database[e.item][ADDRESS]); - if (database[e.item][CITY]) - fprintf(out, "\n%s", - database[e.item][CITY]); - if (database[e.item][STATE] || database[e.item][ZIP]) - fprintf(out, "\n%s %s", - safe_str(database[e.item] - [STATE]), - safe_str(database[e.item] - [ZIP])); - if (database[e.item][COUNTRY]) - fprintf(out, "\n%s", - database[e.item][COUNTRY]); - } - - else if (!safe_strcmp(style, "uk")) { /* UK like */ - for (j = ADDRESS; j <= COUNTRY; j++) - if (database[e.item][j]) - fprintf(out, "\n%s", - database[e.item][j]); - } else { /* EU like */ - fprintf(out, "\n%s", database[e.item][ADDRESS]); - if (database[e.item][ZIP] || - database[e.item][CITY]) - fprintf(out, "\n%s %s", - safe_str(database[e.item][ZIP]), - safe_str(database[e.item] - [CITY])); - if (database[e.item][STATE]) - fprintf(out, "\n%s", - database[e.item][STATE]); - if (database[e.item][COUNTRY]) - fprintf(out, "\n%s", - database[e.item][COUNTRY]); - } + if (!safe_strcmp(style, "us")) /* US like */ + text_write_address_us(out, e.item); + else if (!safe_strcmp(style, "uk")) /* UK like */ + text_write_address_uk(out, e.item); + else /* EU like */ + text_write_address_eu(out, e.item); fprintf(out, "\n"); }