[GRASS-SVN] r36392 - in grass/trunk/lib/vector: Vlib diglib rtree
transform vedit
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Mar 16 05:51:02 EDT 2009
Author: mmetz
Date: 2009-03-16 05:51:02 -0400 (Mon, 16 Mar 2009)
New Revision: 36392
Added:
grass/trunk/lib/vector/diglib/test32.ok
grass/trunk/lib/vector/diglib/test64.ok
Modified:
grass/trunk/lib/vector/Vlib/Makefile
grass/trunk/lib/vector/Vlib/break_lines.c
grass/trunk/lib/vector/Vlib/break_polygons.c
grass/trunk/lib/vector/Vlib/bridges.c
grass/trunk/lib/vector/Vlib/build_nat.c
grass/trunk/lib/vector/Vlib/clean_nodes.c
grass/trunk/lib/vector/Vlib/dangles.c
grass/trunk/lib/vector/Vlib/map.c
grass/trunk/lib/vector/Vlib/open.c
grass/trunk/lib/vector/Vlib/open_nat.c
grass/trunk/lib/vector/Vlib/read.c
grass/trunk/lib/vector/Vlib/read_nat.c
grass/trunk/lib/vector/Vlib/remove_areas.c
grass/trunk/lib/vector/Vlib/remove_duplicates.c
grass/trunk/lib/vector/Vlib/write.c
grass/trunk/lib/vector/Vlib/write_nat.c
grass/trunk/lib/vector/diglib/Makefile
grass/trunk/lib/vector/diglib/cindex_rw.c
grass/trunk/lib/vector/diglib/file.c
grass/trunk/lib/vector/diglib/head.c
grass/trunk/lib/vector/diglib/plus.c
grass/trunk/lib/vector/diglib/plus_line.c
grass/trunk/lib/vector/diglib/plus_struct.c
grass/trunk/lib/vector/diglib/port_init.c
grass/trunk/lib/vector/diglib/port_test.c
grass/trunk/lib/vector/diglib/portable.c
grass/trunk/lib/vector/diglib/spindex_rw.c
grass/trunk/lib/vector/diglib/test.c
grass/trunk/lib/vector/rtree/Makefile
grass/trunk/lib/vector/transform/Makefile
grass/trunk/lib/vector/vedit/Makefile
Log:
experimental LFS support for vector libspart 2
Modified: grass/trunk/lib/vector/Vlib/Makefile
===================================================================
--- grass/trunk/lib/vector/Vlib/Makefile 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/Makefile 2009-03-16 09:51:02 UTC (rev 36392)
@@ -12,5 +12,10 @@
include $(MODULE_TOPDIR)/include/Make/Lib.make
+#compile if LFS (Large File Support) present:
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS += -D_FILE_OFFSET_BITS=64
+endif
+
default: lib
Modified: grass/trunk/lib/vector/Vlib/break_lines.c
===================================================================
--- grass/trunk/lib/vector/Vlib/break_lines.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/break_lines.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -115,6 +115,7 @@
G_verbose_message(_("Intersections: %5d"), nbreaks);
for (iline = 0; iline < nlines; iline++) {
+ G_percent(iline, nlines, 1);
if (List_break) {
aline = List_break->value[iline];
}
@@ -367,7 +368,8 @@
G_debug(3, "nlines = %d", nlines);
} /* for each line */
- G_verbose_message(_("Intersections: %5d"), nbreaks);
+ G_percent(nlines, nlines, 1); /* finish it */
+ G_verbose_message(_("Intersections: %d"), nbreaks);
Vect_destroy_list(List);
Modified: grass/trunk/lib/vector/Vlib/break_polygons.c
===================================================================
--- grass/trunk/lib/vector/Vlib/break_polygons.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/break_polygons.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -115,6 +115,7 @@
XPnts = NULL;
for (i = 1; i <= nlines; i++) {
+ G_percent(i, nlines, 1);
G_debug(3, "i = %d", i);
if (!Vect_line_alive(Map, i))
continue;
@@ -232,12 +233,14 @@
/* G_sleep (10); */
nbreaks = 0;
+ nallpoints = 0;
/* Second loop through lines (existing when loop is started, no need to process lines written again)
* and break at points marked for break */
for (i = 1; i <= nlines; i++) {
int n_orig_points;
+ G_percent(i, nlines, 1);
G_debug(3, "i = %d", i);
if (!Vect_line_alive(Map, i))
continue;
@@ -329,4 +332,5 @@
G_free(XPnts);
RTreeDestroyNode(RTree);
+ G_verbose_message("Breaks: %d", nbreaks);
}
Modified: grass/trunk/lib/vector/Vlib/bridges.c
===================================================================
--- grass/trunk/lib/vector/Vlib/bridges.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/bridges.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -113,6 +113,7 @@
G_debug(1, "nlines = %d", nlines);
for (line = 1; line <= nlines; line++) {
+ G_percent(line, nlines, 1);
if (!Vect_line_alive(Map, line))
continue;
@@ -189,4 +190,6 @@
bridges_removed++;
}
}
+ G_verbose_message("Removed lines: %d", lines_removed);
+ G_verbose_message("Removed bridges: %d", bridges_removed);
}
Modified: grass/trunk/lib/vector/Vlib/build_nat.c
===================================================================
--- grass/trunk/lib/vector/Vlib/build_nat.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/build_nat.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -16,9 +16,11 @@
\date 2001-2008
*/
+#include <grass/config.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <sys/types.h>
#include <grass/glocale.h>
#include <grass/gis.h>
#include <grass/Vect.h>
@@ -38,7 +40,7 @@
{
int j, area, isle, n_lines, line, type, direction;
static int first = 1;
- long offset;
+ off_t offset;
struct Plus_head *plus;
P_LINE *BLine;
static struct line_pnts *Points, *APoints;
@@ -427,7 +429,7 @@
{
struct Plus_head *plus;
int i, s, type, lineid;
- long offset;
+ off_t offset;
int side, line, area;
struct line_pnts *Points, *APoints;
struct line_cats *Cats;
@@ -553,7 +555,7 @@
if (format == G_INFO_FORMAT_PLAIN)
fprintf(stderr, "%d..", i);
else
- fprintf(stderr, "%7d\b\b\b\b\b\b\b", i);
+ fprintf(stderr, "%11d\b\b\b\b\b\b\b\b\b\b\b", i);
}
i++;
Modified: grass/trunk/lib/vector/Vlib/clean_nodes.c
===================================================================
--- grass/trunk/lib/vector/Vlib/clean_nodes.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/clean_nodes.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -39,7 +39,7 @@
Vect_clean_small_angles_at_nodes(struct Map_info *Map, int otype,
struct Map_info *Err)
{
- int node;
+ int node, nnodes;
int nmodif = 0;
struct line_pnts *Points;
struct line_cats *SCats, *LCats, *OCats;
@@ -49,9 +49,12 @@
LCats = Vect_new_cats_struct();
OCats = Vect_new_cats_struct();
+ nnodes = Vect_get_num_nodes(Map);
for (node = 1; node <= Vect_get_num_nodes(Map); node++) {
int i, nlines;
+ if (node <= nnodes)
+ G_percent(node, nnodes, 1);
G_debug(3, "node = %d", node);
if (!Vect_node_alive(Map, node))
continue;
@@ -246,6 +249,7 @@
break;
}
}
+ G_verbose_message("Line modifications: %d", nmodif);
return (nmodif);
}
Modified: grass/trunk/lib/vector/Vlib/dangles.c
===================================================================
--- grass/trunk/lib/vector/Vlib/dangles.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/dangles.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -118,7 +118,7 @@
2 for update at least on GV_BUILD_BASE.
Parameters:
- Map input map where have to be deleted
+ Map input map where dangles have to be deleted
type type of dangles
option dangle option (REMOVE_DANGLE, CHTYPE_DANGLE, SELECT_DANGLE)
maxlength maxlength of dangles or -1 for all dangles
@@ -168,6 +168,7 @@
G_debug(2, "nnodes = %d", nnodes);
for (node = 1; node <= nnodes; node++) {
+ G_percent(node, nnodes, 1);
G_debug(3, "node = %d", node);
if (!Vect_node_alive(Map, node))
continue;
@@ -261,4 +262,6 @@
dangles_removed++;
} /* lcount == 1 */
} /* node <= nnodes */
+ G_verbose_message("Removed lines: %d", lines_removed);
+ G_verbose_message("Removed dangles: %d", dangles_removed);
}
Modified: grass/trunk/lib/vector/Vlib/map.c
===================================================================
--- grass/trunk/lib/vector/Vlib/map.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/map.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -484,7 +484,7 @@
ret =
db_delete_table(Fi->driver, Fi->database, Fi->table);
if (ret == DB_FAILED) {
- G_warning(_("Unable to delete table <%s>"));
+ G_warning(_("Unable to delete table <%s>"), Fi->table);
Vect_close(&Map);
return -1;
}
Modified: grass/trunk/lib/vector/Vlib/open.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/open.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -17,6 +17,7 @@
*
* \date 2001-2008
*/
+#include <grass/config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -180,6 +181,9 @@
return -1;
}
+ G_debug(1, "Map name: %s", Map->name);
+ G_debug(1, "Map mapset: %s", Map->mapset);
+
/* Read vector format information */
format = 0;
sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, Map->name);
@@ -355,7 +359,7 @@
fatal_error(ferror, errmsg);
return (-1);
}
- fseek(Map->hist_fp, (long)0, SEEK_END);
+ fseek(Map->hist_fp, (off_t)0, SEEK_END);
Vect_hist_write(Map,
"---------------------------------------------------------------------------------\n");
@@ -624,7 +628,7 @@
Info->mtime = -1L;
}
else {
- Info->size = (long)stat_buf.st_size; /* file size */
+ Info->size = (off_t)stat_buf.st_size; /* file size */
Info->mtime = (long)stat_buf.st_mtime; /* last modified time */
}
/* stat does not give correct size on MINGW
Modified: grass/trunk/lib/vector/Vlib/open_nat.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open_nat.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/open_nat.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -18,6 +18,7 @@
\date 2001
*/
+#include <grass/config.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -43,6 +44,7 @@
int V1_open_old_nat(struct Map_info *Map, int update)
{
char buf[1000];
+ struct Coor_info CInfo;
G_debug(1, "V1_open_old_nat(): name = %s mapset = %s", Map->name,
Map->mapset);
@@ -55,11 +57,18 @@
Map->dig_fp.file =
G_fopen_old(buf, GRASS_VECT_COOR_ELEMENT, Map->mapset);
- if (Map->dig_fp.file == NULL)
- return -1;
+ if (Map->dig_fp.file == NULL) {
+ G_warning("Could not open coor file for vector map <%s>", Map->name);
+ return -1;
+ }
+ /* needed to determine file size, Map->head.size will be updated by dig__read_head(Map) */
+ Vect_coor_info(Map, &CInfo);
+ Map->head.size = CInfo.size;
+
if (!(dig__read_head(Map)))
return (-1);
+
check_coor(Map);
/* set conversion matrices */
@@ -67,7 +76,7 @@
/* load to memory */
if (!update)
- dig_file_load(&(Map->dig_fp));
+ dig_file_load(&(Map->dig_fp)); /* has currently no effect, file never loaded */
return (0);
}
@@ -118,7 +127,7 @@
G__file_name(name_buf, buf, GRASS_VECT_COOR_ELEMENT, G_mapset());
Map->head.size = 0;
- Map->head.head_size = GV_COOR_HEAD_SIZE;
+ Map->head.head_size = GV_COOR_HEAD_SIZE + 4;
Vect__write_head(Map);
/* set conversion matrices */
@@ -134,7 +143,7 @@
int check_coor(struct Map_info *Map)
{
struct Coor_info CInfo;
- long dif;
+ off_t dif;
Vect_coor_info(Map, &CInfo);
dif = CInfo.size - Map->head.size;
Modified: grass/trunk/lib/vector/Vlib/read.c
===================================================================
--- grass/trunk/lib/vector/Vlib/read.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/read.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -16,6 +16,8 @@
\date 2001-2008
*/
+#include <grass/config.h>
+#include <sys/types.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -185,7 +187,7 @@
\return feature offset
\return -1 on error
*/
-long Vect_get_line_offset(const struct Map_info *Map, int line)
+off_t Vect_get_line_offset(const struct Map_info *Map, int line)
{
if (line < 1 || line > Map->plus.n_lines)
return -1;
Modified: grass/trunk/lib/vector/Vlib/read_nat.c
===================================================================
--- grass/trunk/lib/vector/Vlib/read_nat.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/read_nat.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -23,13 +23,15 @@
\date 2001
*/
+#include <grass/config.h>
+#include <sys/types.h>
#include <grass/gis.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
static int
Vect__Read_line_nat(struct Map_info *,
- struct line_pnts *, struct line_cats *, long);
+ struct line_pnts *, struct line_cats *, off_t);
/*!
* \brief Read line from coor file on given offset.
@@ -47,7 +49,7 @@
int
V1_read_line_nat(struct Map_info *Map,
struct line_pnts *Points,
- struct line_cats *Cats, long offset)
+ struct line_cats *Cats, off_t offset)
{
return Vect__Read_line_nat(Map, Points, Cats, offset);
}
@@ -69,7 +71,7 @@
struct line_pnts *line_p, struct line_cats *line_c)
{
int itype;
- long offset;
+ off_t offset;
BOUND_BOX lbox, mbox;
G_debug(3, "V1_read_next_line_nat()");
@@ -210,11 +212,11 @@
*/
int
Vect__Read_line_nat(struct Map_info *Map,
- struct line_pnts *p, struct line_cats *c, long offset)
+ struct line_pnts *p, struct line_cats *c, off_t offset)
{
int i, dead = 0;
int n_points;
- long size;
+ off_t size;
int n_cats, do_cats;
int type;
char rhead, nc;
@@ -285,10 +287,10 @@
}
else {
if (Map->head.Version_Minor == 1) { /* coor format 5.1 */
- size = (2 * PORT_INT) * n_cats;
+ size = (off_t) (2 * PORT_INT) * n_cats;
}
else { /* coor format 5.0 */
- size = (PORT_SHORT + PORT_INT) * n_cats;
+ size = (off_t) (PORT_SHORT + PORT_INT) * n_cats;
}
dig_fseek(&(Map->dig_fp), size, SEEK_CUR);
@@ -326,9 +328,9 @@
}
else {
if (Map->head.with_z)
- size = n_points * 3 * PORT_DOUBLE;
+ size = (off_t) n_points * 3 * PORT_DOUBLE;
else
- size = n_points * 2 * PORT_DOUBLE;
+ size = (off_t) n_points * 2 * PORT_DOUBLE;
dig_fseek(&(Map->dig_fp), size, SEEK_CUR);
}
Modified: grass/trunk/lib/vector/Vlib/remove_areas.c
===================================================================
--- grass/trunk/lib/vector/Vlib/remove_areas.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/remove_areas.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -40,7 +40,7 @@
Vect_remove_small_areas(struct Map_info *Map, double thresh,
struct Map_info *Err, double *removed_area)
{
- int area;
+ int area, nareas;
int nremoved = 0;
struct ilist *List;
struct ilist *AList;
@@ -53,10 +53,13 @@
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
+ nareas = Vect_get_num_areas(Map);
for (area = 1; area <= Vect_get_num_areas(Map); area++) {
int i, j, centroid, dissolve_neighbour;
double length, size;
+ if (area <= nareas)
+ G_percent(area, nareas, 1);
G_debug(3, "area = %d", area);
if (!Vect_area_alive(Map, area))
continue;
Modified: grass/trunk/lib/vector/Vlib/remove_duplicates.c
===================================================================
--- grass/trunk/lib/vector/Vlib/remove_duplicates.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/remove_duplicates.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -64,6 +64,7 @@
ndupl = 0;
for (i = 1; i <= nlines; i++) {
+ G_percent(i, nlines, 1);
if (!Vect_line_alive(Map, i))
continue;
@@ -113,6 +114,7 @@
nlines = Vect_get_num_lines(Map); /* For future when lines with cats will be rewritten */
G_debug(3, "nlines = %d\n", nlines);
}
+ G_verbose_message("Removed duplicates: %d", ndupl);
}
/*!
Modified: grass/trunk/lib/vector/Vlib/write.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/write.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -17,11 +17,13 @@
\date 2001
*/
+#include <grass/config.h>
+#include <sys/types.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/Vect.h>
-static long write_dummy()
+static off_t write_dummy()
{
G_warning("Vect_write_line() %s",
_("for this format/level not supported"));
@@ -54,7 +56,7 @@
return 0;
}
-static long format_l()
+static off_t format_l()
{
G_fatal_error(_("Requested format is not compiled in this version"));
return 0;
@@ -62,7 +64,7 @@
#endif
-static long (*Write_line_array[][3]) () = {
+static off_t (*Write_line_array[][3]) () = {
{
write_dummy, V1_write_line_nat, V2_write_line_nat}
#ifdef HAVE_OGR
@@ -120,13 +122,13 @@
\param points feature geometry
\param cats feature categories
- \return offset into file where the feature starts
+ \return new feature id (level 2) or offset into file where the feature starts (level 1)
*/
-long
+off_t
Vect_write_line(struct Map_info *Map,
int type, struct line_pnts *points, struct line_cats *cats)
{
- long offset;
+ off_t offset;
G_debug(3, "Vect_write_line(): name = %s, format = %d, level = %d",
Map->name, Map->format, Map->level);
@@ -147,6 +149,7 @@
if (offset == -1)
G_fatal_error(_("Unable to write feature (negative offset)"));
+ /* NOTE: returns new line id on level 2 and file offset on level 1 */
return offset;
}
@@ -255,7 +258,7 @@
\return 0 on success
\return -1 on error
*/
-int Vect_restore_line(struct Map_info *Map, int line, long offset)
+int Vect_restore_line(struct Map_info *Map, int line, off_t offset)
{
int ret;
Modified: grass/trunk/lib/vector/Vlib/write_nat.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write_nat.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/Vlib/write_nat.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -23,7 +23,9 @@
\date 2001
*/
+#include <grass/config.h>
#include <stdio.h>
+#include <sys/types.h>
#include <stdlib.h>
#include <math.h>
@@ -297,7 +299,7 @@
return;
}
-long V1__rewrite_line_nat(struct Map_info *Map, long offset, int type,
+off_t V1__rewrite_line_nat(struct Map_info *Map, off_t offset, int type,
struct line_pnts *points, struct line_cats *cats);
/*!
@@ -311,10 +313,10 @@
\return feature offset into file
\return -1 on error
*/
-long V1_write_line_nat(struct Map_info *Map,
+off_t V1_write_line_nat(struct Map_info *Map,
int type, struct line_pnts *points, struct line_cats *cats)
{
- long offset;
+ off_t offset;
if (dig_fseek(&(Map->dig_fp), 0L, SEEK_END) == -1) /* set to end of file */
return -1;
@@ -337,11 +339,11 @@
\return new feature id
\return -1 on error
*/
-long V2_write_line_nat(struct Map_info *Map,
+off_t V2_write_line_nat(struct Map_info *Map,
int type, struct line_pnts *points, struct line_cats *cats)
{
int line;
- long offset;
+ off_t offset;
struct Plus_head *plus;
BOUND_BOX box;
@@ -371,7 +373,9 @@
G_debug(3, "updated lines : %d , updated nodes : %d", plus->n_uplines,
plus->n_upnodes);
-
+
+ /* returns int line, but is defined as off_t for compatibility with
+ * Write_line_array in write.c */
return line;
}
@@ -394,15 +398,15 @@
\return feature offset (rewriten feature)
\return -1 on error
*/
-long V1_rewrite_line_nat(struct Map_info *Map,
- long offset,
+off_t V1_rewrite_line_nat(struct Map_info *Map,
+ off_t offset,
int type,
struct line_pnts *points, struct line_cats *cats)
{
int old_type;
struct line_pnts *old_points;
struct line_cats *old_cats;
- long new_offset;
+ off_t new_offset;
/* TODO: enable points and cats == NULL */
@@ -482,8 +486,8 @@
\return feature offset
\return -1 on error
*/
-long V1__rewrite_line_nat(struct Map_info *Map,
- long offset,
+off_t V1__rewrite_line_nat(struct Map_info *Map,
+ off_t offset,
int type,
struct line_pnts *points, struct line_cats *cats)
{
@@ -579,7 +583,7 @@
\return 0 on success
\return -1 on error
*/
-int V1_delete_line_nat(struct Map_info *Map, long offset)
+int V1_delete_line_nat(struct Map_info *Map, off_t offset)
{
char rhead;
GVFILE *dig_fp;
@@ -818,7 +822,7 @@
\return 0 on success
\return -1 on error
*/
-int V1_restore_line_nat(struct Map_info *Map, long offset)
+int V1_restore_line_nat(struct Map_info *Map, off_t offset)
{
char rhead;
GVFILE *dig_fp;
@@ -861,7 +865,7 @@
\return 0 on success
\return -1 on error
*/
-int V2_restore_line_nat(struct Map_info *Map, int line, long offset)
+int V2_restore_line_nat(struct Map_info *Map, int line, off_t offset)
{
int i, ret, type;
P_LINE *Line;
Modified: grass/trunk/lib/vector/diglib/Makefile
===================================================================
--- grass/trunk/lib/vector/diglib/Makefile 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/Makefile 2009-03-16 09:51:02 UTC (rev 36392)
@@ -12,6 +12,14 @@
EXTRA_CFLAGS = $(VECT_CFLAGS)
LIBES = $(GISLIB) $(RTREELIB) $(MATHLIB)
+#compile if LFS (Large File Support) present:
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS += -D_FILE_OFFSET_BITS=64
+ TESTFILE = test64.ok
+else
+ TESTFILE = test32.ok
+endif
+
TEST = $(OBJDIR)/test
default: lib
@@ -20,7 +28,7 @@
# Test portable read/write functions
$(OBJDIR)/test: test.c $(DIG2DEP)
echo "==============TEST============="
- $(CC) $(LDFLAGS) $(COMPILE_FLAGS) $(VECT_CFLAGS) $(INC) $(VECT_INC) -o $@ test.c $(DIG2LIB) $(RTREELIB) \
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(INC) $(VECT_INC) -o $@ test.c $(DIG2LIB) $(RTREELIB) \
$(GISLIB) $(DATETIMELIB) $(MATHLIB) $(XDRLIB)
- cd $(OBJDIR); $(LD_LIBRARY_PATH_VAR)="$($(LD_LIBRARY_PATH_VAR)):$(GISBASE)/lib" ./test; diff ./test.tmp ../test.ok
+ cd $(OBJDIR); $(LD_LIBRARY_PATH_VAR)="$($(LD_LIBRARY_PATH_VAR)):$(GISBASE)/lib" ./test; diff ./test.tmp ../$(TESTFILE)
Modified: grass/trunk/lib/vector/diglib/cindex_rw.c
===================================================================
--- grass/trunk/lib/vector/diglib/cindex_rw.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/cindex_rw.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -14,7 +14,9 @@
* for details.
*
*****************************************************************************/
+#include <grass/config.h>
#include <stdlib.h>
+#include <sys/types.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/Vect.h>
@@ -40,6 +42,15 @@
if (0 >= dig__fwrite_port_C(buf, 5, fp))
return (-1);
+ /* get required offset size */
+ if (plus->off_t_size == 0) {
+ /* should not happen, topo is written first */
+ if (plus->coor_size > (off_t)PORT_LONG_MAX)
+ plus->off_t_size = 8;
+ else
+ plus->off_t_size = 4;
+ }
+
/* bytes 6 - 9 : header size */
if (0 >= dig__fwrite_port_L(&length, 1, fp))
return (0);
@@ -89,7 +100,7 @@
}
/* Offset */
- if (0 >= dig__fwrite_port_L(&(ci->offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ci->offset), 1, fp, plus->off_t_size))
return (0);
G_debug(3, "cidx %d offset: %ld", i, ci->offset);
}
@@ -152,6 +163,15 @@
return (-1);
G_debug(3, " header size %ld", plus->cidx_head_size);
+ /* get required offset size */
+ if (plus->off_t_size == 0) {
+ /* should not happen, topo is opened first */
+ if (plus->coor_size > (off_t)PORT_LONG_MAX)
+ plus->off_t_size = 8;
+ else
+ plus->off_t_size = 4;
+ }
+
/* Body of header - info about all fields */
/* Number of fields */
if (0 >= dig__fread_port_I(&(plus->n_cidx), 1, fp))
@@ -201,7 +221,7 @@
}
/* Offset */
- if (0 >= dig__fread_port_L(&(ci->offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ci->offset), 1, fp, plus->off_t_size))
return (0);
}
Modified: grass/trunk/lib/vector/diglib/file.c
===================================================================
--- grass/trunk/lib/vector/diglib/file.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/file.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -14,6 +14,7 @@
* for details.
*
*****************************************************************************/
+#include <grass/config.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
@@ -32,19 +33,19 @@
*
* Returns: current file position
*/
-long dig_ftell(GVFILE * file)
+off_t dig_ftell(GVFILE * file)
{
if (file->loaded) /* using memory */
return (file->current - file->start);
- return (ftell(file->file));
+ return (G_ftell(file->file));
}
/* Set GVFILE position.
*
* Returns: 0 OK, -1 error
*/
-int dig_fseek(GVFILE * file, long offset, int whence)
+int dig_fseek(GVFILE * file, off_t offset, int whence)
{
if (file->loaded) { /* using memory */
switch (whence) {
@@ -61,7 +62,9 @@
return 0;
}
- return (fseek(file->file, offset, whence));
+ G_fseek(file->file, offset, whence);
+
+ return 0;
}
/* Rewind GVFILE position.
@@ -184,7 +187,7 @@
fstat(fileno(file->file), &sbuf);
size = sbuf.st_size;
- G_debug(2, " size = %u", size);
+ G_debug(2, " size = %ld", size);
/* Decide if the file should be loaded */
/* TODO: I don't know how to get size of free memory (portability) to decide if load or not for auto */
Modified: grass/trunk/lib/vector/diglib/head.c
===================================================================
--- grass/trunk/lib/vector/diglib/head.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/head.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -15,6 +15,8 @@
* for details.
*
*****************************************************************************/
+#include <grass/config.h>
+#include <sys/types.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/Vect.h>
@@ -39,6 +41,9 @@
if (0 >= dig__fwrite_port_C(buf, 5, &(Map->dig_fp)))
return (0);
+ /* increase header size for new vectors, already set in V1_open_new_nat() */
+ length = Map->head.head_size;
+
/* bytes 6 - 9 : header size */
if (0 >= dig__fwrite_port_L(&length, 1, &(Map->dig_fp)))
return (0);
@@ -48,10 +53,28 @@
if (0 >= dig__fwrite_port_C(buf, 1, &(Map->dig_fp)))
return (0);
- /* bytes 11 - 14 : size of coordinate file */
+ /* bytes 11 - 18 : size of coordinate file */
G_debug(1, "write coor size (%ld) to head", Map->head.size);
- if (0 >= dig__fwrite_port_L(&(Map->head.size), 1, &(Map->dig_fp)))
- return (0);
+ if (Map->head.head_size >= GV_COOR_HEAD_SIZE + 4) {
+ if (Map->head.size > PORT_LONG_MAX) {
+ /* can only happen when sizeof(off_t) == 8 */
+ if (0 >= dig__fwrite_port_O(&(Map->head.size), 1, &(Map->dig_fp), sizeof(off_t)))
+ return (0);
+ }
+ else {
+ /* write twice to fill the space and set offset (account for sizeof(off_t) == 4) */
+ if (0 >= dig__fwrite_port_L(&(Map->head.size), 1, &(Map->dig_fp)))
+ return (0);
+ if (0 >= dig__fwrite_port_L(&(Map->head.size), 1, &(Map->dig_fp)))
+ return (0);
+ }
+ }
+ else {
+ /* old vector with shorter coor head size got modified */
+ /* bytes 11 - 14 : size of coordinate file */
+ if (0 >= dig__fwrite_port_L(&(Map->head.size), 1, &(Map->dig_fp)))
+ return (0);
+ }
G_debug(2, "coor body offset %ld", dig_ftell(&(Map->dig_fp)));
return (1);
@@ -116,9 +139,17 @@
Map->head.with_z = buf[0];
G_debug(2, " with_z %d", Map->head.with_z);
- /* bytes 11 - 14 : size of coordinate file */
- if (0 >= dig__fread_port_L(&(Map->head.size), 1, &(Map->dig_fp)))
- return (0);
+ /* Map->head.size holds stats value */
+ if (Map->head.size > PORT_LONG_MAX && Map->head.head_size >= GV_COOR_HEAD_SIZE + 4) {
+ /* bytes 11 - 18 : size of coordinate file */
+ if (0 >= dig__fread_port_O(&(Map->head.size), 1, &(Map->dig_fp), sizeof(off_t)))
+ return (0);
+ }
+ else {
+ /* bytes 11 - 14 : size of coordinate file */
+ if (0 >= dig__fread_port_L(&(Map->head.size), 1, &(Map->dig_fp)))
+ return (0);
+ }
G_debug(2, " coor size %ld", Map->head.size);
/* Go to end of header, file may be written by new version of GRASS with longer header */
Modified: grass/trunk/lib/vector/diglib/plus.c
===================================================================
--- grass/trunk/lib/vector/diglib/plus.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/plus.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -14,6 +14,8 @@
* \date 2001-2006
*/
+#include <grass/config.h>
+#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@@ -38,6 +40,8 @@
Plus->Back_Minor = 0;
Plus->with_z = 0;
+ Plus->off_t_size = 0;
+
Plus->box.N = 0;
Plus->box.S = 0;
Plus->box.E = 0;
Modified: grass/trunk/lib/vector/diglib/plus_line.c
===================================================================
--- grass/trunk/lib/vector/diglib/plus_line.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/plus_line.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -14,11 +14,13 @@
* \date 2001-2008
*/
+#include <grass/config.h>
+#include <sys/types.h>
#include <stdlib.h>
#include <grass/Vect.h>
static int add_line(struct Plus_head *plus, int lineid, int type, struct line_pnts *Points,
- long offset)
+ off_t offset)
{
int node, lp;
P_LINE *line;
@@ -100,7 +102,7 @@
*/
int
dig_add_line(struct Plus_head *plus, int type, struct line_pnts *Points,
- long offset)
+ off_t offset)
{
int ret;
@@ -156,7 +158,7 @@
int
dig_restore_line(struct Plus_head *plus, int lineid,
int type, struct line_pnts *Points,
- long offset)
+ off_t offset)
{
if (lineid < 1 || lineid > plus->n_lines) {
return -1;
Modified: grass/trunk/lib/vector/diglib/plus_struct.c
===================================================================
--- grass/trunk/lib/vector/diglib/plus_struct.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/plus_struct.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -15,6 +15,8 @@
* for details.
*
*****************************************************************************/
+#include <grass/config.h>
+#include <sys/types.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/Vect.h>
@@ -165,10 +167,12 @@
ptr = dig_alloc_line();
+ /* type */
ptr->type = dig_type_from_store(tp);
G_debug(5, " line type %d -> %d", tp, ptr->type);
- if (0 >= dig__fread_port_L(&(ptr->offset), 1, fp))
+ /* offset */
+ if (0 >= dig__fread_port_O(&(ptr->offset), 1, fp, Plus->off_t_size))
return (-1);
/* First node */
@@ -266,11 +270,14 @@
return 0;
}
+ /* type */
ch = (char)dig_type_to_store(ptr->type);
G_debug(5, " line type %d -> %d", ptr->type, ch);
if (0 >= dig__fwrite_port_C(&ch, 1, fp))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->offset), 1, fp))
+
+ /* offset */
+ if (0 >= dig__fwrite_port_O(&(ptr->offset), 1, fp, Plus->off_t_size))
return (-1);
/* First node */
@@ -615,6 +622,21 @@
return (-1);
G_debug(2, " header size %ld", ptr->head_size);
+ /* determine required offset size from header size */
+ /* this is not safe in case new fields get added in later versions */
+ /* better: add a new field with off_t_size after byte_order? */
+ if (ptr->head_size >= 142 + 32) /* keep in sync with dig_Wr_Plus_head() */
+ ptr->off_t_size = 8;
+ else
+ ptr->off_t_size = 4;
+
+ if (sizeof(off_t) < ptr->off_t_size) {
+ G_warning("Vector exceeds supported file size limit");
+ return (-1);
+ }
+
+ G_debug(1, "topo off_t size = %d", ptr->off_t_size);
+
/* byte 10 : dimension 2D or 3D */
if (0 >= dig__fread_port_C(buf, 1, fp))
return (-1);
@@ -666,23 +688,23 @@
return (-1);
/* bytes 111 - 138 : Offset */
- if (0 >= dig__fread_port_L(&(ptr->Node_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Node_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Edge_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Edge_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Line_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Line_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Area_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Area_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Isle_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Isle_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Volume_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Volume_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Hole_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Hole_offset), 1, fp, ptr->off_t_size))
return (-1);
/* bytes 139 - 142 : Coor size and time */
- if (0 >= dig__fread_port_L(&(ptr->coor_size), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->coor_size), 1, fp, ptr->off_t_size))
return (-1);
G_debug(2, " coor size %ld", ptr->coor_size);
@@ -709,6 +731,22 @@
if (0 >= dig__fwrite_port_C(buf, 5, fp))
return (-1);
+ /* determine required offset size from coor file size */
+ if (ptr->coor_size > (off_t)PORT_LONG_MAX) {
+ /* can only happen when sizeof(off_t) == 8 */
+ ptr->off_t_size = 8;
+ }
+ else
+ ptr->off_t_size = 4;
+
+ /* add a new field with off_t_size after byte_order? */
+
+ /* adjust header size for large files */
+ if (ptr->off_t_size == 8) {
+ /* 7 offset values and coor file size: add 8 * 4 */
+ length += 32;
+ }
+
/* bytes 6 - 9 : header size */
if (0 >= dig__fwrite_port_L(&length, 1, fp))
return (0);
@@ -763,23 +801,23 @@
return (-1);
/* bytes 111 - 138 : Offset */
- if (0 >= dig__fwrite_port_L(&(ptr->Node_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Node_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Edge_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Edge_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Line_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Line_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Area_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Area_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Isle_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Isle_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Volume_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Volume_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Hole_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Hole_offset), 1, fp, ptr->off_t_size))
return (-1);
/* bytes 139 - 142 : Coor size and time */
- if (0 >= dig__fwrite_port_L(&(ptr->coor_size), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->coor_size), 1, fp, ptr->off_t_size))
return (-1);
G_debug(2, "topo body offset %ld", dig_ftell(fp));
Modified: grass/trunk/lib/vector/diglib/port_init.c
===================================================================
--- grass/trunk/lib/vector/diglib/port_init.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/port_init.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -15,7 +15,9 @@
* for details.
*
*****************************************************************************/
+#include <grass/config.h>
#include <stdio.h>
+#include <sys/types.h>
#include <grass/Vect.h>
/*
@@ -30,7 +32,7 @@
** binary data files.
** The approach is to take known values and compare them against
** the current machine's internal representation. A cross reference
- ** table is then built, and then all file reads and writes must go through
+ ** table is then built, and then all file reads and writes must go
** through these routines to correct the numbers if need be.
**
** As long as the byte switching is symetrical, the conversion routines
@@ -56,12 +58,14 @@
*/
#define TEST_PATTERN 1.3333
+#define OFF_T_TEST 0x0102030405060708
#define LONG_TEST 0x01020304
#define INT_TEST 0x01020304
#define SHORT_TEST 0x0102
static double u_d = TEST_PATTERN;
static float u_f = TEST_PATTERN;
+off_t u_o; /* depends on sizeof(off_t) */
static long u_l = LONG_TEST;
static int u_i = INT_TEST;
static short u_s = SHORT_TEST;
@@ -71,6 +75,7 @@
{ 0x3f, 0xf5, 0x55, 0x32, 0x61, 0x7c, 0x1b, 0xda };
/* flt_cmpr holds the bytes of an IEEE representation of TEST_PATTERN */
static const unsigned char flt_cmpr[] = { 0x3f, 0xaa, 0xa9, 0x93 };
+static const unsigned char off_t_cmpr[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
static const unsigned char lng_cmpr[] = { 0x01, 0x02, 0x03, 0x04 };
static const unsigned char int_cmpr[] = { 0x01, 0x02, 0x03, 0x04 };
static const unsigned char shrt_cmpr[] = { 0x01, 0x02 };
@@ -78,18 +83,21 @@
/* Find native sizes */
int nat_dbl = sizeof(double);
int nat_flt = sizeof(float);
+int nat_off_t = sizeof(off_t);
int nat_lng = sizeof(long);
int nat_int = sizeof(int);
int nat_shrt = sizeof(short);
int dbl_order;
int flt_order;
+int off_t_order;
int lng_order;
int int_order;
int shrt_order;
unsigned char dbl_cnvrt[sizeof(double)];
unsigned char flt_cnvrt[sizeof(float)];
+unsigned char off_t_cnvrt[sizeof(off_t)];
unsigned char lng_cnvrt[sizeof(long)];
unsigned char int_cnvrt[sizeof(int)];
unsigned char shrt_cnvrt[sizeof(short)];
@@ -160,6 +168,7 @@
G_fatal_error("sizeof(double) != %d", PORT_DOUBLE);
if (nat_flt != PORT_FLOAT)
G_fatal_error("sizeof(float) != %d", PORT_DOUBLE);
+ /* off_t size is variable, depending on the vector size and LFS support */
if (nat_lng < PORT_LONG)
G_fatal_error("sizeof(long) < %d", PORT_LONG);
if (nat_int < PORT_INT)
@@ -173,11 +182,18 @@
* endian.
*/
+ if (nat_off_t == 8)
+ u_o = OFF_T_TEST;
+ else
+ u_o = LONG_TEST;
+
dbl_order =
find_offsets(&u_d, dbl_cnvrt, dbl_cmpr, PORT_DOUBLE, nat_dbl,
"double");
flt_order =
find_offsets(&u_f, flt_cnvrt, flt_cmpr, PORT_FLOAT, nat_flt, "float");
+ off_t_order =
+ find_offsets(&u_o, off_t_cnvrt, off_t_cmpr, nat_off_t, nat_off_t, "off_t");
lng_order =
find_offsets(&u_l, lng_cnvrt, lng_cmpr, PORT_LONG, nat_lng, "long");
int_order =
@@ -186,3 +202,46 @@
find_offsets(&u_s, shrt_cnvrt, shrt_cmpr, PORT_SHORT, nat_shrt,
"short");
}
+
+/*
+ comment copied from port_test.c
+ MM Feb 2009
+
+ The 3.0 dig, and dig_plus files are inherently non-portable. This
+ can be seen in moving files between a SUN 386i and other SUN machines.
+ The recommended way to transport files was always to convert to ASCII
+ (b.a.vect) and copy the ASCII files: dig_ascii and dig_att to the
+ destination machine.
+
+ The problem lies in the way that different architectures internally
+ represent data. If a number is internally store as 0x01020304 on
+ a 680x0 family machine, the same number will be stored as
+ 0x04030201 on an 80386 class machine.
+
+ The CERL port of GRASS to the Compaq 386 already has code to deal
+ with this incompatibility. This code converts all files that are written
+ out to conform to the 680x0 standard. These binary files can then be
+ shared between machines without conversion.
+ This code is designed to work with the majority of computers in use
+ today that fit the following requirements:
+ byte == 8 bits
+ int == 4 bytes
+ long == 4 bytes
+ double == IEEE standard 64 bit
+ float == IEEE standard 32 bit
+
+ bytes can be swapped around in any reasonable way, but bits within each
+ byte must be maintained in normal high to low ordering: 76543210
+ is this a problem?
+
+ If this ability is desired on a SUN 386i, for example, you simply
+ define the compiler flag CERL_PORTABLE in the src/CMD/makehead file
+ and recompile all of the mapdev programs.
+ needs update, makehead/mapdev no longer exist
+
+ Binary DLG files are NOT supported by this code, and will continue to
+ be non-portable between different architectures.
+ applies to the files coor/topo/cidx, needs testing
+
+ -dave gerdes
+ */
Modified: grass/trunk/lib/vector/diglib/port_test.c
===================================================================
--- grass/trunk/lib/vector/diglib/port_test.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/port_test.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -15,7 +15,9 @@
* for details.
*
*****************************************************************************/
+#include <grass/config.h>
#include <stdio.h>
+#include <sys/types.h>
#include <grass/Vect.h>
/*
@@ -56,6 +58,7 @@
*/
#define TEST_PATTERN 1.3333
+#define OFF_T_TEST 0x0102030405060708
#define LONG_TEST 0x01020304
#define INT_TEST 0x01020304
#define SHORT_TEST 0x0102
@@ -64,6 +67,7 @@
{
double d;
float f;
+ off_t o;
long l;
int i;
short s;
@@ -76,17 +80,19 @@
{ 0x3f, 0xf5, 0x55, 0x32, 0x61, 0x7c, 0x1b, 0xda };
/* flt_cmpr holds the bytes of an IEEE representation of TEST_PATTERN */
static unsigned char flt_cmpr[] = { 0x3f, 0xaa, 0xa9, 0x93 };
+static unsigned char off_t_cmpr[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
static unsigned char lng_cmpr[] = { 0x01, 0x02, 0x03, 0x04 };
static unsigned char int_cmpr[] = { 0x01, 0x02, 0x03, 0x04 };
static unsigned char shrt_cmpr[] = { 0x01, 0x02 };
static char dbl_cnvrt[sizeof(double)];
static char flt_cnvrt[sizeof(float)];
+static char off_t_cnvrt[sizeof(off_t)];
static char lng_cnvrt[sizeof(long)];
static char int_cnvrt[sizeof(int)];
static char shrt_cnvrt[sizeof(short)];
-static int nat_dbl, nat_flt, nat_lng, nat_int, nat_shrt, nat_char;
+static int nat_dbl, nat_flt, nat_lng, nat_off_t, nat_int, nat_shrt, nat_char;
/* function prototypes */
@@ -105,6 +111,7 @@
printf("\n/* Native machine sizes */\n");
printf("#define NATIVE_DOUBLE %d\n", (nat_dbl = sizeof(double)));
printf("#define NATIVE_FLOAT %d\n", (nat_flt = sizeof(float)));
+ printf("#define NATIVE_OFF_T %d\n", (nat_off_t = sizeof(off_t)));
printf("#define NATIVE_LONG %d\n", (nat_lng = sizeof(long)));
printf("#define NATIVE_INT %d\n", (nat_int = sizeof(int)));
printf("#define NATIVE_SHORT %d\n", (nat_shrt = sizeof(short)));
@@ -117,9 +124,10 @@
err = 1;
}
if (nat_flt != PORT_FLOAT) {
- fprintf(stderr, "ERROR, sizeof (float) != %d\n", PORT_DOUBLE);
+ fprintf(stderr, "ERROR, sizeof (float) != %d\n", PORT_FLOAT);
err = 1;
}
+ /* port_off_t is variable */
if (nat_lng < PORT_LONG) {
fprintf(stderr, "ERROR, sizeof (long) < %d\n", PORT_LONG);
err = 1;
@@ -192,6 +200,34 @@
else
flt_order = ENDIAN_OTHER;
+ /* Find off_t order */
+ if (nat_off_t == 8)
+ u.o = OFF_T_TEST;
+ else
+ u.o = LONG_TEST;
+ for (i = 0; i < nat_off_t; i++) {
+ tmp = find_offset(u.c, off_t_cmpr[i], nat_off_t);
+ if (-1 == tmp) {
+ fprintf(stderr, "ERROR, could not find '%x' in off_t\n",
+ off_t_cmpr[i]);
+ err = 1;
+ }
+ off_t_cnvrt[i] = tmp;
+ }
+ tmp = tmp2 = 1;
+ for (i = 0; i < nat_off_t; i++) {
+ if (off_t_cnvrt[i] != (i + (nat_off_t - nat_off_t)))
+ tmp = 0;
+ if (off_t_cnvrt[i] != (nat_off_t - i - 1))
+ tmp2 = 0;
+ }
+ if (tmp)
+ off_t_order = ENDIAN_BIG;
+ else if (tmp2)
+ off_t_order = ENDIAN_LITTLE;
+ else
+ off_t_order = ENDIAN_OTHER;
+
/* Find long order */
u.l = LONG_TEST;
for (i = 0; i < PORT_LONG; i++) {
@@ -270,6 +306,7 @@
printf("\n/* Native machine byte orders */\n");
printf("#define DOUBLE_ORDER %d\n", dbl_order);
printf("#define FLOAT_ORDER %d\n", flt_order);
+ printf("#define OFF_T_ORDER %d\n", off_t_order);
printf("#define LONG_ORDER %d\n", lng_order);
printf("#define INT_ORDER %d\n", int_order);
printf("#define SHORT_ORDER %d\n", shrt_order);
@@ -320,6 +357,15 @@
}
fprintf(stdout, "};\n\n");
+ fprintf(stdout, "/* off_t format : */\nstatic int off_t_cnvrt[] = {");
+ i = 0;
+ while (i < nat_off_t) {
+ fprintf(stdout, "%d", off_t_cnvrt[i]);
+ if (++i < nat_off_t)
+ fprintf(stdout, ", ");
+ }
+ fprintf(stdout, "};\n\n");
+
fprintf(stdout, "/* Long format : */\nstatic int lng_cnvrt[] = {");
i = 0;
while (i < nat_lng) {
Modified: grass/trunk/lib/vector/diglib/portable.c
===================================================================
--- grass/trunk/lib/vector/diglib/portable.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/portable.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -15,6 +15,8 @@
* for details.
*
*****************************************************************************/
+#include <grass/config.h>
+#include <sys/types.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/Vect.h>
@@ -24,17 +26,20 @@
extern int nat_dbl;
extern int nat_flt;
extern int nat_lng;
+extern int nat_off_t;
extern int nat_int;
extern int nat_shrt;
extern int dbl_order;
extern int flt_order;
+extern int off_t_order;
extern int lng_order;
extern int int_order;
extern int shrt_order;
extern unsigned char dbl_cnvrt[sizeof(double)];
extern unsigned char flt_cnvrt[sizeof(float)];
+extern unsigned char off_t_cnvrt[sizeof(off_t)];
extern unsigned char lng_cnvrt[sizeof(long)];
extern unsigned char int_cnvrt[sizeof(int)];
extern unsigned char shrt_cnvrt[sizeof(short)];
@@ -133,6 +138,88 @@
return 1;
}
+/* read off_ts from the PVF file */
+int dig__fread_port_O(off_t *buf, int cnt, GVFILE * fp, int port_off_t_size)
+{
+ int i, j, ret;
+ unsigned char *c1, *c2;
+
+ if (Cur_Head->off_t_quick) {
+ if (nat_off_t == port_off_t_size) {
+ ret = dig_fread(buf, port_off_t_size, cnt, fp);
+ if (ret != cnt)
+ return 0;
+ }
+ else if (nat_off_t > port_off_t_size) {
+ /* read into buffer */
+ buf_alloc(cnt * port_off_t_size);
+ ret = dig_fread(buffer, port_off_t_size, cnt, fp);
+ if (ret != cnt)
+ return 0;
+ /* set buffer to zero (positive numbers) */
+ memset(buf, 0, cnt * sizeof(off_t));
+ /* read from buffer in changed order */
+ c1 = (unsigned char *)buffer;
+ if (off_t_order == ENDIAN_LITTLE)
+ c2 = (unsigned char *)buf;
+ else
+ c2 = (unsigned char *)buf + nat_off_t - port_off_t_size;
+ for (i = 0; i < cnt; i++) {
+ /* set to FF if the value is negative */
+ if (off_t_order == ENDIAN_LITTLE) {
+ if (c1[port_off_t_size - 1] & 0x80)
+ memset(c2, 0xff, sizeof(off_t));
+ }
+ else {
+ if (c1[0] & 0x80)
+ memset(c2, 0xff, sizeof(off_t));
+ }
+ memcpy(c2, c1, port_off_t_size);
+ c1 += port_off_t_size;
+ c2 += sizeof(off_t);
+ }
+ }
+ else if (nat_off_t < port_off_t_size) {
+ /* should never happen */
+ G_fatal_error("Vector exceeds supported file size limit");
+ }
+ }
+ else {
+ if (nat_off_t >= port_off_t_size) {
+ /* read into buffer */
+ buf_alloc(cnt * port_off_t_size);
+ ret = dig_fread(buffer, port_off_t_size, cnt, fp);
+ if (ret != cnt)
+ return 0;
+ /* set buffer to zero (positive numbers) */
+ memset(buf, 0, cnt * sizeof(off_t));
+ /* read from buffer in changed order */
+ c1 = (unsigned char *)buffer;
+ c2 = (unsigned char *)buf;
+ for (i = 0; i < cnt; i++) {
+ /* set to FF if the value is negative */
+ if (Cur_Head->byte_order == ENDIAN_LITTLE) {
+ if (c1[port_off_t_size - 1] & 0x80)
+ memset(c2, 0xff, sizeof(off_t));
+ }
+ else {
+ if (c1[0] & 0x80)
+ memset(c2, 0xff, sizeof(off_t));
+ }
+ for (j = 0; j < port_off_t_size; j++)
+ c2[Cur_Head->off_t_cnvrt[j]] = c1[j];
+ c1 += port_off_t_size;
+ c2 += sizeof(off_t);
+ }
+ }
+ else if (nat_off_t < port_off_t_size) {
+ /* should never happen */
+ G_fatal_error("Vector exceeds supported file size limit");
+ }
+ }
+ return 1;
+}
+
/* read longs from the PVF file */
int dig__fread_port_L(long *buf, int cnt, GVFILE * fp)
{
@@ -425,6 +512,59 @@
return 0;
}
+int dig__fwrite_port_O(off_t *buf, /* OFF_T */
+ int cnt, GVFILE * fp, int port_off_t_size)
+{
+ int i, j;
+ unsigned char *c1, *c2;
+
+ if (Cur_Head->off_t_quick) {
+ if (nat_off_t == port_off_t_size) {
+ if (dig_fwrite(buf, port_off_t_size, cnt, fp) == cnt)
+ return 1;
+ }
+ else if (nat_off_t > port_off_t_size) {
+ buf_alloc(cnt * port_off_t_size);
+ if (off_t_order == ENDIAN_LITTLE)
+ c1 = (unsigned char *)buf;
+ else
+ c1 = (unsigned char *)buf + nat_off_t - port_off_t_size;
+ c2 = (unsigned char *)buffer;
+ for (i = 0; i < cnt; i++) {
+ memcpy(c2, c1, port_off_t_size);
+ c1 += port_off_t_size;
+ c2 += sizeof(off_t);
+ }
+ if (dig_fwrite(buffer, port_off_t_size, cnt, fp) == cnt)
+ return 1;
+ }
+ else if (nat_off_t < port_off_t_size) {
+ /* should never happen */
+ G_fatal_error("Vector exceeds supported file size limit");
+ }
+ }
+ else {
+ if (nat_off_t >= port_off_t_size) {
+ buf_alloc(cnt * port_off_t_size);
+ c1 = (unsigned char *)buf;
+ c2 = (unsigned char *)buffer;
+ for (i = 0; i < cnt; i++) {
+ for (j = 0; j < port_off_t_size; j++)
+ c2[j] = c1[Cur_Head->off_t_cnvrt[j]];
+ c1 += sizeof(off_t);
+ c2 += port_off_t_size;
+ }
+ if (dig_fwrite(buffer, port_off_t_size, cnt, fp) == cnt)
+ return 1;
+ }
+ else if (nat_off_t < port_off_t_size) {
+ /* should never happen */
+ G_fatal_error("Vector exceeds supported file size limit");
+ }
+ }
+ return 0;
+}
+
int dig__fwrite_port_L(long *buf, /* LONG */
int cnt, GVFILE * fp)
{
@@ -579,6 +719,7 @@
port->byte_order = byte_order;
+ /* double */
if (port->byte_order == dbl_order)
port->dbl_quick = TRUE;
else
@@ -591,6 +732,7 @@
port->dbl_cnvrt[i] = dbl_cnvrt[PORT_DOUBLE - i - 1];
}
+ /* float */
if (port->byte_order == flt_order)
port->flt_quick = TRUE;
else
@@ -603,6 +745,7 @@
port->flt_cnvrt[i] = flt_cnvrt[PORT_FLOAT - i - 1];
}
+ /* long */
if (port->byte_order == lng_order)
port->lng_quick = TRUE;
else
@@ -615,6 +758,7 @@
port->lng_cnvrt[i] = lng_cnvrt[PORT_LONG - i - 1];
}
+ /* int */
if (port->byte_order == int_order)
port->int_quick = TRUE;
else
@@ -627,6 +771,7 @@
port->int_cnvrt[i] = int_cnvrt[PORT_INT - i - 1];
}
+ /* short */
if (port->byte_order == shrt_order)
port->shrt_quick = TRUE;
else
@@ -639,6 +784,19 @@
port->shrt_cnvrt[i] = shrt_cnvrt[PORT_SHORT - i - 1];
}
+ /* off_t */
+ if (port->byte_order == off_t_order)
+ port->off_t_quick = TRUE;
+ else
+ port->off_t_quick = FALSE;
+
+ for (i = 0; i < nat_off_t; i++) {
+ if (port->byte_order == ENDIAN_BIG)
+ port->off_t_cnvrt[i] = off_t_cnvrt[i];
+ else
+ port->off_t_cnvrt[i] = off_t_cnvrt[nat_off_t - i - 1];
+ }
+
return;
}
Modified: grass/trunk/lib/vector/diglib/spindex_rw.c
===================================================================
--- grass/trunk/lib/vector/diglib/spindex_rw.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/spindex_rw.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -14,6 +14,8 @@
* for details.
*
*****************************************************************************/
+#include <grass/config.h>
+#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
@@ -37,6 +39,21 @@
if (0 >= dig__fwrite_port_C(buf, 5, fp))
return (-1);
+ /* get required offset size */
+ if (ptr->off_t_size == 0) {
+ /* should not happen, topo is written first */
+ if (ptr->coor_size > (off_t)PORT_LONG_MAX)
+ ptr->off_t_size = 8;
+ else
+ ptr->off_t_size = 4;
+ }
+
+ /* adjust header size for large files */
+ if (ptr->off_t_size == 8) {
+ /* 7 offset values and coor file size: add 8 * 4 */
+ length += 32;
+ }
+
/* bytes 6 - 9 : header size */
if (0 >= dig__fwrite_port_L(&length, 1, fp))
return (0);
@@ -46,28 +63,28 @@
if (0 >= dig__fwrite_port_C(buf, 1, fp))
return (-1);
- /* bytes 11 - 38 : Offsets */
- if (0 >= dig__fwrite_port_L(&(ptr->Node_spidx_offset), 1, fp))
+ /* bytes 11 - 38 (large files 11 - 66) : Offsets */
+ if (0 >= dig__fwrite_port_O(&(ptr->Node_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Edge_spidx_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Edge_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Line_spidx_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Line_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Area_spidx_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Area_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Isle_spidx_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Isle_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Volume_spidx_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Volume_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fwrite_port_L(&(ptr->Hole_spidx_offset), 1, fp))
+ if (0 >= dig__fwrite_port_O(&(ptr->Hole_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
G_debug(3, "spidx offset node = %ld line = %ld, area = %ld isle = %ld",
ptr->Node_spidx_offset, ptr->Line_spidx_offset,
ptr->Area_spidx_offset, ptr->Isle_spidx_offset);
- /* bytes 39 - 42 : Offsets */
- if (0 >= dig__fwrite_port_L(&(ptr->coor_size), 1, fp))
+ /* bytes 39 - 42 (large files 67 - 74) : Offsets */
+ if (0 >= dig__fwrite_port_O(&(ptr->coor_size), 1, fp, ptr->off_t_size))
return (-1);
G_debug(2, "spidx body offset %ld", dig_ftell(fp));
@@ -135,24 +152,34 @@
ptr->spidx_with_z = buf[0];
G_debug(2, " with_z %d", ptr->spidx_with_z);
- /* bytes 11 - 38 : Offsets */
- if (0 >= dig__fread_port_L(&(ptr->Node_spidx_offset), 1, fp))
+ /* get required offset size */
+ if (ptr->off_t_size == 0) {
+ /* should not happen, topo is opened first */
+ if (ptr->coor_size > (off_t)PORT_LONG_MAX)
+ ptr->off_t_size = 8;
+ else
+ ptr->off_t_size = 4;
+ }
+ /* as long as topo is always opened first, off_t size check is not needed here */
+
+ /* bytes 11 - 38 (large files 11 - 66) : Offsets */
+ if (0 >= dig__fread_port_O(&(ptr->Node_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Edge_spidx_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Edge_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Line_spidx_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Line_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Area_spidx_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Area_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Isle_spidx_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Isle_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Volume_spidx_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Volume_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- if (0 >= dig__fread_port_L(&(ptr->Hole_spidx_offset), 1, fp))
+ if (0 >= dig__fread_port_O(&(ptr->Hole_spidx_offset), 1, fp, ptr->off_t_size))
return (-1);
- /* bytes 39 - 42 : Offsets */
- if (0 >= dig__fread_port_L(&coor_size, 1, fp))
+ /* bytes 39 - 42 (large files 67 - 74) : Offsets */
+ if (0 >= dig__fread_port_O(&coor_size, 1, fp, ptr->off_t_size))
return (-1);
G_debug(2, " coor size %ld", coor_size);
@@ -226,7 +253,7 @@
return (-1);
}
if (level == 0) { /* write data (element id) */
- i = (int)b->child;
+ i = (int) b->child;
if (0 >= dig__fwrite_port_I(&i, 1, fp))
return (-1);
}
@@ -301,7 +328,7 @@
return 0;
}
-/* Read RTree node to file */
+/* Read RTree node from file */
int rtree_read_node(GVFILE * fp, struct Node *n, int with_z)
{
int level, count, i;
Modified: grass/trunk/lib/vector/diglib/test.c
===================================================================
--- grass/trunk/lib/vector/diglib/test.c 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/diglib/test.c 2009-03-16 09:51:02 UTC (rev 36392)
@@ -15,7 +15,9 @@
* for details.
*
*****************************************************************************/
+#include <grass/config.h>
#include <stdio.h>
+#include <sys/types.h>
#include <grass/Vect.h>
/* Test portable r/w functions */
@@ -32,6 +34,7 @@
int byte_order;
struct Port_info port;
GVFILE fp;
+ int port_off_t;
double db, td[] = { -(PORT_DOUBLE_MAX), -(D_TEST), -(PORT_DOUBLE_MIN),
0, PORT_DOUBLE_MIN, D_TEST, PORT_DOUBLE_MAX
@@ -44,7 +47,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 };
+ off_t ob, to[] = { PORT_LONG_MIN, -(L_TEST), 0, L_TEST, PORT_LONG_MAX };
+ port_off_t = sizeof(off_t);
+
if (NULL == (fp.file = fopen("test.tmp", "wb+"))) {
fprintf(stderr, "ERROR, cannot open test.tmp file.\n");
return (1);
@@ -91,6 +97,23 @@
for (j = 0; j < 5; j++) {
dig_fseek(&fp, 0, SEEK_CUR);
+ fprintf(fp.file, "off_t ");
+ dig__fwrite_port_O(&(to[j]), 1, &fp, port_off_t);
+ dig_fseek(&fp, -(port_off_t), SEEK_CUR);
+ dig__fread_port_O(&ob, 1, &fp, port_off_t);
+ dig_fflush(&fp);
+ if (ob != to[j]) {
+ fprintf(stderr,
+ "ERROR in read/write portable off_t, byte_order = %d\n",
+ byte_order);
+ fprintf(stderr, " Written: %ld\n Read : %ld\n", to[j],
+ ob);
+ err = 1;
+ }
+ }
+
+ for (j = 0; j < 5; j++) {
+ dig_fseek(&fp, 0, SEEK_CUR);
fprintf(fp.file, "long ");
dig__fwrite_port_L(&(tl[j]), 1, &fp);
dig_fseek(&fp, -(PORT_LONG), SEEK_CUR);
Added: grass/trunk/lib/vector/diglib/test32.ok
===================================================================
(Binary files differ)
Property changes on: grass/trunk/lib/vector/diglib/test32.ok
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: grass/trunk/lib/vector/diglib/test64.ok
===================================================================
(Binary files differ)
Property changes on: grass/trunk/lib/vector/diglib/test64.ok
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: grass/trunk/lib/vector/rtree/Makefile
===================================================================
--- grass/trunk/lib/vector/rtree/Makefile 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/rtree/Makefile 2009-03-16 09:51:02 UTC (rev 36392)
@@ -6,6 +6,11 @@
EXTRA_LIBS = $(MATHLIB)
+#compile if LFS (Large File Support) present:
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS += -D_FILE_OFFSET_BITS=64
+endif
+
RTLINC = $(ARCH_INCDIR)/rtree
HEADERS := $(RTLINC)/card.h $(RTLINC)/index.h $(RTLINC)/split_q.h \
$(ARCH_INCDIR)/rtree.h
@@ -29,6 +34,6 @@
$(INSTALL_DATA) $< $@
$(OBJDIR)/test: test.c
- $(CC) $(LDFLAGS) $(INC) -o $@ test.c $(RTREELIB) -lm
+ $(CC) $(CFLAGS) $(EXTRA_FLAGS) $(LDFLAGS) $(INC) -o $@ test.c $(RTREELIB) -lm
cd $(OBJDIR) && ./test
Modified: grass/trunk/lib/vector/transform/Makefile
===================================================================
--- grass/trunk/lib/vector/transform/Makefile 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/transform/Makefile 2009-03-16 09:51:02 UTC (rev 36392)
@@ -5,6 +5,11 @@
include $(MODULE_TOPDIR)/include/Make/Lib.make
+#compile if LFS (Large File Support) present:
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS += -D_FILE_OFFSET_BITS=64
+endif
+
default: lib
Modified: grass/trunk/lib/vector/vedit/Makefile
===================================================================
--- grass/trunk/lib/vector/vedit/Makefile 2009-03-16 09:49:17 UTC (rev 36391)
+++ grass/trunk/lib/vector/vedit/Makefile 2009-03-16 09:51:02 UTC (rev 36392)
@@ -11,6 +11,11 @@
include $(MODULE_TOPDIR)/include/Make/Lib.make
include $(MODULE_TOPDIR)/include/Make/Doxygen.make
+#compile if LFS (Large File Support) present:
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS += -D_FILE_OFFSET_BITS=64
+endif
+
default: lib
# doxygen
More information about the grass-commit
mailing list