Allow for header files that are generated on machines with non UNIX like line endings
This commit is contained in:
parent
0a4cc36775
commit
fc9f7069ca
1 changed files with 15 additions and 1 deletions
|
@ -59,6 +59,19 @@ double round( double a ) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
int reads(int fd, char *buf, unsigned int len) {
|
||||||
|
char c;
|
||||||
|
int res;
|
||||||
|
unsigned int i;
|
||||||
|
for (i=0;
|
||||||
|
(i < len) && ((res = read(fd, &c, 1)) != 0)
|
||||||
|
&& ((c != '\n') && (c != '\r'));
|
||||||
|
i++)
|
||||||
|
buf[i] = c;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Read the DEM header to determine various key parameters for this
|
/* Read the DEM header to determine various key parameters for this
|
||||||
* DEM file */
|
* DEM file */
|
||||||
void rawReadDemHdr( fgRAWDEM *raw, char *hdr_file ) {
|
void rawReadDemHdr( fgRAWDEM *raw, char *hdr_file ) {
|
||||||
|
@ -76,7 +89,8 @@ void rawReadDemHdr( fgRAWDEM *raw, char *hdr_file ) {
|
||||||
raw->big_endian = 1;
|
raw->big_endian = 1;
|
||||||
|
|
||||||
/* process each line */
|
/* process each line */
|
||||||
while ( (fgets(line, 256, hdr) != NULL) ) {
|
while ( (reads(fileno(hdr), line, 256) != NULL) ) {
|
||||||
|
|
||||||
/* printf("%s", line); */
|
/* printf("%s", line); */
|
||||||
len = strlen(line);
|
len = strlen(line);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue