From a21df060d2c4fe043e84ce4894afacafcc582b16 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Mon, 29 May 2023 14:22:03 -0400
Subject: qt5-webkit: patches

---
 linhes/qt5-webkit/PKGBUILD                    | 15 ++++++---
 linhes/qt5-webkit/qt5-webkit-bison-3.7.patch  | 46 +++++++++++++++++++++++++++
 linhes/qt5-webkit/qt5-webkit-python-3.9.patch | 27 ++++++++++++++++
 3 files changed, 83 insertions(+), 5 deletions(-)
 create mode 100644 linhes/qt5-webkit/qt5-webkit-bison-3.7.patch
 create mode 100644 linhes/qt5-webkit/qt5-webkit-python-3.9.patch

diff --git a/linhes/qt5-webkit/PKGBUILD b/linhes/qt5-webkit/PKGBUILD
index e706560..466f53e 100644
--- a/linhes/qt5-webkit/PKGBUILD
+++ b/linhes/qt5-webkit/PKGBUILD
@@ -1,25 +1,29 @@
-# Maintainer: Felix Yan <felixonmars@archlinux.org>
-# Maintainer: Antonio Rojas <arojas@archlinux.org>
+# Maintainer: Fabio 'Lolix' Loli <fabio.loli@disroot.org>
+# Contributor: Zen Wen <zen.8841@gmail.com>
+# Contributor: Felix Yan <felixonmars@archlinux.org>
+# Contributor: Antonio Rojas <arojas@archlinux.org>
 # Contributor: Andrea Scarpino <andrea@archlinux.org>
 
 pkgname=qt5-webkit
 _pkgver=5.212.0-alpha4
 _basever=5.15.3
 pkgver=${_pkgver/-/}
