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

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

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

Revision 110 Revision 142
22 22
23#include <stdlib.h> 23#include <stdlib.h>
24 24
25#include "parse_routines.h" 25#include "parse_routines.h"
26#include "error.h" 26#include "error.h"
27
28#ifdef DMALLOC
29#include <dmalloc.h>
30#endif
31
27 32
28struct formula_element 33struct formula_element
29{ 34{
30 psiconv_formula_type_t formula_type; 35 psiconv_formula_type_t formula_type;
31 int number_of_args; 36 int number_of_args;
388{ 393{
389 int res=0; 394 int res=0;
390 int len=0; 395 int len=0;
391 int leng; 396 int leng;
392 int eof = 0; 397 int eof = 0;
393 psiconv_u8 marker,submarker; 398 psiconv_u8 marker,submarker,submarker2;
394 psiconv_formula_list formula_stack; 399 psiconv_formula_list formula_stack;
395 psiconv_formula formula,subformula,subformula1,subformula2, 400 psiconv_formula formula,subformula,subformula1,subformula2,
396 subformula3,subformula4; 401 subformula3,subformula4;
397 psiconv_u16 temp,nr_of_subs; 402 psiconv_u16 temp,nr_of_subs;
398 403
499 len += leng; 504 len += leng;
500 if ((res = psiconv_list_add(formula_stack,formula))) 505 if ((res = psiconv_list_add(formula_stack,formula)))
501 goto ERROR8; 506 goto ERROR8;
502 formula->type = psiconv_formula_unknown; 507 formula->type = psiconv_formula_unknown;
503 } else if ((formula_elements[marker].formula_type == 508 } else if ((formula_elements[marker].formula_type ==
504 psiconv_formula_dat_var) || 509 psiconv_formula_dat_var)) {
505 (formula_elements[marker].formula_type == 510 psiconv_progress(lev+3,off+len,"Next item: a variable reference");
506 psiconv_formula_dat_vcellblock)) { 511 formula->data.dat_variable = psiconv_read_u32(buf,lev+2,off+len,&res);
507 psiconv_warn(lev+3,off+len,"Not yet supported formula mark!"); 512 if (res)
508 goto ERROR8; 513 goto ERROR8;
514 formula->type = formula_elements[marker].formula_type;
515 len += 4;
516 if ((res = psiconv_list_add(formula_stack,formula)))
517 goto ERROR8;
518 formula->type = psiconv_formula_unknown;
509 } else if (formula_elements[marker].number_of_args == -1) { 519 } else if (formula_elements[marker].number_of_args == -1) {
510 psiconv_progress(lev+3,off+len,"Going to parse a vararg function"); 520 psiconv_progress(lev+3,off+len,"Going to parse a vararg function");
511 if (!(formula->data.fun_operands = 521 if (!(formula->data.fun_operands =
512 psiconv_list_new(sizeof(*formula)))) 522 psiconv_list_new(sizeof(*formula))))
513 goto ERROR8; 523 goto ERROR8;
529 psiconv_progress(lev+4,off+len,"Going to read the next marker"); 539 psiconv_progress(lev+4,off+len,"Going to read the next marker");
530 submarker = psiconv_read_u8(buf,lev+4,off+len,&res); 540 submarker = psiconv_read_u8(buf,lev+4,off+len,&res);
531 len ++; 541 len ++;
532 if (res) 542 if (res)
533 goto ERROR8; 543 goto ERROR8;
544 submarker2 = psiconv_read_u8(buf,lev+4,off+len,&res);
545 if (res)
546 goto ERROR8;
534 } while (formula_elements[submarker].formula_type 547 } while ((formula_elements[submarker].formula_type
535 == psiconv_formula_mark_opsep); 548 == psiconv_formula_mark_opsep) &&
549 (formula_elements[submarker2].formula_type
550 != psiconv_formula_mark_opend));
551 if ((formula_elements[submarker].formula_type ==
552 psiconv_formula_mark_opsep) &&
553 (formula_elements[submarker2].formula_type ==
554 psiconv_formula_mark_opend)) {
555 submarker=submarker2;
556 len++;
557 }
536 if (formula_elements[submarker].formula_type 558 if (formula_elements[submarker].formula_type
537 != psiconv_formula_mark_opend) { 559 != psiconv_formula_mark_opend) {
538 psiconv_warn(lev+3,off+len,"Formula corrupted!"); 560 psiconv_warn(lev+3,off+len,"Formula corrupted!");
539 psiconv_debug(lev+3,off+len,"Found unexpected marker %02x",submarker); 561 psiconv_debug(lev+3,off+len,"Found unexpected marker %02x",submarker);
540 goto ERROR8; 562 goto ERROR8;

Legend:
Removed from v.110  
changed lines
  Added in v.142

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