2
0

err-ins.pl 506 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/local/bin/perl
  2. #
  3. # tack error codes onto the end of a file
  4. #
  5. open(ERR,$ARGV[0]) || die "unable to open error file '$ARGV[0]':$!\n";
  6. @err=<ERR>;
  7. close(ERR);
  8. open(IN,$ARGV[1]) || die "unable to open header file '$ARGV[1]':$!\n";
  9. @out="";
  10. while (<IN>)
  11. {
  12. push(@out,$_);
  13. last if /BEGIN ERROR CODES/;
  14. }
  15. close(IN);
  16. open(OUT,">$ARGV[1]") || die "unable to open header file '$ARGV[1]':$1\n";
  17. print OUT @out;
  18. print OUT @err;
  19. print OUT <<"EOF";
  20. #ifdef __cplusplus
  21. }
  22. #endif
  23. #endif
  24. EOF
  25. close(OUT);