reading HEX and OCTAL numbers from input field

James Hawkins truiken at gmail.com
Fri Sep 24 02:43:45 CDT 2004


> Yes, I've put brown bag over my head

Na, it's ok.  You're new to the developemnt process of wine,  and it
can take a while to get a hang of the process.  Just stick with it and
things will be better in no time.


On Thu, 23 Sep 2004 23:56:32 -0700, Primorec <igor.furlan at gmail.com> wrote:
> Just forget my post..  I have not noticed that this feature was
> already implemented.
> 
> Yes, I've put brown bag over my head
> 
> 
> 
> 
> On Thu, 23 Sep 2004 23:05:36 -0700, Primorec <igor.furlan at gmail.com> wrote:
> > This patch allows user to enter HEX and/or OCTAL numbers into the form
> > input field.
> >
> > This is my first patch and in the same time my second C program (first
> > one was Hello World).
> > So, please, have a mercy and be tolerant.
> >
> > Thanks
> >
> > Igor
> >
> > ? patch.diff
> > Index: dlls/oleaut32/variant.c
> > ===================================================================
> > RCS file: /home/wine/wine/dlls/oleaut32/variant.c,v
> > retrieving revision 1.102
> > diff -u -u -r1.102 variant.c
> > --- dlls/oleaut32/variant.c     22 Sep 2004 19:12:18 -0000      1.102
> > +++ dlls/oleaut32/variant.c     24 Sep 2004 05:44:43 -0000
> > @@ -1556,6 +1556,8 @@
> >    DWORD dwState = B_EXPONENT_START|B_INEXACT_ZEROS;
> >    int iMaxDigits = sizeof(rgbTmp) / sizeof(BYTE);
> >    int cchUsed = 0;
> > +  int value = 0;
> > +  OLECHAR first_element;
> >
> >    TRACE("(%s,%ld,0x%08lx,%p,%p)\n", debugstr_w(lpszStr), lcid,
> > dwFlags, pNumprs, rgbDig);
> >
> > @@ -1571,6 +1573,73 @@
> >    pNumprs->nBaseShift = 0;
> >    pNumprs->nPwr10 = 0;
> >
> > +  first_element = *lpszStr++;
> > +
> > +  if ((first_element == '&') && (pNumprs->dwInFlags & NUMPRS_HEX_OCT))
> > +  {
> > +   /*  printf("TONY's hex string %s \n", debugstr_w(lpszStr)); */
> > +
> > +     first_element = *lpszStr++;
> > +
> > +     if (first_element == 'h' || first_element == 'H')
> > +     {
> > +        pNumprs->nBaseShift = 4;     /* hex number */
> > +       first_element = *lpszStr++;
> > +     }
> > +     else
> > +     {
> > +        pNumprs->nBaseShift = 3;     /* octal number */
> > +
> > +       if (first_element == 'o' || first_element == '0')
> > +        {
> > +          first_element = *lpszStr++;
> > +        }
> > +     }
> > +
> > +    while (first_element == '0')
> > +       first_element = *lpszStr++;
> > +
> > +    while (first_element != 0)
> > +    {
> > +       if (pNumprs->nBaseShift == 4)
> > +       {
> > +          if (first_element >= 'a' && first_element <= 'f')
> > +              value = first_element - 'a' + 10;  /* making integer value
> > out of hex character */
> > +          else if (first_element >= 'A' && first_element <= 'F')
> > +              value = first_element - 'A' + 10;  /* making integer value
> > out of hex character */
> > +          else if (first_element >= '0' && first_element <= '9')
> > +              value = first_element - '0';
> > +       }
> > +       else
> > +       {
> > +          if (first_element >= '0' && first_element <= '7')
> > +              value = first_element - '0';
> > +       }
> > +       rgbTmp[cchUsed] = value;
> > +       cchUsed++;                              /* count digits */
> > +       first_element = *lpszStr++;
> > +    }
> > +
> > +    if (cchUsed == 0)
> > +    {
> > +       value = 0;
> > +       rgbTmp[cchUsed] = value;
> > +       cchUsed = 1;
> > +    }
> > +
> > +    pNumprs->cDig = cchUsed;
> > +
> > +    memcpy(rgbDig, rgbTmp, pNumprs->cDig * sizeof(BYTE));
> > +    return S_OK;
> > +  }
> > +
> > +  if (!pNumprs || !rgbDig)
> > +    return E_INVALIDARG;
> > +
> > +  if (pNumprs->cDig < iMaxDigits)
> > +    iMaxDigits = pNumprs->cDig;
> > +
> > +
> >    if (!lpszStr)
> >      return DISP_E_TYPEMISMATCH;
> >
> > @@ -1971,6 +2040,26 @@
> >
> >    if (pNumprs->nBaseShift)
> >    {
> > +
> > +         /* we have to be sure that the number does not use more than 32 bits
> > +          * I am not sure if this is 100% valid - perhaps we should test for 64 ?? */
> > +      int bitCount = (pNumprs->nBaseShift) * (pNumprs->cDig);
> > +      if (bitCount > 32)
> > +             return DISP_E_OVERFLOW;
> > +
> > +      ULONG intValue = 0;
> > +      for ( ; pNumprs->cDig > 0; pNumprs->cDig--)
> > +         intValue = (intValue << (pNumprs->nBaseShift)) + *rgbDig++;
> > +
> > +    FIXME("Only VTBIT_I2 implemented. Need to add other cases :
> > VTBIT_I1, VTBIT_UI1 ...  etc   \n");
> > +    if  (dwVtBits & VTBIT_I2)
> > +    {
> > +          V_VT(pVarDst) = VT_I2;
> > +          V_I2(pVarDst) = intValue;
> > +          return S_OK;
> > +    }
> > +
> > +
> >      /* nBaseShift indicates a hex or octal number */
> >      ULONG64 ul64 = 0;
> >      LONG64 l64;
> >
> 
> 



-- 
James Hawkins



More information about the wine-devel mailing list