Switch to side-by-side view

--- a/unac/unac.c
+++ b/unac/unac.c
@@ -30,9 +30,11 @@
 #include <string>
 #include <algorithm>
 #include <iostream>
-#include UNORDERED_MAP_INCLUDE
+#include <unordered_map>
+#include <mutex>
 
 using std::string;
+using std::vector;
 
 #include "smallut.h"
 
@@ -42,11 +44,10 @@
    instead according to some local rule. There will usually be very
    few of them, but they must be looked up for every translated char.
  */
-STD_UNORDERED_MAP<unsigned short, string> except_trans;
+std::unordered_map<unsigned short, string> except_trans;
 static inline bool is_except_char(unsigned short c, string& trans)
 {
-    STD_UNORDERED_MAP<unsigned short, string>::const_iterator it 
-	= except_trans.find(c);
+    auto it = except_trans.find(c);
     if (it == except_trans.end())
 	return false;
     trans = it->second;
@@ -74,7 +75,6 @@
 #include <stdio.h>
 #include <stdarg.h>
 #endif /* HAVE_VSNPRINTF */
-#include <pthread.h>
 
 #include "unac.h"
 #include "unac_version.h"
@@ -14312,14 +14312,7 @@
 static const char *utf16be = "UTF-16BE";
 static iconv_t u8tou16_cd = (iconv_t)-1;
 static iconv_t u16tou8_cd = (iconv_t)-1;
-static pthread_mutex_t o_unac_mutex;
-static int unac_mutex_is_init;
-// Call this or take your chances with the auto init.
-void unac_init_mt()
-{
-    pthread_mutex_init(&o_unac_mutex, 0);
-    unac_mutex_is_init = 1;
-}
+static std::mutex o_unac_mutex;
 
 /*
  * Convert buffer <in> containing string encoded in charset <from> into
@@ -14341,14 +14334,7 @@
   int from_utf16, from_utf8, to_utf16, to_utf8, u8tou16, u16tou8;
   const char space[] = { 0x00, 0x20 };
 
-  /* Note: better call explicit unac_init_mt() before starting threads than
-     rely on this.
-   */
-  if (unac_mutex_is_init == 0) {
-      pthread_mutex_init(&o_unac_mutex, 0);
-      unac_mutex_is_init = 1;
-  }
-  pthread_mutex_lock(&o_unac_mutex);
+  std::unique_lock<std::mutex> lock(o_unac_mutex);
 
   if (!strcmp(utf16be, from)) {
       from_utf8 = 0;
@@ -14492,7 +14478,6 @@
 
   ret = 0;
 out:
-  pthread_mutex_unlock(&o_unac_mutex);
   return ret;
 }