Skip to content

Commit

Permalink
Change: replace utf8_substring with g_utf8_substring
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmundell committed Jun 14, 2024
1 parent 5e7f0cc commit d1e7f8d
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -8063,33 +8063,6 @@ convert_to_newlines (const char *text)
return new;
}

/**
* @brief Get substring of UTF8 string.
*
* @param[in] str String
* @param[in] start_pos Start.
* @param[in] end_pos End.
*
* @return Substring.
*/
static gchar *
utf8_substring (const gchar *str, glong start_pos, glong end_pos)
{
gchar *start, *end, *out;

/* TODO This is a copy of g_utf8_substring from glib 2.38.2. Once our glib
* minimum goes past 2.30 we can just use g_utf8_substring. */

start = g_utf8_offset_to_pointer (str, start_pos);
end = g_utf8_offset_to_pointer (start, end_pos - start_pos);

out = g_malloc (end - start + 1);
memcpy (out, start, end - start);
out[end - start] = 0;

return out;
}

/**
* @brief Buffer XML for a single note.
*
Expand Down Expand Up @@ -8169,7 +8142,7 @@ buffer_note_xml (GString *buffer, iterator_t *notes, int include_notes_details,
const char *text;

text = note_iterator_text (notes);
excerpt = utf8_substring (text, 0, setting_excerpt_size_int ());
excerpt = g_utf8_substring (text, 0, setting_excerpt_size_int ());

/* This must match send_get_common. */

Expand Down Expand Up @@ -8467,7 +8440,7 @@ buffer_override_xml (GString *buffer, iterator_t *overrides,
const char *text;

text = override_iterator_text (overrides);
excerpt = utf8_substring (text, 0, setting_excerpt_size_int ());
excerpt = g_utf8_substring (text, 0, setting_excerpt_size_int ());

/* This must match send_get_common. */

Expand Down Expand Up @@ -18058,7 +18031,6 @@ handle_get_tasks (gmp_parser_t *gmp_parser, GError **error)
g_free (task_schedule_xml);

SENDF_TO_CLIENT_OR_FAIL ("</task>");

}
else
{
Expand Down

0 comments on commit d1e7f8d

Please sign in to comment.