-pkgrel=18
+pkgrel=19
 arch=(x86_64)
 url='https://github.com/qtwebkit/qtwebkit'
 license=(GPL3 LGPL3 FDL custom)
 pkgdesc='Classes for a WebKit2 based implementation and a new QML API'
 source=("https://github.com/qtwebkit/qtwebkit/releases/download/qtwebkit-$_pkgver/qtwebkit-$_pkgver.tar.xz"
+        "https://src.fedoraproject.org/rpms/qt5-qtwebkit/raw/rawhide/f/qtwebkit-cstdint.patch"
          icu68.patch
          glib-2.68.patch
-         qt5-webkit-python-3.9.patch::"https://github.com/qtwebkit/qtwebkit/commit/78360c01.patch"
-         qt5-webkit-bison-3.7.patch::"https://github.com/qtwebkit/qtwebkit/commit/d92b11fe.patch")
+         qt5-webkit-python-3.9.patch
+         qt5-webkit-bison-3.7.patch)
 depends=(qt5-location qt5-sensors qt5-webchannel libwebp libxslt libxcomposite gst-plugins-base hyphen woff2)
 makedepends=(cmake ruby gperf python qt5-doc qt5-tools)
 optdepends=('gst-plugins-good: Webm codec support')
 sha256sums=('9ca126da9273664dd23a3ccd0c9bebceb7bb534bddd743db31caf6a5a6d4a9e6'
+            '4c71c958eae45cae65c9f002024eb1369d06029b668e595158138ff7971e64f1'
             '0b40ed924f03ff6081af610bb0ee01560b7bd1fb68f8af02053304a01d4ccdf0'
             '4969dd03e482155e2490b50307dada81dda7bbc9e5398e3a53c20bc474f7c04e'
             '6e0cee08e4fa57b04752e80817f33562f48aa42608a3a620930b6040259b4932'
@@ -32,6 +36,7 @@ prepare() {
   patch -p1 -i ../glib-2.68.patch # https://github.com/qtwebkit/qtwebkit/issues/1057
   patch -p1 -i ../qt5-webkit-python-3.9.patch # Fix build with python 3.9
   patch -p1 -i ../qt5-webkit-bison-3.7.patch # Fix build with bison 3.7
+  patch -p1 -i ../qtwebkit-cstdint.patch # gcc 11.1
 }
 
 build() {
diff --git a/linhes/qt5-webkit/qt5-webkit-bison-3.7.patch b/linhes/qt5-webkit/qt5-webkit-bison-3.7.patch
new file mode 100644
index 0000000..13dd681
--- /dev/null
+++ b/linhes/qt5-webkit/qt5-webkit-bison-3.7.patch
@@ -0,0 +1,46 @@
+From d92b11fea65364fefa700249bd3340e0cd4c5b31 Mon Sep 17 00:00:00 2001
+From: Dmitry Shachnev <mitya57@gmail.com>
+Date: Tue, 4 Aug 2020 21:04:06 +0300
+Subject: [PATCH] Let Bison generate the header directly, to fix build with
+ Bison 3.7
+
+Starting with Bison 3.7, the generated C++ file #include's the header
+by default, instead of duplicating it. So we should not delete it.
+
+Remove the code to add #ifdef guards to the header, since Bison adds
+them itself since version 2.6.3.
+---
+ Source/WebCore/css/makegrammar.pl | 21 +--------------------
+ 1 file changed, 1 insertion(+), 20 deletions(-)
+
+diff --git a/Source/WebCore/css/makegrammar.pl b/Source/WebCore/css/makegrammar.pl
+index 5d63b08102eb5..9435701c70612 100644
+--- a/Source/WebCore/css/makegrammar.pl
++++ b/Source/WebCore/css/makegrammar.pl
+@@ -73,25 +73,6 @@
+ }
+ 
+ my $fileBase = File::Spec->join($outputDir, $filename);
+-my @bisonCommand = ($bison, "-d", "-p", $symbolsPrefix, $grammarFilePath, "-o", "$fileBase.cpp");
++my @bisonCommand = ($bison, "--defines=$fileBase.h", "-p", $symbolsPrefix, $grammarFilePath, "-o", "$fileBase.cpp");
+ push @bisonCommand, "--no-lines" if $^O eq "MSWin32"; # Work around bug in bison >= 3.0 on Windows where it puts backslashes into #line directives.
+ system(@bisonCommand) == 0 or die;
+-
+-open HEADER, ">$fileBase.h" or die;
+-print HEADER << "EOF";
+-#ifndef CSSGRAMMAR_H
+-#define CSSGRAMMAR_H
+-EOF
+-
+-open HPP, "<$fileBase.cpp.h" or open HPP, "<$fileBase.hpp" or die;
+-while (<HPP>) {
+-    print HEADER;
+-}
+-close HPP;
+-
+-print HEADER "#endif\n";
+-close HEADER;
+-
+-unlink("$fileBase.cpp.h");
+-unlink("$fileBase.hpp");
+-
diff --git a/linhes/qt5-webkit/qt5-webkit-python-3.9.patch b/linhes/qt5-webkit/qt5-webkit-python-3.9.patch
new file mode 100644
index 0000000..bad26ef
--- /dev/null
+++ b/linhes/qt5-webkit/qt5-webkit-python-3.9.patch
@@ -0,0 +1,27 @@
+From 78360c01c796b6260bf828bc9c8a0ef73c5132fd Mon Sep 17 00:00:00 2001
+From: Konstantin Tokarev <annulen@yandex.ru>
+Date: Wed, 3 Jun 2020 15:01:42 +0300
+Subject: [PATCH] Fix compilation with Python 3.9: avoid passing encoding to
+ json.load()
+
+In Python 2.7 UTF-8 is assumed by default, while in Python 3 this argument
+is not supported.
+
+Change-Id: Ic459d60a6b20bc1838d8771bc36ac41614fe61a9
+---
+ Source/JavaScriptCore/generate-bytecode-files | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Source/JavaScriptCore/generate-bytecode-files b/Source/JavaScriptCore/generate-bytecode-files
+index c5dab429c7b0f..af3431275ecf9 100644
+--- a/Source/JavaScriptCore/generate-bytecode-files
++++ b/Source/JavaScriptCore/generate-bytecode-files
+@@ -163,7 +163,7 @@ if __name__ == "__main__":
+         initBytecodesFile = openOrExit(initASMFileName, "w")
+ 
+     try:
+-        bytecodeSections = json.load(bytecodeFile, encoding = "utf-8")
++        bytecodeSections = json.load(bytecodeFile)
+     except:
+         print("Unexpected error parsing {0}: {1}".format(bytecodeJSONFile, sys.exc_info()))
+ 
-- 
cgit v0.12

