Commits

Bryan O'Sullivan committed fbc2fa3

Drop a magic number

  • Participants
  • Parent commits a54fffe

Comments (0)

Files changed (4)

File Data/Text/Encoding.hs

 import qualified Data.Text.Fusion as F
 import Data.Text.Unsafe (unsafeDupablePerformIO)
 
+#include "text_cbits.h"
+
 -- $strict
 --
 -- All of the single-parameter functions for decoding bytestrings
                                                   codepointPtr statePtr
               state <- peek statePtr
               case state of
-                12 -> do
+                UTF8_REJECT -> do
                   -- We encountered an encoding error
                   x <- peek curPtr'
                   case onErr desc (Just x) of
                       poke destOffPtr (destOff + fromIntegral w)
                       poke statePtr 0
                       loop $ curPtr' `plusPtr` 1
- 
+
                 _ -> do
                   -- We encountered the end of the buffer while decoding
                   n <- peek destOffPtr

File cbits/cbits.c

 #include <string.h>
 #include <stdint.h>
 #include <stdio.h>
+#include "text_cbits.h"
 
 void _hs_text_memcpy(void *dest, size_t doff, const void *src, size_t soff,
 		     size_t n)

File include/text_cbits.h

+/*
+ * Copyright (c) 2013 Bryan O'Sullivan <bos@serpentine.com>.
+ */
+
+#ifndef _text_cbits_h
+#define _text_cbits_h
+
+#define UTF8_ACCEPT 0
+#define UTF8_REJECT 12
+
+#endif
   default: False
 
 library
-  c-sources: cbits/cbits.c
+  c-sources:    cbits/cbits.c
+  include-dirs: include
 
   exposed-modules:
     Data.Text
   hs-source-dirs: tests .
   main-is:        Tests.hs
   c-sources:      cbits/cbits.c
+  include-dirs:   include
 
   ghc-options:
     -Wall -threaded -O0 -rtsopts