summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-03-03 19:47:46 -0800
committerJunio C Hamano <junkio@cox.net>2007-03-03 19:47:46 -0800
commit253e772edeb56092e0fad43ec0640658671313c5 (patch)
tree8e9278a4ac03353056acd765c04779e01b0ce2f9 /utf8.c
parent4808bec6f9b5fe414f0dbc2cc0445f54f28e9e9c (diff)
parent7943b3a94f0f862dc9d7dcec6b5639ae5bf027bd (diff)
downloadgit-253e772edeb56092e0fad43ec0640658671313c5.tar.gz
Merge branch 'maint'
* maint: Unset NO_C99_FORMAT on Cygwin. Fix a "pointer type missmatch" warning. Fix some "comparison is always true/false" warnings. Fix an "implicit function definition" warning. Fix a "label defined but unreferenced" warning. Document the config variable format.suffix git-merge: fail correctly when we cannot fast forward. builtin-archive: use RUN_SETUP Fix git-gc usage note
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/utf8.c b/utf8.c
index 9e1a6d4964..a2965c9c11 100644
--- a/utf8.c
+++ b/utf8.c
@@ -3,13 +3,15 @@
/* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */
+typedef unsigned int ucs_char_t; /* assuming 32bit int */
+
struct interval {
int first;
int last;
};
/* auxiliary function for binary search in interval table */
-static int bisearch(wchar_t ucs, const struct interval *table, int max) {
+static int bisearch(ucs_char_t ucs, const struct interval *table, int max) {
int min = 0;
int mid;
@@ -56,11 +58,11 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max) {
* ISO 8859-1 and WGL4 characters, Unicode control characters,
* etc.) have a column width of 1.
*
- * This implementation assumes that wchar_t characters are encoded
+ * This implementation assumes that ucs_char_t characters are encoded
* in ISO 10646.
*/
-static int wcwidth(wchar_t ch)
+static int wcwidth(ucs_char_t ch)
{
/*
* Sorted list of non-overlapping intervals of non-spacing characters,
@@ -157,7 +159,7 @@ static int wcwidth(wchar_t ch)
int utf8_width(const char **start)
{
unsigned char *s = (unsigned char *)*start;
- wchar_t ch;
+ ucs_char_t ch;
if (*s < 0x80) {
/* 0xxxxxxx */
@@ -298,11 +300,17 @@ int is_encoding_utf8(const char *name)
* with iconv. If the conversion fails, returns NULL.
*/
#ifndef NO_ICONV
+#ifdef OLD_ICONV
+ typedef const char * iconv_ibp;
+#else
+ typedef char * iconv_ibp;
+#endif
char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding)
{
iconv_t conv;
size_t insz, outsz, outalloc;
- char *out, *outpos, *cp;
+ char *out, *outpos;
+ iconv_ibp cp;
if (!in_encoding)
return NULL;
@@ -314,7 +322,7 @@ char *reencode_string(const char *in, const char *out_encoding, const char *in_e
outalloc = outsz + 1; /* for terminating NUL */
out = xmalloc(outalloc);
outpos = out;
- cp = (char *)in;
+ cp = (iconv_ibp)in;
while (1) {
size_t cnt = iconv(conv, &cp, &insz, &outpos, &outsz);