fixed a segfault with fgets return value for some cases inside test function compare_...
[openjpeg.git] / tests / comparePGXimages.c
index a31a25f1aa3abb238c141771451a12f9cccbc54f..7839e299d5867352bfdd778a9216750c0770aafd 100644 (file)
@@ -1,3 +1,29 @@
+/*
+ * Copyright (c) 2011, Mickael Savinaud, Communications & Systemes <mickael.savinaud@c-s.fr>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
 /*
  * comparePGXimages.c
  *
@@ -9,6 +35,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
+#include <ctype.h>
 
 #include "opj_config.h"
 #include "getopt.h"
@@ -18,7 +45,7 @@
 #include "convert.h"
 
 double* parseToleranceValues( char* inArg, const int nbcomp);
-void comparePGXimages_help_display();
+void comparePGXimages_help_display(void);
 opj_image_t* readImageFromFilePGX(char* filename, int nbFilenamePGX, char *separator);
 #ifdef HAVE_LIBPNG
 int imageToPNG(const opj_image_t* image, const char* filename, int num_comp_select);
@@ -48,7 +75,7 @@ typedef struct test_cmp_parameters
 /*******************************************************************************
  * Command line help function
  *******************************************************************************/
-void comparePGXimages_help_display() {
+void comparePGXimages_help_display(void) {
   fprintf(stdout,"\nList of parameters for the comparePGX function  \n");
   fprintf(stdout,"\n");
   fprintf(stdout,"  -b \t REQUIRED \t filename to the reference/baseline PGX image \n");
@@ -712,12 +739,12 @@ int main(int argc, char **argv)
        if ( nbPixelDiff > 0)
          {
          char it_compc[255];
+         it_compc[0] = '\0';
 
          printf("<DartMeasurement name=\"NumberOfPixelsWithDifferences_%d\" type=\"numeric/int\"> %d </DartMeasurement> \n", it_comp, nbPixelDiff);
          printf("<DartMeasurement name=\"ComponentError_%d\" type=\"numeric/double\"> %f </DartMeasurement> \n", it_comp, sumDiff);
 
 #ifdef HAVE_LIBPNG
-         it_compc[0] = '\0';
          sprintf(it_compc, "_%i", it_comp);
          strcat(it_compc,".png");
          strcat(filenamePNGbase_it_comp, it_compc);