Skip to content
  • Mike Fleetwood's avatar
    Refactor ::OnReadable() creating get_utf8_char_validated() (#136) · b1cad17a
    Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
    Extract call to GLib's g_utf8_get_char_validated() and the associated
    workaround to also read NUL characters into a separate function to make
    PipeCapture::OnReadable() a little smaller and simpler, so easier to
    understand.
    
    Add max_len > 0 clause into get_utf8_char_validated() like this:
        if (uc == UTF8_PARTIAL && max_len > 0)
    so that the NUL character reading workaround is only applied when
    max_len specifies the maximum number of bytes to read, rather than
    when -1 specifies reading a NUL termination string.  This makes
    get_utf8_char_validated() a complete wrapper of
    g_utf8_get_char_validated() [1], even though GParted always specifies
    the maximum number of bytes to read.
    
    No longer describe the inability to read NUL characters as a bug [2]
    since the GLib author's said it wasn't [3].
    
    [1] GLib Reference Manual, Unicode Manipulation Functions,
        g_utf8_get_char_validated ()
        https://developer.gnome.org/glib/stable/glib-Unicode-Manipu...
    b1cad17a