home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / ASMCNVRT.AWK < prev    next >
Text File  |  1997-07-05  |  1KB  |  44 lines

  1. # +++Date last modified: 05-Jul-1997
  2.  
  3. #   awk script to change block asm statments into the single line
  4. #   style that versions of Turbo C up to 2.01 can parse.
  5. #   asm {
  6. #      pushf
  7. #      pop flags
  8. #   }
  9. #   /*START asm { */
  10. #   asm   pushf
  11. #   asm   pop flags
  12. #   /*END } */
  13. #
  14. # If the asm block start or end lines contain comments you'll end up
  15. # with a nested comment, other than that I believe comments are handled
  16. # correctly. If you fix that or fix or improve anything else send me a
  17. # copy via fidonet 1:140/12.9 or C_ECHO
  18. #
  19. # public domain code written by Ed Kowalski 22 aug 93, use freely.
  20. # The comment code was written by Dan Kozak, check c_lines.awk in
  21. # snippets. (so what's all the fuss about c++ and reusable code<g>)
  22.  
  23. {
  24.  
  25. if ($1 ~ /^\/\*/ && $NF ~ /\*\/$/) { print $0; next }
  26. else if ($0 ~ /\/\*/ && $0 !~ /\*\//) { in_comment = 1 }
  27. else if ($0 !~ /\/\*/ && $0 ~ /\*\//) { in_comment = 0 }
  28. else if ($0 ~/[\t ]*}/ && asmblok) {
  29.     asmblok = 0
  30.     $0 = "/*END" $0 " */"
  31. }
  32. else if ($0 ~ /[\t ]*asm[\t ]+{/ || asmblok > 0 && !in_comment ) {
  33.     if( asmblok )
  34.         $0 = "asm" $0
  35.     else  {
  36.         asmblok = 1
  37.         $0 = $0 = "/*START" $0 " */"
  38.     }
  39. }
  40.  
  41. { print $0 }
  42.  
  43. }
  44.