home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / wvhtm064.zip / notes / convert-to-struct / wvh.awk < prev    next >
Text File  |  2000-09-02  |  627b  |  36 lines

  1. #!/bin/awk -f
  2. {
  3. if (match($1,"[[:digit:]]")) 
  4.     {
  5.     if (match($2,"0x")) 
  6.         {
  7.  
  8.         if (dup == $2)
  9.             printf("/*error, dup offset of above line*/ ");
  10.         dup = $2;
  11.         
  12.         x = split($4,a,"[\[]");
  13.         if (x > 1) 
  14.             printf(a[1]" "$3"["a[2]); 
  15.         else
  16.             printf($4" "$3); 
  17.         }
  18.     }
  19. if (match($5,":")) printf($5); 
  20. if ((match($1,"[[:digit:]]")) && (match($2,"0x"))) 
  21.     printf(" ;                /* ") 
  22.  
  23. if (match($5,":")) 
  24.     printf("Bitfield "$6 " "); 
  25.  
  26. if ((match($1,"[[:digit:]]")) && (match($2,"0x"))) 
  27.     printf($2" */\n") 
  28.  
  29.  
  30. if (match($3,":")) 
  31.     printf($2" "$1); 
  32. if (match($3,":")) printf($3); 
  33. if (match($3,":")) 
  34.     printf(" ;            /* Bitfield "$4" */\n") 
  35. }
  36.