1
0
Fork 0

Fix release build issues with raw2ascii under cmake

This commit is contained in:
James Turner 2011-11-05 16:00:40 +00:00
parent 324ce8acd7
commit 7fb875b44b

View file

@ -34,6 +34,7 @@
#include <sys/types.h> /* open() */ #include <sys/types.h> /* open() */
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h>
#ifdef _MSC_VER #ifdef _MSC_VER
# include <io.h> # include <io.h>
#endif #endif
@ -64,8 +65,18 @@ int reads(int fd, char *buf, unsigned int len) {
char c; char c;
len--; len--;
while ( (i < len) && (read(fd, &c, 1) != 0) ) while ( i < len)
{ {
int sz = read(fd, &c, 1);
if (sz == 0)
return 0;
if (sz < 0)
{
printf("read failed: %s\n", strerror(errno));
return 0;
}
if ((c == '\n') || (c == '\r') ) if ((c == '\n') || (c == '\r') )
break; break;
@ -76,7 +87,6 @@ int reads(int fd, char *buf, unsigned int len) {
buf[i++] = '\n'; buf[i++] = '\n';
buf[i] = '\0'; buf[i] = '\0';
return i; return i;
} }
@ -85,7 +95,7 @@ int reads(int fd, char *buf, unsigned int len) {
* DEM file */ * DEM file */
void rawReadDemHdr( fgRAWDEM *raw, char *hdr_file ) { void rawReadDemHdr( fgRAWDEM *raw, char *hdr_file ) {
FILE *hdr; FILE *hdr;
static char line[256], key[256], value[256]; char line[256], key[256], value[256];
int i, len, offset; int i, len, offset;
double tmp; double tmp;
@ -106,7 +116,6 @@ void rawReadDemHdr( fgRAWDEM *raw, char *hdr_file ) {
line[len] = 0; // kill EOL characters line[len] = 0; // kill EOL characters
} }
printf("%s ", line); printf("%s ", line);
len = strlen(line); len = strlen(line);
/* extract key */ /* extract key */
@ -183,9 +192,9 @@ void rawReadDemHdr( fgRAWDEM *raw, char *hdr_file ) {
(double)raw->ydim / 3600.0); (double)raw->ydim / 3600.0);
} else { } else {
/* ignore for now */ /* ignore for now */
printf( "- ignore for now\n" ); printf( "- ignore for now: '%s'\n", key );
}
} }
} // of line iteration
raw->rootx = raw->ulxmap - (raw->xdim / 2); raw->rootx = raw->ulxmap - (raw->xdim / 2);
raw->rooty = raw->ulymap + (raw->ydim / 2); raw->rooty = raw->ulymap + (raw->ydim / 2);
@ -496,7 +505,7 @@ void rawProcessStrip( fgRAWDEM *raw, int lat_degrees, char *path ) {
/* convert to arcsec */ /* convert to arcsec */
lat = lat_degrees * 3600; lat = lat_degrees * 3600;
printf("Max Latitude = %d arcsec (%f degs)\n", lat, lat_degrees); printf("Max Latitude = %d arcsec (%d degs)\n", lat, lat_degrees);
/* validity check ... */ /* validity check ... */
if ( (lat > raw->rooty) || if ( (lat > raw->rooty) ||