From: Frank Lahm Date: Tue, 3 Jan 2012 14:26:39 +0000 (+0100) Subject: Merge master X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=7be2a68aa70fa5641e944ad0aed6f699736d3de9;hp=-c Merge master --- 7be2a68aa70fa5641e944ad0aed6f699736d3de9 diff --combined etc/cnid_dbd/cnid_metad.c index 19087f19,aec73eca..2a3bc6b9 --- a/etc/cnid_dbd/cnid_metad.c +++ b/etc/cnid_dbd/cnid_metad.c @@@ -44,7 -44,7 +44,7 @@@ #include #include #include -#define _XPG4_2 1 +// #define _XPG4_2 1 #include #include #include @@@ -90,7 -90,6 +90,7 @@@ #include #include #include +#include #include "usockfd.h" @@@ -451,8 -450,12 +451,12 @@@ int main(int argc, char *argv[] set_processname("cnid_metad"); - while (( cc = getopt( argc, argv, "ds:p:h:u:g:l:f:")) != -1 ) { + while (( cc = getopt( argc, argv, "vVds:p:h:u:g:l:f:")) != -1 ) { switch (cc) { + case 'v': + case 'V': + printf("cnid_metad (Netatalk %s)\n", VERSION); + return -1; case 'd': debug = 1; break; diff --combined etc/cnid_dbd/main.c index 1219712e,e050a0e5..55bbcddb --- a/etc/cnid_dbd/main.c +++ b/etc/cnid_dbd/main.c @@@ -8,20 -8,28 +8,20 @@@ #include "config.h" #endif /* HAVE_CONFIG_H */ -#ifdef HAVE_UNISTD_H #include -#endif /* HAVE_UNISTD_H */ -#ifdef HAVE_FCNTL_H #include -#endif /* HAVE_FCNTL_H */ #include #include #include #include #include -#ifdef HAVE_SYS_TYPES_H #include -#endif /* HAVE_SYS_TYPES_H */ #include -#ifdef HAVE_SYS_STAT_H #include -#endif /* HAVE_SYS_STAT_H */ #include #include +#include -#include #include #include #include @@@ -280,8 -288,12 +280,12 @@@ int main(int argc, char *argv[] set_processname("cnid_dbd"); - while (( ret = getopt( argc, argv, "d")) != -1 ) { + while (( ret = getopt( argc, argv, "vVd")) != -1 ) { switch (ret) { + case 'v': + case 'V': + printf("cnid_dbd (Netatalk %s)\n", VERSION); + return -1; case 'd': delete_bdb = 1; break; diff --combined libatalk/unicode/util_unistr.c index 3c9a194b,decd8c0a..e5ea4ba0 --- a/libatalk/unicode/util_unistr.c +++ b/libatalk/unicode/util_unistr.c @@@ -19,7 -19,8 +19,7 @@@ #include #include #include - -#include +#include #include #include "precompose.h" @@@ -38,8 -39,8 +38,8 @@@ int strlower_w(ucs2_t *s while (*s) { if ((0xD800 <= *s) && (*s < 0xDC00)) { if ((0xDC00 <= s[1]) && (s[1] < 0xE000)) { - u_int32_t s_sp = (u_int32_t)*s << 16 | (u_int32_t)s[1]; - u_int32_t v_sp = tolower_sp(s_sp); + uint32_t s_sp = (uint32_t)*s << 16 | (uint32_t)s[1]; + uint32_t v_sp = tolower_sp(s_sp); if (v_sp != s_sp) { *s = v_sp >> 16; s++; @@@ -72,8 -73,8 +72,8 @@@ int strupper_w(ucs2_t *s while (*s) { if ((0xD800 <= *s) && (*s < 0xDC00)) { if ((0xDC00 <= s[1]) && (s[1] < 0xE000)) { - u_int32_t s_sp = (u_int32_t)*s << 16 | (u_int32_t)s[1]; - u_int32_t v_sp = toupper_sp(s_sp); + uint32_t s_sp = (uint32_t)*s << 16 | (uint32_t)s[1]; + uint32_t v_sp = toupper_sp(s_sp); if (v_sp != s_sp) { *s = v_sp >> 16; s++; @@@ -104,7 -105,7 +104,7 @@@ int islower_w(ucs2_t c return ( c == tolower_w(c)); } -int islower_sp(u_int32_t c_sp) +int islower_sp(uint32_t c_sp) { return ( c_sp == tolower_sp(c_sp)); } @@@ -120,7 -121,7 +120,7 @@@ int isupper_w(ucs2_t c return ( c == toupper_w(c)); } -int isupper_sp(u_int32_t c_sp) +int isupper_sp(uint32_t c_sp) { return ( c_sp == toupper_sp(c_sp)); } @@@ -179,8 -180,7 +179,7 @@@ wide & sp strcasechr( ucs2_t *strcasechr_w(const ucs2_t *s, ucs2_t c) { while (*s != 0) { - /* LOG(log_debug, logtype_default, "Comparing %X to %X (%X - %X)", c, *s, toupper_w(c), toupper_w(*s));*/ - if (toupper_w(c) == toupper_w(*s)) return (ucs2_t *)s; + if (tolower_w(c) == tolower_w(*s)) return (ucs2_t *)s; s++; } if (c == *s) return (ucs2_t *)s; @@@ -188,11 -188,11 +187,11 @@@ return NULL; } -ucs2_t *strcasechr_sp(const ucs2_t *s, u_int32_t c_sp) +ucs2_t *strcasechr_sp(const ucs2_t *s, uint32_t c_sp) { if (*s == 0) return NULL; while (s[1] != 0) { - if (toupper_sp(c_sp) == toupper_sp((uint32_t)*s << 16 | (uint32_t)s[1])) return (ucs2_t *)s; - if (tolower_sp(c_sp) == tolower_sp((u_int32_t)*s << 16 | (u_int32_t)s[1])) return (ucs2_t *)s; ++ if (tolower_sp(c_sp) == tolower_sp((uint32_t)*s << 16 | (uint32_t)s[1])) return (ucs2_t *)s; s++; } @@@ -249,7 -249,7 +248,7 @@@ ucs2_t *strstr_w(const ucs2_t *s, cons /******************************************************************* wide strcasestr() ********************************************************************/ - /* */ + /* surrogate pair support */ ucs2_t *strcasestr_w(const ucs2_t *s, const ucs2_t *ins) { @@@ -260,9 -260,22 +259,22 @@@ slen = strlen_w(s); inslen = strlen_w(ins); r = (ucs2_t *)s; - while ((r = strcasechr_w(r, *ins))) { - if (strncasecmp_w(r, ins, inslen) == 0) return r; - r++; + + if ((0xD800 <= *ins) && (*ins < 0xDC00)) { + if ((0xDC00 <= ins[1]) && (ins[1] < 0xE000)) { + u_int32_t ins_sp = (u_int32_t)*ins << 16 | (u_int32_t)ins[1]; + while ((r = strcasechr_sp(r, ins_sp))) { + if (strncasecmp_w(r, ins, inslen) == 0) return r; + r++; + } + } else { + return NULL; /* illegal sequence */ + } + } else { + while ((r = strcasechr_w(r, *ins))) { + if (strncasecmp_w(r, ins, inslen) == 0) return r; + r++; + } } return NULL; } @@@ -279,7 -292,7 +291,7 @@@ int strcasecmp_w(const ucs2_t *a, cons while (*a && *b) { if ((0xD800 <= *a) && (*a < 0xDC00)) { - if (ret = tolower_sp((u_int32_t)*a << 16 | (u_int32_t)a[1]) - tolower_sp((u_int32_t)*b << 16 | (u_int32_t)b[1])) return ret; + if (ret = tolower_sp((uint32_t)*a << 16 | (uint32_t)a[1]) - tolower_sp((uint32_t)*b << 16 | (uint32_t)b[1])) return ret; a++; b++; if (!(*a && *b)) return (tolower_w(*a) - tolower_w(*b)); /* avoid buffer over run */ @@@ -305,7 -318,7 +317,7 @@@ int strncasecmp_w(const ucs2_t *a, cons while ((n < len) && *a && *b) { if ((0xD800 <= *a) && (*a < 0xDC00)) { - if (ret = tolower_sp((u_int32_t)*a << 16 | (u_int32_t)a[1]) - tolower_sp((u_int32_t)*b << 16 | (u_int32_t)b[1])) return ret; + if (ret = tolower_sp((uint32_t)*a << 16 | (uint32_t)a[1]) - tolower_sp((uint32_t)*b << 16 | (uint32_t)b[1])) return ret; a++; b++; n++; @@@ -358,6 -371,8 +370,8 @@@ ucs2_t *strdup_w(const ucs2_t *src /******************************************************************* copy a string with max len ********************************************************************/ + /* This function is not used. */ + /* NOTE: not check isolation of surrogate pair */ ucs2_t *strncpy_w(ucs2_t *dest, const ucs2_t *src, const size_t max) { @@@ -377,7 -392,9 +391,9 @@@ /******************************************************************* append a string of len bytes and add a terminator ********************************************************************/ + /* These functions are not used. */ + /* NOTE: not check isolation of surrogate pair */ ucs2_t *strncat_w(ucs2_t *dest, const ucs2_t *src, const size_t max) { size_t start; @@@ -394,7 -411,7 +410,7 @@@ return dest; } - + /* no problem of surrogate pair */ ucs2_t *strcat_w(ucs2_t *dest, const ucs2_t *src) { size_t start; @@@ -421,7 -438,7 +437,7 @@@ static ucs2_t do_precomposition(unsigne int min = 0; int max = PRECOMP_COUNT - 1; int mid; - u_int32_t sought = (base << 16) | comb, that; + uint32_t sought = (base << 16) | comb, that; /* binary search */ while (max >= min) { @@@ -440,17 -457,17 +456,17 @@@ } /* ------------------------ */ -static u_int32_t do_precomposition_sp(unsigned int base_sp, unsigned int comb_sp) +static uint32_t do_precomposition_sp(unsigned int base_sp, unsigned int comb_sp) { int min = 0; int max = PRECOMP_SP_COUNT - 1; int mid; - u_int64_t sought_sp = ((u_int64_t)base_sp << 32) | (u_int64_t)comb_sp, that_sp; + uint64_t sought_sp = ((uint64_t)base_sp << 32) | (uint64_t)comb_sp, that_sp; /* binary search */ while (max >= min) { mid = (min + max) / 2; - that_sp = ((u_int64_t)precompositions_sp[mid].base_sp << 32) | ((u_int64_t)precompositions_sp[mid].comb_sp); + that_sp = ((uint64_t)precompositions_sp[mid].base_sp << 32) | ((uint64_t)precompositions_sp[mid].comb_sp); if (that_sp < sought_sp) { min = mid + 1; } else if (that_sp > sought_sp) { @@@ -464,13 -481,13 +480,13 @@@ } /* -------------------------- */ -static u_int32_t do_decomposition(ucs2_t base) +static uint32_t do_decomposition(ucs2_t base) { int min = 0; int max = DECOMP_COUNT - 1; int mid; - u_int32_t sought = base; - u_int32_t result, that; + uint32_t sought = base; + uint32_t result, that; /* binary search */ while (max >= min) { @@@ -490,14 -507,14 +506,14 @@@ } /* -------------------------- */ -static u_int64_t do_decomposition_sp(unsigned int base_sp) +static uint64_t do_decomposition_sp(unsigned int base_sp) { int min = 0; int max = DECOMP_SP_COUNT - 1; int mid; - u_int32_t sought_sp = base_sp; - u_int32_t that_sp; - u_int64_t result_sp; + uint32_t sought_sp = base_sp; + uint32_t that_sp; + uint64_t result_sp; /* binary search */ while (max >= min) { @@@ -508,7 -525,7 +524,7 @@@ } else if (that_sp > sought_sp) { max = mid - 1; } else { - result_sp = ((u_int64_t)decompositions_sp[mid].base_sp << 32) | ((u_int64_t)decompositions_sp[mid].comb_sp); + result_sp = ((uint64_t)decompositions_sp[mid].base_sp << 32) | ((uint64_t)decompositions_sp[mid].comb_sp); return result_sp; } } @@@ -535,11 -552,11 +551,11 @@@ size_t precompose_w (ucs2_t *name, size { size_t i; ucs2_t base, comb; - u_int32_t base_sp, comb_sp; + uint32_t base_sp, comb_sp; ucs2_t *in, *out; ucs2_t lindex, vindex; ucs2_t result; - u_int32_t result_sp; + uint32_t result_sp; size_t o_len = *outlen; if (!inplen || (inplen & 1) || inplen > o_len) @@@ -588,9 -605,9 +604,9 @@@ /* Binary Search for Surrogate Pair */ else if ((0xD800 <= base) && (base < 0xDC00)) { if ((0xDC00 <= comb) && (comb < 0xE000) && (i + 6 <= inplen)) { - base_sp = ((u_int32_t)base << 16) | (u_int32_t)comb; + base_sp = ((uint32_t)base << 16) | (uint32_t)comb; do { - comb_sp = ((u_int32_t)in[1] << 16) | (u_int32_t)in[2]; + comb_sp = ((uint32_t)in[1] << 16) | (uint32_t)in[2]; if (result_sp = do_precomposition_sp(base_sp, comb_sp)) { base_sp = result_sp; i += 4; @@@ -647,11 -664,11 +663,11 @@@ size_t decompose_w (ucs2_t *name, size_ size_t i; size_t comblen; ucs2_t base, comb[COMBBUFLEN]; - u_int32_t base_sp; + uint32_t base_sp; ucs2_t sindex, tjamo; ucs2_t *in, *out; unsigned int result; - u_int64_t result_sp; + uint64_t result_sp; size_t o_len = *outlen; if (!inplen || (inplen & 1)) @@@ -689,7 -706,7 +705,7 @@@ /* Binary Search for Surrogate Pair */ else if ((0xD800 <= base) && (base < 0xDC00)) { if (i + 2 < inplen) { - base_sp = ((u_int32_t)base << 16) | (u_int32_t)in[1]; + base_sp = ((uint32_t)base << 16) | (uint32_t)in[1]; do { if ( !(result_sp = do_decomposition_sp(base_sp))) break; comblen += 2;