From: Michihiro NAKAJIMA Date: Fri, 16 Mar 2012 07:08:26 +0000 (+0900) Subject: Rename some internal functions as other related functions. X-Git-Tag: v3.0.4~2^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb54aceea1bd462863f51ce43583cb950b1b3b68;p=thirdparty%2Flibarchive.git Rename some internal functions as other related functions. archive_strcpy_in_locale ==> archive_strcpy_l archive_strncpy_in_locale ==> archive_strncpy_l archive_strncat_in_locale ==> archive_strncat_l --- diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c index 93e29c006..2728a376c 100644 --- a/libarchive/archive_string.c +++ b/libarchive/archive_string.c @@ -1879,8 +1879,8 @@ archive_string_conversion_set_opt(struct archive_string_conv *sc, int opt) * * Copy one archive_string to another in locale conversion. * - * archive_strncpy_in_locale(); - * archive_strcpy_in_locale(); + * archive_strncat_l(); + * archive_strncpy_l(); * */ @@ -1926,15 +1926,15 @@ utf16nbytes(const void *_p, size_t n) } int -archive_strncpy_in_locale(struct archive_string *as, const void *_p, size_t n, +archive_strncpy_l(struct archive_string *as, const void *_p, size_t n, struct archive_string_conv *sc) { as->length = 0; - return (archive_strncat_in_locale(as, _p, n, sc)); + return (archive_strncat_l(as, _p, n, sc)); } int -archive_strncat_in_locale(struct archive_string *as, const void *_p, size_t n, +archive_strncat_l(struct archive_string *as, const void *_p, size_t n, struct archive_string_conv *sc) { const void *s; @@ -3887,7 +3887,7 @@ archive_mstring_get_utf8(struct archive *a, struct archive_mstring *aes, sc = archive_string_conversion_to_charset(a, "UTF-8", 1); if (sc == NULL) return (-1);/* Couldn't allocate memory for sc. */ - r = archive_strncpy_in_locale(&(aes->aes_mbs), aes->aes_mbs.s, + r = archive_strncpy_l(&(aes->aes_mbs), aes->aes_mbs.s, aes->aes_mbs.length, sc); if (a == NULL) free_sconv_object(sc); @@ -4016,7 +4016,7 @@ archive_mstring_get_mbs_l(struct archive_mstring *aes, *length = aes->aes_mbs.length; return (0); } - ret = archive_strncpy_in_locale(&(aes->aes_mbs_in_locale), + ret = archive_strncpy_l(&(aes->aes_mbs_in_locale), aes->aes_mbs.s, aes->aes_mbs.length, sc); *p = aes->aes_mbs_in_locale.s; if (length != NULL) @@ -4117,7 +4117,7 @@ archive_mstring_copy_mbs_len_l(struct archive_mstring *aes, * Translate multi-bytes from some character-set to UTF-8. */ sc->cd = sc->cd_w; - r = archive_strncpy_in_locale(&(aes->aes_utf8), mbs, len, sc); + r = archive_strncpy_l(&(aes->aes_utf8), mbs, len, sc); sc->cd = cd; if (r != 0) { aes->aes_set = 0; @@ -4149,7 +4149,7 @@ archive_mstring_copy_mbs_len_l(struct archive_mstring *aes, aes->aes_set = 0; } #else - r = archive_strncpy_in_locale(&(aes->aes_mbs), mbs, len, sc); + r = archive_strncpy_l(&(aes->aes_mbs), mbs, len, sc); if (r == 0) aes->aes_set = AES_SET_MBS; /* Only MBS form is set now. */ else @@ -4193,7 +4193,7 @@ archive_mstring_update_utf8(struct archive *a, struct archive_mstring *aes, sc = archive_string_conversion_from_charset(a, "UTF-8", 1); if (sc == NULL) return (-1);/* Couldn't allocate memory for sc. */ - r = archive_strcpy_in_locale(&(aes->aes_mbs), utf8, sc); + r = archive_strcpy_l(&(aes->aes_mbs), utf8, sc); if (a == NULL) free_sconv_object(sc); if (r != 0) diff --git a/libarchive/archive_string.h b/libarchive/archive_string.h index a5c0436fc..23f491657 100644 --- a/libarchive/archive_string.h +++ b/libarchive/archive_string.h @@ -117,13 +117,13 @@ archive_string_conversion_set_opt(struct archive_string_conv *, int); /* Copy one archive_string to another in locale conversion. * Return -1 if conversion failes. */ int -archive_strncpy_in_locale(struct archive_string *, const void *, size_t, +archive_strncpy_l(struct archive_string *, const void *, size_t, struct archive_string_conv *); /* Copy one archive_string to another in locale conversion. * Return -1 if conversion failes. */ int -archive_strncat_in_locale(struct archive_string *, const void *, size_t, +archive_strncat_l(struct archive_string *, const void *, size_t, struct archive_string_conv *); @@ -164,8 +164,8 @@ archive_wstrcat(struct archive_wstring *, const wchar_t *); archive_strncpy((as), (p), ((p) == NULL ? 0 : strlen(p))) #define archive_wstrcpy(as,p) \ archive_wstrncpy((as), (p), ((p) == NULL ? 0 : wcslen(p))) -#define archive_strcpy_in_locale(as,p,lo) \ - archive_strncpy_in_locale((as), (p), ((p) == NULL ? 0 : strlen(p)), (lo)) +#define archive_strcpy_l(as,p,lo) \ + archive_strncpy_l((as), (p), ((p) == NULL ? 0 : strlen(p)), (lo)) /* Copy a C string to an archive_string with limit, resizing as necessary. */ #define archive_strncpy(as,p,l) \ diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c index 3277803e6..483de9086 100644 --- a/libarchive/archive_write_set_format_iso9660.c +++ b/libarchive/archive_write_set_format_iso9660.c @@ -2244,7 +2244,7 @@ set_str_utf16be(struct archive_write *a, unsigned char *p, const char *s, onepad = 0; if (vdc == VDC_UCS2) { struct iso9660 *iso9660 = a->format_data; - if (archive_strncpy_in_locale(&iso9660->utf16be, s, strlen(s), + if (archive_strncpy_l(&iso9660->utf16be, s, strlen(s), iso9660->sconv_to_utf16be) != 0 && errno == ENOMEM) { archive_set_error(&a->archive, ENOMEM, "Can't allocate memory for UTF-16BE"); @@ -6274,7 +6274,7 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent, * Get a length of MBS of a full-pathname. */ if ((int)np->file->basename_utf16.length > ffmax) { - if (archive_strncpy_in_locale(&iso9660->mbs, + if (archive_strncpy_l(&iso9660->mbs, (const char *)np->identifier, l, iso9660->sconv_from_utf16be) != 0 && errno == ENOMEM) { diff --git a/libarchive/archive_write_set_format_pax.c b/libarchive/archive_write_set_format_pax.c index dec6bc363..3b0f4ae29 100644 --- a/libarchive/archive_write_set_format_pax.c +++ b/libarchive/archive_write_set_format_pax.c @@ -334,8 +334,7 @@ archive_write_pax_header_xattrs(struct archive_write *a, url_encoded_name = url_encode(name); if (url_encoded_name != NULL) { /* Convert narrow-character to UTF-8. */ - r = archive_strcpy_in_locale( - &(pax->l_url_encoded_name), + r = archive_strcpy_l(&(pax->l_url_encoded_name), url_encoded_name, pax->sconv_utf8); free(url_encoded_name); /* Done with this. */ if (r == 0) diff --git a/libarchive/test/test_archive_string_conversion.c b/libarchive/test/test_archive_string_conversion.c index 3d217a10f..1fc116818 100644 --- a/libarchive/test/test_archive_string_conversion.c +++ b/libarchive/test/test_archive_string_conversion.c @@ -380,7 +380,7 @@ test_archive_string_normalization(int mac_nfd) /* * Normalize an NFC string for import. */ - assertEqualInt(0, archive_strcpy_in_locale( + assertEqualInt(0, archive_strcpy_l( &utf8, utf8_nfc, f_sconv8)); if (should_be_nfc) { failure("NFC(%s) should not be converted to" @@ -396,7 +396,7 @@ test_archive_string_normalization(int mac_nfd) /* * Normalize an NFD string for import. */ - assertEqualInt(0, archive_strcpy_in_locale( + assertEqualInt(0, archive_strcpy_l( &utf8, utf8_nfd, f_sconv8)); failure("NFD(%s) should not be any changed:%d", nfd, line); @@ -405,7 +405,7 @@ test_archive_string_normalization(int mac_nfd) /* * Copy an NFD string for export. */ - assertEqualInt(0, archive_strcpy_in_locale( + assertEqualInt(0, archive_strcpy_l( &utf8, utf8_nfd, t_sconv8)); failure("NFD(%s) should not be any changed:%d", nfd, line); @@ -414,7 +414,7 @@ test_archive_string_normalization(int mac_nfd) /* * Normalize an NFC string in UTF-16BE for import. */ - assertEqualInt(0, archive_strncpy_in_locale( + assertEqualInt(0, archive_strncpy_l( &utf8, utf16be_nfc, 100000, f_sconv16be)); if (should_be_nfc) { failure("NFC(%s) should not be converted to" @@ -429,7 +429,7 @@ test_archive_string_normalization(int mac_nfd) /* * Normalize an NFC string in UTF-16LE for import. */ - assertEqualInt(0, archive_strncpy_in_locale( + assertEqualInt(0, archive_strncpy_l( &utf8, utf16le_nfc, 100000, f_sconv16le)); if (should_be_nfc) { failure("NFC(%s) should not be converted to" @@ -445,7 +445,7 @@ test_archive_string_normalization(int mac_nfd) /* * Normalize an NFD string for import. */ - assertEqualInt(0, archive_strcpy_in_locale( + assertEqualInt(0, archive_strcpy_l( &utf8, utf8_nfd, f_sconv8)); failure("NFD(%s) should be converted to NFC(%s):%d", nfd, nfc, line); @@ -454,7 +454,7 @@ test_archive_string_normalization(int mac_nfd) /* * Normalize an NFC string for import. */ - assertEqualInt(0, archive_strcpy_in_locale( + assertEqualInt(0, archive_strcpy_l( &utf8, utf8_nfc, f_sconv8)); failure("NFC(%s) should not be any changed:%d", nfc, line); @@ -463,7 +463,7 @@ test_archive_string_normalization(int mac_nfd) /* * Copy an NFC string for export. */ - assertEqualInt(0, archive_strcpy_in_locale( + assertEqualInt(0, archive_strcpy_l( &utf8, utf8_nfc, t_sconv8)); failure("NFC(%s) should not be any changed:%d", nfc, line); @@ -472,7 +472,7 @@ test_archive_string_normalization(int mac_nfd) /* * Normalize an NFD string in UTF-16BE for import. */ - assertEqualInt(0, archive_strncpy_in_locale( + assertEqualInt(0, archive_strncpy_l( &utf8, utf16be_nfd, 100000, f_sconv16be)); failure("NFD(%s) should be converted to NFC(%s):%d", nfd, nfc, line); @@ -481,7 +481,7 @@ test_archive_string_normalization(int mac_nfd) /* * Normalize an NFD string in UTF-16LE for import. */ - assertEqualInt(0, archive_strncpy_in_locale( + assertEqualInt(0, archive_strncpy_l( &utf8, utf16le_nfd, 100000, f_sconv16le)); failure("NFD(%s) should be converted to NFC(%s):%d", nfd, nfc, line);