#! /usr/bin/perl $b="  "; $t=" "x8; $r="
"; $lt="<"; $gt=">"; $comment=""; $matcher=""; $macro=""; $number=""; $strs=""; $keywd=""; if(@ARGV!=2){ die("Wrong usage!\n"); } open(INF,"<",$ARGV[0]) or die("Can't open file: $ARGV[0]\n"); open(OUTF,">",$ARGV[1]) or die("Can't open file: $ARGV[1]\n"); $keystring="int|char|short|unsigned|signed|long|register|static|extern|if|for|else|while|return|sizeof|void|struct|union|inline|typedef|do|double|float|const"; while(){ chomp; s//$gt/g; s/$/$r/g; s/ /$b/g; s/\t/$t/g; s/\".*\"/$strs$&$matcher/g;#this one also must be first among the last. s/\'.*\'/$number$&$matcher/g; s/\/\*/$comment\/\*/g; s/\*\//\*\/$matcher/g; s/^[ \t]*#[a-z]+/$macro$&$matcher/g; #look ahead & after, but NOT go. s/(?=\W)\d\w*(?=\W)/$number$&$matcher/ig; s/(?=\W|^)$keystring(?=\W)/$keywd$&$matcher/g; print OUTF "$_\n"; } print OUTF "
"; print OUTF "
This is generated by c2html.pl. Copyright © WANG Cong.
\n";