diff options
| author | Tobias Markmann <tm@ayena.de> | 2015-09-24 18:59:52 (GMT) |
|---|---|---|
| committer | Swift Review <review@swift.im> | 2015-10-30 14:13:39 (GMT) |
| commit | 3d62970e1b929cf676202fc6cebc1cf426c14ff2 (patch) | |
| tree | a68c82c3829a001c6f8cadbb2d68d91c98f617bf /3rdParty/LibIDN/src/stringprep.c | |
| parent | 3cc7e86420e4b3d67c5882d8d68e1e6a003c6154 (diff) | |
| download | swift-3d62970e1b929cf676202fc6cebc1cf426c14ff2.zip swift-3d62970e1b929cf676202fc6cebc1cf426c14ff2.tar.bz2 | |
Update libIDN in 3rdParty to version 1.32
Updated existing libIDN files in 3rdParty folder to latest
1.32 version and added remaining dependencies for compilation.
Updated SConscript file accordingly.
Test-Information:
Build and ran test=unit on OS X 10.10.
Change-Id: Iec6506e1cc88fe2983b2019aca95a42580d1c80e
Diffstat (limited to '3rdParty/LibIDN/src/stringprep.c')
| -rw-r--r-- | 3rdParty/LibIDN/src/stringprep.c | 73 |
1 files changed, 45 insertions, 28 deletions
diff --git a/3rdParty/LibIDN/src/stringprep.c b/3rdParty/LibIDN/src/stringprep.c index 96fa316..8ff28e6 100644 --- a/3rdParty/LibIDN/src/stringprep.c +++ b/3rdParty/LibIDN/src/stringprep.c @@ -1,29 +1,37 @@ /* stringprep.c --- Core stringprep implementation. - * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Simon Josefsson - * - * This file is part of GNU Libidn. - * - * GNU Libidn is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * GNU Libidn is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with GNU Libidn; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - */ + Copyright (C) 2002-2015 Simon Josefsson + + This file is part of GNU Libidn. + + GNU Libidn is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version. + + or both in parallel, as here. + + GNU Libidn is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <stdlib.h> #include <string.h> #include "stringprep.h" @@ -98,19 +106,19 @@ stringprep_apply_table_to_string (uint32_t * ucs4, return STRINGPREP_OK; } #define INVERTED(x) ((x) & ((~0UL) >> 1)) #define UNAPPLICAPLEFLAGS(flags, profileflags) \ ((!INVERTED(profileflags) && !(profileflags & flags) && profileflags) || \ ( INVERTED(profileflags) && (profileflags & flags))) /** - * stringprep_4i - prepare internationalized string + * stringprep_4i: * @ucs4: input/output array with string to prepare. * @len: on input, length of input array with Unicode code points, * on exit, length of output array with Unicode code points. * @maxucs4len: maximum length of input/output array. * @flags: a #Stringprep_profile_flags value, or 0. * @profile: pointer to #Stringprep_profile to use. * * Prepare the input UCS-4 string according to the stringprep profile, * and write back the result to the input string. @@ -286,19 +294,19 @@ stringprep_4zi_1 (uint32_t * ucs4, size_t ucs4len, size_t maxucs4len, if (ucs4len >= maxucs4len) return STRINGPREP_TOO_SMALL_BUFFER; ucs4[ucs4len] = 0; return STRINGPREP_OK; } /** - * stringprep_4zi - prepare internationalized string + * stringprep_4zi: * @ucs4: input/output array with zero terminated string to prepare. * @maxucs4len: maximum length of input/output array. * @flags: a #Stringprep_profile_flags value, or 0. * @profile: pointer to #Stringprep_profile to use. * * Prepare the input zero terminated UCS-4 string according to the * stringprep profile, and write back the result to the input string. * * Since the stringprep operation can expand the string, @maxucs4len @@ -323,19 +331,19 @@ stringprep_4zi (uint32_t * ucs4, size_t maxucs4len, size_t ucs4len; for (ucs4len = 0; ucs4len < maxucs4len && ucs4[ucs4len] != 0; ucs4len++) ; return stringprep_4zi_1 (ucs4, ucs4len, maxucs4len, flags, profile); } /** - * stringprep - prepare internationalized string + * stringprep: * @in: input/ouput array with string to prepare. * @maxlen: maximum length of input/output array. * @flags: a #Stringprep_profile_flags value, or 0. * @profile: pointer to #Stringprep_profile to use. * * Prepare the input zero terminated UTF-8 string according to the * stringprep profile, and write back the result to the input string. * * Note that you must convert strings entered in the systems locale @@ -364,21 +372,22 @@ stringprep (char *in, int rc; char *utf8 = NULL; uint32_t *ucs4 = NULL; size_t ucs4len, maxucs4len, adducs4len = 50; do { uint32_t *newp; - if (ucs4) - free (ucs4); + free (ucs4); ucs4 = stringprep_utf8_to_ucs4 (in, -1, &ucs4len); + if (ucs4 == NULL) + return STRINGPREP_ICONV_ERROR; maxucs4len = ucs4len + adducs4len; newp = realloc (ucs4, maxucs4len * sizeof (uint32_t)); if (!newp) { free (ucs4); return STRINGPREP_MALLOC_ERROR; } ucs4 = newp; @@ -389,35 +398,35 @@ stringprep (char *in, if (rc != STRINGPREP_OK) { free (ucs4); return rc; } utf8 = stringprep_ucs4_to_utf8 (ucs4, ucs4len, 0, 0); free (ucs4); if (!utf8) - return STRINGPREP_MALLOC_ERROR; + return STRINGPREP_ICONV_ERROR; if (strlen (utf8) >= maxlen) { free (utf8); return STRINGPREP_TOO_SMALL_BUFFER; } strcpy (in, utf8); /* flawfinder: ignore */ free (utf8); return STRINGPREP_OK; } /** - * stringprep_profile - prepare internationalized string + * stringprep_profile: * @in: input array with UTF-8 string to prepare. * @out: output variable with pointer to newly allocate string. * @profile: name of stringprep profile to use. * @flags: a #Stringprep_profile_flags value, or 0. * * Prepare the input zero terminated UTF-8 string according to the * stringprep profile, and return the result in a newly allocated * variable. * @@ -447,20 +456,19 @@ stringprep_profile (const char *in, for (p = &stringprep_profiles[0]; p->name; p++) if (strcmp (p->name, profile) == 0) break; if (!p || !p->name || !p->tables) return STRINGPREP_UNKNOWN_PROFILE; do { - if (str) - free (str); + free (str); str = (char *) malloc (len); if (str == NULL) return STRINGPREP_MALLOC_ERROR; strcpy (str, in); rc = stringprep (str, len, flags, p->tables); len += 50; } @@ -578,18 +586,19 @@ stringprep_profile (const char *in, * @STRINGPREP_TOO_SMALL_BUFFER: Buffer handed to function was too * small. This usually indicate a problem in the calling * application. * @STRINGPREP_PROFILE_ERROR: The stringprep profile was inconsistent. * This usually indicate an internal error in the library. * @STRINGPREP_FLAG_ERROR: The supplied flag conflicted with profile. * This usually indicate a problem in the calling application. * @STRINGPREP_UNKNOWN_PROFILE: The supplied profile name was not * known to the library. + * @STRINGPREP_ICONV_ERROR: Could not convert string in locale encoding. * @STRINGPREP_NFKC_FAILED: The Unicode NFKC operation failed. This * usually indicate an internal error in the library. * @STRINGPREP_MALLOC_ERROR: The malloc() was out of memory. This is * usually a fatal error. * * Enumerated return codes of stringprep(), stringprep_profile() * functions (and macros using those functions). The value 0 is * guaranteed to always correspond to success. */ @@ -605,18 +614,26 @@ stringprep_profile (const char *in, * override it unless in special situations. * @STRINGPREP_NO_UNASSIGNED: Make the library return with an error if * string contains unassigned characters according to profile. * * Stringprep profile flags. */ /** * Stringprep_profile_steps: + * @STRINGPREP_NFKC: The NFKC step. + * @STRINGPREP_BIDI: The BIDI step. + * @STRINGPREP_MAP_TABLE: The MAP step. + * @STRINGPREP_UNASSIGNED_TABLE: The Unassigned step. + * @STRINGPREP_PROHIBIT_TABLE: The Prohibited step. + * @STRINGPREP_BIDI_PROHIBIT_TABLE: The BIDI-Prohibited step. + * @STRINGPREP_BIDI_RAL_TABLE: The BIDI-RAL step. + * @STRINGPREP_BIDI_L_TABLE: The BIDI-L step. * * Various steps in the stringprep algorithm. You really want to * study the source code to understand this one. Only useful if you * want to add another profile. */ /** * stringprep_nameprep: * @in: input/ouput array with string to prepare. |
Swift