Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.2 KiB

  1. #
  2. # Vkeytbl.pl
  3. #
  4. # Pick up the VK definitions and normalize them.
  5. # input: stdin
  6. # output: stdout
  7. #
  8. # Created: hiroyama Jan 1999
  9. #
  10. #
  11. # Firstly read all VK definitions
  12. # and store them.
  13. #
  14. my ($file, $symbol, $def, @lines, %value, @finish);
  15. foreach $file (@ARGV) {
  16. next unless open(FILE, $file);
  17. while (<FILE>) {
  18. if (/^#define/ && /VK_/ && !/ERICSSON/) {
  19. chop;
  20. ($symbol, $def) = (split ' ')[1,2];
  21. # if the definition is final, normalize the caps
  22. # in 0xXX form.
  23. $def =~ tr/A-FX/a-fx/ if $def =~ /^0[Xx]/;
  24. # normalize 0x0ff form to 0xff
  25. $def =~ s/^0x0([0-9a-f][0-9a-f])/0x$1/;
  26. # add this VK def to our array
  27. push(@lines, "$def $symbol");
  28. # remember the definition
  29. $value{$symbol} = $def;
  30. }
  31. }
  32. close(FILE);
  33. }
  34. #
  35. # Dereference the indirect definitions, like
  36. # #define VK_ABC VK_OTHER
  37. #
  38. # VK_OTHER should have been registered in %value
  39. # in the loop above. Now resolve them.
  40. #
  41. foreach (@lines) {
  42. ($def, $symbol) = split ' ';
  43. $def = $value{$def} unless $def =~ /^0x/;
  44. push(@finish, "$def, \"$symbol\",");
  45. }
  46. #
  47. # Let's sort it and print !
  48. #
  49. print join("\n", sort @finish) . "\n";