mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 04:22:34 +03:00
(mc_g_string_append_c_len): new API that extends GString one.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
822ef80f5b
commit
fc02bf666b
@ -297,3 +297,32 @@ mc_g_string_dup (const GString * s)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* mc_g_string_append_c_len:
|
||||
* @s: (not nullable): the destination #GString.
|
||||
* @c: the byte to append onto the end of @s
|
||||
* @len: the number of bytes @c to append onto the end of @s
|
||||
* @return: @s
|
||||
*
|
||||
* Adds @len bytes @c onto the end of @s.
|
||||
*
|
||||
* There is no such API in GLib2.
|
||||
*/
|
||||
GString *
|
||||
mc_g_string_append_c_len (GString * s, gchar c, guint len)
|
||||
{
|
||||
g_return_val_if_fail (s != NULL, NULL);
|
||||
|
||||
if (len != 0)
|
||||
{
|
||||
guint s_len = s->len;
|
||||
|
||||
g_string_set_size (s, s->len + len);
|
||||
memset (s->str + s_len, (unsigned char) c, len);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -40,6 +40,9 @@ GString *mc_g_string_copy (GString * dest, const GString * src);
|
||||
/* There is no such API in GLib2 */
|
||||
GString *mc_g_string_dup (const GString * s);
|
||||
|
||||
/* There is no such API in GLib2 */
|
||||
GString *mc_g_string_append_c_len (GString * s, gchar c, guint len);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC_GLIBCOMPAT_H */
|
||||
|
@ -153,9 +153,7 @@ _str_convert (GIConv coder, const char *string, int size, GString * buffer)
|
||||
case G_CONVERT_ERROR_NO_CONVERSION:
|
||||
/* Conversion between the requested character sets is not supported. */
|
||||
g_free (tmp_buff);
|
||||
tmp_buff = g_strnfill (strlen (string), '?');
|
||||
g_string_append (buffer, tmp_buff);
|
||||
g_free (tmp_buff);
|
||||
mc_g_string_append_c_len (buffer, '?', strlen (string));
|
||||
return ESTR_FAILURE;
|
||||
|
||||
case G_CONVERT_ERROR_ILLEGAL_SEQUENCE:
|
||||
@ -186,12 +184,7 @@ _str_convert (GIConv coder, const char *string, int size, GString * buffer)
|
||||
g_string_append (buffer, tmp_buff);
|
||||
g_free (tmp_buff);
|
||||
if ((int) bytes_read < left)
|
||||
{
|
||||
left = left - bytes_read;
|
||||
tmp_buff = g_strnfill (left, '?');
|
||||
g_string_append (buffer, tmp_buff);
|
||||
g_free (tmp_buff);
|
||||
}
|
||||
mc_g_string_append_c_len (buffer, '?', left - bytes_read);
|
||||
return ESTR_PROBLEM;
|
||||
|
||||
case G_CONVERT_ERROR_BAD_URI: /* Don't know how handle this error :( */
|
||||
|
Loading…
Reference in New Issue
Block a user