#!/usr/bin/env perl # Updates http://cvs.gnome.org/viewcvs/gtk%2B/gdk/gdkkeysyms.h from upstream (X.org 6.9/7.0), # OLD OLD -----from http://cvs.freedesktop.org/xorg/xc/include/keysymdef.h------ OLD OLD # from http://webcvs.freedesktop.org/*checkout*/xorg/proto/X11/keysymdef.h # # Author : Simos Xenitellis . # Version : 1.0 # # Input : http://webcvs.freedesktop.org/xorg/proto/X11/keysymdef.h # Output : http://cvs.gnome.org/viewcvs/gtk%2B/gdk/gdkkeysyms.h # # Notes : It downloads keysymdef.h from the Internet if not found locally # Notes : and creates an updated gdkkeysyms.h use strict; # Used for reading the keysymdef symbols. my @keysymelements; if ( ! -f "keysymdef.h" ) { print "Trying to download keysymdef.h from\n"; print "http://webcvs.freedesktop.org/xorg/proto/X11/keysymdef.h: "; die "Unable to download keysymdef.h from http://webcvs.freedesktop.org/xorg/proto/X11/keysymdef.h\n" unless system("wget -q \"http://webcvs.freedesktop.org/*checkout*/xorg/proto/X11/keysymdef.h\"") == 0; print " done.\n\n"; } else { print "We are using existing keysymdef.h found in this directory.\n"; print "It is assume that you took care and it is a recent version\n"; print "as found at http://webcvs.freedesktop.org/*checkout*/xorg/proto/X11/keysymdef.h\n\n"; } if ( -f "gdkkeysyms.h" ) { print "There is already a gdkkeysyms.h file in this directory. We are not overwriting it.\n"; print "Please move it in order to run this script.\n"; die "Exiting...\n\n"; } # Source: http://cvs.freedesktop.org/xorg/xc/include/keysymdef.h die "Could not open file keysymdef.h: $!\n" unless open(IN_KEYSYMDEF, "<:utf8", "keysymdef.h"); # Output: gtk+/gdk/gdkkeysyms.h die "Could not open file gdkkeysyms.h: $!\n" unless open(OUT_GDKKEYSYMS, ">:utf8", "gdkkeysyms.h"); print OUT_GDKKEYSYMS<) { next if ( ! /^#define / ); @keysymelements = split(/\s+/); die "Internal error, no \@keysymelements: $_\n" unless @keysymelements; $_ = $keysymelements[1]; die "Internal error, was expecting \"XC_*\", found: $_\n" if ( ! /^XK_/ ); $_ = $keysymelements[2]; die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ ); $keysymelements[1] =~ s/^XK_/GDK_/g; printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $keysymelements[1], hex($keysymelements[2]); } #$gdksyms{"0"} = "0000"; close IN_KEYSYMDEF; print OUT_GDKKEYSYMS<