chiark / gitweb /
log: more general error message formatting
[disorder] / lib / charset.c
index 0e2926968d9802d31ee685b83f620779afd1c365..feb4469e5950d0c7de9837ee3fa49d80e22ecff2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007, 2008, 2013 Richard Kettlewell
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 #include "common.h"
 
-#include <iconv.h>
+#if HAVE_ICONV_H
+# include <iconv.h>
+#endif
 #include <errno.h>
-#include <langinfo.h>
+#if HAVE_LANGINFO_H
+# include <langinfo.h>
+#endif
 
 #include "mem.h"
 #include "log.h"
@@ -45,7 +49,7 @@ static void *convert(const char *from, const char *to,
   size_t bufsize = 0, sl, dl;
 
   if((i = iconv_open(to, from)) == (iconv_t)-1)
-    fatal(errno, "error calling iconv_open");
+    disorder_fatal(errno, "error calling iconv_open");
   do {
     bufsize = bufsize ? 2 * bufsize : 32;
     buf = xrealloc_noptr(buf, bufsize);
@@ -59,7 +63,7 @@ static void *convert(const char *from, const char *to,
   } while(len == (size_t)-1 && errno == E2BIG);
   iconv_close(i);
   if(len == (size_t)-1) {
-    error(errno, "error converting from %s to %s", from, to);
+    disorder_error(errno, "error converting from %s to %s", from, to);
     return 0;
   }
   return buf;