ALDT (Arnulf's LaTeX Documentation Tool)

Check-in [f41e96b23b]
Login

Check-in [f41e96b23b]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixes and new code
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f41e96b23b7c2c514060496850e4c0a51922b16f
User & Date: arnulf 2012-08-29 19:23:13.842
Context
2012-09-01
14:15
fixes check-in: fc88728dc3 user: arnulf tags: trunk
2012-08-29
19:23
fixes and new code check-in: f41e96b23b user: arnulf tags: trunk
17:34
fixes and new code check-in: 55cf454cd6 user: arnulf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to EvalStatement.tcl.
487
488
489
490
491
492
493
494
495
496
497
498

499
500
501
502
503
504


505
506
507
508

509
510
511
512
513
514
515
516
517
518
519

520
521
522
523
524
525
526
527
          # need interpolation 
puts "word_tokens 1!"
if {$eval_stmt_debug > -2} {
puts "evalObj dump2 i!$i!"
$script dumpToken $i
puts "argv!$argv!"
}
          switch (token.get(i).token) {
          case TOKEN_COMMENT:
            had_comment = true;
            num_comments++;
            break;

          case TOKEN_QUOTE_ESC:
            /* fall through */
          case TOKEN_ESC:
          case TOKEN_STR:
            word_obj_ptr = token.get(i).obj_ptr;
            break;


          case TOKEN_VAR_ARRAY_NAME:
//print("stmt var_array_name");
            word_obj_ptr = interp.array_obj_type.expandArray(token.get(i).obj_ptr);
            break;

          case TOKEN_VAR:
//print("evalObj! VAR!"+token.get(i).obj_ptr+"!"+token.get(i).obj_ptr.getString()+"!"+interp.frame_ptr.ns_ptr.toDebugString()+"!");
            ArrayList<Variable> result_var_ptr = new ArrayList<Variable>();
            word_obj_ptr = interp.variable_obj_type.getVariable(token.get(i).obj_ptr, FUNCTION_FLAGS_LEAVE_ERR_MSG, result_var_ptr);
            Variable result_var = result_var_ptr.get(0);
            /* special case for ::itcl::type type variable !! */
            if (word_obj_ptr == null && result_var != null && token.get(i).obj_ptr.getString().equals("type")) {
              word_obj_ptr = interp.string_obj_type.newStringObj(result_var.namespace.full_name, -1, "EVAL_STATEMENT_7");
              word_obj_ptr.incrRefCount("I_EVAL_STATEMENT_5");
            }
            break;

          case TOKEN_EXPRSUGAR:
            word_obj_ptr = interp.expr_obj_type.expandExprSugar(token.get(i).obj_ptr);
            break;
          case TOKEN_BRACE:
            if (!in_quotes) {
              if (argc == 1) {
                /* seems to be the special of setting a variable which is a list
                 * in a ::itcl::macro and then executing the variable!!







|
|
|
|
<
>
|
<
|
|
|
<
>
>
|


<
>
|









<
>
|







487
488
489
490
491
492
493
494
495
496
497

498
499

500
501
502

503
504
505
506
507

508
509
510
511
512
513
514
515
516
517
518

519
520
521
522
523
524
525
526
527
          # need interpolation 
puts "word_tokens 1!"
if {$eval_stmt_debug > -2} {
puts "evalObj dump2 i!$i!"
$script dumpToken $i
puts "argv!$argv!"
}
          switch [::Parser::Token::token2String [[lindex $token $i] getToken]] {
          TOKEN_COMMENT {
            set had_comment true
            incr num_comments

            }
          TOKEN_QUOTE_ESC -

          TOKEN_ESC -
          TOKEN_STR {
            set word_obj_ptr [[lindex $token $i] getObjPtr]

puts "TOK_ESC_STR![$word_obj_ptr toDebugString]!"
            }
          TOKEN_VAR_ARRAY_NAME {
//print("stmt var_array_name");
            word_obj_ptr = interp.array_obj_type.expandArray(token.get(i).obj_ptr);

            }
          TOKEN_VAR {
//print("evalObj! VAR!"+token.get(i).obj_ptr+"!"+token.get(i).obj_ptr.getString()+"!"+interp.frame_ptr.ns_ptr.toDebugString()+"!");
            ArrayList<Variable> result_var_ptr = new ArrayList<Variable>();
            word_obj_ptr = interp.variable_obj_type.getVariable(token.get(i).obj_ptr, FUNCTION_FLAGS_LEAVE_ERR_MSG, result_var_ptr);
            Variable result_var = result_var_ptr.get(0);
            /* special case for ::itcl::type type variable !! */
            if (word_obj_ptr == null && result_var != null && token.get(i).obj_ptr.getString().equals("type")) {
              word_obj_ptr = interp.string_obj_type.newStringObj(result_var.namespace.full_name, -1, "EVAL_STATEMENT_7");
              word_obj_ptr.incrRefCount("I_EVAL_STATEMENT_5");
            }

            }
          TOKEN_EXPRSUGAR {
            word_obj_ptr = interp.expr_obj_type.expandExprSugar(token.get(i).obj_ptr);
            break;
          case TOKEN_BRACE:
            if (!in_quotes) {
              if (argc == 1) {
                /* seems to be the special of setting a variable which is a list
                 * in a ::itcl::macro and then executing the variable!!
535
536
537
538
539
540
541



542

543
544


545
546

547
548
549
550
551

552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575

576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599

600
601
602
603
604
605
606
607
608
609



610
611
612
613
614
615
616
617
618
            } else {
              ArrayList<ApwtclObj> result_ptr2 = new ArrayList<ApwtclObj>();
              retcode = interp.script_obj_type.substObj(token.get(i).obj_ptr, result_ptr2, FUNCTION_FLAGS_LEAVE_ERR_MSG);
              if (retcode == OK) {
                word_obj_ptr = result_ptr2.get(0);
              }
                }



            break;

          case TOKEN_CMD:
            retcode = evalObj(token.get(i).obj_ptr);


            if (retcode == OK) {
              word_obj_ptr = interp.result;

            }
            break;
          default:
            panic(true, "default token type reached in evalObj(): "+getTokenString(token.get(i).token));
          }

        } else {
          /* For interpolation we call a helper
           * function to do the work for us. 
           */
          word_obj_ptr = interpolateTokens(script, i, word_tokens, TOKEN_NONE);
//print("interpolate!"+word_obj_ptr.ToDebugString()+"!");
          if (word_obj_ptr != null && word_obj_ptr.len == 0) {
            /* we had only comment tokens, nothing to do */
            had_comment = true;
          }
        }
//print("EVALOBJ9");
        i += word_tokens;
        if (!had_comment) {
          if (word_obj_ptr == null) {
            if (retcode == OK) {
              retcode = ERROR;
            }
            break;
          }
          word_obj_ptr.incrRefCount("I_EVAL_STATEMENT_6");
          if (!expand) {
            if (!had_comment) {
              argv.add(word_obj_ptr);

            }
          } else {
            /* Need to expand word_obj_ptr into multiple args from argv[j] ... */
            int len = interp.list_obj_type.listLength(word_obj_ptr);
            int k;
  
//print(">>>EXPAND!"+argc+"!"+len+"!"+newargc+"!"+word_obj_ptr.toDebugString()+"!");
            /* Now copy in the expanded version */
            for (k = 0; k < len; k++) {
              argv.add(word_obj_ptr.listValue_GetElem().get(k));
              j++;
              word_obj_ptr.listValue_GetElem().get(k).incrRefCount("I_EVAL_STATEMENT_7");
            }
            /* The original object reference is no longer needed,
             * after the expansion it is no longer present on
             * the argument vector, but the single elements are
             * in its place. 
             */
            word_obj_ptr.decrRefCount("D_EVAL_STATEMENT_6");
            /* And update the indexes */
            j--;
            argc += len - 1;
          }
        }

      }
//print("EVALOBJ10");
      if (had_comment) {
        continue;
      }
      argc -= num_comments;
      if (retcode == OK && argc != 0) {
        /* Lookup the command to call */
//        cmd = interp.command_obj_type.getCommand(argv.get(0), FUNCTION_FLAGS_LEAVE_ERR_MSG);
        ArrayList<ArrayList<ApwtclObj>> extra_args_ptr = new ArrayList<ArrayList<ApwtclObj>>();



        ArrayList<ApwtclObj> extra_args;
        cmd = interp.getCommand(argv.get(0), 0, extra_args_ptr);
        extra_args = extra_args_ptr.get(0);
//print("EVALOBJ11!"+cmd+"!"+argc+"!");
        if ((cmd == null) && (argc == 1)) {
          /* check if the argument looks like a list and the expand it (old style!!) */
          int len = interp.list_obj_type.listLength(argv.get(0));
          ArrayList<ApwtclObj> result_ptr3 = new ArrayList<ApwtclObj>();
//print("EVALOBJ11a");







>
>
>
|
>
|
|
>
>
|
|
>

<
|
|
|
>

|
|
|
|
|
|
|
|


|
|
|
|
|
|

|

|
|
|
|
>


|
|




















>

|
|
|

|
|
|
|
<
>
>
>
|
|







535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554

555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617

618
619
620
621
622
623
624
625
626
627
628
629
            } else {
              ArrayList<ApwtclObj> result_ptr2 = new ArrayList<ApwtclObj>();
              retcode = interp.script_obj_type.substObj(token.get(i).obj_ptr, result_ptr2, FUNCTION_FLAGS_LEAVE_ERR_MSG);
              if (retcode == OK) {
                word_obj_ptr = result_ptr2.get(0);
              }
                }
            }
          TOKEN_BRACKET {
            set word_obj_ptr [[lindex $token $i] getObjPtr]
puts "BRACKET reached![$word_obj_ptr toDebugString]!"
            }
          TOKEN_BRACE {
            set word_obj_ptr [[lindex $token $i] getObjPtr]
puts "BRACE reached![$word_obj_ptr toDebugString]!"
            }
          TOKEN_TAG_NAME {
            set word_obj_ptr [[lindex $token $i] getObjPtr]
puts "TAG_NAME reached![$word_obj_ptr toDebugString]!"
            }

          default {
            ::Interp::panic true "default token type reached in evalObj(): [::Parser::Token::token2String [[lindex $token $i] getToken]]"
            }
          }
        } else {
          # For interpolation we call a helper
          # function to do the work for us. 
          
          set word_obj_ptr [interpolateTokens $script $i $word_tokens TOKEN_NONE]
#puts "interpolate![$word_obj_ptr ToDebugString]!"
          if {$word_obj_ptr != [list] && [$word_obj_ptr getLen] == 0} {
            # we had only comment tokens, nothing to do
            set had_comment true
          }
        }
puts "EVALOBJ9"
        incr i $word_tokens
        if {!$had_comment} {
          if {$word_obj_ptr == [list]} {
            if {$retcode == [::Interp::string2ReturnCode OK]} {
              set retcode [::Interp::string2ReturnCode ERROR]
            }
            break
          }
          $word_obj_ptr incrRefCount "I_EVAL_STATEMENT_6"
          if {!$expand} {
            if {!$had_comment} {
              lappend argv $word_obj_ptr
puts "lappend argv![$word_obj_ptr toDebugString]!"
            }
          } else {
            # Need to expand word_obj_ptr into multiple args from argv[j] ... 
            set len [$::Interp::list_obj_type listLength $word_obj_ptr]
            int k;
  
//print(">>>EXPAND!"+argc+"!"+len+"!"+newargc+"!"+word_obj_ptr.toDebugString()+"!");
            /* Now copy in the expanded version */
            for (k = 0; k < len; k++) {
              argv.add(word_obj_ptr.listValue_GetElem().get(k));
              j++;
              word_obj_ptr.listValue_GetElem().get(k).incrRefCount("I_EVAL_STATEMENT_7");
            }
            /* The original object reference is no longer needed,
             * after the expansion it is no longer present on
             * the argument vector, but the single elements are
             * in its place. 
             */
            word_obj_ptr.decrRefCount("D_EVAL_STATEMENT_6");
            /* And update the indexes */
            j--;
            argc += len - 1;
          }
        }
	incr j
      }
puts "EVALOBJ10"
      if {$had_comment} {
        continue
      }
      incr argc [expr {-$num_comments}]
      if {$retcode == [::Interp::string2ReturnCode OK] && $argc != 0} {
        # Lookup the command to call
puts "lookup command!$argv!"

foreach arg $argv {
puts "arg!$arg![$arg toDebugString]!"
}
	set extra_args_ptr [list]
        set cmd [::Interp::getCommand [lindex $argv 0] 0 extra_args_ptr]
        extra_args = extra_args_ptr.get(0);
//print("EVALOBJ11!"+cmd+"!"+argc+"!");
        if ((cmd == null) && (argc == 1)) {
          /* check if the argument looks like a list and the expand it (old style!!) */
          int len = interp.list_obj_type.listLength(argv.get(0));
          ArrayList<ApwtclObj> result_ptr3 = new ArrayList<ApwtclObj>();
//print("EVALOBJ11a");
698
699
700
701
702
703
704
705

706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
            /* Call [unknown] */
            retcode = interp.unknownFcn(argc, argv, script.script_object.file_name_obj, line_no);
          } else {
            /* we do not call unknown, if we had only the empty string as command and no arguments */
          }
        }
      }
