Yukihiro Matsumoto wrote:

> Hi,
> 
> In message "Request patch to Win32API.c"
>     on 04/03/07, Michael Davis <mdavis / sevasoftware.com> writes:
> 
> |I would like to request an enhancement to Win32API.c to support short integers.  This is needed so support an ODBC interface I am working.  The return codes from all ODBC function calls through Win32API are incorrect using 'i' or 'l'.  Adding support for 's' (short int) corrects this problem.  Here is the diff of Win32API.c from Ruby 1.8.1 and my working code with support for short integers.  Please let me know if there is any thing I can do to help this enhancement along.
> 
> I'm not the one to decide, but at least you'd better use unified diff
> (diff -u) to show your changes.
> 
> 							matz.
> 
> 
Thanks.

diff -u Win32API.c Win32API_mjd.c

--- Win32API.c  Wed Aug 13 04:02:04 2003
+++ Win32API_mjd.c      Sun Mar  7 21:27:42 2004
@@ -12,6 +12,7 @@
 #define _T_NUMBER   1
 #define _T_POINTER  2
 #define _T_INTEGER  3
+#define _T_SHORT    4
 
 #include "ruby.h"
 
@@ -85,6 +86,9 @@
            case 'I': case 'i':
                rb_ary_push(a_import, INT2FIX(_T_INTEGER));
                break;
+           case 'S': case 's':
+               rb_ary_push(a_import, INT2FIX(_T_SHORT));
+               break;
            }
        }
         break;
@@ -102,6 +106,9 @@
            case 'I': case 'i':
                rb_ary_push(a_import, INT2FIX(_T_INTEGER));
                break;
+           case 'S': case 's':
+               rb_ary_push(a_import, INT2FIX(_T_SHORT));
+               break;
            }
        }
         break;
@@ -130,6 +137,9 @@
        case 'I': case 'i':
            ex = _T_INTEGER;
            break;
+       case 'S': case 's':
+           ex = _T_SHORT;
+           break;
        }
     }
     rb_iv_set(self, "__export__", INT2FIX(ex));
@@ -167,6 +177,9 @@
        unsigned long lParam = 0;
        switch (FIX2INT(rb_ary_entry(obj_import, i))) {
            VALUE str;
+       case _T_SHORT:
+           lParam = (short)FIX2INT(rb_ary_entry(args, i));
+           break;
        case _T_NUMBER:
        case _T_INTEGER:
        default:
@@ -191,6 +204,8 @@
     ret = ApiFunction(param);
 
     switch (FIX2INT(obj_export)) {
+       case _T_SHORT:
+           return INT2FIX((short)ret);
     case _T_NUMBER:
     case _T_INTEGER:
        return INT2NUM(ret);