… | |
… | |
16 | along with this program; if not, write to the Free Software |
16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | */ |
18 | */ |
19 | |
19 | |
20 | #include "config.h" |
20 | #include "config.h" |
|
|
21 | #include "compat.h" |
|
|
22 | |
21 | #include <stdlib.h> |
23 | #include <stdlib.h> |
22 | #include <math.h> |
24 | #include <math.h> |
23 | |
25 | |
24 | #include "data.h" |
|
|
25 | #include "parse_routines.h" |
26 | #include "parse_routines.h" |
|
|
27 | #include "error.h" |
26 | |
28 | |
27 | int psiconv_parse_color(const psiconv_buffer buf, int lev, psiconv_u32 off, |
29 | int psiconv_parse_color(const psiconv_buffer buf, int lev, psiconv_u32 off, |
28 | int *length, psiconv_color *result) |
30 | int *length, psiconv_color *result) |
29 | { |
31 | { |
30 | int res = 0; |
32 | int res = 0; |
… | |
… | |
161 | |
163 | |
162 | psiconv_progress(lev+2,off+len,"Going to read border thickness"); |
164 | psiconv_progress(lev+2,off+len,"Going to read border thickness"); |
163 | (*result)->thickness = psiconv_read_size(buf,lev+2,off+len,&leng,&res); |
165 | (*result)->thickness = psiconv_read_size(buf,lev+2,off+len,&leng,&res); |
164 | if (res) |
166 | if (res) |
165 | goto ERROR2; |
167 | goto ERROR2; |
|
|
168 | #if 0 |
|
|
169 | /* This seems no longer necessary to test? */ |
166 | if (((*result)->kind != psiconv_border_solid) && |
170 | if (((*result)->kind != psiconv_border_solid) && |
167 | ((*result)->kind != psiconv_border_double) && |
171 | ((*result)->kind != psiconv_border_double) && |
168 | ((*result)->thickness != 0.0) && |
172 | ((*result)->thickness != 0.0) && |
169 | (fabs((*result)->thickness - 1/20) >= 1/1000)) { |
173 | (fabs((*result)->thickness - 1/20) >= 1/1000)) { |
170 | psiconv_warn(lev+2,off, |
174 | psiconv_warn(lev+2,off, |
171 | "Border thickness specified for unlikely border type"); |
175 | "Border thickness specified for unlikely border type"); |
172 | } |
176 | } |
|
|
177 | #endif |
173 | psiconv_debug(lev+2,off+len,"Thickness: %f",(*result)->thickness); |
178 | psiconv_debug(lev+2,off+len,"Thickness: %f",(*result)->thickness); |
174 | len += leng; |
179 | len += leng; |
175 | |
180 | |
176 | psiconv_progress(lev+2,off+len,"Going to read the border color"); |
181 | psiconv_progress(lev+2,off+len,"Going to read the border color"); |
177 | if ((psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color))) |
182 | if ((psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color))) |
178 | goto ERROR2; |
183 | goto ERROR2; |
179 | len += leng; |
184 | len += leng; |
180 | |
185 | |
181 | psiconv_progress(lev+2,off+len,"Going to read the final unknown byte " |
186 | psiconv_progress(lev+2,off+len,"Going to read the final unknown byte " |
182 | "(0x01 expected)"); |
187 | "(0x00 or 0x01 expected)"); |
183 | temp = psiconv_read_u8(buf,lev+2,off + len,&res); |
188 | temp = psiconv_read_u8(buf,lev+2,off + len,&res); |
184 | if (res) |
189 | if (res) |
185 | goto ERROR3; |
190 | goto ERROR3; |
186 | if (temp != 0x01) { |
191 | if ((temp != 0x01) && (temp != 0x00)) { |
187 | psiconv_warn(lev+2,off,"Unknown last byte in border specification"); |
192 | psiconv_warn(lev+2,off,"Unknown last byte in border specification"); |
188 | psiconv_debug(lev+2,off+len, "Last byte: read %02x, expected %02x", |
193 | psiconv_debug(lev+2,off+len, "Last byte: read %02x, expected %02x or %02x", |
189 | temp,0x01); |
194 | temp,0x00,0x01); |
190 | } |
195 | } |
191 | len ++; |
196 | len ++; |
192 | |
197 | |
193 | if (length) |
198 | if (length) |
194 | *length = len; |
199 | *length = len; |