Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | initial version |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
33a1c9b94318685be2e0df80241f769a |
User & Date: | arnulf 2012-08-26 10:26:31.865 |
Context
2012-08-26
| ||
11:35 | initial version check-in: 94c59675c0 user: arnulf tags: trunk | |
10:26 | initial version check-in: 33a1c9b943 user: arnulf tags: trunk | |
10:19 | initial version check-in: c1c5d81242 user: arnulf tags: trunk | |
Changes
Added LatexObj.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 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 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 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 528 529 530 531 532 533 534 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 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 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 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 | #===================================================== # LatexObj.tcl # * # * ALDT (Arnulf's Latex Documentation Tool) # * A Tcl parser for LaTeX files for generating document output (for example html) # * # * Latex obj info # * # * Released under same BSD license as Tcl. # * (Tcl BSD license found at <http://www.tcl.tk/software/tcltk/license.html>) # * # * Copyright 2012 Arnulf P. Wiedemann #===================================================== namespace eval ::Parser { ::itcl::class LatexObj { public common oid 0 public common free_obj_list [list] public common live_obj_list [list] public variable id private variable next_obj_ptr private variable prev_obj_ptr private variable obj_type_base public variable value1 public variable value2 public variable value3 public variable bytes public variable len public variable allocated public variable freed public variable incr_lst public variable decr_lst public variable check_allocate public variable ref_count public variable obj_type constructor {} {} public method mySelf {} public method toString {} public method toDebugString {} } # ==================== constructor ================================== ::itcl::body LatexObj::constructor {} { incr oid set id $oid set bytes "" set len 0; set allocated "" set freed "" set obj_type_base [ObjTypeBase #auto] set incr_lst [list] set decr_lst [list] set check_allocate true } # ==================== mySelf ================================== ::itcl::body LatexObj::mySelf {} { set str "LatexObj!$id!" return $str } # ==================== toString ===================================== ::itcl::body LatexObj::toString {} { return "[mySelf]!" } # ==================== toDebugString ===================================== ::itcl::body LatexObj::toDebugString {} { set str "[mySelf]\n" append str " ref_count: $ref_count\n" append str " len: $len\n" append str " obj_type: [getObjTypeString $obj_type]\n" append str " allocated: $allocated\n" append str " freed: $freed\n" append str " incr: $incr_lst\n" append str " decr: $decr_lst\n" append str " value1: $value1\n" append str " value2: $value2\n" append str " value3: $value3\n" append str " bytes: $bytes\n" if {$obj_type > 0} { switch $obj_type { OBJ_TYPE_LIST { # str.append(" list_elem: "+listValue_GetElem()+"\n"); } OBJ_TYPE_INT { append str " value: [wideValue_GetValue]\n"); } } } return $str } if {0} { /* ==================== arrayValue_GetVarNameObjPtr ================================== */ public LatexObj arrayValue_GetVarNameObjPtr() { return (LatexObj)value1; } /* ==================== arrayValue_SetVarNameObjPtr ================================== */ public LatexObj arrayValue_SetVarNameObjPtr(LatexObj var_name_obj_ptr) { //print("arrayValue_SetVarNameObjPtr!"+this.mySelf()+"!"); value1 = (Object)var_name_obj_ptr; return var_name_obj_ptr; } /* ==================== arrayValue_GetIndexObjPtr ================================== */ public LatexObj arrayValue_GetIndexObjPtr() { return (LatexObj)value2; } /* ==================== arrayValue_SetIndexObjPtr ================================== */ public LatexObj arrayValue_SetIndexObjPtr(LatexObj index_obj_ptr) { //print("arrayValue_SetIndexObjPtr!"+this.mySelf()+"!"); value2 = (Object)index_obj_ptr; return index_obj_ptr; } /* ==================== binaryValue_GetData ================================== */ public Object binaryValue_GetData() { return value1; } /* ==================== binaryValue_SetData ================================== */ public Object binaryValue_SetVarNameObj(Object data) { //print("binaryValue_SetData!"+this.mySelf()+"!"); value1 = data; return data; } /* ==================== binaryValue_GetLen ================================== */ public int binaryValue_GetLen() { return (Integer)value2; } /* ==================== binaryValue_SetLen ================================== */ public int binaryValue_SetLen(int len) { //print("binaryValue_SetLen!"+this.mySelf()+"!"); value2 = (Object)len; return len; } /* ==================== cmdValue_GetEpoch ================================== */ public int cmdValue_GetEpoch() { return (Integer)value1; } /* ==================== cmdValue_SetEpoch ================================== */ public int cmdValue_SetEpoch(int epoch) { //print("cmdValue_SetEpoch!"+this.mySelf()+"!"); value1 = epoch; return epoch; } /* ==================== cmdValue_GetResolvedCmdNamePtr ================================== */ public ResolvedCmdName cmdValue_GetResolvedCmdNamePtr() { return (ResolvedCmdName)value2; } /* ==================== cmdValue_SetResolvedCmdNamePtr ================================== */ public ResolvedCmdName cmdValue_SetResolvedCmdNamePtr(ResolvedCmdName cmd_ptr) { //print("cmdValue_SetResolvedCmdNamePtr!"+this.mySelf()+"!"); value2 = (Object)cmd_ptr; return cmd_ptr; } /* ==================== dictValue_GetHashTable ================================== */ public LinkedHashMap<String, LatexObj> dictValue_GetHashTable() { return (LinkedHashMap<String, LatexObj>)value1; } /* ==================== dictValue_SetHashTable ================================== */ public LinkedHashMap<String, LatexObj> dictValue_SetHashTable(LinkedHashMap<String, LatexObj> hash_table) { //print("dictValue_SetHashTable!"+this.mySelf()+"!"); value1 = (Object)hash_table; return hash_table; } /* ==================== doubleValue_GetValue ================================== */ public double doubleValue_GetValue() { return (Double)value1; } /* ==================== doubleValue_SetValue ================================== */ public double doubleValue_SetValue(double val) { //print("doubleValue_SetValue!"+this.mySelf()+"!"); value1 = (Object)((Double)val); return val; } /* ==================== hashValue_GetValue ================================== */ public Object hashValue_GetValue() { return value1; } /* ==================== hashValue_SetValue ================================== */ public Object hashValue_SetValue(Object val) { //print("hashValue_SetValue!"+this.mySelf()+"!"); value1 = val; return val; } /* ==================== indexValue_GetValue ================================== */ public int indexValue_GetValue() { return (Integer)value1; } /* ==================== indexValue_SetValue ================================== */ public int indexValue_SetValue(int val) { //print("indexValue_SetValue!"+this.mySelf()+"!"); value1 = (Object)val; return val; } /* ==================== itclClassValue_GetClassDef ================================== */ public LatexObj itclClassValue_GetClassDef() { return (LatexObj)value1; } /* ==================== itclClassValue_SetClassDef ================================== */ public LatexObj itclClassValue_SetClassDef(LatexObj class_def) { //print("itclClassValue_SetClassDef!"+this.mySelf()+"!"); value1 = (Object)class_def; return class_def; } /* ==================== itclClassValue_GetClassType ================================== */ public int itclClassValue_GetClassType() { return (Integer)value2; } /* ==================== itclClassValue_SetClassType ================================== */ public int itclClassValue_SetClassType(int class_type) { //print("itclClassValue_SetClassType!"+this.mySelf()+"!"); value2 = (Object)class_type; return class_type; } /* ==================== itclClassValue_GetClassObjects ================================== */ public LatexObj itclClassValue_GetClassObjects() { return (LatexObj)value3; } /* ==================== itclClassValue_SetClassObjects ================================== */ public LatexObj itclClassValue_SetMaxLen(LatexObj class_objects) { //print("itclClassValue_SetClassObjects!"+this.mySelf()+"!"); value3 = (LatexObj)class_objects; return class_objects; } /* ==================== listValue_GetElem ================================== */ public ArrayList<LatexObj> listValue_GetElem() { //print("listValue_GetElem!"+value1+"!"); return (ArrayList<LatexObj>)value1; } /* ==================== listValue_SetElem ================================== */ public ArrayList<LatexObj> listValue_SetElem(ArrayList<LatexObj> elem) { //print("listValue_SetElem!"+this.mySelf()+"!"); value1 = (Object)elem; return elem; } /* ==================== listValue_GetLen ================================== */ public int listValue_GetLen() { return (Integer)value2; } /* ==================== listValue_SetLen ================================== */ public int listValue_SetLen(int len) { //print("listValue_SetLen!"+this.mySelf()+"!"); value2 = (Object)len; return len; } /* ==================== listValue_GetMaxLen ================================== */ public int listValue_GetMaxLen() { return (Integer)value3; } /* ==================== listValue_SetMaxLen ================================== */ public int listValue_SetMaxLen(int max_len) { //print("listValue_SetMaxLength"+this.mySelf()+"!"+max_len+"!"); value3 = (Object)max_len; return max_len; } /* ==================== namespaceValue_GetNamespace ================================== */ public LatexObj namespaceValue_GetNamespace() { return (LatexObj)value1; } /* ==================== namespaceValue_SetNamespace ================================== */ public LatexObj namespaceValue_SetNamespace(LatexObj namespace) { //print("namespaceValue_SetNamespace!"+this.mySelf()+"!"); value1 = (Object)namespace; return namespace; } /* ==================== namespaceValue_GetFullName ================================== */ public String namespaceValue_GetFullName() { return (String)value2; } /* ==================== namespaceValue_SetFullName ================================== */ public String namespaceValue_SetFullName(String full_name) { //print("namespaceValue_SetFullName!"+this.mySelf()+"!"); value2 = (Object)full_name; return full_name; } /* ==================== paramInfoValue_GetParams ================================== */ public FunctionArgList paramInfoValue_GetParams() { return (FunctionArgList)value1; } /* ==================== paramInfoValue_SetParams ================================== */ public FunctionArgList paramInfoValue_SetParams(FunctionArgList params) { //print("paramInfoValue_SetParams!"+this.mySelf()+"!"); value1 = (Object)params; return params; } /* ==================== paramInfoValue_GetOrigParams ================================== */ public FunctionArgList paramInfoValue_GetOrigParams() { return (FunctionArgList)value2; } /* ==================== 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) { //print("refValue_SetRefPtr!"+this.mySelf()+"!"); value1 = (Object)ref_ptr; return ref_ptr; } /* ==================== refValue_GetId ================================== */ public int refValue_GetId() { return (Integer)value2; } /* ==================== refValue_SetId ================================== */ public int refValue_SetId(int id) { //print("refValue_SetID!"+this.mySelf()+"!"); value2 = (Object)id; return id; } /* ==================== regexpValue_GetCompre ================================== */ public Pattern regexpValue_GetCompre() { return (Pattern)value1; } /* ==================== regexpValue_SetCompre ================================== */ public Pattern regexpValue_SetCompre(Pattern compre) { //print("regexpValue_SetCompre!"+this.mySelf()+"!"); value1 = (Object)compre; return compre; } /* ==================== regexpValue_GetFlags ================================== */ public int regexpValue_GetFlags() { return (Integer)value2; } /* ==================== regexpValue_SetFlags ================================== */ public int regexpValue_SetFlags(int flags) { //print("regexpValue_SetFlags!"+this.mySelf()+"!"); value2 = (Object)flags; return flags; } /* ==================== returnCodeValue_GetReturnCode ================================== */ public int returnCodeValue_GetReturnCode() { return (Integer)value1; } /* ==================== returnCodeValue_SetReturnCode ================================== */ public int returnCodeValue_SetReturnCode(int return_code) { //print("returnCodeValue_SetReturnCode!"+this.mySelf()+"!"); value1 = (Object)return_code; return return_code; } /* ==================== scriptLineValue_GetLine ================================== */ public int scriptLineValue_GetLine() { return (Integer)value1; } /* ==================== scriptLineValue_SetLine ================================== */ public int scriptLineValue_SetLine(int val) { //print("scriptLineValue_SetLine!"+this.mySelf()+"!"); value1 = (Object)val; return val; } /* ==================== scriptLineValue_GetArgc ================================== */ public int scriptLineValue_GetArgc() { return (Integer)value2; } /* ==================== scriptLineValue_SetArgc ================================== */ public int scriptLineValue_SetArgc(int val) { //print("scriptLineValue_SetArgc!"+this.mySelf()+"!"); value2 = (Object)val; return val; } /* ==================== scriptValue_GetScript ================================== */ public Script scriptValue_GetScript() { //print("scriptValue_GetScript!"+value1+"!"); return (Script)value1; } /* ==================== scriptValue_SetScript ================================== */ public Script scriptValue_SetScript(Script script) { //print("scriptValue_SetScript!"+this.mySelf()+"!"); value1 = (Object)script; return script; } /* ==================== sourceValue_GetFileNameObj ================================== */ public LatexObj sourceValue_GetFileNameObj() { return (LatexObj)value1; } /* ==================== sourceValue_SetFileNameObj ================================== */ public LatexObj sourceValue_SetFileNameObj(LatexObj file_name_obj) { //print("sourceValue_SetFileNameObj!"+this.mySelf()+"!"); value1 = (Object)file_name_obj; return file_name_obj; } /* ==================== sourceValue_GetLineNumber ================================== */ public int sourceValue_GetLineNumber() { return (Integer)value2; } /* ==================== sourceValue_SetLineNumber ================================== */ public int sourceValue_SetLineNumber(int line_number) { //print("sourceValue_SetLineNumber!"+this.mySelf()+"!"); value2 = (Object)line_number; return line_number; } /* ==================== strValue_GetCharLength ================================== */ public int strValue_GetCharLength() { if (value2 == null) { print("strValue_GetCharLength fix value2!"); value2 = len; } return (Integer)value2; } /* ==================== strValue_SetCharLength ================================== */ public int strValue_SetCharLength(int char_length) { //print("strValue_SetCharLength!"+this.mySelf()+"!"); value2 = (Object)char_length; return char_length; } /* ==================== strValue_GetMaxLength ================================== */ public int strValue_GetMaxLength() { //print("strValue_GetMaxLength!"+value1+"!"); if (value1 == null) { return (Integer)0; } return (Integer)value1; } /* ==================== strValue_SetMaxLength ================================== */ public int strValue_SetMaxLength(int max_length) { //print("strValue_SetMaxLength!"+this.mySelf()+"!"+max_length); value1 = (Object)max_length; return max_length; } /* ==================== twoPtrValue_GetPtr1 ================================== */ public Object twoPtrValue_GetPtr1() { return value1; } /* ==================== twoPtrValue_SetPtr1 ================================== */ public Object twoPtrValue_SetPtr1(Object ptr1) { //print("twoPtrValue_SetPtr1!"+this.mySelf()+"!"); value1 = ptr1; return ptr1; } /* ==================== twoPtrValue_GetPtr2 ================================== */ public Object twoPtrValue_GetPtr2() { return value2; } /* ==================== twoPtrValue_SetPtr2 ================================== */ public Object twoPtrValue_SetPtr2(Object ptr2) { //print("twoPtrValue_SetPtr2!"+this.mySelf()+"!"); value2 = ptr2; return ptr2; } /* ==================== varValue_GetCallFrame ================================== */ public CallFrame varValue_GetCallFrame() { return (CallFrame)value1; } /* ==================== varValue_SetCallFrame ================================== */ public CallFrame varValue_SetCallFrame(CallFrame call_frame) { //print("varValue_SetCallFrame!"+this.mySelf()+"!"); value1 = (Object)call_frame; return call_frame; } /* ==================== varValue_GetNamespace ================================== */ public Namespace varValue_GetNamespace() { return (Namespace)value2; } /* ==================== varValue_SetNamespace ================================== */ public Namespace varValue_SetNamespace(Namespace namespace) { //print("varValue_SetNamespace!"+this.mySelf()+"!"); value2 = (Object)namespace; return namespace; } /* ==================== varValue_GetVarPtr ================================== */ public Variable varValue_GetVarPtr() { return (Variable)value3; } /* ==================== varValue_SetVarPtr ================================== */ public Variable varValue_SetVarPtr(Variable var_ptr) { //print("varValue_SetVarPtr!"+this.mySelf()+"!"); value3 = (Object)var_ptr; return var_ptr; } /* ==================== wideValue_GetValue ================================== */ public long wideValue_GetValue() { return (Long)value1; } /* ==================== wideValue_SetValue ================================== */ public long wideValue_SetValue(long val) { //print("wideValue_SetValue!"+this.mySelf()+"!"); value1 = (Object)val; return val; } /* ==================== updateString ================================== */ public int updateString() { return OK; } /* =========================== newObj ===================================== */ public LatexObj newObj() { LatexObj my_obj_ptr; /* -- Check if there are objects in the free list -- */ if (free_obj_list != null) { /* -- Unlink the object from the free list -- */ my_obj_ptr = free_obj_list; free_obj_list = my_obj_ptr.next_obj_ptr; } else { /* -- No ready to use objects: allocate a new one -- */ my_obj_ptr = new LatexObj(interp); } /* Object is returned with ref_count of 0. Every * kind of GC implemented should take care to don't try * to scan objects with ref_count == 0. */ my_obj_ptr.ref_count = 0; /* All the other fields are left not initialized to save time. * The caller will probably want to set them to the right * value anyway. */ /* -- Put the object into the live list -- */ my_obj_ptr.prev_obj_ptr = null; my_obj_ptr.next_obj_ptr = live_obj_list; if (live_obj_list != null) { live_obj_list.prev_obj_ptr = my_obj_ptr; } live_obj_list = my_obj_ptr; my_obj_ptr.obj_type = 0; my_obj_ptr.bytes = null; return my_obj_ptr; } /* ==================== freeNewObj ===================================== */ public void freeNewObj(String where) { freeObj(where); freed = where; } /* ==================== freeObj ===================================== */ /* Free an Obj. Actually Objs are never freed, but * just moved to the free obj list, where they will be * reused by NewObj(). */ public void freeObj(String where) { //print("freeObj!"+mySelf()+"!"+obj_type+"!"+getString()+"!"); /* Check if the object was already freed, panic. */ panic(ref_count != 0, "!!! "+mySelf()+" freed with bad ref_count "+ref_count+", type="+getObjTypeString(obj_type)+"!"+toDebugString()+"!"); freeIntRep(); /* Free the string representation */ if (bytes != null) { bytes = null; } /* free the values */ value1 = null; value2 = null; value3 = null; /* Unlink the object from the live objects list */ if (prev_obj_ptr != null) { prev_obj_ptr.next_obj_ptr = next_obj_ptr; } if (next_obj_ptr != null) { next_obj_ptr.prev_obj_ptr = prev_obj_ptr; } if (live_obj_list == this) { live_obj_list = next_obj_ptr; } /* Link the object into the free objects list */ prev_obj_ptr = null; next_obj_ptr = free_obj_list; if (free_obj_list != null) { free_obj_list.prev_obj_ptr = this; } free_obj_list = this; ref_count = -1; freed = where; } /* ==================== dumpObjLists ===================================== */ public void dumpObjLists() { LatexObj obj_ptr; print("live_list!"+live_obj_list+"!"); obj_ptr = live_obj_list; while (obj_ptr != null) { print(obj_ptr.toDebugString()); // print(obj_ptr.mySelf()); obj_ptr = obj_ptr.next_obj_ptr; } print("free_list!"+free_obj_list+"!"); obj_ptr = free_obj_list; while (obj_ptr != null) { print(obj_ptr.toDebugString()); // print(obj_ptr.mySelf()); obj_ptr = obj_ptr.next_obj_ptr; } } /* ==================== invalidateStringRep ===================================== */ public void invalidateStringRep() { if (bytes != null) { bytes = null; } } /* ==================== setIntRepPtr ===================================== */ public void setIntRepPtr(Object ptr) { ptrValue_SetPtr(ptr); } /* ==================== freeIntRep ===================================== */ public void freeIntRep() { obj_type_base.callFreeIntRepProc(obj_type, this); } /* ==================== setStringRep ===================================== */ public void setStringRep(LatexObj obj_ptr, String str, int len) { obj_ptr.bytes.append(str); obj_ptr.len = len; } /* ==================== initStringRep ===================================== */ /* Set the initial string representation for an object. */ public void initStringRep(LatexObj obj_ptr, String str, int len) { if (obj_ptr.bytes == null) { obj_ptr.bytes = new StringBuffer(""); } if (str != null) { obj_ptr.bytes.append(str); } obj_ptr.len = len; } /* Xdigitval and Odigitval are helper functions for escapeBackslash() */ /* ==================== xdigitval ===================================== */ public int xdigitval(char ch) { if (ch >= '0' && ch <= '9') { return ch - '0'; } if (ch >= 'a' && ch <= 'f') { return ch - 'a' + 10; } if (ch >= 'A' && ch <= 'F') { return ch - 'A' + 10; } return -1; } /* ==================== odigitval ===================================== */ public int odigitval(char ch) { if (ch >= '0' && ch <= '7') { return ch - '0'; } return -1; } /* ==================== escapeBackslash ================================== */ /* Perform Tcl escape substitution of 's', storing the result * string into 'dest_ptr'. The escaped string is guaranteed to * be the same length or shorted than the source string. * Slen is the length of the string at 's', if it's -1 the string * length will be calculated by the function. * * The function returns the length of the resulting string. */ public int escapeBackslash(ArrayList<String> dest_ptr, String str, int slen) { int i; int len; StringBuffer p = new StringBuffer(""); //print("escapeBackslash!"); if (slen == -1) { slen = str.length(); } for (i = 0; i < slen; i++) { switch (str.charAt(i)) { case '\\': switch (str.charAt(i + 1)) { case 'b': p.append('\b'); i++; break; case 'f': p.append('\f'); i++; break; case 'n': p.append('\n'); i++; break; case 'r': p.append('\r'); i++; break; case 't': p.append('\t'); i++; break; case 'u': case 'x': /* A unicode or hex sequence. * \u1111 Expect 1-4 hex chars and convert to utf-8. * \x Expect 1-2 hex chars and convert to hex. * An invalid sequence means simply the escaped char. */ int val = 0; int k; i++; for (k = 0; k < (str.charAt(i) == 'u' ? 4 : 2); k++) { int c = xdigitval(str.charAt(i + k + 1)); if (c == -1) { break; } val = (val << 4) | c; } if (k > 0) { /* Got a valid sequence, so convert */ if (str.charAt(i) == 'u') { // p.append(utf8_fromunicode(p, val)); } else { p.append(val); } i += k; break; } /* Not a valid codepoint, just an escaped char */ p.append(str.charAt(i)); break; case 'v': p.append(0xb); i++; break; case '\n': /* Replace all spaces and tabs after backslash newline with a single space*/ p.append(" "); do { i++; } while (str.charAt(i) == ' ' || str.charAt(i) == '\t'); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': /* octal escape */ val = 0; int c = odigitval(str.charAt(i + 1)); val = c; c = odigitval(str.charAt(i + 2)); if (c == -1) { p.append(val); i++; break; } val = (val * 8) + c; // c = odigitval(str, i + 3); if (c == -1) { p.append(val); i += 2; break; } val = (val * 8) + c; p.append(val); i += 3; break; default: p.append(str.charAt(i + 1)); i++; break; } break; default: p.append(str.charAt(i)); break; } } len = p.length(); dest_ptr.add(p.toString()); return len; } /* ==================== isShared ================================== */ public boolean isShared() { return (ref_count > 1); } /* ==================== isListObj ================================== */ public boolean isListObj() { return (obj_type == OBJ_TYPE_LIST); } /* ==================== getIntRepPtr ================================== */ public Object getIntRepPtr() { return ptrValue_GetPtr(); } /* ==================== incrRefCount ================================== */ public int incrRefCount(String where) { ref_count++; if (check_allocate) { incr_lst.add(where); } return ref_count; } /* ==================== decrRefCount ================================== */ public int decrRefCount(String where) { ref_count--; if (check_allocate) { decr_lst.add(where); } if (ref_count <= 0) { freeObj(where); } return ref_count; } /* ==================== getString ===================================== */ public String getString() { if (bytes == null) { /* Invalid string repr. Generate it. */ if (obj_type == 0) { print("obj!"+toDebugString()+"!"); } if (!obj_type_base.haveUpdateString(obj_type)) { print("obj!"+toDebugString()+"!"); } panic(obj_type == 0, "UpdateStringProc called against '<none>' type."+mySelf()+"!"); panic(!obj_type_base.haveUpdateString(obj_type), "UpdateString called against '"+getObjTypeString(obj_type)+"' type."+mySelf()+"!"); obj_type_base.callUpdateString(obj_type, this); } if (bytes == null) { strValue_SetCharLength(0); strValue_SetMaxLength(0); return ""; } // strValue_SetCharLength(len); // strValue_SetMaxLength(len); return bytes.substring(0, len); } /* ==================== getStringLength ===================================== */ public int getStringLength() { if (bytes == null) { /* Invalid string repr. Generate it. */ panic(obj_type == 0, "UpdateStringProc called against '<none>' type."+mySelf()+"!"); panic(!obj_type_base.haveUpdateString(obj_type), "UpdateString called against '"+getObjTypeString(obj_type)+"' type."); obj_type_base.callUpdateString(obj_type, this); } return len; } /* ==================== getStringFromArray ===================================== */ public String getStringFromArray(ArrayList<LatexObj> list, int nested) { ArrayList<String> res = new ArrayList<String>(); String str; for (int i = 0; i < list.size(); i++) { str = list.get(i).getString(); if (isList(str) && !isNested(str)) { res.add("{"+str+"}"); } else { if (str.equals("")) { res.add("{}"); } else { res.add(str); } } } if (res.size() == 1) { return res.get(0); } StringBuilder sb = new StringBuilder(); for (String s : res){ sb.append(s); sb.append(" "); } return sb.toString(); } /* ==================== findHashEntry ===================================== */ public LatexObj findHashEntry(HashMap<String, LatexObj> hash_table, String key) { return hash_table.get(key); } /* ==================== deleteHashEntry ===================================== */ public int deleteHashEntry(HashMap<String, LatexObj> hash_table, String key) { if (hash_table.get(key) == null) { return ERROR; } hash_table.remove(key); return OK; } /* ==================== addHashEntry ===================================== */ public int addHashEntry(HashMap<String, LatexObj> hash_table, String key, LatexObj val) { /* Check if the new element already exists. */ if (hash_table.get(key) != null) { return ERROR; } /* stores key */ hash_table.put(key, val); return OK; } /* ==================== concatObj ===================================== */ public LatexObj concatObj(int objc, ArrayList<LatexObj> objv) { int i; /* If all the objects in objv are lists, * it's possible to return a list as result, that's the * concatenation of all the lists. */ for (i = 0; i < objc; i++) { if (!objv.get(i).isListObj()) { break; } } if (i == objc) { LatexObj obj_ptr = interp.list_obj_type.newListObj(null, 0); for (i = 0; i < objc; i++) { interp.list_obj_type.listAppendList(obj_ptr, objv.get(i)); } return obj_ptr; } else { /* Else... we have to glue strings together */ int len = 0; int obj_len; StringBuffer p; /* Compute the length */ for (i = 0; i < objc; i++) { len += objv.get(i).getStringLength(); } if (objc > 0) { len += objc - 1; } /* Create the string rep, and a string object holding it. */ p = new StringBuffer(""); for (i = 0; i < objc; i++) { String s = objv.get(i).getString(); int j = 0; obj_len = objv.get(i).getStringLength(); /* Remove leading space */ while (obj_len > 0 && (s.charAt(j) == ' ' || s.charAt(j) == '\t' || s.charAt(j) == '\n')) { j++; obj_len--; len--; } /* And trailing space */ while (obj_len > 0 && (s.charAt(obj_len - 1) == ' ' || s.charAt(obj_len - 1) == '\n' || s.charAt(obj_len - 1) == '\t')) { /* Handle trailing backslash-space case */ if (obj_len > 1 && s.charAt(obj_len - 2) == '\\') { break; } obj_len--; len--; } p.append(s.substring(j, obj_len)); j += obj_len; if (obj_len != 0 && i + 1 != objc) { p.append(" "); } else { if (i + 1 != objc) { /* Drop the space calcuated for this * element that is instead null. */ len--; } } } return interp.string_obj_type.newStringObjNoAlloc(p.toString(), len, "OBJ_1"); } } /* ==================== duplicateObj ===================================== */ public LatexObj duplicateObj() { LatexObj dup_ptr; dup_ptr = newObj(); if (bytes == null) { /* Object does not have a valid string representation. */ dup_ptr.bytes = null; } else { initStringRep(dup_ptr, (String)(bytes == null ? bytes : bytes.toString()), len); } /* By default, the new object has the same type as the old object */ dup_ptr.obj_type = obj_type; if (obj_type > 0) { if (!obj_type_base.haveDupInternalRep(obj_type)) { dup_ptr.value1 = value1; dup_ptr.value2 = value2; dup_ptr.value3 = value3; } else { /* The dup proc may set a different type, e.g. null */ obj_type_base.callDupInternalRep(obj_type, this, dup_ptr); } } return dup_ptr; } /* ==================== utf8_tounicode_case ===================================== */ public int utf8_tounicode_case(char ch, ArrayList<Character> result_ch, int upper) { /* this is just a dummy right now, real utf8 support is missing !! */ ArrayList<Character> res_ch_ptr = new ArrayList<Character>(); int l = utf8_tounicode(ch, res_ch_ptr); Character res_ch = res_ch_ptr.get(0); if (upper != 0) { result_ch.add(Character.toUpperCase(res_ch)); } else { result_ch.add(res_ch); } return l; } /* ==================== utf8_tounicode ===================================== */ public int utf8_tounicode(char ch, ArrayList<Character>result_ch) { /* String s = str; if (s.charCodeAt(0) < 0xc0) { result_ch.add(s.charAt(0)); return 1; } if (s.charCodeAt(0) < 0xe0) { if ((s.charCodeAt(1) & 0xc0) == 0x80) { result_ch[0] = string.fromCharCode(((s.charCodeAt(0) & ~0xc0) << 6) | (s.charCodeAt(1) & ~0x80)); return 2; } } else { if (s.charCodeAt(0) < 0xf0) { if (((str.charCodeAt(1) & 0xc0) == 0x80) && ((strcharCodeAt(2) & 0xc0) == 0x80)) { result_ch[0] = string.fromCharCode(((s.charCodeAt(0) & ~0xe0) << 12) | ((s.charCodeAt(1) & ~0x80) << 6) | (s.charCodeAt(2) & ~0x80)); return 3; } } } /* Invalid sequence, so just return the byte */ /* this is just a dummy right now, real utf8 support is missing !! */ result_ch.add(ch); return 1; /* this is just a dummy right now, real utf8 support is missing !! */ // result_ch[0] = str.charAt(0); // return 1; } /* ==================== utf8_tounicode ===================================== */ public int utf8_tounicode(String str, ArrayList<Character>result_ch) { String s = str; if (s.charAt(0) < 0xc0) { result_ch.add(s.charAt(0)); return 1; } if (s.charAt(0) < 0xe0) { if ((s.charAt(1) & 0xc0) == 0x80) { result_ch.set(0, (char)(((s.charAt(0) & ~0xc0) << 6) | (s.charAt(1) & ~0x80))); return 2; } } else { if (s.charAt(0) < 0xf0) { if (((str.charAt(1) & 0xc0) == 0x80) && ((str.charAt(2) & 0xc0) == 0x80)) { result_ch.set(0, (char)(((s.charAt(0) & ~0xe0) << 12) | ((s.charAt(1) & ~0x80) << 6) | (s.charAt(2) & ~0x80))); return 3; } } } /* Invalid sequence, so just return the byte */ result_ch.add(0, s.charAt(0)); return 1; } /* ==================== utf8_memchr ===================================== */ public int utf8_memchr(String str, int len, char ch) { /* need code for UTF8! */ /* now it's without that */ return str.indexOf(ch); } /* ==================== utf8_prev_len ===================================== */ public int utf8_prev_len(String str, int len) { int n = 1; /* Look up to len chars backward for a start-of-char byte */ // while (--len) { // if ((str.chatAt(len) & 0x80) == 0) { // /* Start of a 1-byte char */ // break; // } // if ((str.charAt(len) & 0xc0) == 0xc0) { // /* Start of a multi-byte char */ // break; // } // n++; // } return n; } /* ==================== utf8_length ===================================== */ public int utf8_length(LatexObj obj_ptr) { /* no utf8 support yet !! */ return obj_ptr.getStringLength(); } /* ==================== utf8_index ===================================== */ public int utf8_index(String str, int index) { int idx = 0; while (index-- > 0) { ArrayList<Character> c_ptr = new ArrayList<Character>(); idx += utf8_tounicode(str.substring(idx), c_ptr); } return idx; } /* ==================== globMatch ===================================== */ public int globMatch(String pattern, String str, int nocase) { ArrayList<Character> c = new ArrayList<Character>(); ArrayList<Character> pchar = new ArrayList<Character>(); int i = 0; int j = 0; //print("gM 1!"+pattern+"!"+str+"!"+nocase+"!"+pattern.length()+"!"); while (i < pattern.length()) { switch (pattern.charAt(i)) { case '*': //print("gM 2!"+i+"!"+pattern.length()+"!"); i++; while (i < pattern.length() && pattern.charAt(i) == '*') { i++; } // if (pattern.charAt(i) == '\0' || i >= pattern.length()) if (i >= pattern.length()) { return 1; /* match */ } pattern = pattern.substring(i); i = 0; while (str.length() > j) { /* Recursive call - Does the remaining pattern match anywhere? */ if (globMatch(pattern.substring(i), str.substring(j), nocase) == 1) { return 1; /* match */ } j += utf8_tounicode(str.charAt(j), c); } return 0; /* no match */ case '?': //print("?!"+j+"!"); j += utf8_tounicode(str.charAt(j), c); //print("?i2!"+j+"!"); break; case '[': j += utf8_tounicode(str.charAt(j), c); // pattern = JimCharsetMatch(pattern + 1, c, nocase != 0 ? NOCASE : 0); if (pattern != "") { return 0; } if (pattern.length() <= i) { /* Ran out of pattern (no ']') */ continue; } break; case '\\': if (pattern.length() < i) { i++; } /* fall through */ default: //print("gM 3!"); c = new ArrayList<Character>(); pchar = new ArrayList<Character>(); int k = utf8_tounicode_case(str.charAt(j), c, nocase); str = str.substring(k); utf8_tounicode_case(pattern.charAt(i), pchar, nocase); if (pchar.get(0) != c.get(0)) { return 0; } break; } //print("gM 4!"+i+"!"); i += utf8_tounicode_case(pattern.charAt(0), pchar, nocase); //print("gM 5!"+i+"!"+j+"!"+str.length()+"!"); if (str.length() <= j) { while (i < str.length() && pattern.charAt(i) == '*') { i++; } break; } //print("gM 6!"+i+"!"); } //print("gM 7!"+i+"!"); if (pattern.length() <= i && str.length() <= j) { return 1; } return 0; } /* ==================== stringMatch ===================================== */ public int stringMatch(String str, int nocase) { return globMatch(getString(), str, nocase); } /* ==================== stringMatchObj ===================================== */ public int stringMatchObj(LatexObj obj_ptr, int nocase) { return stringMatch(obj_ptr.getString(), nocase); } /* ==================== getSign ===================================== */ public int getSign(long wide_value) { if (wide_value == 0) { return 0; } else { if (wide_value < 0) { return -1; } return 1; } } /* ==================== stringCompareNoCase ===================================== */ /* * No-case version. * * If maxchars is -1, compares to end of string. * Otherwise compares at most 'max_chars' characters. */ public int stringCompareNoCase(String s1, String s2, int max_chars) { int idx1 = 0; int idx2 = 0; //print("stringCompareNoCase"); while (idx1 < s1.length() && idx2 < s2.length() && max_chars != 0) { ArrayList<Character> c1_ptr = new ArrayList<Character>(); ArrayList<Character> c2_ptr = new ArrayList<Character>(); idx1 += utf8_tounicode_case(s1.charAt(idx1), c1_ptr, 1); idx2 += utf8_tounicode_case(s2.charAt(idx2), c2_ptr, 1); //print("idx1!"+idx1+"!"+idx2+"!"+c1_ptr.get(0)+"!"+c2_ptr.get(0)+"!"); if (c1_ptr.get(0) != c2_ptr.get(0)) { char c1 = c1_ptr.get(0); char c2 = c2_ptr.get(0); return getSign(c1 - c2); } max_chars--; } if (max_chars != 0) { return 0; } /* One string or both terminated */ if (idx1 < s1.length()) { return 1; } if (idx2 < s2.length()) { return -1; } return 0; } /* ==================== stringCompare ===================================== */ public int stringCompare(String s1, int l1, String s2, int l2) { int idx1 = 0; int idx2 = 0; //print("stringCompare!"+s1+"!"+l1+"!"+s2+"!"+l2+"!"); while (idx1 < l1 && idx2 < l2) { ArrayList<Character> c1_ptr = new ArrayList<Character>(); ArrayList<Character> c2_ptr = new ArrayList<Character>(); idx1 += utf8_tounicode_case(s1.charAt(idx1), c1_ptr, 1); idx2 += utf8_tounicode_case(s2.charAt(idx2), c2_ptr, 1); if (c1_ptr.get(0) != c2_ptr.get(0)) { char c1 = c1_ptr.get(0); char c2 = c2_ptr.get(0); return getSign(c1 - c2); } } /* One string or both terminated */ if (idx1 < l1) { return 1; } if (idx2 < l2) { return -1; } return 0; } /* ==================== stringCompareObj ===================================== */ public int stringCompareObj(LatexObj second_obj_ptr, int nocase) { LatexObj first_obj_ptr = this; String s1; String s2; int l1; int l2; s1 = first_obj_ptr.getString(); l1 = first_obj_ptr.getStringLength(); s2 = second_obj_ptr.getString(); l2 = second_obj_ptr.getStringLength(); if (nocase != 0) { return stringCompareNoCase(s1, s2, -1); } return stringCompare(s1, l1, s2, l2); } /* ==================== stringEqObj ===================================== */ public boolean stringEqObj(LatexObj second_obj_ptr) { String a_str; String b_str; int a_len; int b_len; if (this == second_obj_ptr) { return true; } a_str = getString(); a_len = getStringLength(); b_str = second_obj_ptr.getString(); b_len = second_obj_ptr.getStringLength(); if (a_len != b_len) { return false; } return (a_str.equals(b_str)); } } } |