From 52f2739da1c583b7ded38b859388bc067b9485ee Mon Sep 17 00:00:00 2001 From: krangelov Date: Wed, 27 Feb 2019 08:27:50 +0100 Subject: [PATCH] strip empty phrases in bracketedLinearize --- src/runtime/haskell-bind/PGF2.hsc | 12 +++++++----- 1 file 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