minor, replace nullptr checks with implicit ones

This commit is contained in:
Ebrahim Byagowi 2020-04-20 23:48:23 +04:30
parent 0181f03019
commit 2be859d289
18 changed files with 87 additions and 89 deletions

View File

@ -567,7 +567,7 @@ fail_without_close:
HANDLE fd;
unsigned int size = strlen (file_name) + 1;
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);
#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->mapping = CreateFileMapping (fd, nullptr, PAGE_READONLY, 0, 0, nullptr);
#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)
file->contents = (char *) MapViewOfFileFromApp (file->mapping, FILE_MAP_READ, 0, 0);
#else
file->contents = (char *) MapViewOfFile (file->mapping, FILE_MAP_READ, 0, 0, 0);
#endif
if (unlikely (file->contents == nullptr)) goto fail;
if (unlikely (!file->contents)) goto fail;
CloseHandle (fd);
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 */
unsigned long len = 0, allocated = BUFSIZ * 16;
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");
if (unlikely (fp == nullptr)) goto fread_fail_without_close;
if (unlikely (!fp)) goto fread_fail_without_close;
while (!feof (fp))
{
@ -640,7 +640,7 @@ fail_without_close:
can cover files like that but lets limit our fallback reader */
if (unlikely (allocated > (2 << 28))) goto fread_fail;
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;
}

View File

@ -258,11 +258,11 @@ struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
TRACE_SERIALIZE (this);
HBUINT8 *p = c->allocate_size<HBUINT8> (1);
if (unlikely (p == nullptr)) return_trace (false);
if (unlikely (!p)) return_trace (false);
*p = intOp;
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));
}
@ -539,7 +539,7 @@ struct op_serializer_t
TRACE_SERIALIZE (this);
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);
return_trace (true);
}

View File

@ -76,12 +76,12 @@ struct biased_subrs_t
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; }
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);
else
return (*subrs)[index];

View File

@ -90,7 +90,7 @@ struct cff2_cs_interp_env_t : cs_interp_env_t<blend_arg_t, CFF2Subrs>
seen_blend = false;
seen_vsindex_ = false;
scalars.init ();
do_blend = (coords != nullptr) && num_coords && (varStore != &Null (CFF2VariationStore));
do_blend = num_coords && coords && varStore->size;
set_ivs (acc.privateDicts[fd].ivs);
}

View File

@ -635,7 +635,7 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan,
bool isRightToLeft = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
const wchar_t localeName[20] = {0};
if (buffer->props.language != nullptr)
if (buffer->props.language)
mbstowcs ((wchar_t*) localeName,
hb_language_to_string (buffer->props.language), 20);

View File

@ -107,7 +107,7 @@ struct CFFIndex
TRACE_SERIALIZE (this);
unsigned int size = src.get_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);
return_trace (true);
}
@ -120,7 +120,7 @@ struct CFFIndex
if (byteArray.length == 0)
{
COUNT *dest = c->allocate_min<COUNT> ();
if (unlikely (dest == nullptr)) return_trace (false);
if (unlikely (!dest)) return_trace (false);
*dest = 0;
}
else
@ -147,8 +147,7 @@ struct CFFIndex
{
const byte_str_t &bs = byteArray[i];
unsigned char *dest = c->allocate_size<unsigned char> (bs.length);
if (unlikely (dest == nullptr))
return_trace (false);
if (unlikely (!dest)) return_trace (false);
memcpy (dest, &bs[0], bs.length);
}
}
@ -178,7 +177,7 @@ struct CFFIndex
if (it.len () == 0)
{
COUNT *dest = c->allocate_min<COUNT> ();
if (unlikely (dest == nullptr)) return_trace (false);
if (unlikely (!dest)) return_trace (false);
*dest = 0;
}
else
@ -355,8 +354,7 @@ struct CFFIndexOf : CFFIndex<COUNT>
for (unsigned int i = 0; i < dataArrayLen; i++)
{
TYPE *dest = c->start_embed<TYPE> ();
if (unlikely (dest == nullptr ||
!dest->serialize (c, dataArray[i], param1, param2)))
if (unlikely (!dest || !dest->serialize (c, dataArray[i], param1, param2)))
return_trace (false);
}
return_trace (true);
@ -390,7 +388,7 @@ struct Dict : UnsizedByteStr
TRACE_SERIALIZE (this);
/* serialize the opcode */
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))
{
*p = OpCode_escape;
@ -561,7 +559,7 @@ struct FDSelect
TRACE_SERIALIZE (this);
unsigned int size = src.get_size (num_glyphs);
FDSelect *dest = c->allocate_size<FDSelect> (size);
if (unlikely (dest == nullptr)) return_trace (false);
if (unlikely (!dest)) return_trace (false);
memcpy (dest, &src, size);
return_trace (true);
}

