Switch to unified view

a/src/common/unacpp.cpp b/src/common/unacpp.cpp
...
...
23
#include <cstdlib>
23
#include <cstdlib>
24
#include <errno.h>
24
#include <errno.h>
25
25
26
#include <string>
26
#include <string>
27
27
28
#ifndef NO_NAMESPACES
29
using std::string;
30
#endif /* NO_NAMESPACES */
31
32
#include "unacpp.h"
28
#include "unacpp.h"
33
#include "unac.h"
29
#include "unac.h"
30
#include "debuglog.h"
31
#include "utf8iter.h"
34
32
35
36
bool unacmaybefold(const std::string &in, std::string &out, 
33
bool unacmaybefold(const string &in, string &out, 
37
           const char *encoding, bool dofold)
34
           const char *encoding, bool dofold)
38
{
35
{
39
    char *cout = 0;
36
    char *cout = 0;
40
    size_t out_len;
37
    size_t out_len;
41
    int status;
38
    int status;
...
...
52
    }
49
    }
53
    out.assign(cout, out_len);
50
    out.assign(cout, out_len);
54
    if (cout)
51
    if (cout)
55
    free(cout);
52
    free(cout);
56
    return true;
53
    return true;
54
}
55
56
bool unaciscapital(const string& in)
57
{
58
    if (in.empty())
59
  return false;
60
    Utf8Iter it(in);
61
    string shorter;
62
    it.appendchartostring(shorter);
63
64
    string noacterm, noaclowterm;
65
    if (!unacmaybefold(shorter, noacterm, "UTF-8", false)) {
66
  LOGINFO(("unaciscapital: unac failed for [%s]\n", in.c_str()));
67
  return false;
68
    } 
69
    if (!unacmaybefold(noacterm, noaclowterm, "UTF-8", true)) {
70
  LOGINFO(("unaciscapital: unacfold failed for [%s]\n", in.c_str()));
71
  return false;
72
    }
73
    Utf8Iter it1(noacterm);
74
    Utf8Iter it2(noaclowterm);
75
    if (*it1 != *it2)
76
  return true;
77
    else
78
  return false;
57
}
79
}
58
80
59
#else // not testing
81
#else // not testing
60
82
61
#include <unistd.h>
83
#include <unistd.h>