Opened 13 years ago
Last modified 13 years ago
#3814 assigned defect
Error while reading template file on Windows
Reported by: | dmorissette | Owned by: | dmorissette |
---|---|---|---|
Priority: | normal | Milestone: | 6.0 release |
Component: | MapServer C Library | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | jmckenna, assefa, tbonfort |
Description
In ticket #3812, jmckenna reported:
The following legend template works with 5.x and upto beta3:
[leg_class_html opt_flag=12] <img src='[leg_icon]'> [leg_class_name]<br> [/leg_class_html]
with trunk, I get the error: "generateLegendTemplate(): Unable to access file. Error while reading template file."
but if I modify the legend template file to the following it works with trunk:
[leg_class_html opt_flag=12]<img src='[leg_icon]'>[leg_class_name][/leg_class_html]
Bizarre!
Attachments (3)
Change History (7)
comment:1 by , 13 years ago
by , 13 years ago
Attachment: | testcase3814.zip added |
---|
dmorissette's test case (which works fine on Linux)
comment:2 by , 13 years ago
I can't reproduce with that test case; however if I copy the problem legend-template into that test case I get the same error (attached my problem template)
comment:3 by , 13 years ago
seems to be dos vs uni file format. I have not checked into the code yet but if you do a dos2unix on the "problematic" template, It will work. If you do a unix2dos on it, it will give an error.
comment:4 by , 13 years ago
Status: | new → assigned |
---|
The DOS vs Unix LF format was my guess as well, and jmckenna confirmed with a test patch that I sent him that removing the check on fread() in maptemplate.c that was added in r11430 solves the problem for him.
I have committed this workaround in r11484... and we can use that for beta5
I'll leave the ticket open for Assefa or someone else on Windows to figure the right way to do error checking on fread() in that block of code... if any is needed. (Since ftell() is called before we may just need to do a ferror() check and that might be enough)
I am unable to reproduce the error on Linux (maybe I'd need the exact html legend file and not just a copy/paste of it).
However, looking at the error message I suspect the error is related to r11430. Possibly that on Windows fread() does something funky and does not return 1 as expected by this changeset. Maybe something related to linefeeds, which would explain why converting the template to a single line fixes it.
I'll attach my testcase and hopefully a Windows dev (assefa?) can use it to reproduce the issue and find the right fix.
I'll delay 6.0.0-beta5 until tomorrow to wait for this fix.