[GRASS-SVN] r37337 -
grass/branches/releasebranch_6_4/lib/vector/diglib
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu May 21 13:07:11 EDT 2009
Author: martinl
Date: 2009-05-21 13:07:11 -0400 (Thu, 21 May 2009)
New Revision: 37337
Modified:
grass/branches/releasebranch_6_4/lib/vector/diglib/test.c
Log:
use G_ fns, EXIT_SUCCESS/FAILURE
(merge from trunk, r37335)
Modified: grass/branches/releasebranch_6_4/lib/vector/diglib/test.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/vector/diglib/test.c 2009-05-21 17:03:31 UTC (rev 37336)
+++ grass/branches/releasebranch_6_4/lib/vector/diglib/test.c 2009-05-21 17:07:11 UTC (rev 37337)
@@ -6,15 +6,16 @@
* AUTHOR(S): Original author CERL, probably Dave Gerdes.
* Update to GRASS 5.7 Radim Blazek.
*
- * PURPOSE: Lower level functions for reading/writing/manipulating vectors.
+ * PURPOSE: Test portable r/w functions
*
- * COPYRIGHT: (C) 2001 by the GRASS Development Team
+ * COPYRIGHT: (C) 2001-2009 by the GRASS Development Team
*
* This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
*
*****************************************************************************/
+#include <stdlib.h>
#include <stdio.h>
#include <grass/Vect.h>
@@ -25,10 +26,10 @@
#define S_TEST 12345
#define C_TEST 123
-int main(int argc, char **argv)
+int main()
{
int i, j;
- int err = 0;
+ int err;
int byte_order;
struct Port_info port;
GVFILE fp;
@@ -44,10 +45,10 @@
short sb, ts[] = { PORT_SHORT_MIN, -(S_TEST), 0, S_TEST, PORT_SHORT_MAX };
char cb, tc[] = { PORT_CHAR_MIN, -(C_TEST), 0, C_TEST, PORT_CHAR_MAX };
-
+ err = EXIT_SUCCESS;
+
if (NULL == (fp.file = fopen("test.tmp", "wb+"))) {
- fprintf(stderr, "ERROR, cannot open test.tmp file.\n");
- return (1);
+ G_fatal_error("Unable tp open test.tmp file");
}
fp.loaded = 0;
@@ -64,12 +65,10 @@
dig__fread_port_D(&db, 1, &fp);
dig_fflush(&fp);
if (db != td[j]) {
- fprintf(stderr,
- "ERROR in read/write portable double, byte_order = %d\n",
- byte_order);
- fprintf(stderr, " Written: %.16e3E\n Read : %.16e3E\n",
- td[j], db);
- err = 1;
+ G_warning("Error in read/write portable double, byte_order = %d"
+ " Written: %.16e3E Read: %.16e3E",
+ byte_order, td[j], db);
+ err = EXIT_FAILURE;
}
}
for (j = 0; j < 7; j++) {
@@ -80,12 +79,10 @@
dig__fread_port_F(&fb, 1, &fp);
dig_fflush(&fp);
if (fb != tf[j]) {
- fprintf(stderr,
- "ERROR in read/write portable float, byte_order = %d\n",
- byte_order);
- fprintf(stderr, " Written: %.8e3E\n Read : %.8e3E\n",
- tf[j], fb);
- err = 1;
+ G_warning("Error in read/write portable float, byte_order = %d"
+ " Written: %.8e3E Read: %.8e3E",
+ byte_order, tf[j], fb);
+ err = EXIT_FAILURE;
}
}
@@ -97,12 +94,10 @@
dig__fread_port_L(&lb, 1, &fp);
dig_fflush(&fp);
if (lb != tl[j]) {
- fprintf(stderr,
- "ERROR in read/write portable long, byte_order = %d\n",
- byte_order);
- fprintf(stderr, " Written: %ld\n Read : %ld\n", tl[j],
- lb);
- err = 1;
+ G_warning("Error in read/write portable long, byte_order = %d"
+ " Written: %lu Read: %lu",
+ byte_order, (long unsigned) tl[j], (long unsigned) lb);
+ err = EXIT_FAILURE;
}
}
@@ -114,11 +109,11 @@
dig__fread_port_I(&ib, 1, &fp);
dig_fflush(&fp);
if (ib != ti[j]) {
- fprintf(stderr,
- "ERROR in read/write portable int, byte_order = %d\n",
- byte_order);
- fprintf(stderr, " Written: %d\n Read : %d\n", ti[j], ib);
- err = 1;
+ G_warning("Error in read/write portable int, byte_order = %d"
+ " Written: %d Read: %d",
+ byte_order, ti[j], ib);
+
+ err = EXIT_FAILURE;
}
}
@@ -130,11 +125,11 @@
dig__fread_port_S(&sb, 1, &fp);
dig_fflush(&fp);
if (sb != ts[j]) {
- fprintf(stderr,
- "ERROR in read/write portable short, byte_order = %d\n",
- byte_order);
- fprintf(stderr, " Written: %d\n Read : %d\n", ts[j], sb);
- err = 1;
+ G_warning("Error in read/write portable short, byte_order = %d"
+ " Written: %d Read: %d",
+ byte_order, ts[j], sb);
+
+ err = EXIT_FAILURE;
}
}
for (j = 0; j < 5; j++) {
@@ -145,11 +140,10 @@
dig__fread_port_C(&cb, 1, &fp);
dig_fflush(&fp);
if (cb != tc[j]) {
- fprintf(stderr,
- "ERROR in read/write portable char, byte_order = %d\n",
- byte_order);
- fprintf(stderr, " Written: %d\n Read : %d\n", tc[j], cb);
- err = 1;
+ G_warning("Error in read/write portable char, byte_order = %d"
+ " Written: %d Read: %d",
+ byte_order, tc[j], cb);
+ err = EXIT_FAILURE;
}
@@ -159,5 +153,6 @@
fclose(fp.file);
- return (err);
+ exit(err);
}
+
More information about the grass-commit
mailing list