Skip to content

Commit

Permalink
Fixes for building cleanly on Mac OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Feb 17, 2016
1 parent 7735d8d commit 5a285c1
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ void Buffer_convertToUTF8(Buffer* this) {
Line* l = (Line*) this->panel->items->head;
while (l) {
char* intext = Line_toString(l);
int insize = Line_bytes(l);
int outsize = insize * 4 + 1;
size_t insize = Line_bytes(l);
size_t outsize = insize * 4 + 1;
char* outtext = calloc(outsize, 1);
int outleft = outsize;
size_t outleft = outsize;
char* outptr = outtext;
int err = iconv(cd, &intext, &insize, &outptr, &outleft);
if (err != -1) {
Expand Down Expand Up @@ -1149,13 +1149,13 @@ bool Buffer_find(Buffer* this, Text needle, bool findNext, bool caseSensitive, b

static void writeLineInFormat(FILE* fd, Line* l, bool utf8, iconv_t cd) {
char* intext = Line_toString(l);
int insize = Line_bytes(l);
size_t insize = Line_bytes(l);
if (utf8) {
fwrite(intext, insize, 1, fd);
} else {
int outsize = insize + 1;
size_t outsize = insize + 1;
char* outtext = calloc(outsize, 1);
int outleft = outsize;
size_t outleft = outsize;
char* outptr = outtext;
int err = iconv(cd, &intext, &insize, &outptr, &outleft);
if (err == -1) {
Expand Down
13 changes: 9 additions & 4 deletions Display.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ static Hashtable* Display_terminalSequences;
#ifdef HAVE_NCURSESW_CURSES_H
#include <ncursesw/curses.h>
#define HAVE_CURSES 1
#undef mvaddchnstr
#define mvaddchnstr mvadd_wchnstr
#elif HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
#define HAVE_CURSES 1
Expand Down Expand Up @@ -199,6 +197,14 @@ typedef struct mevent {
#endif
#ifdef HAVE_LIBNCURSESW
#define Display_writeChstrAtn mvadd_wchnstr
#elif HAVE_CURSES
#define Display_writeChstrAtn mvaddchnstr
#else
#define Display_writeChstrAtn Display_manualWriteChstrAtn
#endif
}*/

void Display_getScreenSize(int* w, int* h) {
Expand Down Expand Up @@ -358,9 +364,8 @@ void Display_clear() {
#endif

#if HAVE_CURSES
#define Display_writeChstrAtn mvaddchnstr
#else
void Display_writeChstrAtn(int y, int x, CharType* chstr, int n) {
void Display_manualWriteChstrAtn(int y, int x, CharType* chstr, int n) {
printf("\033[%d;%df", y+1, x+1, y, x, n);
/*
char str[n];
Expand Down
2 changes: 1 addition & 1 deletion Panel.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#include "Prototypes.h"
//#needs Object RichString
//#needs Object RichString Display

#include <math.h>
#include <sys/param.h>
Expand Down
1 change: 1 addition & 0 deletions RichString.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Prototypes.h"
// #needs Display

#include <stdlib.h>
#include <string.h>
Expand Down
3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if you have the `iconv' library (-liconv). */
#undef HAVE_LIBICONV

/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM

Expand Down
10 changes: 9 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,22 @@ if test "x$enable_unicode" = xyes; then
LIBS="-lncursesw6 $LIBS "
], [
AC_CHECK_LIB([ncursesw], [refresh], [], [
AC_CHECK_LIB([ncurses], [addnwstr], [
AC_DEFINE(HAVE_LIBNCURSESW, 1, [])
LIBS="-lncurses $LIBS "
], [
missing_libraries="$missing_libraries libncursesw"
AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])
])
])])
])
AC_CHECK_HEADERS([ncursesw/curses.h],[:],
[AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
[AC_CHECK_HEADERS([ncurses/curses.h],[:],
[AC_CHECK_HEADERS([ncurses.h],[:],[missing_headers="$missing_headers $ac_header"])])])])
AC_CHECK_LIB([iconv], [iconv], [], [
missing_libraries="$missing_libraries libiconv"
AC_MSG_ERROR([You may want to use --disable-unicode or install libiconv.])
])
else
AC_CHECK_LIB([ncurses], [refresh], [], [missing_libraries="$missing_libraries libncurses"])
AC_CHECK_HEADERS([curses.h],[:],
Expand Down
2 changes: 1 addition & 1 deletion dit.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static bool Dit_save(Buffer* buffer, TabManager* tabs) {
while (true) {
char fifoName[1025];
if (sudo) {
snprintf(fifoName, 1024, "%s/dit.write.%d.%d", getenv("TMPDIR"), getpid(), time(NULL));
snprintf(fifoName, 1024, "%s/dit.write.%d.%ld", getenv("TMPDIR"), getpid(), time(NULL));
unlink(fifoName);
int err = mkfifo(fifoName, 0600);
if (!err) {
Expand Down

0 comments on commit 5a285c1

Please sign in to comment.