File: 0004-Remove-compatibility-to-ruby-1.8.patch

package info (click to toggle)
ruby-serialport 1.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 532 kB
  • sloc: ansic: 1,425; ruby: 74; sh: 16; makefile: 4
file content (101 lines) | stat: -rw-r--r-- 2,744 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
From ed475f1328c8e5e8c6b0c36884cd909e27c2bcaa Mon Sep 17 00:00:00 2001
From: Lars Kanis <lars.kanis@sincnovation.com>
Date: Wed, 12 Feb 2025 15:04:59 +0100
Subject: [PATCH 04/10] Remove compatibility to ruby-1.8

---
 ext/native/posix_serialport_impl.c |  8 --------
 ext/native/serialport.h            | 15 ++-------------
 ext/native/win_serialport_impl.c   | 12 ++----------
 3 files changed, 4 insertions(+), 31 deletions(-)

diff --git a/ext/native/posix_serialport_impl.c b/ext/native/posix_serialport_impl.c
index a38d29f..fe0fc57 100644
--- a/ext/native/posix_serialport_impl.c
+++ b/ext/native/posix_serialport_impl.c
@@ -64,17 +64,9 @@ static char sIoctl[] = "ioctl";
 int get_fd_helper(obj)
    VALUE obj;
 {
-#ifdef HAVE_RUBY_IO_H
    rb_io_t *fptr;
-#else
-   OpenFile *fptr;
-#endif
    GetOpenFile(obj, fptr);
-#ifdef HAVE_RUBY_IO_H
    return (fptr->fd);
-#else
-   return (fileno(fptr->f));
-#endif
 }
 
 VALUE sp_create_impl(class, _port)
diff --git a/ext/native/serialport.h b/ext/native/serialport.h
index 166b88a..8c51412 100644
--- a/ext/native/serialport.h
+++ b/ext/native/serialport.h
@@ -22,11 +22,7 @@
 #define _RUBY_SERIAL_PORT_H_
 
 #include <ruby.h>    /* ruby inclusion */
-#ifdef HAVE_RUBY_IO_H      /* ruby io inclusion */
-   #include <ruby/io.h>
-#else
-   #include <rubyio.h>
-#endif
+#include <ruby/io.h>
 
 #ifndef HAVE_RB_IO_OPEN_DESCRIPTOR
 VALUE io_open_descriptor_fallback(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, void *encoding);
@@ -61,14 +57,7 @@ struct line_signals
    #define EVEN   EVENPARITY
    #define ODD    ODDPARITY
 
-   #ifndef RB_SERIAL_EXPORT
-	 #ifndef HAVE_RUBY_IO_H
-     	#define RB_SERIAL_EXPORT __declspec(dllexport)
-	 #else
-		#define RB_SERIAL_EXPORT
-	 #endif
-   #endif
-
+   #define RB_SERIAL_EXPORT
 #else
    #define EVEN   1
    #define ODD    2
diff --git a/ext/native/win_serialport_impl.c b/ext/native/win_serialport_impl.c
index 465d5f8..781bbc1 100644
--- a/ext/native/win_serialport_impl.c
+++ b/ext/native/win_serialport_impl.c
@@ -36,25 +36,17 @@ static char sSetCommTimeouts[] = "SetCommTimeouts";
 static HANDLE get_handle_helper(obj)
    VALUE obj;
 {
-#ifdef HAVE_RUBY_IO_H
    rb_io_t *fptr;
-#else
-   OpenFile *fptr;
-#endif
 
    GetOpenFile(obj, fptr);
-#ifdef HAVE_RUBY_IO_H
    return (HANDLE) _get_osfhandle(fptr->fd);
-#else
-   return (HANDLE) _get_osfhandle(fileno(fptr->f));
-#endif
 }
 
 /* hack to work around the fact that Ruby doesn't use GetLastError? */
 static void _rb_win32_fail(const char *function_call) {
   rb_raise(
-    rb_eRuntimeError, 
-    "%s failed: GetLastError returns %d", 
+    rb_eRuntimeError,
+    "%s failed: GetLastError returns %d",
     function_call, GetLastError( )
   );
 }
-- 
2.39.5