php对nesc编译后的文件处理

2021-07-14 08:05

阅读:520

标签:++   input   puts   gets   blog   logs   位置   put   nbsp   

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、代码位置信息(如:# 19 、#line 22)
  $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 )
  $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、$符号的处理
  $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对nesc编译后的文件处理

标签:++   input   puts   gets   blog   logs   位置   put   nbsp   

原文地址:http://www.cnblogs.com/tinyos/p/7076487.html


评论


亲,登录后才可以留言!