[GHC] #4452: Graphics.Win32.GDI.Clip.enumClipboardFormats fails on success.

GHC cvs-ghc at haskell.org
Fri Oct 29 09:10:25 EDT 2010


#4452: Graphics.Win32.GDI.Clip.enumClipboardFormats fails on success.
---------------------------------+------------------------------------------
    Reporter:  fryguybob         |       Owner:                             
        Type:  bug               |      Status:  new                        
    Priority:  normal            |   Component:  libraries (other)          
     Version:  6.12.3            |    Keywords:  Win32, Clipboard           
    Testcase:                    |   Blockedby:                             
          Os:  Windows           |    Blocking:                             
Architecture:  Unknown/Multiple  |     Failure:  Incorrect result at runtime
---------------------------------+------------------------------------------
 According to the documentation for the Win32 EnumClipboardFormats
 function:

 http://msdn.microsoft.com/en-us/library/ms649038(VS.85).aspx

 A return value of zero is only an error if a subsequent call to
 GetLastError does not return ERROR_SUCCESS.  The following code is what I
 would expect:


 {{{
 errorWinNotErrorSuccess :: (Num a) => String -> IO a
 errorWinNotErrorSuccess fn_name = do
   err_code <- getLastError
   if err_code == 0 then return 0 else failWith fn_name err_code

 failIfZeroAndNotErrorSuccess :: Num a => String -> IO a -> IO a
 failIfZeroAndNotErrorSuccess wh act = do
   v <- act
   if v == 0 then errorWinNotErrorSuccess wh else return v

 enumClipboardFormats :: ClipboardFormat -> IO ClipboardFormat
 enumClipboardFormats format =
   failIfZeroAndNotErrorSuccess "EnumClipboardFormats" $
 c_EnumClipboardFormats format
 }}}

 Instead of the current:

 {{{
 enumClipboardFormats :: ClipboardFormat -> IO ClipboardFormat
 enumClipboardFormats format =
   failIfZero "EnumClipboardFormats" $ c_EnumClipboardFormats format
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4452>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list