| 9 |
|
#include <stdlib.h> |
| 10 |
|
#include <string.h> |
| 11 |
|
#include <fcntl.h> |
| 12 |
+ |
#include "platform.h" |
| 13 |
|
#include "resolu.h" |
| 14 |
< |
#include "rtprocess.h" |
| 14 |
> |
#include "paths.h" |
| 15 |
|
#include "rmatrix.h" |
| 16 |
|
|
| 17 |
|
static char rmx_mismatch_warn[] = "WARNING: data type mismatch\n"; |
| 112 |
|
rmx_load_ascii(RMATRIX *rm, FILE *fp) |
| 113 |
|
{ |
| 114 |
|
int i, j, k; |
| 115 |
< |
#ifdef _WIN32 |
| 115 |
< |
_setmode(fileno(fp), _O_TEXT); |
| 116 |
< |
#endif |
| 115 |
> |
|
| 116 |
|
for (i = 0; i < rm->nrows; i++) |
| 117 |
|
for (j = 0; j < rm->ncols; j++) |
| 118 |
|
for (k = 0; k < rm->ncomp; k++) |
| 194 |
|
|
| 195 |
|
if (inspec == NULL) { /* reading from stdin? */ |
| 196 |
|
inspec = "<stdin>"; |
| 197 |
< |
#ifdef _WIN32 |
| 197 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 198 |
|
_setmode(fileno(stdin), _O_BINARY); |
| 199 |
|
#endif |
| 200 |
|
} else if (inspec[0] == '!') { |
| 201 |
|
if ((fp = popen(inspec+1, "r")) == NULL) |
| 202 |
|
return(NULL); |
| 203 |
< |
#ifdef _WIN32 |
| 203 |
> |
#if defined(_WIN32) || defined(_WIN64) |
| 204 |
|
_setmode(fileno(fp), _O_BINARY); |
| 205 |
|
#endif |
| 206 |
|
} else { |
| 215 |
|
return(NULL); |
| 216 |
|
dnew = rmx_from_cmatrix(cm); |
| 217 |
|
cm_free(cm); |
| 218 |
+ |
dnew->dtype = DTascii; |
| 219 |
|
return(dnew); |
| 220 |
|
} |
| 221 |
|
/* else open it ourselves */ |
| 253 |
|
dnew->info = dinfo.info; |
| 254 |
|
switch (dinfo.dtype) { |
| 255 |
|
case DTascii: |
| 256 |
+ |
#if defined(_WIN32) || defined(_WIN64) |
| 257 |
+ |
_setmode(fileno(fp), _O_TEXT); |
| 258 |
+ |
#endif |
| 259 |
|
if (!rmx_load_ascii(dnew, fp)) |
| 260 |
|
goto loaderr; |
| 261 |
|
dnew->dtype = DTascii; /* should leave double? */ |
| 303 |
|
rmx_write_ascii(const RMATRIX *rm, FILE *fp) |
| 304 |
|
{ |
| 305 |
|
int i, j, k; |
| 306 |
< |
#ifdef _WIN32 |
| 304 |
< |
_setmode(fileno(fp), _O_TEXT); |
| 305 |
< |
#endif |
| 306 |
> |
|
| 307 |
|
for (i = 0; i < rm->nrows; i++) { |
| 308 |
|
for (j = 0; j < rm->ncols; j++) { |
| 309 |
|
for (k = 0; k < rm->ncomp; k++) |
| 386 |
|
|
| 387 |
|
if ((rm == NULL) | (fp == NULL)) |
| 388 |
|
return(0); |
| 389 |
+ |
#ifdef getc_unlocked |
| 390 |
+ |
flockfile(fp); |
| 391 |
+ |
#endif |
| 392 |
|
/* complete header */ |
| 393 |
|
if (rm->info) |
| 394 |
|
fputs(rm->info, fp); |
| 433 |
|
return(0); |
| 434 |
|
} |
| 435 |
|
ok &= (fflush(fp) == 0); |
| 436 |
+ |
#ifdef getc_unlocked |
| 437 |
+ |
funlockfile(fp); |
| 438 |
+ |
#endif |
| 439 |
|
rmx_free(mydm); |
| 440 |
|
return(ok); |
| 441 |
|
} |