393 |
|
} /* else open it ourselves */ |
394 |
|
fp = fopen(inspec, "r"); |
395 |
|
} |
396 |
< |
if (!fp) |
396 |
> |
if (!fp) { |
397 |
> |
fprintf(stderr, "Cannot open for reading: %s\n", inspec); |
398 |
|
return(NULL); |
399 |
+ |
} |
400 |
|
#ifdef getc_unlocked |
401 |
|
flockfile(fp); |
402 |
|
#endif |
501 |
|
if (nc < 3) return(0); |
502 |
|
scan = (uby8 *)tempbuffer((nc+1)*len); |
503 |
|
if (!scan) return(0); |
504 |
< |
for (j = len; j--; dp += nc) { |
504 |
> |
for (j = 0; j < len; j++, dp += nc) { |
505 |
|
for (k = nc; k--; ) |
506 |
|
scol[k] = dp[k]; |
507 |
|
scolor2scolr(scan+j*(nc+1), scol, nc); |
541 |
|
dtype = DTxyze; |
542 |
|
else if ((dtype == DTxyze) & (rm->dtype == DTrgbe)) |
543 |
|
dtype = DTrgbe; |
544 |
< |
if ((dtype == DTspec) & (rm->ncomp <= 3)) |
544 |
> |
if ((dtype < DTspec) & (rm->ncomp > 3)) |
545 |
> |
dtype = DTspec; |
546 |
> |
else if ((dtype == DTspec) & (rm->ncomp <= 3)) |
547 |
|
return(0); |
548 |
|
|
549 |
|
if (dtype == DTascii) /* set file type (WINDOWS) */ |
687 |
|
rsrc->info = NULL; rsrc->mapped = NULL; rsrc->mtx = NULL; |
688 |
|
return(1); |
689 |
|
} |
690 |
+ |
#ifdef MAP_FILE /* just matrix data -- leave metadata */ |
691 |
|
if (rdst->mapped) |
692 |
< |
return(0); /* XXX can't handle this case */ |
693 |
< |
/* just matrix data -- leave metadata */ |
694 |
< |
if (rdst->mtx) free(rdst->mtx); |
692 |
> |
munmap(rdst->mapped, mapped_size(rdst)); |
693 |
> |
else |
694 |
> |
#endif |
695 |
> |
if (rdst->mtx) |
696 |
> |
free(rdst->mtx); |
697 |
> |
rdst->mapped = rsrc->mapped; |
698 |
|
rdst->mtx = rsrc->mtx; |
699 |
< |
rsrc->mtx = NULL; |
699 |
> |
rsrc->mapped = NULL; rsrc->mtx = NULL; |
700 |
|
return(1); |
701 |
|
} |
702 |
|
|