//      /* Finished with the command, so decrement ref counts of each argument */

      for (j = 0; j < argv.size(); j++) {
        argv.get(j).decrRefCount("D_EVAL_STATEMENT_7!"+argv.get(j).obj_type+"!"+(argv.get(j).bytes == null ? "null" : argv.get(j).bytes.toString())+"!");
      }
      argv = new ArrayList<ApwtclObj>();
    }

    /* Possibly add to the error stack trace */
    addErrorToStack(retcode, script.script_object.file_name_obj, line_no);

    /* Note that we don't have to decrement ref_count, because the
     * following code transfers our use of the reference again to
     * the script object. */
    script_obj_ptr.freeIntRep();
    script_obj_ptr.obj_type = OBJ_TYPE_SCRIPT;
    script_obj_ptr.setIntRepPtr(script);
    script_obj_ptr.decrRefCount("D_EVAL_STATEMENT_8");
if (eval_stmt_debug > 0) {
print("EVALOBJ end level!"+eval_level+"!"+retcode+"!");
}
    if (macro_cmd_level == eval_level) {
      had_macro_cmd = false;
    }
    eval_level--;
    return retcode;
  }

  # ==================== _evalObjVector ===================================== */
  # Eval the object vector 'objv' composed of 'objc' elements.
  # Every element is used as single argument.
  # evalObj() will call this function every time its object
  # argument is of "list" type, with no string representation.







