Changeset 3953 for trunk/tools/database/www/cvs.php3
- Timestamp:
- Aug 6, 2000, 7:12:35 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/www/cvs.php3
r3952 r3953 8 8 $sCVSROOT = "."; 9 9 $sCVSROOT = "d:/odin32/cvs/cvsroot"; 10 $sCVSROOT = "g:/cvsroot"; 10 11 11 12 … … 96 97 * Parse the file. 97 98 */ 99 $Timer = Odin32DBTimerStart("CVS Parse"); 98 100 $this->fOk = $this->ParseFile2($hFile, 0);// $fNoDeltas); 101 Odin32DBTimerStop($Timer); 99 102 100 103 fclose($hFile); … … 289 292 if ($sRev == "") 290 293 { /* Base keys */ 291 if (sizeof($this->aa Keys) <= 0 //sanity check! head must come first and have a value!294 if (sizeof($this->aasKeys) <= 0 //sanity check! head must come first and have a value! 292 295 && ($sKey != "head" || sizeof($asValue) <= 0 || $asValue[0] == "")) 293 296 { … … 498 501 if ($sRev == "") 499 502 { /* Base keys */ 500 if (sizeof($this->aa Keys) <= 0 //sanity check! head must come first and have a value!503 if (sizeof($this->aasKeys) <= 0 //sanity check! head must come first and have a value! 501 504 && ($sKey != "head" || sizeof($asValue) <= 0 || $asValue[0] == "")) 502 505 { 503 506 $this->sError = "Invalid file format."; 504 507 fclose($hFile); 505 return 1;508 return 0; 506 509 } 507 510 $this->aasKeys[$sKey] = $asValue; … … 611 614 * Initiate the color encoder. 612 615 */ 613 switch ( $this->sExt)616 switch (strtolower($this->sExt)) 614 617 { 615 618 case 'c': … … 621 624 $iColorEncoder = 1; 622 625 break; 626 627 case 'asm': 628 case 'inc': 629 case 's': 630 ASM_ColorInit($aVariables); 631 $iColorEncoder = 2; 632 break; 633 634 case 'mk': 635 case 'mak': 636 Make_ColorInit($aVariables); 637 $iColorEncoder = 3; 638 break; 639 623 640 default: 641 if (strtolower($this->sName) == "makefile"); 642 { 643 Make_ColorInit($aVariables); 644 $iColorEncoder = 3; 645 break; 646 } 624 647 $iColorEncoder = 0; 625 648 } … … 630 653 * Write it! 631 654 */ 655 $Timer = Odin32DBTimerStart("Write timer"); 632 656 echo "<table><tr><td bgcolor=#020286><pre><font size=-0 face=\"System VIO, System Monospaced\" color=#02FEFE>\n"; 633 657 … … 639 663 * Preprocessing... Color coding 640 664 */ 665 echo "<a name=$iLine>"; 641 666 switch ($iColorEncoder) 642 667 { 643 668 case 1: 644 echo "<a name=$iLine>"; 645 echo C_ColorEncode(htmlspecialchars($this->aasDeltas[$sRevision][$iLine]), $aVariables); 646 //C_ColorEncode2(htmlspecialchars($this->aasDeltas[$sRevision][$iLine]), $aVariables); 647 echo "</a>"; 669 echo str_replace("\t", " ", C_ColorEncode(htmlspecialchars($this->aasDeltas[$sRevision][$iLine]), $aVariables)); 648 670 break; 649 671 case 2: 672 echo str_replace("\t", " ", ASM_ColorEncode(htmlspecialchars($this->aasDeltas[$sRevision][$iLine]), $aVariables)); 673 break; 674 case 3: 675 echo str_replace("\t", " ", Make_ColorEncode(htmlspecialchars($this->aasDeltas[$sRevision][$iLine]), $aVariables)); 676 break; 650 677 default: 651 echo "<a name=$iLine>",htmlspecialchars($this->aasDeltas[$sRevision][$iLine]),"</a>"; 652 } 653 } 654 655 echo "</pre></td></tr></table>\n"; 678 echo htmlspecialchars($this->aasDeltas[$sRevision][$iLine]); 679 } 680 echo "</a>"; 681 } 682 683 echo " \n", //80-columns line 684 "</pre></td></tr></table>\n"; 685 Odin32DBTimerStop($Timer); 656 686 657 687 return 1; … … 792 822 } 793 823 824 /** 825 * Get the workfile extention. 826 * @returns The workfile extention (without '.'). 827 */ 828 function getWorkfileExt() 829 { 830 return $this->sExt; 831 } 832 833 834 /** 835 * Get the workfile extention. 836 * @returns The workfile name (with extention) 837 */ 838 function getWorkfileName() 839 { 840 return $this->sName; 841 } 842 843 /** 844 * Is this a binary file? We'll simply check for the expand keyword. 845 * @returns True (1) if binary, false (0) if not. 846 */ 847 function isBinary() 848 { 849 return isset($this->aasKeys["expand"]); 850 } 794 851 } 795 852 … … 862 919 * Get CVS data. 863 920 */ 921 $aExtIcons = array( 922 "c" => "c.gif", 923 "cpp" => "c.gif", 924 "cxx" => "c.gif", 925 "h" => "c.gif", 926 "hpp" => "c.gif", 927 "c" => "c.gif", 928 /* these are caught by the isBinary test. 929 "exe" => "binary.gif", 930 "dll" => "binary.gif", 931 "lib" => "binary.gif", 932 "obj" => "binary.gif", 933 "a" => "binary.gif", 934 */ 935 "bmp" => "image1.gif", 936 "gif" => "image1.gif", 937 "ico" => "image1.gif", 938 "jpg" => "image1.gif", 939 "pal" => "image1.gif", 940 "png" => "image1.gif", 941 "asm" => "text.gif", 942 "def" => "text.gif", 943 "doc" => "text.gif", 944 "inc" => "text.gif", 945 "lib" => "text.gif", 946 "mak" => "text.gif", 947 "mk" => "text.gif", 948 "txt" => "text.gif", 949 "" => "text.gif", 950 "bat" => "script.gif", 951 "cmd" => "script.gif", 952 "perl" => "script.gif", 953 "sh" => "script.gif" 954 ); 864 955 $cvstimer = Odin32DBTimerStart("Get CVS Data"); 865 956 $asRev = array(); … … 867 958 $asAuthor = array(); 868 959 $asLog = array(); 960 $asIcon = array(); 869 961 for ($i = 0; list($sKey, $sFile) = each($asFiles); $i++) 870 962 { … … 888 980 $asLog[$sFile] = $sLog; 889 981 $sLog = ""; 982 $asIcon[$sFile] = isset($aExtIcons[strtolower($obj->getWorkfileExt())]) 983 ? $aExtIcons[strtolower($obj->getWorkfileExt())] : 984 ($obj->isBinary() ? "binary.gif" : "unknown.gif"); 890 985 } 891 986 else … … 913 1008 * Present data 914 1009 */ 915 $aColumnColors = array("# cccccc","#cccccc","#cccccc","#cccccc", "#88ff88","#cccccc","#cccccc","#cccccc","#cccccc");1010 $aColumnColors = array("#d0dce0","#d0dce0","#d0dce0","#d0dce0", "#d0dcff","#d0dce0","#d0dce0","#d0dce0","#d0dce0"); 916 1011 echo "<table border=0 width=100% cellspacing=1 cellpadding=2>\n", 917 1012 " <hr NOSHADE>\n", … … 926 1021 if ($sDir != "." && $sDir != "") 927 1022 { 928 if (($j = strrpos($sDir, '/')) > 0)929 $sParentDir = substr($sDir, 0, $j - 1);1023 if (($j = strrpos($sDir, "/")) > 0) 1024 $sParentDir = substr($sDir, 0, $j); 930 1025 else 931 $sParentDir = " ";932 $sBgColor = ($i++ % 2) ? "" : " bgcolor=# ccccee";1026 $sParentDir = "."; 1027 $sBgColor = ($i++ % 2) ? "" : " bgcolor=#f0f0f0"; 933 1028 echo "<tr>\n", 934 1029 " <td", $sBgColor , ">", 935 "<font size=-1><a href=\"cvs.phtml?sDir=",$sParentDir,"\"><img src=\" cvsicons/parent.gif\" border=0> Parent Directory</a></font></td>\n",1030 "<font size=-1><a href=\"cvs.phtml?sDir=",$sParentDir,"\"><img src=\"/icons/back.gif\" border=0> Parent Directory</a></font></td>\n", 936 1031 " <td$sBgColor> </td>\n", 937 1032 " <td$sBgColor> </td>\n", … … 942 1037 while (list($sKey, $sVal) = each($asSubDirs)) 943 1038 { 944 $sBgColor = ($i++ % 2) ? "" : " bgcolor=# ccccee";1039 $sBgColor = ($i++ % 2) ? "" : " bgcolor=#f0f0f0"; 945 1040 echo "<tr>\n", 946 " <td$sBgColor><font size=-1><a href=\"cvs.phtml?sDir=$sDir/$sVal\"><img src=\" cvsicons/dir.gif\" border=0> $sVal</a></font></td>\n",1041 " <td$sBgColor><font size=-1><a href=\"cvs.phtml?sDir=$sDir/$sVal\"><img src=\"/icons/dir.gif\" border=0> $sVal</a></font></td>\n", 947 1042 " <td$sBgColor> </td>\n", 948 1043 " <td$sBgColor> </td>\n", … … 955 1050 while (list($sKey, $sVal) = each($asSorted)) 956 1051 { 957 $sBgColor = ($i++ % 2) ? "" : " bgcolor=# ccccee";1052 $sBgColor = ($i++ % 2) ? "" : " bgcolor=#f0f0f0"; 958 1053 $sRev = isset($asRev[$sKey]) ? $asRev[$sKey] : "<i> error </i>"; 959 1054 $sAge = isset($asAge[$sKey]) ? $asAge[$sKey] : "<i> error </i>"; 960 1055 $sAuthor= isset($asAuthor[$sKey])?$asAuthor[$sKey] : "<i> error </i>"; 961 $sLog = isset($asLog[$sKey]) ?$asLog[$sKey] : "<i> error </i>"; 1056 $sLog = isset($asLog[$sKey]) ? $asLog[$sKey] : "<i> error </i>"; 1057 $sIcon = isset($asIcon[$sKey]) ? $asIcon[$sKey] : "<i> error </i>"; 962 1058 echo "<tr>\n", 963 " <td$sBgColor><font size=-1><a href=\"cvs.phtml?sFile=$sDir/$sKey\"><img src=\" cvsicons/file.gif\" border=0>",substr($sKey, 0, -2),"</a></font></td>\n",964 " <td$sBgColor><font size=- 2><a href=\"cvs.phtml?sFile=$sDir/$sKey?sRev=$sRev\">$sRev</a></font></td>\n",965 " <td$sBgColor><font size=- 2>$sAge</font></td>\n",966 " <td$sBgColor><font size=- 2>$sAuthor</font></td>\n",1059 " <td$sBgColor><font size=-1><a href=\"cvs.phtml?sFile=$sDir/$sKey\"><img src=\"/icons/$sIcon\" border=0>",substr($sKey, 0, -2),"</a></font></td>\n", 1060 " <td$sBgColor><font size=-1><a href=\"cvs.phtml?sFile=$sDir/$sKey?sRev=$sRev\">$sRev</a></font></td>\n", 1061 " <td$sBgColor><font size=-1>$sAge</font></td>\n", 1062 " <td$sBgColor><font size=-1>$sAuthor</font></td>\n", 967 1063 " <td$sBgColor><font size=-2>$sLog</font></td>\n", 968 1064 "</tr>\n"; … … 1253 1349 { 1254 1350 $j = $i + 1; 1255 while ($j < $cchLine && ($sLine[$j] == ' ' || $sLine[$j] == '\t'))1351 while ($j < $cchLine && ($sLine[$j] == " " || $sLine[$j] == "\t")) 1256 1352 $j++; 1257 1353 $j += C_WordLen($sLine, $cchLine, $j); … … 1265 1361 * If non-blank, lets check if we're at the start of a word... 1266 1362 */ 1267 $fBlank = ($ch == ' ' || $ch == '\t'); //TODO more "blanks"?1363 $fBlank = ($ch == " " || $ch == "\t" || $ch == "\n"); 1268 1364 if ($fFirstNonBlank) $fFirstNonBlank = $fBlank; 1269 1365 $cchWord = !$fBlank ? C_WordLen($sLine, $cchLine, $i) : 0; … … 1274 1370 * Check for keyword or number. 1275 1371 */ 1276 if ( $cchWord > 0 && (isset($aC_Keywords[substr($sLine, $i, $cchWord)]) || ($ch >= '0' && $ch <= '9')))1372 if (isset($aC_Keywords[substr($sLine, $i, $cchWord)]) || ($ch >= '0' && $ch <= '9')) 1277 1373 $sRet .= "<font color=#FF0202>" . substr($sLine, $i, $cchWord) . "</font>"; 1278 1374 … … 1432 1528 { 1433 1529 $j = $i + 1; 1434 while ($j < $cchLine && ($sLine[$j] == ' ' || $sLine[$j] == '\t'))1530 while ($j < $cchLine && ($sLine[$j] == ' ' || $sLine[$j] == "\t")) 1435 1531 $j++; 1436 1532 $j += C_WordLen($sLine, $cchLine, $j); … … 1444 1540 * If non-blank, lets check if we're at the start of a word... 1445 1541 */ 1446 $fBlank = ($ch == ' ' || $ch == '\t'); //TODO more "blanks"?1542 $fBlank = ($ch == ' ' || $ch == "\t"); //TODO more "blanks"? 1447 1543 if ($fFirstNonBlank) $fFirstNonBlank = $fBlank; 1448 1544 $cchWord = !$fBlank ? C_WordLen($sLine, $cchLine, $i) : 0; … … 1453 1549 * Check for keyword or number. 1454 1550 */ 1455 if ( $cchWord > 0 && (isset($aC_Keywords[substr($sLine, $i, $cchWord)]) || ($ch >= '0' && $ch <= '9')))1551 if (isset($aC_Keywords[substr($sLine, $i, $cchWord)]) || ($ch >= '0' && $ch <= '9')) 1456 1552 echo "<font color=#FF0202>" . substr($sLine, $i, $cchWord) . "</font>"; 1457 1553 … … 1472 1568 if ($ch == '&') 1473 1569 { 1474 /*1475 while ($cchWord < 8 && $sLine[$i+$cchWord] != ';' &&1476 ( ($sLine[$i+$cchWord] >= 'a' && $sLine[$i+$cchWord] <= 'z')1477 || ($sLine[$i+$cchWord] >= 'A' && $sLine[$i+$cchWord] <= 'Z')1478 )1479 )1480 $cchWord++;1481 1482 if ($sLine[$i + $cchWord++] != ';')1483 $cchWord = 1;1484 */1485 1570 if (substr($sLine, $i, 5) == "&") 1486 1571 $cchWord = 5; … … 1554 1639 } 1555 1640 1641 1642 /* 1643 * 1644 */ 1645 1646 /* 1647 * ASM color encoding. 1648 */ 1649 $aASM_Keywords = array( 1650 "aaa" => 1, 1651 "aad" => 1, 1652 "aam" => 1, 1653 "aas" => 1, 1654 "adc" => 1, 1655 "add" => 1, 1656 "and" => 1, 1657 "arpl" => 1, 1658 "bound" => 1, 1659 "bsf" => 1, 1660 "bsr" => 1, 1661 "bswap" => 1, 1662 "bt" => 1, 1663 "btc" => 1, 1664 "btr" => 1, 1665 "bts" => 1, 1666 "call" => 1, 1667 "cbw" => 1, 1668 "cdq" => 1, 1669 "clc" => 1, 1670 "cld" => 1, 1671 "cli" => 1, 1672 "clts" => 1, 1673 "cmc" => 1, 1674 "cmp" => 1, 1675 "cmps" => 1, 1676 "cmpxchg" => 1, 1677 "cwd" => 1, 1678 "cwde" => 1, 1679 "daa" => 1, 1680 "das" => 1, 1681 "dec" => 1, 1682 "div" => 1, 1683 "enter" => 1, 1684 "hlt" => 1, 1685 "idiv" => 1, 1686 "imul" => 1, 1687 "in" => 1, 1688 "inc" => 1, 1689 "ins" => 1, 1690 "int" => 1, 1691 "into" => 1, 1692 "invd" => 1, 1693 "invlpg" => 1, 1694 "iret" => 1, 1695 "ja" => 1, 1696 "jae" => 1, 1697 "jb" => 1, 1698 "jbe" => 1, 1699 "jc" => 1, 1700 "jcxz" => 1, 1701 "jecxz" => 1, 1702 "je" => 1, 1703 "jg" => 1, 1704 "jge" => 1, 1705 "jl" => 1, 1706 "jle" => 1, 1707 "jna" => 1, 1708 "jnae" => 1, 1709 "jnb" => 1, 1710 "jnbe" => 1, 1711 "jnc" => 1, 1712 "jne" => 1, 1713 "jng" => 1, 1714 "jnge" => 1, 1715 "jnl" => 1, 1716 "jnle" => 1, 1717 "jno" => 1, 1718 "jnp" => 1, 1719 "jns" => 1, 1720 "jnz" => 1, 1721 "jo" => 1, 1722 "jp" => 1, 1723 "jpe" => 1, 1724 "jpo" => 1, 1725 "js" => 1, 1726 "jz" => 1, 1727 "jmp" => 1, 1728 "lahf" => 1, 1729 "lar" => 1, 1730 "lea" => 1, 1731 "leave" => 1, 1732 "lgdt" => 1, 1733 "lidt" => 1, 1734 "lldt" => 1, 1735 "lmsw" => 1, 1736 "lock" => 1, 1737 "lods" => 1, 1738 "loop" => 1, 1739 "loopz" => 1, 1740 "loopnz" => 1, 1741 "loope" => 1, 1742 "loopne" => 1, 1743 "lds" => 1, 1744 "les" => 1, 1745 "lfs" => 1, 1746 "lgs" => 1, 1747 "lss" => 1, 1748 "lsl" => 1, 1749 "ltr" => 1, 1750 "mov" => 1, 1751 "movs" => 1, 1752 "movsx" => 1, 1753 "movzx" => 1, 1754 "mul" => 1, 1755 "neg" => 1, 1756 "nop" => 1, 1757 "not" => 1, 1758 "or" => 1, 1759 "out" => 1, 1760 "outs" => 1, 1761 "pop" => 1, 1762 "popa" => 1, 1763 "popad" => 1, 1764 "popf" => 1, 1765 "popfd" => 1, 1766 "push" => 1, 1767 "pusha" => 1, 1768 "pushad" => 1, 1769 "pushf" => 1, 1770 "pushfd" => 1, 1771 "rcl" => 1, 1772 "rcr" => 1, 1773 "rep" => 1, 1774 "ret" => 1, 1775 "retf" => 1, 1776 "rol" => 1, 1777 "ror" => 1, 1778 "sahf" => 1, 1779 "sal" => 1, 1780 "sar" => 1, 1781 "sbb" => 1, 1782 "scas" => 1, 1783 "seta" => 1, 1784 "setae" => 1, 1785 "setb" => 1, 1786 "setbe" => 1, 1787 "setc" => 1, 1788 "sete" => 1, 1789 "setg" => 1, 1790 "setge" => 1, 1791 "setl" => 1, 1792 "setle" => 1, 1793 "setna" => 1, 1794 "setnae" => 1, 1795 "setnb" => 1, 1796 "setnbe" => 1, 1797 "setnc" => 1, 1798 "setne" => 1, 1799 "setng" => 1, 1800 "setnge" => 1, 1801 "setnl" => 1, 1802 "setnle" => 1, 1803 "setno" => 1, 1804 "setnp" => 1, 1805 "setns" => 1, 1806 "setnz" => 1, 1807 "seto" => 1, 1808 "setp" => 1, 1809 "setpe" => 1, 1810 "setpo" => 1, 1811 "sets" => 1, 1812 "setz" => 1, 1813 "sgdt" => 1, 1814 "shl" => 1, 1815 "shld" => 1, 1816 "shr" => 1, 1817 "shrd" => 1, 1818 "sidt" => 1, 1819 "sldt" => 1, 1820 "smsw" => 1, 1821 "stc" => 1, 1822 "std" => 1, 1823 "sti" => 1, 1824 "stos" => 1, 1825 "str" => 1, 1826 "sub" => 1, 1827 "test" => 1, 1828 "verr" => 1, 1829 "verw" => 1, 1830 "wait" => 1, 1831 "wbinvd" => 1, 1832 "xadd" => 1, 1833 "xchg" => 1, 1834 "xlatb" => 1, 1835 "xor" => 1, 1836 "fabs" => 1, 1837 "fadd" => 1, 1838 "fbld" => 1, 1839 "fbstp" => 1, 1840 "fchs" => 1, 1841 "fclex" => 1, 1842 "fcom" => 1, 1843 "fcos" => 1, 1844 "fdecstp" => 1, 1845 "fdiv" => 1, 1846 "fdivr" => 1, 1847 "ffree" => 1, 1848 "fiadd" => 1, 1849 "ficom" => 1, 1850 "fidiv" => 1, 1851 "fidivr" => 1, 1852 "fild" => 1, 1853 "fimul" => 1, 1854 "fincstp" => 1, 1855 "finit" => 1, 1856 "fist" => 1, 1857 "fisub" => 1, 1858 "fisubr" => 1, 1859 "fld" => 1, 1860 "fld1" => 1, 1861 "fldl2e" => 1, 1862 "fldl2t" => 1, 1863 "fldlg2" => 1, 1864 "fldln2" => 1, 1865 "fldpi" => 1, 1866 "fldz" => 1, 1867 "fldcw" => 1, 1868 "fldenv" => 1, 1869 "fmul" => 1, 1870 "fnop" => 1, 1871 "fpatan" => 1, 1872 "fprem" => 1, 1873 "fprem1" => 1, 1874 "fptan" => 1, 1875 "frndint" => 1, 1876 "frstor" => 1, 1877 "fsave" => 1, 1878 "fscale" => 1, 1879 "fsetpm" => 1, 1880 "fsin" => 1, 1881 "fsincos" => 1, 1882 "fsqrt" => 1, 1883 "fst" => 1, 1884 "fstcw" => 1, 1885 "fstenv" => 1, 1886 "fstsw" => 1, 1887 "fsub" => 1, 1888 "fsubr" => 1, 1889 "ftst" => 1, 1890 "fucom" => 1, 1891 "fwait" => 1, 1892 "fxam" => 1, 1893 "fxch" => 1, 1894 "fxtract" => 1, 1895 "fyl2x" => 1, 1896 "fyl2xp1" => 1, 1897 "f2xm1" => 1 1898 ); 1899 1900 $aASM_PPKeywords = array( 1901 ".align" => 1, 1902 ".alpha" => 1, 1903 "and" => 1, 1904 "assume" => 1, 1905 "byte" => 1, 1906 "code" => 1, 1907 ".code" => 1, 1908 "comm" => 1, 1909 "comment" => 1, 1910 ".const" => 1, 1911 ".cref" => 1, 1912 ".data" => 1, 1913 ".data?" => 1, 1914 "db" => 1, 1915 "dd" => 1, 1916 "df" => 1, 1917 "dosseg" => 1, 1918 "dq" => 1, 1919 "dt" => 1, 1920 "dw" => 1, 1921 "dword" => 1, 1922 "else" => 1, 1923 "end" => 1, 1924 "endif" => 1, 1925 "endm" => 1, 1926 "endp" => 1, 1927 "ends" => 1, 1928 "eq" => 1, 1929 "equ" => 1, 1930 ".err" => 1, 1931 ".err1" => 1, 1932 ".err2" => 1, 1933 ".errb" => 1, 1934 ".errdef" => 1, 1935 ".errdif" => 1, 1936 ".erre" => 1, 1937 ".erridn" => 1, 1938 ".errnb" => 1, 1939 ".errndef" => 1, 1940 ".errnz" => 1, 1941 "event" => 1, 1942 "exitm" => 1, 1943 "extrn" => 1, 1944 "far" => 1, 1945 ".fardata" => 1, 1946 ".fardata?" => 1, 1947 "fword" => 1, 1948 "ge" => 1, 1949 "group" => 1, 1950 "gt" => 1, 1951 "high" => 1, 1952 "if" => 1, 1953 "if1" => 1, 1954 "if2" => 1, 1955 "ifb" => 1, 1956 "ifdef" => 1, 1957 "ifdif" => 1, 1958 "ife" => 1, 1959 "ifidn" => 1, 1960 "ifnb" => 1, 1961 "ifndef" => 1, 1962 "include" => 1, 1963 "includelib" => 1, 1964 "irp" => 1, 1965 "irpc" => 1, 1966 "label" => 1, 1967 ".lall" => 1, 1968 "le" => 1, 1969 "length" => 1, 1970 ".lfcond" => 1, 1971 ".list" => 1, 1972 "local" => 1, 1973 "low" => 1, 1974 "lt" => 1, 1975 "macro" => 1, 1976 "mask" => 1, 1977 "mod" => 1, 1978 ".model" => 1, 1979 "name" => 1, 1980 "ne" => 1, 1981 "near" => 1, 1982 "not" => 1, 1983 "offset" => 1, 1984 "or" => 1, 1985 "org" => 1, 1986 "%out" => 1, 1987 "page" => 1, 1988 "proc" => 1, 1989 "ptr" => 1, 1990 "public" => 1, 1991 "purge" => 1, 1992 "qword" => 1, 1993 ".radix" => 1, 1994 "record" => 1, 1995 "rept" => 1, 1996 ".sall" => 1, 1997 "seg" => 1, 1998 "segment" => 1, 1999 ".seq" => 1, 2000 ".sfcond" => 1, 2001 "short" => 1, 2002 "size" => 1, 2003 ".stack" => 1, 2004 "struc" => 1, 2005 "subttl" => 1, 2006 "tbyte" => 1, 2007 ".tfcond" => 1, 2008 "this" => 1, 2009 "title" => 1, 2010 "type" => 1, 2011 ".type" => 1, 2012 "width" => 1, 2013 "word" => 1, 2014 ".xall" => 1, 2015 ".xcref" => 1, 2016 ".xlist" => 1, 2017 "xor" => 1 2018 ); 2019 2020 $aASM_Symbols = array( 2021 "{" => 1, 2022 "}" => 1, 2023 "!" => 1, 2024 "%" => 1, 2025 "&" => 1, 2026 "*" => 1, 2027 "-" => 1, 2028 "=" => 1, 2029 "+" => 1, 2030 "<" => 1, 2031 ">" => 1, 2032 "/" => 1, 2033 "|" => 1, 2034 "~" => 1, 2035 "*" => 1); 2036 2037 /** 2038 * Initiate the variable array used by the C Color encoder. 2039 * @param $aVaraibles Variable array. (output) 2040 */ 2041 function ASM_ColorInit(&$aVariables) 2042 { 2043 global $aASM_Keywords; 2044 global $aASM_PPKeywords; 2045 global $aASM_Symbols; 2046 2047 ksort($aASM_Keywords); 2048 ksort($aASM_PPKeywords); 2049 ksort($aASM_Symbols); 2050 } 2051 2052 2053 /** 2054 * Encode a line of C code. 2055 * @param $sLine Line string to encode. 2056 * @param $aVariables Variable array. 2057 * @returns Color encoded line string. 2058 */ 2059 function ASM_ColorEncode($sLine, &$aVariables) 2060 { 2061 global $aASM_Keywords; 2062 global $aASM_PPKeywords; 2063 global $aASM_Symbols; 2064 2065 $sRet = ""; 2066 $cchLine = strlen($sLine); 2067 $i = 0; 2068 $fFirstNonBlank = 1; 2069 2070 /* 2071 * Loop thru the (remainings) of the line. 2072 */ 2073 while ($i < $cchLine) 2074 { 2075 $ch = $sLine[$i]; 2076 2077 /* comment check */ 2078 if ($ch == ';') 2079 { 2080 return $sRet . "<font color=#02FE02>" . substr($sLine, $i) . "</font>"; 2081 } 2082 2083 /* 2084 * Check for string. 2085 */ 2086 if ((($fDbl = (substr($sLine, $i, 6) == """)) || $sLine[$i] == "'") 2087 && ($i == 0 || $sLine[$i-1] != '\\')) 2088 { /* start of a string */ 2089 2090 $j = $i + 1; 2091 if ($fDbl) 2092 { 2093 while ($j < $cchLine && ($sLine[$j] != '&' || substr($sLine, $j, 6) != """)) 2094 $j += ($sLine[$j] == '\\') ? 2 : 1; 2095 if ($j < $cchLine) 2096 $j += 5; 2097 } 2098 else 2099 while ($j < $cchLine && $sLine[$j] != "'") 2100 $j += ($sLine[$j] == '\\') ? 2 : 1; 2101 $j++; 2102 $sRet .= "<font color=#FEFE02>".substr($sLine, $i, $j - $i)."</font>"; 2103 $i = $j; 2104 $fFirstNonBlank = 0; 2105 continue; 2106 } 2107 2108 /* 2109 * If non-blank, lets check if we're at the start of a word... 2110 */ 2111 $fBlank = ($ch == " " || $ch == "\t" || $ch == "\n"); 2112 $cchWord = !$fBlank ? ASM_WordLen($sLine, $cchLine, $i) : 0; 2113 2114 if ($cchWord > 0) 2115 { 2116 $sWord = strtolower(substr($sLine, $i, $cchWord)); 2117 2118 /* 2119 * Check for number. 2120 */ 2121 if (($ch >= '0' && $ch <= '9')) 2122 $sRet .= "<font color=#FF0202>" . substr($sLine, $i, $cchWord) . "</font>"; 2123 else 2124 { 2125 if ($fFirstNonBlank) 2126 { 2127 /* 2128 * Check for asm keyword. 2129 */ 2130 if (isset($aASM_Keywords[$sWord])) 2131 $sRet .= "<font color=#FF0202>" . substr($sLine, $i, $cchWord) . "</font>"; 2132 /* 2133 * Check for preprocessor directive. 2134 */ 2135 else if (($f = isset($aASM_PPKeywords[$sWord])) 2136 || 2137 ($i > 0 && $sLine[$i-1] == '.' && isset($aASM_PPKeywords[".".$sWord])) 2138 ) 2139 { 2140 if ($f) 2141 $sRet .= "<font color=#CECECE>" . substr($sLine, $i, $cchWord) . "</font>"; 2142 else 2143 $sRet = substr($sRet, 0, -1) . "<font color=#CECECE>." . substr($sLine, $i, $cchWord) . "</font>"; 2144 } 2145 /* 2146 * Skip word. 2147 */ 2148 else 2149 $sRet .= substr($sLine, $i, $cchWord); 2150 } 2151 else 2152 { 2153 /* 2154 * Check for preprocessor directive. 2155 */ 2156 if (($f = isset($aASM_PPKeywords[$sWord])) 2157 || 2158 ($i > 0 && $sLine[$i-1] == '.' && isset($aASM_PPKeywords[".".$sWord])) 2159 ) 2160 { 2161 if ($f) 2162 $sRet .= "<font color=#CECECE>" . substr($sLine, $i, $cchWord) . "</font>"; 2163 else 2164 $sRet = substr($sRet, 0, -1) . "<font color=#CECECE>." . substr($sLine, $i, $cchWord) . "</font>"; 2165 } 2166 /* 2167 * Check for asm keyword. 2168 */ 2169 else if (isset($aASM_Keywords[$sWord])) 2170 $sRet .= "<font color=#FF0202>" . substr($sLine, $i, $cchWord) . "</font>"; 2171 /* 2172 * Skip word. 2173 */ 2174 else 2175 $sRet .= substr($sLine, $i, $cchWord); 2176 } 2177 } 2178 2179 $i += $cchWord; 2180 $fFirstNonBlank = 0; 2181 continue; 2182 } 2183 2184 /* 2185 * Prepare for symbol check. (we'll have to check for HTML stuff like &). 2186 */ 2187 $cchWord = 1; 2188 if ($ch == '&') 2189 { 2190 if (substr($sLine, $i, 5) == "&") 2191 $cchWord = 5; 2192 else if (substr($sLine, $i, 4) == ">" || substr($sLine, $i, 4) == "<") 2193 $cchWord = 4; 2194 } 2195 2196 /* 2197 * Check for Symbol. 2198 */ 2199 if (isset($aASM_Symbols[substr($sLine, $i, $cchWord)])) 2200 { 2201 $sRet .= "<font color=#CECECE>" . substr($sLine, $i, $cchWord) . "</font>"; 2202 $i += $cchWord; 2203 $fFirstNonBlank = 0; 2204 continue; 2205 } 2206 2207 2208 /* 2209 * Copy char 2210 */ 2211 $sRet .= $sLine[$i]; 2212 $i++; 2213 if ($fFirstNonBlank && !$fBlank) 2214 $fFirstNonBlank = 0; 2215 } 2216 2217 return $sRet; 2218 } 2219 2220 /** 2221 * Calculates the lenght of the word which eventually starts at [$i]. 2222 * @param $sLine Line. 2223 * @param $cchLine Line length. 2224 * @param $i Line index. 2225 * @returns Word length. 2226 */ 2227 function ASM_WordLen($sLine, $cchLine, $i) 2228 { 2229 2230 /* 2231 * Check that previous letter wasen't a possible 2232 * word part. 2233 */ 2234 if ($i > 0) 2235 { 2236 $ch = $sLine[$i - 1]; 2237 if ( ($ch >= 'a' && $ch <= 'z') 2238 || ($ch >= 'A' && $ch <= 'Z') 2239 || ($ch >= '0' && $ch <= '9') 2240 || ($ch == '_') 2241 || ($ch == '@') 2242 || ($ch == '?') 2243 || ($ch == '$') 2244 ) 2245 return 0; 2246 } 2247 2248 /* 2249 * Count letters in the word 2250 */ 2251 $j = $i; 2252 $ch = $sLine[$i]; 2253 while ($i < $cchLine && 2254 ( ($ch >= 'a' && $ch <= 'z') 2255 || ($ch >= 'A' && $ch <= 'Z') 2256 || ($ch >= '0' && $ch <= '9') 2257 || ($ch == '_') 2258 || ($ch == '@') 2259 || ($ch == '?') 2260 || ($ch == '$') 2261 ) 2262 ) 2263 $ch = @$sLine[++$i]; 2264 return $i - $j; 2265 } 2266 2267 2268 2269 /* 2270 * 2271 */ 2272 /* hardcoded 2273 $aMake_Keywords = array( 2274 "\$&" => 1, 2275 "\$**" => 1, 2276 "\$*" => 1, 2277 "\$." => 1, 2278 "\$:" => 1, 2279 "\$<" => 1, 2280 "\$?" => 1, 2281 "\$@" => 1, 2282 "\$d" => 1); 2283 */ 2284 $aMake_Symbols = array( 2285 "@" => 1, 2286 "(" => 1, 2287 ")" => 1, 2288 "." => 1, 2289 "=" => 1, 2290 "*" => 1, 2291 "+" => 1, 2292 "-" => 1, 2293 "/" => 1, 2294 "" => 1, 2295 "[" => 1, 2296 "]" => 1, 2297 "," => 1, 2298 "<" => 1, 2299 ">" => 1, 2300 ":" => 1, 2301 ";" => 1); 2302 /** 2303 * Initiate the variable array used by the C Color encoder. 2304 * @param $aVaraibles Variable array. (output) 2305 */ 2306 function Make_ColorInit(&$aVariables) 2307 { 2308 //global $aMake_Keywords; 2309 global $aMake_Symbols; 2310 //$aVariables = array("fInline" => 0) 2311 //ksort($aMake_Keywords); 2312 ksort($aMake_Symbols); 2313 } 2314 2315 2316 /** 2317 * Encode a line of C code. 2318 * @param $sLine Line string to encode. 2319 * @param $aVariables Variable array. 2320 * @returns Color encoded line string. 2321 */ 2322 function Make_ColorEncode($sLine, &$aVariables) 2323 { 2324 global $aMake_Keywords; 2325 global $aMake_Symbols; 2326 2327 $sRet = ""; 2328 $cchLine = strlen($sLine); 2329 $i = 0; 2330 $fFirstNonBlank = 1; 2331 2332 /* 2333 * Loop thru the (remainings) of the line. 2334 */ 2335 while ($i < $cchLine) 2336 { 2337 $ch = $sLine[$i]; 2338 2339 /* comment check */ 2340 if ($ch == '#') 2341 { 2342 return $sRet . "<font color=#02FE02>" . substr($sLine, $i) . "</font>"; 2343 } 2344 2345 2346 /* 2347 * Check for string. 2348 */ 2349 if ((($fDbl = (substr($sLine, $i, 6) == """)) || $sLine[$i] == "'") 2350 && ($i == 0 || $sLine[$i-1] != '\\')) 2351 { /* start of a string */ 2352 2353 $j = $i + 1; 2354 if ($fDbl) 2355 { 2356 while ($j < $cchLine && ($sLine[$j] != '&' || substr($sLine, $j, 6) != """)) 2357 $j += ($sLine[$j] == '\\') ? 2 : 1; 2358 if ($j < $cchLine) 2359 $j += 5; 2360 } 2361 else 2362 while ($j < $cchLine && $sLine[$j] != "'") 2363 $j += ($sLine[$j] == '\\') ? 2 : 1; 2364 $j++; 2365 $sRet .= "<font color=#FEFE02>".substr($sLine, $i, $j - $i)."</font>"; 2366 $i = $j; 2367 $fFirstNonBlank = 0; 2368 continue; 2369 } 2370 2371 /* 2372 * Check for ! or % words 2373 */ 2374 if (($fFirstNonBlank && ($ch == "#" || $ch == "!"))) 2375 { 2376 $j = $i + 1; 2377 while ($j < $cchLine && ($sLine[$j] == ' ' || $sLine[$j] == "\t")) 2378 $j++; 2379 $j += Make_WordLen($sLine, $cchLine, $j); 2380 echo "<font color=#CECECE>" . substr($sLine, $i, $j - $i) . "</font>"; 2381 $i = $j; 2382 $fFirstNonBlank = 0; 2383 continue; 2384 } 2385 2386 /* 2387 * Check for keyword 2388 */ 2389 /* don't work 2390 if ($ch == "$" && $i + 1 < $cchLine) 2391 { 2392 $cch = 0; 2393 $sWord = substr($sLine, $i+1, 1); 2394 if ( $sWord == "*" 2395 || $sWord == "." 2396 || $sWord == ":" 2397 || $sWord == "?" 2398 || $sWord == "@" 2399 || $sWord == "d") 2400 $cch = 2; 2401 else if ($i + 2 < $cchLine && ($sWord = substr($sLine, $i+1, 2)) == "**") 2402 $cch = 3; 2403 else if ($i + 4 < $cchLine && ($sWord = substr($sLine, $i+1, 5)) == "&") 2404 $cch = 6; 2405 else if ($i + 5 < $cchLine && ($sWord = substr($sLine, $i+1, 4)) == "<") 2406 $cch = 5; 2407 if ($cch > 0) 2408 { 2409 echo "<font color=#CECECE>$" . $sWord . "</font>"; 2410 $i += $cch; 2411 $fFirstNonBlank = 0; 2412 continue; 2413 } 2414 } */ 2415 2416 /* 2417 * If non-blank, lets check if we're at the start of a word... 2418 */ 2419 $fBlank = ($ch == " " || $ch == "\t" || $ch == "\n"); 2420 $cchWord = !$fBlank ? Make_WordLen($sLine, $cchLine, $i) : 0; 2421 2422 if ($cchWord > 0) 2423 { 2424 $sWord = strtolower(substr($sLine, $i, $cchWord)); 2425 2426 /* 2427 * Check for keywords. 2428 */ 2429 if ($f = isset($aMake_Keywords[$sWord])) 2430 $sRet .= "<font color=#FF0202>" . substr($sLine, $i, $cchWord) . "</font>"; 2431 2432 /* 2433 * Check for number. 2434 */ 2435 else if (($ch >= '0' && $ch <= '9')) 2436 $sRet .= "<font color=#FF0202>" . substr($sLine, $i, $cchWord) . "</font>"; 2437 2438 /* 2439 * Skip word. 2440 */ 2441 else 2442 $sRet .= substr($sLine, $i, $cchWord); 2443 2444 $i += $cchWord; 2445 $fFirstNonBlank = 0; 2446 continue; 2447 } 2448 2449 /* 2450 * Prepare for symbol check. (we'll have to check for HTML stuff like &). 2451 */ 2452 $cchWord = 1; 2453 if ($ch == '&') 2454 { 2455 if (substr($sLine, $i, 5) == "&") 2456 $cchWord = 5; 2457 else if (substr($sLine, $i, 4) == ">" || substr($sLine, $i, 4) == "<") 2458 $cchWord = 4; 2459 } 2460 2461 /* 2462 * Check for Symbol. 2463 */ 2464 if (isset($aMake_Symbols[substr($sLine, $i, $cchWord)])) 2465 { 2466 $sRet .= "<font color=#CECECE>" . substr($sLine, $i, $cchWord) . "</font>"; 2467 $i += $cchWord; 2468 $fFirstNonBlank = 0; 2469 continue; 2470 } 2471 2472 2473 /* 2474 * Copy char 2475 */ 2476 $sRet .= $sLine[$i]; 2477 $i++; 2478 if ($fFirstNonBlank && !$fBlank) 2479 $fFirstNonBlank = 0; 2480 } 2481 2482 return $sRet; 2483 } 2484 2485 /** 2486 * Calculates the lenght of the word which eventually starts at [$i]. 2487 * @param $sLine Line. 2488 * @param $cchLine Line length. 2489 * @param $i Line index. 2490 * @returns Word length. 2491 */ 2492 function Make_WordLen($sLine, $cchLine, $i) 2493 { 2494 2495 /* 2496 * Check that previous letter wasen't a possible 2497 * word part. 2498 */ 2499 if ($i > 0) 2500 { 2501 $ch = $sLine[$i - 1]; 2502 if ( ($ch >= 'a' && $ch <= 'z') 2503 || ($ch >= 'A' && $ch <= 'Z') 2504 || ($ch >= '0' && $ch <= '9') 2505 || ($ch == '_') 2506 ) 2507 return 0; 2508 } 2509 2510 /* 2511 * Count letters in the word 2512 */ 2513 $j = $i; 2514 $ch = $sLine[$i]; 2515 while ($i < $cchLine && 2516 ( ($ch >= 'a' && $ch <= 'z') 2517 || ($ch >= 'A' && $ch <= 'Z') 2518 || ($ch >= '0' && $ch <= '9') 2519 || ($ch == '_') 2520 ) 2521 ) 2522 $ch = @$sLine[++$i]; 2523 return $i - $j; 2524 } 2525 2526 1556 2527 ?> 1557 2528
Note:
See TracChangeset
for help on using the changeset viewer.