… | |
… | |
388 | { |
388 | { |
389 | int res=0; |
389 | int res=0; |
390 | int len=0; |
390 | int len=0; |
391 | int leng; |
391 | int leng; |
392 | int eof = 0; |
392 | int eof = 0; |
393 | psiconv_u8 marker,submarker; |
393 | psiconv_u8 marker,submarker,submarker2; |
394 | psiconv_formula_list formula_stack; |
394 | psiconv_formula_list formula_stack; |
395 | psiconv_formula formula,subformula,subformula1,subformula2, |
395 | psiconv_formula formula,subformula,subformula1,subformula2, |
396 | subformula3,subformula4; |
396 | subformula3,subformula4; |
397 | psiconv_u16 temp,nr_of_subs; |
397 | psiconv_u16 temp,nr_of_subs; |
398 | |
398 | |
… | |
… | |
499 | len += leng; |
499 | len += leng; |
500 | if ((res = psiconv_list_add(formula_stack,formula))) |
500 | if ((res = psiconv_list_add(formula_stack,formula))) |
501 | goto ERROR8; |
501 | goto ERROR8; |
502 | formula->type = psiconv_formula_unknown; |
502 | formula->type = psiconv_formula_unknown; |
503 | } else if ((formula_elements[marker].formula_type == |
503 | } else if ((formula_elements[marker].formula_type == |
504 | psiconv_formula_dat_var) || |
504 | psiconv_formula_dat_var)) { |
505 | (formula_elements[marker].formula_type == |
505 | psiconv_progress(lev+3,off+len,"Next item: a variable reference"); |
506 | psiconv_formula_dat_vcellblock)) { |
506 | 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!"); |
507 | if (res) |
508 | goto ERROR8; |
508 | goto ERROR8; |
|
|
509 | formula->type = formula_elements[marker].formula_type; |
|
|
510 | len += 4; |
|
|
511 | if ((res = psiconv_list_add(formula_stack,formula))) |
|
|
512 | goto ERROR8; |
|
|
513 | formula->type = psiconv_formula_unknown; |
509 | } else if (formula_elements[marker].number_of_args == -1) { |
514 | } else if (formula_elements[marker].number_of_args == -1) { |
510 | psiconv_progress(lev+3,off+len,"Going to parse a vararg function"); |
515 | psiconv_progress(lev+3,off+len,"Going to parse a vararg function"); |
511 | if (!(formula->data.fun_operands = |
516 | if (!(formula->data.fun_operands = |
512 | psiconv_list_new(sizeof(*formula)))) |
517 | psiconv_list_new(sizeof(*formula)))) |
513 | goto ERROR8; |
518 | goto ERROR8; |
… | |
… | |
529 | psiconv_progress(lev+4,off+len,"Going to read the next marker"); |
534 | psiconv_progress(lev+4,off+len,"Going to read the next marker"); |
530 | submarker = psiconv_read_u8(buf,lev+4,off+len,&res); |
535 | submarker = psiconv_read_u8(buf,lev+4,off+len,&res); |
531 | len ++; |
536 | len ++; |
532 | if (res) |
537 | if (res) |
533 | goto ERROR8; |
538 | goto ERROR8; |
|
|
539 | submarker2 = psiconv_read_u8(buf,lev+4,off+len,&res); |
|
|
540 | if (res) |
|
|
541 | goto ERROR8; |
534 | } while (formula_elements[submarker].formula_type |
542 | } while ((formula_elements[submarker].formula_type |
535 | == psiconv_formula_mark_opsep); |
543 | == psiconv_formula_mark_opsep) && |
|
|
544 | (formula_elements[submarker2].formula_type |
|
|
545 | != psiconv_formula_mark_opend)); |
|
|
546 | if ((formula_elements[submarker].formula_type == |
|
|
547 | psiconv_formula_mark_opsep) && |
|
|
548 | (formula_elements[submarker2].formula_type == |
|
|
549 | psiconv_formula_mark_opend)) { |
|
|
550 | submarker=submarker2; |
|
|
551 | len++; |
|
|
552 | } |
536 | if (formula_elements[submarker].formula_type |
553 | if (formula_elements[submarker].formula_type |
537 | != psiconv_formula_mark_opend) { |
554 | != psiconv_formula_mark_opend) { |
538 | psiconv_warn(lev+3,off+len,"Formula corrupted!"); |
555 | psiconv_warn(lev+3,off+len,"Formula corrupted!"); |
539 | psiconv_debug(lev+3,off+len,"Found unexpected marker %02x",submarker); |
556 | psiconv_debug(lev+3,off+len,"Found unexpected marker %02x",submarker); |
540 | goto ERROR8; |
557 | goto ERROR8; |