diff -r 4912234d80be -r 189183b37598 bookloupe/bookloupe.c --- a/bookloupe/bookloupe.c Sun Sep 29 22:51:27 2013 +0100 +++ b/bookloupe/bookloupe.c Mon Oct 21 23:36:40 2013 +0100 @@ -245,7 +245,7 @@ gboolean mixdigit(const char *); gchar *getaword(const char **); -char *flgets(char **,long); +char *flgets(char **,long,gboolean); void postprocess_for_HTML(char *); char *linehasmarkup(char *); char *losemarkup(char *); @@ -735,11 +735,20 @@ gchar *inword; QuoteClass qc; lines=g_strsplit(etext,"\n",0); + if (lines[0]) + /* If there's at least one line, we might have UNIX-style terminators */ + results.unix_lineends=TRUE; for (j=0;lines[j];j++) { lbytes=strlen(lines[j]); - while (lbytes>0 && lines[j][lbytes-1]=='\r') - lines[j][--lbytes]='\0'; + if (lbytes>0 && lines[j][lbytes-1]=='\r') + { + results.unix_lineends=FALSE; + do + { + lines[j][--lbytes]='\0'; + } while (lbytes>0 && lines[j][lbytes-1]=='\r'); + } llen=g_utf8_strlen(lines[j],lbytes); linecnt++; if (strstr(lines[j],"*END") && strstr(lines[j],"SMALL PRINT") && @@ -881,6 +890,13 @@ struct warnings *report_first_pass(struct first_pass_results *results) { static struct warnings warnings={0}; + warnings.nocr=1; + if (results->unix_lineends) + { + warnings.nocr=0; + g_print(" --> No lines in this file have a CR. Not reporting them. " + "Project Gutenberg requires that all lineends be CR-LF.\n"); + } if (cnt_spacend>0) g_print(" --> %ld lines in this file have white space at end\n", cnt_spacend); @@ -2869,7 +2885,7 @@ */ linecnt=0; etext_ptr=etext; - while ((aline=flgets(&etext_ptr,linecnt+1))) + while ((aline=flgets(&etext_ptr,linecnt+1,warnings->nocr))) { linecnt++; if (linecnt==1) @@ -3015,7 +3031,7 @@ * * Returns: a pointer to the line. */ -char *flgets(char **etext,long lcnt) +char *flgets(char **etext,long lcnt,gboolean warn_nocr) { gunichar c; gboolean isCR=FALSE; @@ -3054,7 +3070,7 @@ else { /* Error - a LF without a preceding CR */ - if (pswit[LINE_END_SWITCH]) + if (pswit[LINE_END_SWITCH] && warn_nocr) { if (pswit[ECHO_SWITCH]) {