|
>
|
|

|


|
|

|
|
|
|
|
|
|
|
|

|
|

|
|







709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
            /* Call [unknown] */
            retcode = interp.unknownFcn(argc, argv, script.script_object.file_name_obj, line_no);
          } else {
            /* we do not call unknown, if we had only the empty string as command and no arguments */
          }
        }
      }
      # Finished with the command, so decrement ref counts of each argument
puts "EVALOBJ10a!$retcode!$argv!"
      foreach arg $argv {
        $arg decrRefCount "D_EVAL_STATEMENT_7![$arg getObjType]![$arg getBytes]!"
      }
      set argv [list]
    }

    # Possibly add to the error stack trace 
#    addErrorToStack(retcode, script.script_object.file_name_obj, line_no);

    # Note that we don't have to decrement ref_count, because the
    # following code transfers our use of the reference again to
    # the script object.
    $script_obj_ptr freeIntRep
    $script_obj_ptr setObjType [::Interp::string2ObjType OBJ_TYPE_SCRIPT]
    $script_obj_ptr setIntRepPtr $script
    $script_obj_ptr decrRefCount "D_EVAL_STATEMENT_8"
if {$eval_stmt_debug > 0} {
puts "EVALOBJ end level!$eval_level!$retcode!"
}
    if {$macro_cmd_level == $eval_level} {
      set had_macro_cmd false
    }
    incr eval_level -1
    return $retcode
  }

  # ==================== _evalObjVector ===================================== */
  # Eval the object vector 'objv' composed of 'objc' elements.
  # Every element is used as single argument.
  # evalObj() will call this function every time its object
  # argument is of "list" type, with no string representation.
