Bryan O'Sullivan committed fbc2fa3

Drop a magic number

Comments (0)

Files changed (4)


 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
 #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)


+ * Copyright (c) 2013 Bryan O'Sullivan <>.
+ */
+#ifndef _text_cbits_h
+#define _text_cbits_h
+#define UTF8_ACCEPT 0
+#define UTF8_REJECT 12
   default: False
-  c-sources: cbits/cbits.c
+  c-sources:    cbits/cbits.c
+  include-dirs: include
   hs-source-dirs: tests .
   main-is:        Tests.hs
   c-sources:      cbits/cbits.c
+  include-dirs:   include
     -Wall -threaded -O0 -rtsopts
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.