From: N. Brouard Date: Mon, 17 Jul 2017 08:53:49 +0000 (+0000) Subject: Summary: BOM files can be read now X-Git-Tag: imach-099s7~219 X-Git-Url: https://henry.ined.fr/git/?a=commitdiff_plain;h=341142cb2377549e6aa0652d93b8a93b215b0c71;p=.git Summary: BOM files can be read now --- diff --git a/src/imach.c b/src/imach.c index ccba45c..471a89a 100644 --- a/src/imach.c +++ b/src/imach.c @@ -1,6 +1,9 @@ /* $Id$ $State$ $Log$ + Revision 1.276 2017/06/30 15:48:31 brouard + Summary: Graphs improvements + Revision 1.275 2017/06/30 13:39:33 brouard Summary: Saito's color @@ -10610,7 +10613,7 @@ int main(int argc, char *argv[]) int vpopbased=0; int nres=0; int endishere=0; - + int noffset=0; int ncurrv=0; /* Temporary variable */ char ca[32], cb[32]; @@ -10839,11 +10842,32 @@ int main(int argc, char *argv[]) /* Reads comments: lines beginning with '#' */ numlinepar=0; - - /* First parameter line */ + /* Is it a BOM UTF-8 Windows file? */ + /* First parameter line */ while(fgets(line, MAXLINE, ficpar)) { + noffset=0; + if( line[0] == (char)0xEF && line[1] == (char)0xBB) /* EF BB BF */ + { + noffset=noffset+3; + printf("# File is an UTF8 Bom.\n"); // 0xBF + } + else if( line[0] == (char)0xFE && line[1] == (char)0xFF) + { + noffset=noffset+2; + printf("# File is an UTF16BE BOM file\n"); + } + else if( line[0] == 0 && line[1] == 0) + { + if( line[2] == (char)0xFE && line[3] == (char)0xFF){ + noffset=noffset+4; + printf("# File is an UTF16BE BOM file\n"); + } + } else{ + ;/*printf(" Not a BOM file\n");*/ + } + /* If line starts with a # it is a comment */ - if (line[0] == '#') { + if (line[noffset] == '#') { numlinepar++; fputs(line,stdout); fputs(line,ficparo);