Changes to LatexObj.tcl.
38
39
40
41
42
43
44






45
46
47
48
49
50
51
  public variable ref_count
  public variable obj_type

  constructor {} {}
  public method mySelf {}
  public method toString {}
  public method toDebugString {}






  public method scriptLineValue_GetLine {}
  public method scriptLineValue_SetLine {val}
  public method scriptLineValue_GetArgc {}
  public method scriptLineValue_SetArgc {val}
  public method scriptValue_GetScript {}
  public method scriptValue_SetScript {script}
  public method sourceValue_GetFileNameObj {}







>
>
>
>
>
>







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  public variable ref_count
  public variable obj_type

  constructor {} {}
  public method mySelf {}
  public method toString {}
  public method toDebugString {}
  public method ptrAndLongRepValue_GetPtr {}
  public method ptrAndLongRepValue_SetPtr {ptr}
  public method ptrAndLongRepValue_GetValue {}
  public method ptrAndLongRepValue_SetValue {val}
  public method ptrValue_GetPtr {}
  public method ptrValue_SetPtr {ptr}
  public method scriptLineValue_GetLine {}
  public method scriptLineValue_SetLine {val}
  public method scriptLineValue_GetArgc {}
  public method scriptLineValue_SetArgc {val}
  public method scriptValue_GetScript {}
  public method scriptValue_SetScript {script}
  public method sourceValue_GetFileNameObj {}
