From 391313b9de097b84ad9b1ca80bb4ee26eaf2d0b3 Mon Sep 17 00:00:00 2001
From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com>
Date: Mon, 20 Mar 2023 09:22:38 +0100
Subject: [PATCH] [fltk] fix narrowing error in clang-cl (#29995)

* [fltk] fix narrowing error in clang-cl

* v db
---
 ports/fltk/fix-narrow.patch | 13 +++++++++++++
 ports/fltk/portfile.cmake   |  1 +
 ports/fltk/vcpkg.json       |  2 +-
 versions/baseline.json      |  2 +-
 versions/f-/fltk.json       |  5 +++++
 5 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 ports/fltk/fix-narrow.patch

diff --git a/ports/fltk/fix-narrow.patch b/ports/fltk/fix-narrow.patch
new file mode 100644
index 0000000000..1af2eb89da
--- /dev/null
+++ b/ports/fltk/fix-narrow.patch
@@ -0,0 +1,13 @@
+diff --git a/fluid/ExternalCodeEditor_WIN32.cxx b/fluid/ExternalCodeEditor_WIN32.cxx
+index 4646fe5..3b7f693 100644
+--- a/fluid/ExternalCodeEditor_WIN32.cxx
++++ b/fluid/ExternalCodeEditor_WIN32.cxx
+@@ -474,7 +474,7 @@ void ExternalCodeEditor::reap_cleanup() {
+ int ExternalCodeEditor::reap_editor(DWORD *pid_reaped) {
+   if ( pid_reaped ) *pid_reaped = 0;
+   if ( !is_editing() ) return -2;
+-  int err;
++  DWORD err;
+   DWORD msecs_wait = 50;   // .05 sec
+   switch ( err = WaitForSingleObject(pinfo_.hProcess, msecs_wait) ) {
+     case WAIT_TIMEOUT: {   // process didn't reap, still running
diff --git a/ports/fltk/portfile.cmake b/ports/fltk/portfile.cmake
index 018d2e7b20..ccfdb91d11 100644
--- a/ports/fltk/portfile.cmake
+++ b/ports/fltk/portfile.cmake
@@ -12,6 +12,7 @@ vcpkg_from_github(
         include.patch
         fix-system-link.patch
         math-h-polyfill.patch
+        fix-narrow.patch
 )
 file(REMOVE_RECURSE
     "${SOURCE_PATH}/jpeg"
diff --git a/ports/fltk/vcpkg.json b/ports/fltk/vcpkg.json
index 6de014b9ab..7fd2392dd6 100644
--- a/ports/fltk/vcpkg.json
+++ b/ports/fltk/vcpkg.json
@@ -1,7 +1,7 @@
 {
   "name": "fltk",
   "version": "1.3.8",
-  "port-version": 4,
+  "port-version": 5,
   "description": "FLTK (pronounced fulltick) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. FLTK provides modern GUI functionality without the bloat and supports 3D graphics via OpenGL and its built-in GLUT emulation.",
   "homepage": "https://www.fltk.org/",
   "license": null,
diff --git a/versions/baseline.json b/versions/baseline.json
index d649ea583b..5755eb7d75 100644
--- a/versions/baseline.json
+++ b/versions/baseline.json
@@ -2486,7 +2486,7 @@
     },
     "fltk": {
       "baseline": "1.3.8",
-      "port-version": 4
+      "port-version": 5
     },
     "fluidlite": {
       "baseline": "2020-08-27",
diff --git a/versions/f-/fltk.json b/versions/f-/fltk.json
index 27c943380c..6d08fa04b4 100644
--- a/versions/f-/fltk.json
+++ b/versions/f-/fltk.json
@@ -1,5 +1,10 @@
 {
   "versions": [
+    {
+      "git-tree": "bb00fc235046a91ebcdb47e9bcb4474b82cb81d8",
+      "version": "1.3.8",
+      "port-version": 5
+    },
     {
       "git-tree": "20def1217e8d9ac6306e900f9bdc5662bf593d82",
       "version": "1.3.8",