#! /usr/bin/gawk -f # Last edited on 2003-04-21 11:41:46 by stolfi BEGIN { # Reformats a lits of points and colors, collcted with # the "xv" eyedropper, to the format COL ROW RED GRN BLU # (whitout commas). abort = -1; } (abort >= 0) { exit abort; } /^ *([#]|$)/ { next; } /^ *[0-9]+[, ]+[0-9]+ *[=] *[0-9]+[, ]+[0-9]+[, ]+[0-9]+([ ]+|$)/ { gsub(/[\]\[(),=]/, " ", $0); gsub(/ +/, " ", $0); if (NF != 12) { data_error("bad format"); } printf " %04d %04d %03d %03d %03d / 255\n", $1, $2, $3, $4, $5; next; } /./ { data_error("bad format"); } END{ if (abort >= 0) { exit abort; } } function data_error(msg) { printf "%d: **%s\n", FNR, msg > "/dev/stderr"; abort = 1; exit abort; } function arg_error(msg) { printf "**%s\n", msg > "/dev/stderr"; abort = 1; exit abort; }