<?PHP$f _output=fopen("App_out.c", "W");$f _input=fopen("App.c", "R"); while(!feof($f _input)) while(!feof($f _input)){ $next _match= 1; $line=fgets($f _input); //1, Code location information (such as: # 19, #line) $pattern= '/(^ (#line \s\d+)) | (^ (#\s\d+) (. *))/'; //$replacement = '//${0} '; $replacement= ' '; $r=Preg_match($pattern,$line); if($r ) { $line=Preg_replace($pattern,$replacement,$line); Break; } //2, inline function flag information (such as: inline) $pattern= '/(\b__inline\b) | (__inline\b)/'; //$replacement = '/* ${0} */'; $replacement = ' inline '; $replacement= ' '; $r=Preg_match($pattern,$line); if($next _match&&$r ) { $line=Preg_replace($pattern,$replacement,$line); $next _match= 0; } //3, the handling of the $ symbol $contents=$line; $pattern= '/(\w+) (\$) (\w+)/'; $replacement= ' ${1}__${3} '; $matchCount= 0; while($next _match) { $r=Preg_match($pattern,$contents); if($r ) { $matchCount++; $contents=Preg_replace($pattern,$replacement,$contents); } Else { if($matchCount= = 0 ) { Break; } $line=$contents; $next _match= 0; Break; } } fputs($f _output,$line);}fclose($f _input);fclose($f _output);?>
PHP post-compilation file processing for Nesc