summaryrefslogtreecommitdiff
path: root/src/runtime/haskell-bind
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/haskell-bind')
-rw-r--r--src/runtime/haskell-bind/PGF2.hsc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/runtime/haskell-bind/PGF2.hsc b/src/runtime/haskell-bind/PGF2.hsc
index 186aa2b31..75afabb3d 100644
--- a/src/runtime/haskell-bind/PGF2.hsc
+++ b/src/runtime/haskell-bind/PGF2.hsc
@@ -990,11 +990,13 @@ withBracketLinFuncs ref exn f =
end_phrase ref _ c_cat c_fid c_lindex c_fun = do
(bs':stack,bs) <- readIORef ref
- cat <- peekUtf8CString c_cat
- let fid = fromIntegral c_fid
- let lindex = fromIntegral c_lindex
- fun <- peekUtf8CString c_fun
- writeIORef ref (stack, Bracket cat fid lindex fun (reverse bs) : bs')
+ if null bs
+ then writeIORef ref (stack, bs')
+ else do cat <- peekUtf8CString c_cat
+ let fid = fromIntegral c_fid
+ let lindex = fromIntegral c_lindex
+ fun <- peekUtf8CString c_fun
+ writeIORef ref (stack, Bracket cat fid lindex fun (reverse bs) : bs')
symbol_ne exn _ = do
gu_exn_raise exn gu_exn_type_PgfLinNonExist