Retourner au contenu associé (journal : Rajouter automatiquement une ligne dans chaque void d'un source C)
Posté par philz le 25 mai 2004 à 23:16. En réponse au journal Rajouter automatiquement une ligne dans chaque void d'un source C. Évalué à 5.
#!/usr/bin/perl use strict; my $currentFunction; my $pos = 0; while (my $line = ) { print $line; if ($pos == 0 and $line =~ m/^\s*static\s+void\s+([^\s]+)\s*\(/ ) { $currentFunction = 1ドル; $pos = 1; } if ($pos == 1 and $line =~ m/\)/) { $pos = 2; } if ($pos == 2 and $line =~ m/^\s*\/\// ) { $pos = 3; } if ($pos == 3 and $line =~ m/^\s*\{/ ) { print 'fprintf(stderr,"', $currentFunction, '\n")', "\n"; $pos = 0; } }
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
# En perl ?
Posté par philz . En réponse au journal Rajouter automatiquement une ligne dans chaque void d'un source C. Évalué à 5.
#!/usr/bin/perl use strict; my $currentFunction; my $pos = 0; while (my $line = ) { print $line; if ($pos == 0 and $line =~ m/^\s*static\s+void\s+([^\s]+)\s*\(/ ) { $currentFunction = 1ドル; $pos = 1; } if ($pos == 1 and $line =~ m/\)/) { $pos = 2; } if ($pos == 2 and $line =~ m/^\s*\/\// ) { $pos = 3; } if ($pos == 3 and $line =~ m/^\s*\{/ ) { print 'fprintf(stderr,"', $currentFunction, '\n")', "\n"; $pos = 0; } }