mirror of
https://gitee.com/openharmony/global_i18n
synced 2024-11-27 09:11:40 +00:00
规范性整改并与黄区代码同步2
Signed-off-by: zhangdd_ewan <zhangdongdong50@huawei.com>
This commit is contained in:
parent
194a259f5f
commit
ff707c4a3b
@ -17,6 +17,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <png.h>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include "i18n_types.h"
|
||||
@ -81,6 +82,7 @@ private:
|
||||
static void GetTimezoneIDFromZoneInfo(std::set<std::string> &availableIDs, std::string &parentPath,
|
||||
std::string &parentName);
|
||||
static std::vector<int> GetColorData(const int x, const int y);
|
||||
static int InitPngptr(png_structp &png_ptr, png_infop &info_ptr, FILE **fp);
|
||||
};
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/unistr.h"
|
||||
#include "utils.h"
|
||||
#include <png.h>
|
||||
#include <cstdio>
|
||||
|
||||
namespace OHOS {
|
||||
@ -1002,25 +1001,11 @@ std::vector<int> I18nTimeZone::GetColorData(const int x, const int y)
|
||||
return result;
|
||||
}
|
||||
FILE *fp;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
png_bytep row_pointers;
|
||||
fp = fopen(TZ_PIXEL_PATH, "rb");
|
||||
if (fp == NULL) {
|
||||
HiLog::Error(LABEL, "timezone data resource file not exists.");
|
||||
return result;
|
||||
}
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png_ptr) {
|
||||
fclose(fp);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
|
||||
HiLog::Error(LABEL, "create read_struct failed.");
|
||||
return result;
|
||||
}
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr) {
|
||||
fclose(fp);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
|
||||
HiLog::Error(LABEL, "create info_struct failed.");
|
||||
int code = InitPngptr(png_ptr, info_ptr, &fp);
|
||||
if (code != 0) {
|
||||
return result;
|
||||
}
|
||||
try {
|
||||
@ -1029,7 +1014,7 @@ std::vector<int> I18nTimeZone::GetColorData(const int x, const int y)
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
unsigned int rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
row_pointers = (png_bytep)png_malloc(png_ptr, rowbytes);
|
||||
if (row_pointers == NULL) {
|
||||
if (row_pointers == nullptr) {
|
||||
fclose(fp);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
|
||||
HiLog::Error(LABEL, "malloc rowbytes failed.");
|
||||
@ -1051,6 +1036,30 @@ std::vector<int> I18nTimeZone::GetColorData(const int x, const int y)
|
||||
fclose(fp);
|
||||
return result;
|
||||
}
|
||||
|
||||
int I18nTimeZone::InitPngptr(png_structp &png_ptr, png_infop &info_ptr, FILE **fp)
|
||||
{
|
||||
*fp = fopen(TZ_PIXEL_PATH, "rb");
|
||||
if (*fp == NULL) {
|
||||
HiLog::Error(LABEL, "timezone data resource file not exists.");
|
||||
return 1;
|
||||
}
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png_ptr) {
|
||||
fclose(*fp);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
|
||||
HiLog::Error(LABEL, "create read_struct failed.");
|
||||
return 1;
|
||||
}
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr) {
|
||||
fclose(*fp);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
|
||||
HiLog::Error(LABEL, "create info_struct failed.");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ ohos_unittest("intl_test") {
|
||||
"//third_party/googletest:gtest_main",
|
||||
"//third_party/icu/icu4c:shared_icui18n",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
"//third_party/libpng:libpng",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -28,5 +28,6 @@ group("fuzztest") {
|
||||
"relativetimeformat_fuzzer:RelativeTimeFormatFuzzTest",
|
||||
"timezone_fuzzer:TimeZoneFuzzTest",
|
||||
"utils_fuzzer:UtilsFuzzTest",
|
||||
"//third_party/libpng:libpng",
|
||||
]
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ ohos_fuzztest("TimeZoneFuzzTest") {
|
||||
"//base/global/i18n/frameworks/intl:intl_util",
|
||||
"//third_party/icu/icu4c:shared_icui18n",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
"//third_party/libpng:libpng",
|
||||
]
|
||||
|
||||
subsystem_name = "global"
|
||||
|
@ -42,6 +42,7 @@ ohos_shared_library("zone_util") {
|
||||
"//third_party/icu/icu4c:shared_icui18n",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
"//third_party/libphonenumber/cpp:phonenumber_standard",
|
||||
"//third_party/libpng:libpng",
|
||||
"//third_party/libxml2:xml2",
|
||||
]
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
|
@ -75,6 +75,7 @@ ohos_shared_library("i18n") {
|
||||
"//base/global/i18n/frameworks/intl:preferred_language",
|
||||
"//third_party/icu/icu4c:shared_icui18n",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
"//third_party/libpng:libpng",
|
||||
]
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
|
Loading…
Reference in New Issue
Block a user