/[public]/psiconv/trunk/lib/psiconv/parse_layout.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/parse_layout.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 183 Revision 184
62 return 0; 62 return 0;
63 63
64ERROR2: 64ERROR2:
65 free(*result); 65 free(*result);
66ERROR1: 66ERROR1:
67 psiconv_warn(config,lev+1,off,"Reading of Color failed"); 67 psiconv_error(config,lev+1,off,"Reading of Color failed");
68 if (length) 68 if (length)
69 *length = 0; 69 *length = 0;
70 if (res == 0) 70 if (res == 0)
71 return -PSICONV_E_NOMEM; 71 return -PSICONV_E_NOMEM;
72 else 72 else
80 int *length, psiconv_font *result) 80 int *length, psiconv_font *result)
81{ 81{
82 int res = 0; 82 int res = 0;
83 char *str_copy; 83 char *str_copy;
84 int len=0; 84 int len=0;
85 int leng; 85 int fontlen;
86 86
87 psiconv_progress(config,lev+1,off,"Going to parse font"); 87 psiconv_progress(config,lev+1,off,"Going to parse font");
88 if (!(*result = malloc(sizeof(**result)))) 88 if (!(*result = malloc(sizeof(**result))))
89 goto ERROR1; 89 goto ERROR1;
90 90
91 fontlen = psiconv_read_u8(config,buf,lev+2,off,&res);
92 if (res)
93 goto ERROR2;
94 len = 1;
95
91 (*result)->name = psiconv_read_short_string(config,buf,lev+2,off+len, 96 (*result)->name = psiconv_read_charlist(config,buf,lev+2,off, fontlen-1,&res);
92 &leng,&res);
93 if (res) 97 if (res)
94 goto ERROR2; 98 goto ERROR2;
95 len += leng; 99 len += fontlen - 1;
96 100
97 (*result)->screenfont = psiconv_read_u8(config,buf,lev+2,off+len,&res); 101 (*result)->screenfont = psiconv_read_u8(config,buf,lev+2,off+len,&res);
98 if (res) 102 if (res)
99 goto ERROR3; 103 goto ERROR3;
100 104
101 if (!(str_copy = psiconv_make_printable((*result)->name))) 105 if (!(str_copy = psiconv_make_printable(config,(*result)->name)))
102 goto ERROR3; 106 goto ERROR3;
103 107
104 psiconv_debug(config,lev+2,off+len, 108 psiconv_debug(config,lev+2,off+len,
105 "Found font `%s', displayed with screen font %02x", 109 "Found font `%s', displayed with screen font %02x",
106 str_copy,(*result)->screenfont); 110 str_copy,(*result)->screenfont);
117ERROR3: 121ERROR3:
118 free ((*result)->name); 122 free ((*result)->name);
119ERROR2: 123ERROR2:
120 free (*result); 124 free (*result);
121ERROR1: 125ERROR1:
122 psiconv_warn(config,lev+1,off,"Reading of Font failed"); 126 psiconv_error(config,lev+1,off,"Reading of Font failed");
123 if (length) 127 if (length)
124 *length = 0; 128 *length = 0;
125 if (!res) 129 if (!res)
126 return -PSICONV_E_NOMEM; 130 return -PSICONV_E_NOMEM;
127 else 131 else
212ERROR3: 216ERROR3:
213 psiconv_free_color((*result)->color); 217 psiconv_free_color((*result)->color);
214ERROR2: 218ERROR2:
215 free (result); 219 free (result);
216ERROR1: 220ERROR1:
217 psiconv_warn(config,lev+1,off,"Reading of Border failed"); 221 psiconv_error(config,lev+1,off,"Reading of Border failed");
218 if (length) 222 if (length)
219 *length = 0; 223 *length = 0;
220 if (!res) 224 if (!res)
221 return -PSICONV_E_NOMEM; 225 return -PSICONV_E_NOMEM;
222 else 226 else
229{ 233{
230 int res = 0; 234 int res = 0;
231 int len = 0; 235 int len = 0;
232 int leng; 236 int leng;
233 int bullet_length; 237 int bullet_length;
238 psiconv_u8 temp;
234 239
235 if (!(*result = malloc(sizeof(**result)))) 240 if (!(*result = malloc(sizeof(**result))))
236 goto ERROR1; 241 goto ERROR1;
237 (*result)->on = psiconv_bool_true; 242 (*result)->on = psiconv_bool_true;
238 243
249 if (res) 254 if (res)
250 goto ERROR2; 255 goto ERROR2;
251 len +=leng; 256 len +=leng;
252 257
253 psiconv_progress(config,lev+2,off+len,"Going to read bullet character"); 258 psiconv_progress(config,lev+2,off+len,"Going to read bullet character");
254 (*result)->character = psiconv_read_u8(config,buf,lev+2,off+len,&res); 259 temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
255 if (res) 260 if (res)
256 goto ERROR2; 261 goto ERROR2;
262 (*result)->character = psiconv_unicode_from_char(config,temp);
257 psiconv_debug(config,lev+2,off+len,"Character: %02x",(*result)->character); 263 psiconv_debug(config,lev+2,off+len,"Character: %02x",(*result)->character);
258 len ++; 264 len ++;
259 265
260 psiconv_progress(config,lev+2,off+len,"Going to read indent on/off"); 266 psiconv_progress(config,lev+2,off+len,"Going to read indent on/off");
261 if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->indent))) 267 if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->indent)))
289ERROR3: 295ERROR3:
290 psiconv_free_color((*result)->color); 296 psiconv_free_color((*result)->color);
291ERROR2: 297ERROR2:
292 free (result); 298 free (result);
293ERROR1: 299ERROR1:
294 psiconv_warn(config,lev+1,off,"Reading of Bullet failed"); 300 psiconv_error(config,lev+1,off,"Reading of Bullet failed");
295 if (length) 301 if (length)
296 *length = 0; 302 *length = 0;
297 if (!res) 303 if (!res)
298 return -PSICONV_E_NOMEM; 304 return -PSICONV_E_NOMEM;
299 else 305 else
345 return 0; 351 return 0;
346 352
347ERROR2: 353ERROR2:
348 free (result); 354 free (result);
349ERROR1: 355ERROR1:
350 psiconv_warn(config,lev+1,off,"Reading of Tab failed"); 356 psiconv_error(config,lev+1,off,"Reading of Tab failed");
351 if (length) 357 if (length)
352 *length = 0; 358 *length = 0;
353 if (!res) 359 if (!res)
354 return -PSICONV_E_NOMEM; 360 return -PSICONV_E_NOMEM;
355 else 361 else
600 } 606 }
601 nr ++; 607 nr ++;
602 } 608 }
603 609
604 if (len - 4 != list_length) { 610 if (len - 4 != list_length) {
605 psiconv_warn(config,lev+2,off+len, 611 psiconv_error(config,lev+2,off+len,
606 "Read past end of paragraph layout codes list. I probably lost track" 612 "Read past end of paragraph layout codes list. I probably lost track "
607 "somewhere!"); 613 "somewhere!");
608 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d", 614 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
609 len-4,list_length); 615 len-4,list_length);
610 res = PSICONV_E_PARSE; 616 res = PSICONV_E_PARSE;
611 goto ERROR1; 617 goto ERROR1;
619 if (length) 625 if (length)
620 *length = len; 626 *length = len;
621 return 0; 627 return 0;
622 628
623ERROR1: 629ERROR1:
624 psiconv_warn(config,lev+1,off,"Reading of paragraph_layout_list failed"); 630 psiconv_error(config,lev+1,off,"Reading of paragraph_layout_list failed");
625 if (length) 631 if (length)
626 *length = 0; 632 *length = 0;
627 if (!res) 633 if (!res)
628 return -PSICONV_E_NOMEM; 634 return -PSICONV_E_NOMEM;
629 else 635 else
769 } 775 }
770 nr ++; 776 nr ++;
771 } 777 }
772 778
773 if (len - 4 != list_length) { 779 if (len - 4 != list_length) {
774 psiconv_warn(config,lev+2,off+len, 780 psiconv_error(config,lev+2,off+len,
775 "Read past end of character layout codes list. I probably lost track" 781 "Read past end of character layout codes list. I probably lost track "
776 "somewhere!"); 782 "somewhere!");
777 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d", 783 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
778 len-4,list_length); 784 len-4,list_length);
779 res = PSICONV_E_PARSE; 785 res = PSICONV_E_PARSE;
780 goto ERROR1; 786 goto ERROR1;
788 if (length) 794 if (length)
789 *length = len; 795 *length = len;
790 return res; 796 return res;
791 797
792ERROR1: 798ERROR1:
793 psiconv_warn(config,lev+1,off,"Reading of character_layout_list failed"); 799 psiconv_error(config,lev+1,off,"Reading of character_layout_list failed");
794 if (length) 800 if (length)
795 *length = 0; 801 *length = 0;
796 if (!res) 802 if (!res)
797 return -PSICONV_E_NOMEM; 803 return -PSICONV_E_NOMEM;
798 else 804 else

Legend:
Removed from v.183  
changed lines
  Added in v.184

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26