99
100
101
102
103
104
105


106
107
108
109
110
111
112
    set bytes ""
    set len 0;
    set allocated ""
    set freed ""
    set obj_type_base [::Parser::ObjTypeBase #auto]
    set incr_lst [list]
    set decr_lst [list]


    set check_allocate true
    set ref_count 0
    set value1 ""
    set value2 ""
    set value3 ""
  }








>
>







105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    set bytes ""
    set len 0;
    set allocated ""
    set freed ""
    set obj_type_base [::Parser::ObjTypeBase #auto]
    set incr_lst [list]
    set decr_lst [list]
    set prev_obj_ptr [list]
    set next_obj_ptr [list]
    set check_allocate true
    set ref_count 0
    set value1 ""
    set value2 ""
    set value3 ""
  }

385
386
387
388
389
390
391
392

393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428

429
430
431
432
433
434
435

  /* ==================== paramInfoValue_SetOrigParams ================================== */
  public FunctionArgList paramInfoValue_SetOrigParams(FunctionArgList orig_params) {
//print("paramInfoValue_SetOrigParams!"+this.mySelf()+"!");
    value2 = (Object)orig_params;
    return orig_params;
  }


  /* ==================== ptrAndLongRepValue_GetPtr ================================== */
  public LatexObj ptrAndLongRepValue_GetPtr() {
    return (LatexObj)value1;
  }

  /* ==================== ptrAndLongRepValue_SetPtr ================================== */
  public LatexObj ptrAndLongRepValue_SetPtr(LatexObj ptr) {
//print("ptrAndLongRepValue_SetPtr!"+this.mySelf()+"!");
    value1 = (Object)ptr;
    return ptr;
  }

  /* ==================== ptrAndLongRepValue_GetValue ============================= */
  public long ptrAndLongRepValue_GetValue() {
    return (Long)value2;
  }

  /* ==================== ptrAndLongRepValue_SetValue ============================= */
  public long ptrAndLongRepValue_SetValue(long val) {
//print("ptrAndLongRepValue_SetValue!"+this.mySelf()+"!");
    value2 = (Object)val;
    return val;
  }

  /* ==================== ptrValue_GetPtr ================================== */
  public Object ptrValue_GetPtr() {
    return (Object)value1;
  }

  /* ==================== ptrValue_SetPtr ================================== */
  public Object ptrValue_SetPtr(Object ptr) {
//print("ptrValue_SetPtr!"+this.mySelf()+"!");
    value1 = (Object)ptr;
    return ptr;
  }


  /* ==================== refValue_GetRefPtr ================================== */
  public LatexObj refValue_GetRefPtr() {
    return (LatexObj)value1;
  }

  /* ==================== refValue_SetRefPtr ================================== */
  public LatexObj refValue_SetRefPtr(LatexObj ref_ptr) {







|
>
|
|
|


|
|
|
|
|


|
|
|


|
|
|
|
|


|
|
|


|
|
|
|
|


>







393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445

  /* ==================== paramInfoValue_SetOrigParams ================================== */
  public FunctionArgList paramInfoValue_SetOrigParams(FunctionArgList orig_params) {
//print("paramInfoValue_SetOrigParams!"+this.mySelf()+"!");
    value2 = (Object)orig_params;
    return orig_params;
  }
}

  # ==================== ptrAndLongRepValue_GetPtr ==================================
