riccardinofuffolo

Sistemi Operativi - 07/11/2005 - Es. 6

Aug 15th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.69 KB | None | 0 0
  1. #!/bin/awk -f
  2. # Tema d'esame 07/11/2005 A (www.labinf.polito.it/whitone/index.php?summ=SO)
  3. # Uso: awk -f scommenta.awk sorgente.txt
  4. # 15/08/2012 - BNCRCR
  5.  
  6. BEGIN {
  7.     dentro = 0;
  8. }
  9.  
  10. # Pattern che identifica una riga che comincia con /*
  11. /^\/\*/ {
  12.     dentro = 1         
  13. }
  14.  
  15. # Pattern che identifica una riga che finisce con */
  16. /\*\/$/ {
  17.     dentro = 0
  18. }
  19.  
  20. # Pattern che identifica una riga che non comincia con // o */
  21. # (quelle che iniziano con /* sono già scartate da dentro = 1)
  22. # (espressione regolare un po' spartana)
  23. /^[^\/\/]/ && /^[^\*\/]/  {
  24.     if (!dentro)
  25.         print $0 >> "output.tmp"
  26. }
  27.  
  28.  
  29. END {
  30.     comando = "cat output.tmp > " FILENAME
  31.     system(comando)
  32.     system("rm -f output.tmp")
  33. }
Advertisement
Add Comment
Please, Sign In to add comment