minor, replace nullptr checks with implicit ones
This commit is contained in:
parent
0181f03019
commit
2be859d289
|
@ -567,7 +567,7 @@ fail_without_close:
|
||||||
HANDLE fd;
|
HANDLE fd;
|
||||||
unsigned int size = strlen (file_name) + 1;
|
unsigned int size = strlen (file_name) + 1;
|
||||||
wchar_t * wchar_file_name = (wchar_t *) malloc (sizeof (wchar_t) * size);
|
wchar_t * wchar_file_name = (wchar_t *) malloc (sizeof (wchar_t) * size);
|
||||||
if (unlikely (wchar_file_name == nullptr)) goto fail_without_close;
|
if (unlikely (!wchar_file_name)) goto fail_without_close;
|
||||||
mbstowcs (wchar_file_name, file_name, size);
|
mbstowcs (wchar_file_name, file_name, size);
|
||||||
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
|
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
|
||||||
{
|
{
|
||||||
|
@ -601,14 +601,14 @@ fail_without_close:
|
||||||
file->length = (unsigned long) GetFileSize (fd, nullptr);
|
file->length = (unsigned long) GetFileSize (fd, nullptr);
|
||||||
file->mapping = CreateFileMapping (fd, nullptr, PAGE_READONLY, 0, 0, nullptr);
|
file->mapping = CreateFileMapping (fd, nullptr, PAGE_READONLY, 0, 0, nullptr);
|
||||||
#endif
|
#endif
|
||||||
if (unlikely (file->mapping == nullptr)) goto fail;
|
if (unlikely (!file->mapping)) goto fail;
|
||||||
|
|
||||||
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
|
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
|
||||||
file->contents = (char *) MapViewOfFileFromApp (file->mapping, FILE_MAP_READ, 0, 0);
|
file->contents = (char *) MapViewOfFileFromApp (file->mapping, FILE_MAP_READ, 0, 0);
|
||||||
#else
|
#else
|
||||||
file->contents = (char *) MapViewOfFile (file->mapping, FILE_MAP_READ, 0, 0, 0);
|
file->contents = (char *) MapViewOfFile (file->mapping, FILE_MAP_READ, 0, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
if (unlikely (file->contents == nullptr)) goto fail;
|
if (unlikely (!file->contents)) goto fail;
|
||||||
|
|
||||||
CloseHandle (fd);
|
CloseHandle (fd);
|
||||||
return hb_blob_create (file->contents, file->length,
|
return hb_blob_create (file->contents, file->length,
|
||||||
|
@ -626,10 +626,10 @@ fail_without_close:
|
||||||
It's used as a fallback for systems without mmap or to read from pipes */
|
It's used as a fallback for systems without mmap or to read from pipes */
|
||||||
unsigned long len = 0, allocated = BUFSIZ * 16;
|
unsigned long len = 0, allocated = BUFSIZ * 16;
|
||||||
char *data = (char *) malloc (allocated);
|
char *data = (char *) malloc (allocated);
|
||||||
if (unlikely (data == nullptr)) return hb_blob_get_empty ();
|
if (unlikely (!data)) return hb_blob_get_empty ();
|
||||||
|
|
||||||
FILE *fp = fopen (file_name, "rb");
|
FILE *fp = fopen (file_name, "rb");
|
||||||
if (unlikely (fp == nullptr)) goto fread_fail_without_close;
|
if (unlikely (!fp)) goto fread_fail_without_close;
|
||||||
|
|
||||||
while (!feof (fp))
|
while (!feof (fp))
|
||||||
{
|
{
|
||||||
|
@ -640,7 +640,7 @@ fail_without_close:
|
||||||
can cover files like that but lets limit our fallback reader */
|
can cover files like that but lets limit our fallback reader */
|
||||||
if (unlikely (allocated > (2 << 28))) goto fread_fail;
|
if (unlikely (allocated > (2 << 28))) goto fread_fail;
|
||||||
char *new_data = (char *) realloc (data, allocated);
|
char *new_data = (char *) realloc (data, allocated);
|
||||||
if (unlikely (new_data == nullptr)) goto fread_fail;
|
if (unlikely (!new_data)) goto fread_fail;
|
||||||
data = new_data;
|
data = new_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,11 +258,11 @@ struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
|
|
||||||
HBUINT8 *p = c->allocate_size<HBUINT8> (1);
|
HBUINT8 *p = c->allocate_size<HBUINT8> (1);
|
||||||
if (unlikely (p == nullptr)) return_trace (false);
|
if (unlikely (!p)) return_trace (false);
|
||||||
*p = intOp;
|
*p = intOp;
|
||||||
|
|
||||||
T *ip = c->allocate_size<T> (T::static_size);
|
T *ip = c->allocate_size<T> (T::static_size);
|
||||||
if (unlikely (ip == nullptr)) return_trace (false);
|
if (unlikely (!ip)) return_trace (false);
|
||||||
return_trace (c->check_assign (*ip, value));
|
return_trace (c->check_assign (*ip, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ struct op_serializer_t
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
|
|
||||||
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.length);
|
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.length);
|
||||||
if (unlikely (d == nullptr)) return_trace (false);
|
if (unlikely (!d)) return_trace (false);
|
||||||
memcpy (d, &opstr.str[0], opstr.str.length);
|
memcpy (d, &opstr.str[0], opstr.str.length);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,12 +76,12 @@ struct biased_subrs_t
|
||||||
|
|
||||||
void fini () {}
|
void fini () {}
|
||||||
|
|
||||||
unsigned int get_count () const { return (subrs == nullptr) ? 0 : subrs->count; }
|
unsigned int get_count () const { return subrs ? subrs->count : 0; }
|
||||||
unsigned int get_bias () const { return bias; }
|
unsigned int get_bias () const { return bias; }
|
||||||
|
|
||||||
byte_str_t operator [] (unsigned int index) const
|
byte_str_t operator [] (unsigned int index) const
|
||||||
{
|
{
|
||||||
if (unlikely ((subrs == nullptr) || index >= subrs->count))
|
if (unlikely (!subrs || index >= subrs->count))
|
||||||
return Null (byte_str_t);
|
return Null (byte_str_t);
|
||||||
else
|
else
|
||||||
return (*subrs)[index];
|
return (*subrs)[index];
|
||||||
|
|
|
@ -90,7 +90,7 @@ struct cff2_cs_interp_env_t : cs_interp_env_t<blend_arg_t, CFF2Subrs>
|
||||||
seen_blend = false;
|
seen_blend = false;
|
||||||
seen_vsindex_ = false;
|
seen_vsindex_ = false;
|
||||||
scalars.init ();
|
scalars.init ();
|
||||||
do_blend = (coords != nullptr) && num_coords && (varStore != &Null (CFF2VariationStore));
|
do_blend = num_coords && coords && varStore->size;
|
||||||
set_ivs (acc.privateDicts[fd].ivs);
|
set_ivs (acc.privateDicts[fd].ivs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -635,7 +635,7 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan,
|
||||||
bool isRightToLeft = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
|
bool isRightToLeft = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
|
||||||
|
|
||||||
const wchar_t localeName[20] = {0};
|
const wchar_t localeName[20] = {0};
|
||||||
if (buffer->props.language != nullptr)
|
if (buffer->props.language)
|
||||||
mbstowcs ((wchar_t*) localeName,
|
mbstowcs ((wchar_t*) localeName,
|
||||||
hb_language_to_string (buffer->props.language), 20);
|
hb_language_to_string (buffer->props.language), 20);
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ struct CFFIndex
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
unsigned int size = src.get_size ();
|
unsigned int size = src.get_size ();
|
||||||
CFFIndex *dest = c->allocate_size<CFFIndex> (size);
|
CFFIndex *dest = c->allocate_size<CFFIndex> (size);
|
||||||
if (unlikely (dest == nullptr)) return_trace (false);
|
if (unlikely (!dest)) return_trace (false);
|
||||||
memcpy (dest, &src, size);
|
memcpy (dest, &src, size);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ struct CFFIndex
|
||||||
if (byteArray.length == 0)
|
if (byteArray.length == 0)
|
||||||
{
|
{
|
||||||
COUNT *dest = c->allocate_min<COUNT> ();
|
COUNT *dest = c->allocate_min<COUNT> ();
|
||||||
if (unlikely (dest == nullptr)) return_trace (false);
|
if (unlikely (!dest)) return_trace (false);
|
||||||
*dest = 0;
|
*dest = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -146,9 +146,8 @@ struct CFFIndex
|
||||||
for (unsigned int i = 0; i < byteArray.length; i++)
|
for (unsigned int i = 0; i < byteArray.length; i++)
|
||||||
{
|
{
|
||||||
const byte_str_t &bs = byteArray[i];
|
const byte_str_t &bs = byteArray[i];
|
||||||
unsigned char *dest = c->allocate_size<unsigned char> (bs.length);
|
unsigned char *dest = c->allocate_size<unsigned char> (bs.length);
|
||||||
if (unlikely (dest == nullptr))
|
if (unlikely (!dest)) return_trace (false);
|
||||||
return_trace (false);
|
|
||||||
memcpy (dest, &bs[0], bs.length);
|
memcpy (dest, &bs[0], bs.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +177,7 @@ struct CFFIndex
|
||||||
if (it.len () == 0)
|
if (it.len () == 0)
|
||||||
{
|
{
|
||||||
COUNT *dest = c->allocate_min<COUNT> ();
|
COUNT *dest = c->allocate_min<COUNT> ();
|
||||||
if (unlikely (dest == nullptr)) return_trace (false);
|
if (unlikely (!dest)) return_trace (false);
|
||||||
*dest = 0;
|
*dest = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -355,8 +354,7 @@ struct CFFIndexOf : CFFIndex<COUNT>
|
||||||
for (unsigned int i = 0; i < dataArrayLen; i++)
|
for (unsigned int i = 0; i < dataArrayLen; i++)
|
||||||
{
|
{
|
||||||
TYPE *dest = c->start_embed<TYPE> ();
|
TYPE *dest = c->start_embed<TYPE> ();
|
||||||
if (unlikely (dest == nullptr ||
|
if (unlikely (!dest || !dest->serialize (c, dataArray[i], param1, param2)))
|
||||||
!dest->serialize (c, dataArray[i], param1, param2)))
|
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
}
|
}
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
|
@ -390,7 +388,7 @@ struct Dict : UnsizedByteStr
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
/* serialize the opcode */
|
/* serialize the opcode */
|
||||||
HBUINT8 *p = c->allocate_size<HBUINT8> (OpCode_Size (op));
|
HBUINT8 *p = c->allocate_size<HBUINT8> (OpCode_Size (op));
|
||||||
if (unlikely (p == nullptr)) return_trace (false);
|
if (unlikely (!p)) return_trace (false);
|
||||||
if (Is_OpCode_ESC (op))
|
if (Is_OpCode_ESC (op))
|
||||||
{
|
{
|
||||||
*p = OpCode_escape;
|
*p = OpCode_escape;
|
||||||
|
@ -561,7 +559,7 @@ struct FDSelect
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
unsigned int size = src.get_size (num_glyphs);
|
unsigned int size = src.get_size (num_glyphs);
|
||||||
FDSelect *dest = c->allocate_size<FDSelect> (size);
|
FDSelect *dest = c->allocate_size<FDSelect> (size);
|
||||||
if (unlikely (dest == nullptr)) return_trace (false);
|
if (unlikely (!dest)) return_trace (false);
|
||||||
memcpy (dest, &src, size);
|
memcpy (dest, &src, size);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ struct Encoding
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
unsigned int size = src.get_size ();
|
unsigned int size = src.get_size ();
|
||||||
Encoding *dest = c->allocate_size<Encoding> (size);
|
Encoding *dest = c->allocate_size<Encoding> (size);
|
||||||
if (unlikely (dest == nullptr)) return_trace (false);
|
if (unlikely (!dest)) return_trace (false);
|
||||||
memcpy (dest, &src, size);
|
memcpy (dest, &src, size);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
@ -188,13 +188,13 @@ struct Encoding
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
Encoding *dest = c->extend_min (*this);
|
Encoding *dest = c->extend_min (*this);
|
||||||
if (unlikely (dest == nullptr)) return_trace (false);
|
if (unlikely (!dest)) return_trace (false);
|
||||||
dest->format = format | ((supp_codes.length > 0) ? 0x80 : 0);
|
dest->format = format | ((supp_codes.length > 0) ? 0x80 : 0);
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
Encoding0 *fmt0 = c->allocate_size<Encoding0> (Encoding0::min_size + HBUINT8::static_size * enc_count);
|
Encoding0 *fmt0 = c->allocate_size<Encoding0> (Encoding0::min_size + HBUINT8::static_size * enc_count);
|
||||||
if (unlikely (fmt0 == nullptr)) return_trace (false);
|
if (unlikely (!fmt0)) return_trace (false);
|
||||||
fmt0->nCodes () = enc_count;
|
fmt0->nCodes () = enc_count;
|
||||||
unsigned int glyph = 0;
|
unsigned int glyph = 0;
|
||||||
for (unsigned int i = 0; i < code_ranges.length; i++)
|
for (unsigned int i = 0; i < code_ranges.length; i++)
|
||||||
|
@ -211,7 +211,7 @@ struct Encoding
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
Encoding1 *fmt1 = c->allocate_size<Encoding1> (Encoding1::min_size + Encoding1_Range::static_size * code_ranges.length);
|
Encoding1 *fmt1 = c->allocate_size<Encoding1> (Encoding1::min_size + Encoding1_Range::static_size * code_ranges.length);
|
||||||
if (unlikely (fmt1 == nullptr)) return_trace (false);
|
if (unlikely (!fmt1)) return_trace (false);
|
||||||
fmt1->nRanges () = code_ranges.length;
|
fmt1->nRanges () = code_ranges.length;
|
||||||
for (unsigned int i = 0; i < code_ranges.length; i++)
|
for (unsigned int i = 0; i < code_ranges.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -228,7 +228,7 @@ struct Encoding
|
||||||
if (supp_codes.length)
|
if (supp_codes.length)
|
||||||
{
|
{
|
||||||
CFF1SuppEncData *suppData = c->allocate_size<CFF1SuppEncData> (CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_codes.length);
|
CFF1SuppEncData *suppData = c->allocate_size<CFF1SuppEncData> (CFF1SuppEncData::min_size + SuppEncoding::static_size * supp_codes.length);
|
||||||
if (unlikely (suppData == nullptr)) return_trace (false);
|
if (unlikely (!suppData)) return_trace (false);
|
||||||
suppData->nSups () = supp_codes.length;
|
suppData->nSups () = supp_codes.length;
|
||||||
for (unsigned int i = 0; i < supp_codes.length; i++)
|
for (unsigned int i = 0; i < supp_codes.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -445,7 +445,7 @@ struct Charset
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
unsigned int size = src.get_size (num_glyphs);
|
unsigned int size = src.get_size (num_glyphs);
|
||||||
Charset *dest = c->allocate_size<Charset> (size);
|
Charset *dest = c->allocate_size<Charset> (size);
|
||||||
if (unlikely (dest == nullptr)) return_trace (false);
|
if (unlikely (!dest)) return_trace (false);
|
||||||
memcpy (dest, &src, size);
|
memcpy (dest, &src, size);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
@ -458,14 +458,14 @@ struct Charset
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
Charset *dest = c->extend_min (*this);
|
Charset *dest = c->extend_min (*this);
|
||||||
if (unlikely (dest == nullptr)) return_trace (false);
|
if (unlikely (!dest)) return_trace (false);
|
||||||
dest->format = format;
|
dest->format = format;
|
||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
Charset0 *fmt0 = c->allocate_size<Charset0> (Charset0::min_size + HBUINT16::static_size * (num_glyphs - 1));
|
Charset0 *fmt0 = c->allocate_size<Charset0> (Charset0::min_size + HBUINT16::static_size * (num_glyphs - 1));
|
||||||
if (unlikely (fmt0 == nullptr)) return_trace (false);
|
if (unlikely (!fmt0)) return_trace (false);
|
||||||
unsigned int glyph = 0;
|
unsigned int glyph = 0;
|
||||||
for (unsigned int i = 0; i < sid_ranges.length; i++)
|
for (unsigned int i = 0; i < sid_ranges.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -479,7 +479,7 @@ struct Charset
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
Charset1 *fmt1 = c->allocate_size<Charset1> (Charset1::min_size + Charset1_Range::static_size * sid_ranges.length);
|
Charset1 *fmt1 = c->allocate_size<Charset1> (Charset1::min_size + Charset1_Range::static_size * sid_ranges.length);
|
||||||
if (unlikely (fmt1 == nullptr)) return_trace (false);
|
if (unlikely (!fmt1)) return_trace (false);
|
||||||
for (unsigned int i = 0; i < sid_ranges.length; i++)
|
for (unsigned int i = 0; i < sid_ranges.length; i++)
|
||||||
{
|
{
|
||||||
if (unlikely (!(sid_ranges[i].glyph <= 0xFF)))
|
if (unlikely (!(sid_ranges[i].glyph <= 0xFF)))
|
||||||
|
@ -493,7 +493,7 @@ struct Charset
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
Charset2 *fmt2 = c->allocate_size<Charset2> (Charset2::min_size + Charset2_Range::static_size * sid_ranges.length);
|
Charset2 *fmt2 = c->allocate_size<Charset2> (Charset2::min_size + Charset2_Range::static_size * sid_ranges.length);
|
||||||
if (unlikely (fmt2 == nullptr)) return_trace (false);
|
if (unlikely (!fmt2)) return_trace (false);
|
||||||
for (unsigned int i = 0; i < sid_ranges.length; i++)
|
for (unsigned int i = 0; i < sid_ranges.length; i++)
|
||||||
{
|
{
|
||||||
if (unlikely (!(sid_ranges[i].glyph <= 0xFFFF)))
|
if (unlikely (!(sid_ranges[i].glyph <= 0xFFFF)))
|
||||||
|
@ -1148,7 +1148,7 @@ struct cff1
|
||||||
blob = nullptr;
|
blob = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid () const { return blob != nullptr; }
|
bool is_valid () const { return blob; }
|
||||||
bool is_CID () const { return topDict.is_CID (); }
|
bool is_CID () const { return topDict.is_CID (); }
|
||||||
|
|
||||||
bool is_predef_charset () const { return topDict.CharsetOffset <= ExpertSubsetCharset; }
|
bool is_predef_charset () const { return topDict.CharsetOffset <= ExpertSubsetCharset; }
|
||||||
|
@ -1288,7 +1288,7 @@ struct cff1
|
||||||
byte_str_t ustr = (*stringIndex)[sid - cff1_std_strings_length];
|
byte_str_t ustr = (*stringIndex)[sid - cff1_std_strings_length];
|
||||||
gname.name = hb_bytes_t ((const char*)ustr.arrayZ, ustr.length);
|
gname.name = hb_bytes_t ((const char*)ustr.arrayZ, ustr.length);
|
||||||
}
|
}
|
||||||
if (unlikely (gname.name.arrayZ == nullptr)) { fini (); return; }
|
if (unlikely (!gname.name.arrayZ)) { fini (); return; }
|
||||||
glyph_names.push (gname);
|
glyph_names.push (gname);
|
||||||
}
|
}
|
||||||
glyph_names.qsort ();
|
glyph_names.qsort ();
|
||||||
|
@ -1337,7 +1337,7 @@ struct cff1
|
||||||
|
|
||||||
gname_t key = { hb_bytes_t (name, len), 0 };
|
gname_t key = { hb_bytes_t (name, len), 0 };
|
||||||
const gname_t *gname = glyph_names.bsearch (key);
|
const gname_t *gname = glyph_names.bsearch (key);
|
||||||
if (gname == nullptr) return false;
|
if (!gname) return false;
|
||||||
hb_codepoint_t gid = sid_to_glyph (gname->sid);
|
hb_codepoint_t gid = sid_to_glyph (gname->sid);
|
||||||
if (!gid && gname->sid) return false;
|
if (!gid && gname->sid) return false;
|
||||||
*glyph = gid;
|
*glyph = gid;
|
||||||
|
|
|
@ -55,7 +55,7 @@ struct CFF2FDSelect
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
unsigned int size = src.get_size (num_glyphs);
|
unsigned int size = src.get_size (num_glyphs);
|
||||||
CFF2FDSelect *dest = c->allocate_size<CFF2FDSelect> (size);
|
CFF2FDSelect *dest = c->allocate_size<CFF2FDSelect> (size);
|
||||||
if (unlikely (dest == nullptr)) return_trace (false);
|
if (unlikely (!dest)) return_trace (false);
|
||||||
memcpy (dest, &src, size);
|
memcpy (dest, &src, size);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ struct CFF2VariationStore
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
unsigned int size_ = varStore->get_size ();
|
unsigned int size_ = varStore->get_size ();
|
||||||
CFF2VariationStore *dest = c->allocate_size<CFF2VariationStore> (size_);
|
CFF2VariationStore *dest = c->allocate_size<CFF2VariationStore> (size_);
|
||||||
if (unlikely (dest == nullptr)) return_trace (false);
|
if (unlikely (!dest)) return_trace (false);
|
||||||
memcpy (dest, varStore, size_);
|
memcpy (dest, varStore, size_);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
@ -480,7 +480,7 @@ struct cff2
|
||||||
blob = nullptr;
|
blob = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid () const { return blob != nullptr; }
|
bool is_valid () const { return blob; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
hb_blob_t *blob;
|
hb_blob_t *blob;
|
||||||
|
|
|
@ -1549,7 +1549,7 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
glyphs_length = glyphs->get_population ();
|
glyphs_length = glyphs->get_population ();
|
||||||
if (lookups != nullptr)
|
if (lookups)
|
||||||
{
|
{
|
||||||
for (hb_codepoint_t lookup_index = HB_SET_VALUE_INVALID; hb_set_next (lookups, &lookup_index);)
|
for (hb_codepoint_t lookup_index = HB_SET_VALUE_INVALID; hb_set_next (lookups, &lookup_index);)
|
||||||
gsub.get_lookup (lookup_index).closure (&c, lookup_index);
|
gsub.get_lookup (lookup_index).closure (&c, lookup_index);
|
||||||
|
|
|
@ -223,8 +223,7 @@ static unsigned int
|
||||||
_hb_ot_os2_get_unicode_range_bit (hb_codepoint_t cp)
|
_hb_ot_os2_get_unicode_range_bit (hb_codepoint_t cp)
|
||||||
{
|
{
|
||||||
auto *range = hb_sorted_array (_hb_os2_unicode_ranges).bsearch (cp);
|
auto *range = hb_sorted_array (_hb_os2_unicode_ranges).bsearch (cp);
|
||||||
if (unlikely (range == nullptr)) return -1;
|
return range ? range->bit : -1;
|
||||||
return range->bit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace OT */
|
} /* namespace OT */
|
||||||
|
|
|
@ -158,7 +158,7 @@ serialize_fdselect_3_4 (hb_serialize_context_t *c,
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
FDSELECT3_4 *p = c->allocate_size<FDSELECT3_4> (size);
|
FDSELECT3_4 *p = c->allocate_size<FDSELECT3_4> (size);
|
||||||
if (unlikely (p == nullptr)) return_trace (false);
|
if (unlikely (!p)) return_trace (false);
|
||||||
p->nRanges () = fdselect_ranges.length;
|
p->nRanges () = fdselect_ranges.length;
|
||||||
for (unsigned int i = 0; i < fdselect_ranges.length; i++)
|
for (unsigned int i = 0; i < fdselect_ranges.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -184,7 +184,7 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c,
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
FDSelect *p = c->allocate_min<FDSelect> ();
|
FDSelect *p = c->allocate_min<FDSelect> ();
|
||||||
if (unlikely (p == nullptr)) return_trace (false);
|
if (unlikely (!p)) return_trace (false);
|
||||||
p->format = fdselect_format;
|
p->format = fdselect_format;
|
||||||
size -= FDSelect::min_size;
|
size -= FDSelect::min_size;
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c,
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
FDSelect0 *p = c->allocate_size<FDSelect0> (size);
|
FDSelect0 *p = c->allocate_size<FDSelect0> (size);
|
||||||
if (unlikely (p == nullptr)) return_trace (false);
|
if (unlikely (!p)) return_trace (false);
|
||||||
unsigned int range_index = 0;
|
unsigned int range_index = 0;
|
||||||
unsigned int fd = fdselect_ranges[range_index++].code;
|
unsigned int fd = fdselect_ranges[range_index++].code;
|
||||||
for (unsigned int i = 0; i < num_glyphs; i++)
|
for (unsigned int i = 0; i < num_glyphs; i++)
|
||||||
|
|
|
@ -185,7 +185,7 @@ struct cff_font_dict_op_serializer_t : op_serializer_t
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.length);
|
HBUINT8 *d = c->allocate_size<HBUINT8> (opstr.str.length);
|
||||||
if (unlikely (d == nullptr)) return_trace (false);
|
if (unlikely (!d)) return_trace (false);
|
||||||
memcpy (d, &opstr.str[0], opstr.str.length);
|
memcpy (d, &opstr.str[0], opstr.str.length);
|
||||||
}
|
}
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
|
@ -461,19 +461,19 @@ struct subr_subset_param_t
|
||||||
template <typename ENV>
|
template <typename ENV>
|
||||||
void set_current_str (ENV &env, bool calling)
|
void set_current_str (ENV &env, bool calling)
|
||||||
{
|
{
|
||||||
parsed_cs_str_t *parsed_str = get_parsed_str_for_context (env.context);
|
parsed_cs_str_t *parsed_str = get_parsed_str_for_context (env.context);
|
||||||
if (likely (parsed_str != nullptr))
|
if (unlikely (!parsed_str))
|
||||||
{
|
{
|
||||||
/* If the called subroutine is parsed partially but not completely yet,
|
|
||||||
* it must be because we are calling it recursively.
|
|
||||||
* Handle it as an error. */
|
|
||||||
if (unlikely (calling && !parsed_str->is_parsed () && (parsed_str->values.length > 0)))
|
|
||||||
env.set_error ();
|
|
||||||
else
|
|
||||||
current_parsed_str = parsed_str;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
env.set_error ();
|
env.set_error ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* If the called subroutine is parsed partially but not completely yet,
|
||||||
|
* it must be because we are calling it recursively.
|
||||||
|
* Handle it as an error. */
|
||||||
|
if (unlikely (calling && !parsed_str->is_parsed () && (parsed_str->values.length > 0)))
|
||||||
|
env.set_error ();
|
||||||
|
else
|
||||||
|
current_parsed_str = parsed_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
parsed_cs_str_t *current_parsed_str;
|
parsed_cs_str_t *current_parsed_str;
|
||||||
|
|
|
@ -351,8 +351,8 @@ struct cff1_subr_subsetter_t : subr_subsetter_t<cff1_subr_subsetter_t, CFF1Subrs
|
||||||
param.current_parsed_str->set_parsed ();
|
param.current_parsed_str->set_parsed ();
|
||||||
for (unsigned int i = 0; i < env.callStack.get_count (); i++)
|
for (unsigned int i = 0; i < env.callStack.get_count (); i++)
|
||||||
{
|
{
|
||||||
parsed_cs_str_t *parsed_str = param.get_parsed_str_for_context (env.callStack[i]);
|
parsed_cs_str_t *parsed_str = param.get_parsed_str_for_context (env.callStack[i]);
|
||||||
if (likely (parsed_str != nullptr))
|
if (likely (parsed_str))
|
||||||
parsed_str->set_parsed ();
|
parsed_str->set_parsed ();
|
||||||
else
|
else
|
||||||
env.set_error ();
|
env.set_error ();
|
||||||
|
@ -715,7 +715,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
if (plan.subset_localsubrs[i].length > 0)
|
if (plan.subset_localsubrs[i].length > 0)
|
||||||
{
|
{
|
||||||
CFF1Subrs *dest = c->start_embed <CFF1Subrs> ();
|
CFF1Subrs *dest = c->start_embed <CFF1Subrs> ();
|
||||||
if (unlikely (dest == nullptr)) return false;
|
if (unlikely (!dest)) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
if (likely (dest && dest->serialize (c, plan.subset_localsubrs[i])))
|
if (likely (dest && dest->serialize (c, plan.subset_localsubrs[i])))
|
||||||
subrs_link = c->pop_pack ();
|
subrs_link = c->pop_pack ();
|
||||||
|
@ -726,8 +726,8 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivateDict *pd = c->start_embed<PrivateDict> ();
|
PrivateDict *pd = c->start_embed<PrivateDict> ();
|
||||||
if (unlikely (pd == nullptr)) return false;
|
if (unlikely (!pd)) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints);
|
cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints);
|
||||||
/* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */
|
/* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */
|
||||||
|
@ -751,7 +751,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
/* CharStrings */
|
/* CharStrings */
|
||||||
{
|
{
|
||||||
CFF1CharStrings *cs = c->start_embed<CFF1CharStrings> ();
|
CFF1CharStrings *cs = c->start_embed<CFF1CharStrings> ();
|
||||||
if (unlikely (cs == nullptr)) return false;
|
if (unlikely (!cs)) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
if (likely (cs->serialize (c, plan.subset_charstrings)))
|
if (likely (cs->serialize (c, plan.subset_charstrings)))
|
||||||
plan.info.char_strings_link = c->pop_pack ();
|
plan.info.char_strings_link = c->pop_pack ();
|
||||||
|
@ -765,8 +765,8 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
/* FDArray (FD Index) */
|
/* FDArray (FD Index) */
|
||||||
if (acc.fdArray != &Null (CFF1FDArray))
|
if (acc.fdArray != &Null (CFF1FDArray))
|
||||||
{
|
{
|
||||||
CFF1FDArray *fda = c->start_embed<CFF1FDArray> ();
|
CFF1FDArray *fda = c->start_embed<CFF1FDArray> ();
|
||||||
if (unlikely (fda == nullptr)) return false;
|
if (unlikely (!fda)) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
cff1_font_dict_op_serializer_t fontSzr;
|
cff1_font_dict_op_serializer_t fontSzr;
|
||||||
auto it = + hb_zip (+ hb_iter (plan.fontdicts_mod), + hb_iter (plan.fontdicts_mod));
|
auto it = + hb_zip (+ hb_iter (plan.fontdicts_mod), + hb_iter (plan.fontdicts_mod));
|
||||||
|
@ -798,7 +798,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
if (plan.subset_charset)
|
if (plan.subset_charset)
|
||||||
{
|
{
|
||||||
Charset *dest = c->start_embed<Charset> ();
|
Charset *dest = c->start_embed<Charset> ();
|
||||||
if (unlikely (dest == nullptr)) return false;
|
if (unlikely (!dest)) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
if (likely (dest->serialize (c,
|
if (likely (dest->serialize (c,
|
||||||
plan.subset_charset_format,
|
plan.subset_charset_format,
|
||||||
|
@ -816,7 +816,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
if (plan.subset_encoding)
|
if (plan.subset_encoding)
|
||||||
{
|
{
|
||||||
Encoding *dest = c->start_embed<Encoding> ();
|
Encoding *dest = c->start_embed<Encoding> ();
|
||||||
if (unlikely (dest == nullptr)) return false;
|
if (unlikely (!dest)) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
if (likely (dest->serialize (c,
|
if (likely (dest->serialize (c,
|
||||||
plan.subset_enc_format,
|
plan.subset_enc_format,
|
||||||
|
@ -835,7 +835,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
{
|
{
|
||||||
c->push ();
|
c->push ();
|
||||||
CFF1Subrs *dest = c->start_embed <CFF1Subrs> ();
|
CFF1Subrs *dest = c->start_embed <CFF1Subrs> ();
|
||||||
if (unlikely (dest == nullptr)) return false;
|
if (unlikely (!dest)) return false;
|
||||||
if (likely (dest->serialize (c, plan.subset_globalsubrs)))
|
if (likely (dest->serialize (c, plan.subset_globalsubrs)))
|
||||||
c->pop_pack ();
|
c->pop_pack ();
|
||||||
else
|
else
|
||||||
|
@ -848,7 +848,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
/* String INDEX */
|
/* String INDEX */
|
||||||
{
|
{
|
||||||
CFF1StringIndex *dest = c->start_embed<CFF1StringIndex> ();
|
CFF1StringIndex *dest = c->start_embed<CFF1StringIndex> ();
|
||||||
if (unlikely (dest == nullptr)) return false;
|
if (unlikely (!dest)) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
if (likely (dest->serialize (c, *acc.stringIndex, plan.sidmap)))
|
if (likely (dest->serialize (c, *acc.stringIndex, plan.sidmap)))
|
||||||
c->pop_pack ();
|
c->pop_pack ();
|
||||||
|
@ -876,7 +876,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
{
|
{
|
||||||
/* serialize singleton TopDict */
|
/* serialize singleton TopDict */
|
||||||
TopDict *top = c->start_embed<TopDict> ();
|
TopDict *top = c->start_embed<TopDict> ();
|
||||||
if (top == nullptr) return false;
|
if (!top) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
cff1_top_dict_op_serializer_t topSzr;
|
cff1_top_dict_op_serializer_t topSzr;
|
||||||
unsigned top_size = 0;
|
unsigned top_size = 0;
|
||||||
|
@ -893,7 +893,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
}
|
}
|
||||||
/* serialize INDEX header for above */
|
/* serialize INDEX header for above */
|
||||||
CFF1Index *dest = c->start_embed<CFF1Index> ();
|
CFF1Index *dest = c->start_embed<CFF1Index> ();
|
||||||
if (dest == nullptr) return false;
|
if (!dest) return false;
|
||||||
return dest->serialize_header (c, hb_iter (hb_array_t<unsigned> (&top_size, 1)));
|
return dest->serialize_header (c, hb_iter (hb_array_t<unsigned> (&top_size, 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,7 +354,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
|
||||||
if (plan.subset_localsubrs[i].length > 0)
|
if (plan.subset_localsubrs[i].length > 0)
|
||||||
{
|
{
|
||||||
CFF2Subrs *dest = c->start_embed <CFF2Subrs> ();
|
CFF2Subrs *dest = c->start_embed <CFF2Subrs> ();
|
||||||
if (unlikely (dest == nullptr)) return false;
|
if (unlikely (!dest)) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
if (likely (dest->serialize (c, plan.subset_localsubrs[i])))
|
if (likely (dest->serialize (c, plan.subset_localsubrs[i])))
|
||||||
subrs_link = c->pop_pack ();
|
subrs_link = c->pop_pack ();
|
||||||
|
@ -364,8 +364,8 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrivateDict *pd = c->start_embed<PrivateDict> ();
|
PrivateDict *pd = c->start_embed<PrivateDict> ();
|
||||||
if (unlikely (pd == nullptr)) return false;
|
if (unlikely (!pd)) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints);
|
cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints);
|
||||||
if (likely (pd->serialize (c, acc.privateDicts[i], privSzr, subrs_link)))
|
if (likely (pd->serialize (c, acc.privateDicts[i], privSzr, subrs_link)))
|
||||||
|
@ -385,7 +385,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
|
||||||
/* CharStrings */
|
/* CharStrings */
|
||||||
{
|
{
|
||||||
CFF2CharStrings *cs = c->start_embed<CFF2CharStrings> ();
|
CFF2CharStrings *cs = c->start_embed<CFF2CharStrings> ();
|
||||||
if (unlikely (cs == nullptr)) return false;
|
if (unlikely (!cs)) return false;
|
||||||
c->push ();
|
c->push ();
|
||||||
if (likely (cs->serialize (c, plan.subset_charstrings)))
|
if (likely (cs->serialize (c, plan.subset_charstrings)))
|
||||||
plan.info.char_strings_link = c->pop_pack ();
|
plan.info.char_strings_link = c->pop_pack ();
|
||||||
|
@ -414,8 +414,8 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
|
||||||
/* FDArray (FD Index) */
|
/* FDArray (FD Index) */
|
||||||
{
|
{
|
||||||
c->push ();
|
c->push ();
|
||||||
CFF2FDArray *fda = c->start_embed<CFF2FDArray> ();
|
CFF2FDArray *fda = c->start_embed<CFF2FDArray> ();
|
||||||
if (unlikely (fda == nullptr)) return false;
|
if (unlikely (!fda)) return false;
|
||||||
cff_font_dict_op_serializer_t fontSzr;
|
cff_font_dict_op_serializer_t fontSzr;
|
||||||
auto it =
|
auto it =
|
||||||
+ hb_zip (+ hb_iter (acc.fontDicts)
|
+ hb_zip (+ hb_iter (acc.fontDicts)
|
||||||
|
@ -432,8 +432,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
|
||||||
{
|
{
|
||||||
c->push ();
|
c->push ();
|
||||||
CFF2VariationStore *dest = c->start_embed<CFF2VariationStore> ();
|
CFF2VariationStore *dest = c->start_embed<CFF2VariationStore> ();
|
||||||
if (unlikely (dest == nullptr)) return false;
|
if (unlikely (!dest || !dest->serialize (c, acc.varStore))) return false;
|
||||||
if (unlikely (!dest->serialize (c, acc.varStore))) return false;
|
|
||||||
plan.info.var_store_link = c->pop_pack ();
|
plan.info.var_store_link = c->pop_pack ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,7 +455,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
|
||||||
/* global subrs */
|
/* global subrs */
|
||||||
{
|
{
|
||||||
CFF2Subrs *dest = c->start_embed <CFF2Subrs> ();
|
CFF2Subrs *dest = c->start_embed <CFF2Subrs> ();
|
||||||
if (unlikely (dest == nullptr)) return false;
|
if (unlikely (!dest)) return false;
|
||||||
return dest->serialize (c, plan.subset_globalsubrs);
|
return dest->serialize (c, plan.subset_globalsubrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ static void
|
||||||
dump_glyphs (hb_blob_t *blob, const char *font_name)
|
dump_glyphs (hb_blob_t *blob, const char *font_name)
|
||||||
{
|
{
|
||||||
FILE *font_name_file = fopen ("out/.dumped_font_name", "r");
|
FILE *font_name_file = fopen ("out/.dumped_font_name", "r");
|
||||||
if (font_name_file != nullptr)
|
if (font_name_file)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Purge or rename ./out folder if you like to run a glyph dump,\n"
|
fprintf (stderr, "Purge or rename ./out folder if you like to run a glyph dump,\n"
|
||||||
"run it like `rm -rf out && mkdir out && src/main font-file.ttf`\n");
|
"run it like `rm -rf out && mkdir out && src/main font-file.ttf`\n");
|
||||||
|
@ -287,7 +287,7 @@ dump_glyphs (hb_blob_t *blob, const char *font_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
font_name_file = fopen ("out/.dumped_font_name", "w");
|
font_name_file = fopen ("out/.dumped_font_name", "w");
|
||||||
if (font_name_file == nullptr)
|
if (!font_name_file)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "./out is not accessible as a folder, create it please\n");
|
fprintf (stderr, "./out is not accessible as a folder, create it please\n");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -68,7 +68,7 @@ main (int argc, char **argv)
|
||||||
buf = hb_buffer_create ();
|
buf = hb_buffer_create ();
|
||||||
|
|
||||||
char line[BUFSIZ], out[BUFSIZ];
|
char line[BUFSIZ], out[BUFSIZ];
|
||||||
while (fgets (line, sizeof(line), stdin) != nullptr)
|
while (fgets (line, sizeof(line), stdin))
|
||||||
{
|
{
|
||||||
hb_buffer_clear_contents (buf);
|
hb_buffer_clear_contents (buf);
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ struct subset_consumer_t
|
||||||
gunichar cp = g_utf8_get_char(c);
|
gunichar cp = g_utf8_get_char(c);
|
||||||
hb_codepoint_t hb_cp = cp;
|
hb_codepoint_t hb_cp = cp;
|
||||||
hb_set_add (codepoints, hb_cp);
|
hb_set_add (codepoints, hb_cp);
|
||||||
} while ((c = g_utf8_find_next_char(c, text + text_len)) != nullptr);
|
} while ((c = g_utf8_find_next_char(c, text + text_len)));
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
|
@ -74,7 +74,7 @@ struct subset_consumer_t
|
||||||
const char* data = hb_blob_get_data (blob, &data_length);
|
const char* data = hb_blob_get_data (blob, &data_length);
|
||||||
|
|
||||||
FILE *fp_out = fopen(output_file, "wb");
|
FILE *fp_out = fopen(output_file, "wb");
|
||||||
if (fp_out == nullptr) {
|
if (!fp_out) {
|
||||||
fprintf(stderr, "Unable to open output file\n");
|
fprintf(stderr, "Unable to open output file\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ pre_parse (GOptionContext *context G_GNUC_UNUSED,
|
||||||
{
|
{
|
||||||
option_group_t *option_group = (option_group_t *) data;
|
option_group_t *option_group = (option_group_t *) data;
|
||||||
option_group->pre_parse (error);
|
option_group->pre_parse (error);
|
||||||
return *error == nullptr;
|
return !*error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -127,7 +127,7 @@ post_parse (GOptionContext *context G_GNUC_UNUSED,
|
||||||
{
|
{
|
||||||
option_group_t *option_group = static_cast<option_group_t *>(data);
|
option_group_t *option_group = static_cast<option_group_t *>(data);
|
||||||
option_group->post_parse (error);
|
option_group->post_parse (error);
|
||||||
return *error == nullptr;
|
return !*error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -152,10 +152,12 @@ option_parser_t::parse (int *argc, char ***argv)
|
||||||
GError *parse_error = nullptr;
|
GError *parse_error = nullptr;
|
||||||
if (!g_option_context_parse (context, argc, argv, &parse_error))
|
if (!g_option_context_parse (context, argc, argv, &parse_error))
|
||||||
{
|
{
|
||||||
if (parse_error != nullptr) {
|
if (parse_error)
|
||||||
|
{
|
||||||
fail (true, "%s", parse_error->message);
|
fail (true, "%s", parse_error->message);
|
||||||
//g_error_free (parse_error);
|
//g_error_free (parse_error);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
fail (true, "Option parse error");
|
fail (true, "Option parse error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue