openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/libsmartcols/src/table_print.c
static char* buffer_get_safe_data(struct libscols_table* tb,
                                  struct libscols_buffer* buf, size_t* cells,
                                  const char* safechars)
{
    char* data = buffer_get_data(buf);
    char* res = NULL;

    if (!data)
        goto nothing;

    if (!buf->encdata)
    {
        buf->encdata = malloc(mbs_safe_encode_size(buf->bufsz) + 1);
        if (!buf->encdata)
            goto nothing;
    }

    if (tb->no_encode)
    {
        *cells = mbs_safe_width(data);
        strcpy(buf->encdata, data);
        res = buf->encdata;
    }
    else
    {
        res = mbs_safe_encode_to_buffer(data, cells, buf->encdata, safechars);
    }

    if (!res || !*cells || *cells == (size_t)-1)
        goto nothing;
    return res;
nothing:
    *cells = 0;
    return NULL;
}
/* encode data by mbs_safe_encode() to avoid control and non-printable chars */
encode data by mbs_safe_encode() to avoid control and non-printable chars
encode data by mbs_safe_encode () to avoid control and non - printable chars
static char* buffer_get_safe_data(struct libscols_table* tb,
                                  struct libscols_buffer* buf, size_t* cells,
                                  const char* safechars)
{
    char* data = buffer_get_data(buf);
    char* res = NULL;
    if (!data)
        goto nothing;
    if (!buf->encdata)
    {
        buf->encdata = malloc(mbs_safe_encode_size(buf->bufsz) + 1);
        if (!buf->encdata)
            goto nothing;
    }
    if (tb->no_encode)
    {
        *cells = mbs_safe_width(data);
        strcpy(buf->encdata, data);
        res = buf->encdata;
    }
    else
    {
        res = mbs_safe_encode_to_buffer(data, cells, buf->encdata, safechars);
    }
    if (!res || !*cells || *cells == (size_t)-1)
        goto nothing;
    return res;
nothing:
    *cells = 0;
    return NULL;
}
static char * buffer_get_safe_data ( struct libscols_table * tb , struct libscols_buffer * buf , size_t * cells , const char * safechars ) { char * data = buffer_get_data ( buf ) ; char * res = NULL ; if ( ! data ) goto nothing ; if ( ! buf -> encdata ) { buf -> encdata = malloc ( mbs_safe_encode_size ( buf -> bufsz ) + 1 ) ; if ( ! buf -> encdata ) goto nothing ; } if ( tb -> no_encode ) { * cells = mbs_safe_width ( data ) ; strcpy ( buf -> encdata , data ) ; res = buf -> encdata ; } else { res = mbs_safe_encode_to_buffer ( data , cells , buf -> encdata , safechars ) ; } if ( ! res || ! * cells || * cells == ( size_t ) -1 ) goto nothing ; return res ; nothing : * cells = 0 ; return NULL ; }
encode data by mbs_safe_encode() to avoid control and non-printable chars
encode data by mbs_safe_encode () to avoid control and non - printable chars