View File

@ -174,7 +174,7 @@ struct Encoding
TRACE_SERIALIZE (this);
unsigned int size = src.get_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);
return_trace (true);
}
@ -188,13 +188,13 @@ struct Encoding
{
TRACE_SERIALIZE (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);
switch (format) {
case 0:
{
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;
unsigned int glyph = 0;
for (unsigned int i = 0; i < code_ranges.length; i++)
@ -211,7 +211,7 @@ struct Encoding
case 1:
{
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;
for (unsigned int i = 0; i < code_ranges.length; i++)
{
@ -228,7 +228,7 @@ struct Encoding
if (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;
for (unsigned int i = 0; i < supp_codes.length; i++)
{
@ -445,7 +445,7 @@ struct Charset
TRACE_SERIALIZE (this);
unsigned int size = src.get_size (num_glyphs);
Charset *dest = c->allocate_size<Charset> (size);
if (unlikely (dest == nullptr)) return_trace (false);
if (unlikely (!dest)) return_trace (false);
memcpy (dest, &src, size);
return_trace (true);
}
@ -458,14 +458,14 @@ struct Charset
{
TRACE_SERIALIZE (this);
Charset *dest = c->extend_min (*this);
if (unlikely (dest == nullptr)) return_trace (false);
if (unlikely (!dest)) return_trace (false);
dest->format = format;
switch (format)
{
case 0:
{
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;
for (unsigned int i = 0; i < sid_ranges.length; i++)
{
@ -479,7 +479,7 @@ struct Charset
case 1:
{
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++)
{
if (unlikely (!(sid_ranges[i].glyph <= 0xFF)))
@ -493,7 +493,7 @@ struct Charset
case 2:
{
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++)
{
if (unlikely (!(sid_ranges[i].glyph <= 0xFFFF)))
@ -1148,7 +1148,7 @@ struct cff1
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_predef_charset () const { return topDict.CharsetOffset <= ExpertSubsetCharset; }
@ -1288,7 +1288,7 @@ struct cff1
byte_str_t ustr = (*stringIndex)[sid - cff1_std_strings_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.qsort ();
@ -1337,7 +1337,7 @@ struct cff1
gname_t key = { hb_bytes_t (name, len), 0 };
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);
if (!gid && gname->sid) return false;
*glyph = gid;

View File

@ -55,7 +55,7 @@ struct CFF2FDSelect
TRACE_SERIALIZE (this);
unsigned int size = src.get_size (num_glyphs);
CFF2FDSelect *dest = c->allocate_size<CFF2FDSelect> (size);
if (unlikely (dest == nullptr)) return_trace (false);
if (unlikely (!dest)) return_trace (false);
memcpy (dest, &src, size);
return_trace (true);
}
@ -123,7 +123,7 @@ struct CFF2VariationStore
TRACE_SERIALIZE (this);
unsigned int size_ = varStore->get_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_);
return_trace (true);
}
@ -480,7 +480,7 @@ struct cff2
blob = nullptr;
}
bool is_valid () const { return blob != nullptr; }
bool is_valid () const { return blob; }
protected:
hb_blob_t *blob;

View File

@ -1549,7 +1549,7 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
do
{
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);)
gsub.get_lookup (lookup_index).closure (&c, lookup_index);

View File

@ -223,8 +223,7 @@ static unsigned int
_hb_ot_os2_get_unicode_range_bit (hb_codepoint_t cp)
{
auto *range = hb_sorted_array (_hb_os2_unicode_ranges).bsearch (cp);
if (unlikely (range == nullptr)) return -1;
return range->bit;
return range ? range->bit : -1;
}
} /* namespace OT */

View File

@ -158,7 +158,7 @@ serialize_fdselect_3_4 (hb_serialize_context_t *c,
{
TRACE_SERIALIZE (this);
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;
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);
FDSelect *p = c->allocate_min<FDSelect> ();
if (unlikely (p == nullptr)) return_trace (false);
if (unlikely (!p)) return_trace (false);
p->format = fdselect_format;
size -= FDSelect::min_size;
@ -194,7 +194,7 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c,
case 0:
{
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 fd = fdselect_ranges[range_index++].code;
for (unsigned int i = 0; i < num_glyphs; i++)

View File

@ -185,7 +185,7 @@ struct cff_font_dict_op_serializer_t : op_serializer_t
else
{
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);
}
return_trace (true);
@ -462,8 +462,11 @@ struct subr_subset_param_t
void set_current_str (ENV &env, bool calling)
{
parsed_cs_str_t *parsed_str = get_parsed_str_for_context (env.context);
if (likely (parsed_str != nullptr))
if (unlikely (!parsed_str))
{
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. */
@ -472,9 +475,6 @@ struct subr_subset_param_t
else
current_parsed_str = parsed_str;
}
else
env.set_error ();
}
parsed_cs_str_t *current_parsed_str;

View File

@ -352,7 +352,7 @@ struct cff1_subr_subsetter_t : subr_subsetter_t<cff1_subr_subsetter_t, CFF1Subrs
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]);
if (likely (parsed_str != nullptr))
if (likely (parsed_str))
parsed_str->set_parsed ();
else
env.set_error ();
@ -715,7 +715,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
if (plan.subset_localsubrs[i].length > 0)
{
CFF1Subrs *dest = c->start_embed <CFF1Subrs> ();
if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest)) return false;
c->push ();
if (likely (dest && dest->serialize (c, plan.subset_localsubrs[i])))
subrs_link = c->pop_pack ();
@ -727,7 +727,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
}
PrivateDict *pd = c->start_embed<PrivateDict> ();
if (unlikely (pd == nullptr)) return false;
if (unlikely (!pd)) return false;
c->push ();
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 */
@ -751,7 +751,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
/* CharStrings */
{
CFF1CharStrings *cs = c->start_embed<CFF1CharStrings> ();
if (unlikely (cs == nullptr)) return false;
if (unlikely (!cs)) return false;
c->push ();
if (likely (cs->serialize (c, plan.subset_charstrings)))
plan.info.char_strings_link = c->pop_pack ();
@ -766,7 +766,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
if (acc.fdArray != &Null (CFF1FDArray))
{
CFF1FDArray *fda = c->start_embed<CFF1FDArray> ();
if (unlikely (fda == nullptr)) return false;
if (unlikely (!fda)) return false;
c->push ();
cff1_font_dict_op_serializer_t fontSzr;
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)
{
Charset *dest = c->start_embed<Charset> ();
if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest)) return false;
c->push ();
if (likely (dest->serialize (c,
plan.subset_charset_format,
@ -816,7 +816,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
if (plan.subset_encoding)
{
Encoding *dest = c->start_embed<Encoding> ();
if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest)) return false;
c->push ();
if (likely (dest->serialize (c,
plan.subset_enc_format,
@ -835,7 +835,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
{
c->push ();
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)))
c->pop_pack ();
else
@ -848,7 +848,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
/* String INDEX */
{
CFF1StringIndex *dest = c->start_embed<CFF1StringIndex> ();
if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest)) return false;
c->push ();
if (likely (dest->serialize (c, *acc.stringIndex, plan.sidmap)))
c->pop_pack ();
@ -876,7 +876,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
{
/* serialize singleton TopDict */
TopDict *top = c->start_embed<TopDict> ();
if (top == nullptr) return false;
if (!top) return false;
c->push ();
cff1_top_dict_op_serializer_t topSzr;
unsigned top_size = 0;
@ -893,7 +893,7 @@ static bool _serialize_cff1 (hb_serialize_context_t *c,
}
/* serialize INDEX header for above */
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)));
}
}

View File

@ -354,7 +354,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
if (plan.subset_localsubrs[i].length > 0)
{
CFF2Subrs *dest = c->start_embed <CFF2Subrs> ();
if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest)) return false;
c->push ();
if (likely (dest->serialize (c, plan.subset_localsubrs[i])))
subrs_link = c->pop_pack ();
@ -365,7 +365,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
}
}
PrivateDict *pd = c->start_embed<PrivateDict> ();
if (unlikely (pd == nullptr)) return false;
if (unlikely (!pd)) return false;
c->push ();
cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints);
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 */
{
CFF2CharStrings *cs = c->start_embed<CFF2CharStrings> ();
if (unlikely (cs == nullptr)) return false;
if (unlikely (!cs)) return false;
c->push ();
if (likely (cs->serialize (c, plan.subset_charstrings)))
plan.info.char_strings_link = c->pop_pack ();
@ -415,7 +415,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
{
c->push ();
CFF2FDArray *fda = c->start_embed<CFF2FDArray> ();
if (unlikely (fda == nullptr)) return false;
if (unlikely (!fda)) return false;
cff_font_dict_op_serializer_t fontSzr;
auto it =
+ hb_zip (+ hb_iter (acc.fontDicts)
@ -432,8 +432,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
{
c->push ();
CFF2VariationStore *dest = c->start_embed<CFF2VariationStore> ();
if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest->serialize (c, acc.varStore))) return false;
if (unlikely (!dest || !dest->serialize (c, acc.varStore))) return false;
plan.info.var_store_link = c->pop_pack ();
}
@ -456,7 +455,7 @@ static bool _serialize_cff2 (hb_serialize_context_t *c,
/* global subrs */
{
CFF2Subrs *dest = c->start_embed <CFF2Subrs> ();
if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest)) return false;
return dest->serialize (c, plan.subset_globalsubrs);
}
}

