From 41c89aaff2ebe6bbcc0db9ea500a163eaa790ce8 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Sat, 20 Dec 2014 15:12:48 +0000
Subject: snes9x: update to 1.53-8

---
 abs/extra/snes9x/PKGBUILD               | 33 +++++++++++++++++++--------------
 abs/extra/snes9x/snes9x-fix-crash.patch | 30 ++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 14 deletions(-)
 create mode 100644 abs/extra/snes9x/snes9x-fix-crash.patch

diff --git a/abs/extra/snes9x/PKGBUILD b/abs/extra/snes9x/PKGBUILD
index 68b8032..a38ac44 100644
--- a/abs/extra/snes9x/PKGBUILD
+++ b/abs/extra/snes9x/PKGBUILD
@@ -1,37 +1,42 @@
-# $Id: PKGBUILD 78959 2012-10-28 04:11:03Z ebelanger $
+# $Id$
 # Maintainer: Eric Bélanger <eric@archlinux.org>
 
 pkgbase=snes9x
 pkgname=('snes9x' 'snes9x-gtk')
 pkgver=1.53
-pkgrel=5
+pkgrel=8
 arch=('i686' 'x86_64')
 url="https://code.google.com/p/snes9x-gtk/"
 license=('custom')
-makedepends=('intltool' 'nasm' 'mesa'  'libpng' 'sdl' 'gtk2' 'libxv' \
-             'desktop-file-utils' )
+makedepends=('intltool' 'nasm' 'mesa' 'libpng' 'sdl' 'gtk2' 'libxv'
+             'desktop-file-utils')
 source=(http://snes9x-gtk.googlecode.com/files/${pkgbase}-${pkgver}-src.tar.bz2
-        snes9x-gtk2.24.diff.gz)
+        snes9x-gtk2.24.diff.gz snes9x-fix-crash.patch)
 sha1sums=('57be6480369f66b9aaaeb722789ce114f58ed1e2'
-          '680dbe0a70f1821bc7931539e72f5a1a95e3938c')
+          '680dbe0a70f1821bc7931539e72f5a1a95e3938c'
+          '995495c68ffc00d8266d10a7bd8fc74fb6c147b1')
 
-build() {
-  cd "${srcdir}/${pkgbase}-${pkgver}-src"
+prepare() {
+  cd ${pkgbase}-${pkgver}-src
   patch -p1 -i "${srcdir}/snes9x-gtk2.24.diff"
-  cd unix
+  patch -p1 -i "${srcdir}/snes9x-fix-crash.patch"
+}
+
+build() {
+  cd ${pkgbase}-${pkgver}-src/unix
   ./configure --prefix=/usr --with-sdd1-decomp --enable-netplay
   make
 
-  cd "${srcdir}/${pkgbase}-${pkgver}-src/gtk"
+  cd ../gtk
   ./configure --prefix=/usr --with-sdd1-decomp --with-netplay --with-opengl
   make
 }
 
 package_snes9x() {
   pkgdesc="A portable Emulator for the Super Nintendo Entertainment System"
-  depends=('gcc-libs' 'libpng' 'libxext' 'libsm')
+  depends=('libpng' 'libxext' 'libsm')
 
-  cd "${srcdir}/${pkgbase}-${pkgver}-src/unix"
+  cd ${pkgbase}-${pkgver}-src/unix
   install -D -m755 snes9x "${pkgdir}/usr/bin/snes9x"
   install -d "${pkgdir}/usr/share/doc/${pkgname}"
   install -D -m644 ../docs/{snes9x.conf.default,{control-inputs,controls,snapshots}.txt} \
@@ -43,10 +48,10 @@ package_snes9x() {
 package_snes9x-gtk() {
   pkgdesc="A portable Emulator for the Super Nintendo Entertainment System - GTK version"
   license=('custom' 'LGPL')
-  depends=('sdl' 'libgl' 'libpulse' 'gtk2' 'libxv' 'desktop-file-utils' 'gnome-icon-theme')
+  depends=('sdl' 'libpulse' 'gtk2' 'libxv' 'desktop-file-utils' 'gnome-icon-theme')
   install=snes9x-gtk.install
 
-  cd "${srcdir}/${pkgbase}-${pkgver}-src/gtk"
+  cd ${pkgbase}-${pkgver}-src/gtk
   make DESTDIR="${pkgdir}" install
   install -d "${pkgdir}/usr/share/doc/${pkgname}"
   install -D -m644 ../docs/{snes9x.conf.default,{control-inputs,controls,snapshots}.txt} \
diff --git a/abs/extra/snes9x/snes9x-fix-crash.patch b/abs/extra/snes9x/snes9x-fix-crash.patch
new file mode 100644
index 0000000..95ed192
--- /dev/null
+++ b/abs/extra/snes9x/snes9x-fix-crash.patch
@@ -0,0 +1,30 @@
+From 6d74746342a73cf65db215f4fdecdfb0cae66792 Mon Sep 17 00:00:00 2001
+From: Brandon Wright <bearoso@gmail.com>
+Date: Mon, 10 Feb 2014 16:28:05 -0600
+Subject: [PATCH] Fix bug caused by virtual directories.
+
+---
+ gtk/src/gtk_file.cpp | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/gtk/src/gtk_file.cpp b/gtk/src/gtk_file.cpp
+index a0df75d..9c0e000 100644
+--- a/gtk/src/gtk_file.cpp
++++ b/gtk/src/gtk_file.cpp
+@@ -465,8 +465,11 @@ S9xOpenROMDialog (void)
+         filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+         directory =
+             gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
+-        strncpy (gui_config->last_directory, directory, PATH_MAX);
+-        g_free (directory);
++        if (directory)
++        {
++            strncpy (gui_config->last_directory, directory, PATH_MAX);
++            g_free (directory);
++        }
+     }
+ 
+     else
+-- 
+1.9.3
+
-- 
cgit v0.12

