]> granicus.if.org Git - python/commitdiff
Added support for H (unsigned short) specifier in PyArg_ParseTuple and
authorJack Jansen <jack.jansen@cwi.nl>
Thu, 6 Jul 2000 12:22:00 +0000 (12:22 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Thu, 6 Jul 2000 12:22:00 +0000 (12:22 +0000)
Py_BuildValue.

Python/getargs.c
Python/modsupport.c

index b213ba2adb69b21c1addeee345d45df7d5cc26a2..a28354dda0c8db70cc973c458218e3265c671539 100644 (file)
@@ -489,6 +489,27 @@ convertsimple1(arg, p_format, p_va)
                        break;
                }
        
+       case 'H': /* unsigned short int */
+               {
+                       unsigned short *p = va_arg(*p_va, unsigned short *);
+                       long ival = PyInt_AsLong(arg);
+                       if (ival == -1 && PyErr_Occurred())
+                               return "integer<H>";
+                       else if (ival < 0) {
+                               PyErr_SetString(PyExc_OverflowError,
+                             "unsigned short integer is less than minimum");
+                               return "integer<H>";
+                       }
+                       else if (ival > USHRT_MAX) {
+                               PyErr_SetString(PyExc_OverflowError,
+                             "unsigned short integer is greater than maximum");
+                               return "integer<H>";
+                       }
+                       else
+                               *p = (unsigned short) ival;
+                       break;
+               }
+       
        case 'i': /* signed int */
                {
                        int *p = va_arg(*p_va, int *);
@@ -509,7 +530,6 @@ convertsimple1(arg, p_format, p_va)
                                *p = ival;
                        break;
                }
-       
        case 'l': /* long int */
                {
                        long *p = va_arg(*p_va, long *);
@@ -1207,6 +1227,12 @@ skipitem(p_format, p_va)
                        break;
                }
        
+       case 'H': /* unsigned short int */
+               {
+                       (void) va_arg(*p_va, unsigned short *);
+                       break;
+               }
+       
        case 'i': /* int */
                {
                        (void) va_arg(*p_va, int *);
index afecc0e51546789384d91d9ab567e1392f5717d7..5cd28709f159971a3055428b11cae77d6e4b7311 100644 (file)
@@ -278,6 +278,9 @@ do_mkvalue(p_format, p_va)
                case 'h':
                case 'i':
                        return PyInt_FromLong((long)va_arg(*p_va, int));
+                       
+               case 'H':
+                       return PyInt_FromLong((long)va_arg(*p_va, unsigned int));
 
                case 'l':
                        return PyInt_FromLong((long)va_arg(*p_va, long));