convert_errcodes.txt.awk 263 B

123456789101112131415
  1. #!/usr/bin/env awk -f
  2. BEGIN {
  3. print "-module(epgsql_errcodes)."
  4. print "-export([to_name/1])."
  5. print
  6. }
  7. NF == 4 && \
  8. $1 ~ /[^\s]{5}/ && \
  9. $2 ~ /[EWS]/ \
  10. {
  11. printf("to_name(<<\"%s\">>) -> %s;\n", $1, $4)
  12. }
  13. END {
  14. print "to_name(_) -> undefined."
  15. }