--- imach/src/imach.c 2017/06/30 15:48:31 1.276 +++ imach/src/imach.c 2017/07/17 08:53:49 1.277 @@ -1,6 +1,9 @@ -/* $Id: imach.c,v 1.276 2017/06/30 15:48:31 brouard Exp $ +/* $Id: imach.c,v 1.277 2017/07/17 08:53:49 brouard Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.277 2017/07/17 08:53:49 brouard + Summary: BOM files can be read now + Revision 1.276 2017/06/30 15:48:31 brouard Summary: Graphs improvements @@ -1031,12 +1034,12 @@ typedef struct { #define ODIRSEPARATOR '\\' #endif -/* $Id: imach.c,v 1.276 2017/06/30 15:48:31 brouard Exp $ */ +/* $Id: imach.c,v 1.277 2017/07/17 08:53:49 brouard Exp $ */ /* $State: Exp $ */ #include "version.h" char version[]=__IMACH_VERSION__; char copyright[]="February 2016,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2018"; -char fullversion[]="$Revision: 1.276 $ $Date: 2017/06/30 15:48:31 $"; +char fullversion[]="$Revision: 1.277 $ $Date: 2017/07/17 08:53:49 $"; char strstart[80]; char optionfilext[10], optionfilefiname[FILENAMELENGTH]; int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ @@ -10613,7 +10616,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]; @@ -10842,11 +10845,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);