View File

@ -279,7 +279,7 @@ static void
dump_glyphs (hb_blob_t *blob, const char *font_name)
{
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"
"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");
if (font_name_file == nullptr)
if (!font_name_file)
{
fprintf (stderr, "./out is not accessible as a folder, create it please\n");
return;

View File

@ -68,7 +68,7 @@ main (int argc, char **argv)
buf = hb_buffer_create ();
char line[BUFSIZ], out[BUFSIZ];
while (fgets (line, sizeof(line), stdin) != nullptr)
while (fgets (line, sizeof(line), stdin))
{
hb_buffer_clear_contents (buf);

View File

@ -65,7 +65,7 @@ struct subset_consumer_t
gunichar cp = g_utf8_get_char(c);
hb_codepoint_t hb_cp = 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
@ -74,7 +74,7 @@ struct subset_consumer_t
const char* data = hb_blob_get_data (blob, &data_length);
FILE *fp_out = fopen(output_file, "wb");
if (fp_out == nullptr) {
if (!fp_out) {
fprintf(stderr, "Unable to open output file\n");
return false;
}

View File

@ -116,7 +116,7 @@ pre_parse (GOptionContext *context G_GNUC_UNUSED,
{
option_group_t *option_group = (option_group_t *) data;
option_group->pre_parse (error);
return *error == nullptr;
return !*error;
}
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->post_parse (error);
return *error == nullptr;
return !*error;
}
void
@ -152,10 +152,12 @@ option_parser_t::parse (int *argc, char ***argv)
GError *parse_error = nullptr;
if (!g_option_context_parse (context, argc, argv, &parse_error))
{
if (parse_error != nullptr) {
if (parse_error)
{
fail (true, "%s", parse_error->message);
//g_error_free (parse_error);
} else
}
else
fail (true, "Option parse error");
}
}