::itcl::body LatexObj::ptrAndLongRepValue_GetPtr {} {
    return $value1
  }

  # ==================== ptrAndLongRepValue_SetPtr ==================================
::itcl::body LatexObj::ptrAndLongRepValue_SetPtr {ptr} {
#puts "ptrAndLongRepValue_SetPtr![mySelf]!"
    set value1 $ptr
    return $ptr;
  }

  # ==================== ptrAndLongRepValue_GetValue =============================
::itcl::body LatexObj::ptrAndLongRepValue_GetValue {} {
    return $value2
  }

  # ==================== ptrAndLongRepValue_SetValue =============================
::itcl::body LatexObj::ptrAndLongRepValue_SetValue {val} {
#puts "ptrAndLongRepValue_SetValue![mySelf]!"
    set value2 $val
    return $val
  }

  # ==================== ptrValue_GetPtr ==================================
::itcl::body LatexObj::ptrValue_GetPtr {} {
    return $value1
  }

  # ==================== ptrValue_SetPtr ==================================
::itcl::body LatexObj::ptrValue_SetPtr {ptr} {
#puts "ptrValue_SetPtr![mySelf]!"
    set value1 $ptr
    return $ptr
  }

if {0} {
  /* ==================== refValue_GetRefPtr ================================== */
  public LatexObj refValue_GetRefPtr() {
    return (LatexObj)value1;
  }

  /* ==================== refValue_SetRefPtr ================================== */
  public LatexObj refValue_SetRefPtr(LatexObj ref_ptr) {
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
    if {$next_obj_ptr != [list]} {
      $next_obj_ptr setPrevObjPtr $prev_obj_ptr
    }
    if {$live_obj_list == $this} {
      set live_obj_list $next_obj_ptr
    }
    # Link the object into the free objects list
    set prev_obj_ptr = [list]
    set next_obj_ptr $free_obj_list
    if {$free_obj_list != [list]} {
      $free_obj_list setPrevObjPtr $this
    }
    set free_obj_list $this
    set ref_count -1
    set freed $where







|







730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
    if {$next_obj_ptr != [list]} {
      $next_obj_ptr setPrevObjPtr $prev_obj_ptr
    }
    if {$live_obj_list == $this} {
      set live_obj_list $next_obj_ptr
    }
    # Link the object into the free objects list
    set prev_obj_ptr [list]
    set next_obj_ptr $free_obj_list
    if {$free_obj_list != [list]} {
      $free_obj_list setPrevObjPtr $this
    }
    set free_obj_list $this
    set ref_count -1
    set freed $where
Changes to Parse.tcl.
142
143
144
145
146
147
148

149
150
151
152
153



154
155
156
157

158

159
160
161
162

163
164
165
166
167




168
169
170
171

172

173
174
175
176
177
178
179
180
181



182
183
184
185

186

187
188
189
190
191
192
193
      if {[$parse_info getState] eq [::Parser::Token::string2ParserState "PARSER_STATE_DEFAULT"]} {
        return [parseEol]
      } else {
        return [parseString]
      }
      }
    "\{" {

      if {[$parse_info getArgument]} {
        if {![$parse_info getWordSep]} {
          # we have to simulate a TOKEN_WORD_SEP here so 
          # EvalStatement will use the optional and mandatory arguments
          # as those and not as a combined string!!



          set ret [parseWordSep]
          return $ret
        }
      }

      $parse_info setWordSep false

      $parse_info setComment false
      return [parseBrace]
      }
    "\[" {

      if {[$parse_info getArgument]} {
        if {![$parse_info getWordSep]} {
          # we have to simulate a TOKEN_WORD_SEP here so 
          # EvalStatement will use the optional and mandatory arguments
          # as those and not as a combined string!!




          set ret [parseWordSep]
          return $ret
        }
      }

      $parse_info setWordSep false

      $parse_info setComment false
      return [parseBracket]
      }
    "\(" {
      if {[$parse_info getArgument]} {
        if {![$parse_info getWordSep]} {
          # we have to simulate a TOKEN_WORD_SEP here so 
          # EvalStatement will use the optional and mandatory arguments
          # as those and not as a combined string!!



          set ret [parseWordSep]
          return $ret
        }
      }

      $parse_info setWordSep false

      $parse_info setComment false
      return [parseParen]
      }
    "$" {
      $parse_info setWordSep false
      $parse_info setComment false
      if {[parseVar] == false} {







>

|
|


>
>
>
|
|


>
|
>




>

|
|


>
>
>
>
|
|


>
|
>






|


>
>
>
|
|


>
|
>







142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
      if {[$parse_info getState] eq [::Parser::Token::string2ParserState "PARSER_STATE_DEFAULT"]} {
        return [parseEol]
      } else {
        return [parseString]
      }
      }
    "\{" {
puts "ARG1![$parse_info getArgument]![$parse_info getWordSep]!"
      if {[$parse_info getArgument]} {
        if {[$parse_info getWordSep]} {
          # we have to simulate a TOKEN_ESC here so 
          # EvalStatement will use the optional and mandatory arguments
          # as those and not as a combined string!!
	  $parse_info setStart [$parse_info getIndex]
	  $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_WORD_SEP"]
          $parse_info setWordSep false
          return true
        }
      }
      if {[$parse_info getArgument]} {
        $parse_info setWordSep true
      }
      $parse_info setComment false
      return [parseBrace]
      }
    "\[" {
puts "BRK1![$parse_info getArgument]![$parse_info getWordSep]!"
      if {[$parse_info getArgument]} {
        if {[$parse_info getWordSep]} {
          # we have to simulate a TOKEN_ESC here so 
          # EvalStatement will use the optional and mandatory arguments
          # as those and not as a combined string!!
	  $parse_info setStart [$parse_info getIndex]
	  $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_WORD_SEP"]
puts "BRK![$parse_info getText]!"
          $parse_info setWordSep false
          return true
        }
      }
      if {[$parse_info getArgument]} {
          $parse_info setWordSep true
      }
      $parse_info setComment false
      return [parseBracket]
      }
    "\(" {
      if {[$parse_info getArgument]} {
        if {![$parse_info getWordSep]} {
          # we have to simulate a TOKEN_ESC here so 
          # EvalStatement will use the optional and mandatory arguments
          # as those and not as a combined string!!
	  $parse_info setStart [$parse_info getIndex]
	  $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_WORD_SEP"]
          $parse_info setWordSep false
          return true
        }
      }
      if {[$parse_info getArgument]} {
        $parse_info setWordSep true
      }
      $parse_info setComment false
      return [parseParen]
      }
    "$" {
      $parse_info setWordSep false
      $parse_info setComment false
      if {[parseVar] == false} {
264
265
266
267
268
269
270

271
272
273
274
275
276
277

# ==================== parseTagName ===================================== */
::itcl::body Parse::parseTagName {} {
  $parse_info setStart [$parse_info getIndex]
  $parse_info setLine [$parse_info getLineNo]
  $parse_info setToken [::Parser::Token::string2Token "TOKEN_TAG_NAME"]
  $parse_info setArgument true

  feedChar
  while {[$parse_info getLen] > 0} {
    switch [$parse_info getCur] {
    "\{" -
    "\[" -
    "\(" -
    "\t" -







>







282
283
284
285
286
287
288
289
290
291
292
293
294
295
296

# ==================== parseTagName ===================================== */
::itcl::body Parse::parseTagName {} {
  $parse_info setStart [$parse_info getIndex]
  $parse_info setLine [$parse_info getLineNo]
  $parse_info setToken [::Parser::Token::string2Token "TOKEN_TAG_NAME"]
  $parse_info setArgument true
  $parse_info setWordSep true
  feedChar
  while {[$parse_info getLen] > 0} {
    switch [$parse_info getCur] {
    "\{" -
    "\[" -
    "\(" -
    "\t" -
871
872
873
874
875
876
877
878
879
880
881
  $parse_info setIndex [expr {[$parse_info getIndex] + 1}]
  $parse_info setLen [expr {[$parse_info getLen] -1}]
  if {[$parse_info getLen] < 0} {
#      throw new PanicException("End of file reached");
    puts stderr "PANIC! End of file reached"
  }
  $parse_info setCur [string range [$parse_info getText] [$parse_info getIndex] [$parse_info getIndex]]
puts "FDCH![$parse_info getLen]![$parse_info getIndex]![$parse_info getCur]![$parse_info getText]!"
}

}







|



890
891
892
893
894
895
896
897
898
899
900
  $parse_info setIndex [expr {[$parse_info getIndex] + 1}]
  $parse_info setLen [expr {[$parse_info getLen] -1}]
  if {[$parse_info getLen] < 0} {
#      throw new PanicException("End of file reached");
    puts stderr "PANIC! End of file reached"
  }
  $parse_info setCur [string range [$parse_info getText] [$parse_info getIndex] [$parse_info getIndex]]
puts "FDCH![$parse_info getLen]![$parse_info getIndex]![$parse_info getCur]![getText]!"
}

}
Changes to StringObjType.tcl.
110
111
112
113
114
115
116

117
118
119
120
121
122
123
  }

  # ==================== newStringObj ================================== 
  # len is in bytes -- see also newStringObjUtf8() 
::itcl::body StringObjType::newStringObj {str len where} {
    set obj_ptr [uplevel #0 ::Parser::LatexObj #auto]


    # Need to find out how many bytes the string requires 
    if {$len == -1} {
      set len [string length $str]
    }
    $obj_ptr strValue_SetCharLength $len
    $obj_ptr strValue_SetMaxLength $len
    if {$len == 0} {







>







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  }

  # ==================== newStringObj ================================== 
  # len is in bytes -- see also newStringObjUtf8() 
::itcl::body StringObjType::newStringObj {str len where} {
    set obj_ptr [uplevel #0 ::Parser::LatexObj #auto]

puts "NEWSTR!$obj_ptr!"
    # Need to find out how many bytes the string requires 
    if {$len == -1} {
      set len [string length $str]
    }
    $obj_ptr strValue_SetCharLength $len
    $obj_ptr strValue_SetMaxLength $len
    if {$len == 0} {
Changes to latex_parse.tcl.
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359

buildCmdList $latex_cmds_info

::Parser::Token::Init
::Interp::Init
::LaTeX::CommandInfo::Init
set str "\\begin\[pf1\]{document}\n abc \n\\end{document}"
set script [$::Interp::string_obj_type newStringObj "::set dir $::Interp::current_dir\n$str" -1 "BASE_2"]
puts "SCRIPT![$script toDebugString]!"
$::Interp::eval_statement evalObj $script

if {0} {
set parser [::Parser::Parse #auto]
$parser parserInit $str [string length $str] 1
while {true} {







|







345
346
347
348
349
350
351
352
353
354
355
356
357
358
359

buildCmdList $latex_cmds_info

::Parser::Token::Init
::Interp::Init
::LaTeX::CommandInfo::Init
set str "\\begin\[pf1\]{document}\n abc \n\\end{document}"
set script [$::Interp::string_obj_type newStringObj "$str" -1 "BASE_2"]
puts "SCRIPT![$script toDebugString]!"
$::Interp::eval_statement evalObj $script

if {0} {
set parser [::Parser::Parse #auto]
$parser parserInit $str [string length $str] 1
while {true} {