Skip to content

Commit

Permalink
prefixed all c functions to avoid Cabal bug #944
Browse files Browse the repository at this point in the history
  • Loading branch information
toothbrush committed Apr 22, 2012
1 parent 68b3372 commit 54d35d6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cbits/gwinsz.c
@@ -1,6 +1,6 @@
#include <sys/ioctl.h>

unsigned long c_get_window_size(void) {
unsigned long vty_c_get_window_size(void) {
struct winsize w;
if (ioctl (0, TIOCGWINSZ, &w) >= 0)
return (w.ws_row << 16) + w.ws_col;
Expand Down
2 changes: 1 addition & 1 deletion cbits/gwinsz.h
@@ -1 +1 @@
unsigned long c_get_window_size(void);
unsigned long vty_c_get_window_size(void);
20 changes: 10 additions & 10 deletions cbits/mk_wcwidth.c
Expand Up @@ -67,7 +67,7 @@ struct interval {
};

/* auxiliary function for binary search in interval table */
static int bisearch(wchar_t ucs, const struct interval *table, int max) {
static int vty_bisearch(wchar_t ucs, const struct interval *table, int max) {
int min = 0;
int mid;

Expand Down Expand Up @@ -119,7 +119,7 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max) {
* in ISO 10646.
*/

int mk_wcwidth(wchar_t ucs)
int vty_mk_wcwidth(wchar_t ucs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */
/* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
Expand Down Expand Up @@ -181,7 +181,7 @@ int mk_wcwidth(wchar_t ucs)
return -1;

/* binary search in table of non-spacing characters */
if (bisearch(ucs, combining,
if (vty_bisearch(ucs, combining,
sizeof(combining) / sizeof(struct interval) - 1))
return 0;

Expand All @@ -204,12 +204,12 @@ int mk_wcwidth(wchar_t ucs)
}


int mk_wcswidth(const wchar_t *pwcs, size_t n)
int vty_mk_wcswidth(const wchar_t *pwcs, size_t n)
{
int w, width = 0;

for (;n-- > 0; pwcs++)
if ((w = mk_wcwidth(*pwcs)) < 0)
if ((w = vty_mk_wcwidth(*pwcs)) < 0)
return -1;
else
width += w;
Expand All @@ -227,7 +227,7 @@ int mk_wcswidth(const wchar_t *pwcs, size_t n)
* the traditional terminal character-width behaviour. It is not
* otherwise recommended for general use.
*/
int mk_wcwidth_cjk(wchar_t ucs)
int vty_mk_wcwidth_cjk(wchar_t ucs)
{
/* sorted list of non-overlapping intervals of East Asian Ambiguous
* characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
Expand Down Expand Up @@ -287,20 +287,20 @@ int mk_wcwidth_cjk(wchar_t ucs)
};

/* binary search in table of non-spacing characters */
if (bisearch(ucs, ambiguous,
if (vty_bisearch(ucs, ambiguous,
sizeof(ambiguous) / sizeof(struct interval) - 1))
return 2;

return mk_wcwidth(ucs);
return vty_mk_wcwidth(ucs);
}


int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
int vty_mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
{
int w, width = 0;

for (;n-- > 0; pwcs++)
if ((w = mk_wcwidth_cjk(*pwcs)) < 0)
if ((w = vty_mk_wcwidth_cjk(*pwcs)) < 0)
return -1;
else
width += w;
Expand Down
2 changes: 1 addition & 1 deletion cbits/set_term_timing.c
Expand Up @@ -3,7 +3,7 @@
#include <unistd.h>
#include <stdlib.h>

void set_term_timing(void)
void vty_set_term_timing(void)
{
struct termios trm;
tcgetattr(STDIN_FILENO, &trm);
Expand Down
4 changes: 2 additions & 2 deletions src/Codec/Binary/UTF8/Width.hs
Expand Up @@ -25,7 +25,7 @@ wcwidth c = unsafePerformIO (withCWString [c] $! \ws -> do
)
{-# NOINLINE wcwidth #-}

foreign import ccall unsafe "mk_wcwidth" wcwidth' :: CWchar -> CInt
foreign import ccall unsafe "vty_mk_wcwidth" wcwidth' :: CWchar -> CInt

wcswidth :: String -> Int
wcswidth str = unsafePerformIO (withCWStringLen str $! \(ws, ws_len) -> do
Expand All @@ -36,4 +36,4 @@ wcswidth str = unsafePerformIO (withCWStringLen str $! \(ws, ws_len) -> do
)
{-# NOINLINE wcswidth #-}

foreign import ccall unsafe "mk_wcswidth" wcswidth' :: Ptr CWchar -> CSize -> CInt
foreign import ccall unsafe "vty_mk_wcswidth" wcswidth' :: Ptr CWchar -> CSize -> CInt
2 changes: 1 addition & 1 deletion src/Graphics/Vty/LLInput.hs
Expand Up @@ -236,4 +236,4 @@ utf8Length c
| c < 0xF0 = 3
| otherwise = 4

foreign import ccall "set_term_timing" set_term_timing :: IO ()
foreign import ccall "vty_set_term_timing" set_term_timing :: IO ()
2 changes: 1 addition & 1 deletion src/Graphics/Vty/Terminal/TerminfoBased.hs
Expand Up @@ -181,7 +181,7 @@ instance Terminal Term where

output_handle t = return (term_handle t)

foreign import ccall "gwinsz.h c_get_window_size" c_get_window_size
foreign import ccall "gwinsz.h vty_c_get_window_size" c_get_window_size
:: IO CLong

get_window_size :: IO (Int,Int)
Expand Down
2 changes: 1 addition & 1 deletion vty.cabal
@@ -1,5 +1,5 @@
Name: vty
Version: 4.7.0.10
Version: 4.7.0.11
License: BSD3
License-file: LICENSE
Author: Stefan O'Rear, Corey O'Connor
Expand Down

0 comments on commit 54d35d6

Please sign in to comment.