forked from enlightenment/efl
Replace strncmp code
the structure "!strcmp(X, "foo", strlen("foo"))" is equal to "eina_has_prefix(X, "foo")", and the later is nicer to read, hence this replaces it. Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D11620
This commit is contained in:
parent
6fb79af116
commit
11da918983
|
@ -120,7 +120,7 @@ eina_content_new(Eina_Slice data, const char *type)
|
||||||
{
|
{
|
||||||
Eina_Content *content;
|
Eina_Content *content;
|
||||||
|
|
||||||
if (!strncmp(type, "text", strlen("text")))
|
if (eina_str_has_prefix(type,"text"))
|
||||||
{
|
{
|
||||||
//last char in the mem must be \0
|
//last char in the mem must be \0
|
||||||
if (((char*)data.mem)[data.len - 1] != '\0')
|
if (((char*)data.mem)[data.len - 1] != '\0')
|
||||||
|
|
|
@ -681,7 +681,7 @@ _elm_ctxpopup_efl_ui_widget_theme_apply(Eo *obj, Elm_Ctxpopup_Data *sd)
|
||||||
|
|
||||||
if (sd->list)
|
if (sd->list)
|
||||||
{
|
{
|
||||||
if (!strncmp(elm_object_style_get(obj), "default", strlen("default")))
|
if (eina_str_has_prefix(elm_object_style_get(obj),"default"))
|
||||||
elm_object_style_set(sd->list, "ctxpopup");
|
elm_object_style_set(sd->list, "ctxpopup");
|
||||||
else
|
else
|
||||||
elm_object_style_set(sd->list, elm_object_style_get(obj));
|
elm_object_style_set(sd->list, elm_object_style_get(obj));
|
||||||
|
@ -1480,7 +1480,7 @@ _elm_ctxpopup_item_init(Eo *eo_item,
|
||||||
if (!sd->list)
|
if (!sd->list)
|
||||||
{
|
{
|
||||||
sd->list = elm_list_add(obj);
|
sd->list = elm_list_add(obj);
|
||||||
if (!strncmp(elm_object_style_get(obj), "default", strlen("default")))
|
if (eina_str_has_prefix(elm_object_style_get(obj),"default"))
|
||||||
elm_object_style_set(sd->list, "ctxpopup");
|
elm_object_style_set(sd->list, "ctxpopup");
|
||||||
else elm_object_style_set(sd->list, elm_object_style_get(obj));
|
else elm_object_style_set(sd->list, elm_object_style_get(obj));
|
||||||
elm_list_mode_set(sd->list, ELM_LIST_EXPAND);
|
elm_list_mode_set(sd->list, ELM_LIST_EXPAND);
|
||||||
|
|
|
@ -518,7 +518,7 @@ _ecore_evas_cocoa_selection_request(Ecore_Evas *ee EINA_UNUSED, unsigned int sea
|
||||||
Eina_Rw_Slice slice;
|
Eina_Rw_Slice slice;
|
||||||
|
|
||||||
data = ecore_cocoa_clipboard_get(&size, mime_type);
|
data = ecore_cocoa_clipboard_get(&size, mime_type);
|
||||||
if (!strncmp(mime_type, "text", strlen("text")))
|
if (eina_str_has_prefix(mime_type,"text"))
|
||||||
{
|
{
|
||||||
//ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
|
//ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
|
||||||
slice.len = size + 1;
|
slice.len = size + 1;
|
||||||
|
|
|
@ -2689,7 +2689,7 @@ _wl_selection_receive(void *data, int type EINA_UNUSED, void *event)
|
||||||
//Now deliver the content
|
//Now deliver the content
|
||||||
Eina_Slice slice;
|
Eina_Slice slice;
|
||||||
|
|
||||||
if (!strncmp(ready->mimetype, "text", strlen("text")))
|
if (eina_str_has_prefix(ready->mimetype,"text"))
|
||||||
{
|
{
|
||||||
//ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
|
//ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
|
||||||
slice.len = ready->len + 1;
|
slice.len = ready->len + 1;
|
||||||
|
|
|
@ -3862,7 +3862,7 @@ _deliver_content(Ecore_Evas *ee, Ecore_Evas_Engine_Data_X11 *edata, Ecore_Evas_S
|
||||||
Eina_Content *result = NULL;
|
Eina_Content *result = NULL;
|
||||||
Eina_Stringshare *mime_type = _decrypt_type(edata->selection_data[selection].requested_type);
|
Eina_Stringshare *mime_type = _decrypt_type(edata->selection_data[selection].requested_type);
|
||||||
|
|
||||||
if (!strncmp(mime_type, "text", strlen("text")))
|
if (eina_str_has_prefix(mime_type,"text"))
|
||||||
{
|
{
|
||||||
//ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
|
//ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
|
||||||
void *null_terminated = eina_memdup(x11_data->data, x11_data->length, EINA_TRUE);
|
void *null_terminated = eina_memdup(x11_data->data, x11_data->length, EINA_TRUE);
|
||||||
|
@ -3870,7 +3870,7 @@ _deliver_content(Ecore_Evas *ee, Ecore_Evas_Engine_Data_X11 *edata, Ecore_Evas_S
|
||||||
result = _create_deliveriy_content(x11_data->length + 1, null_terminated, mime_type);
|
result = _create_deliveriy_content(x11_data->length + 1, null_terminated, mime_type);
|
||||||
free(null_terminated);
|
free(null_terminated);
|
||||||
}
|
}
|
||||||
else if (!strncmp(mime_type, "image", strlen("image")))
|
else if (eina_str_has_prefix(mime_type,"image"))
|
||||||
{
|
{
|
||||||
Eina_Content *tmp_container = eina_content_new((Eina_Slice){.len = x11_data->length, .mem = x11_data->data}, mime_type);
|
Eina_Content *tmp_container = eina_content_new((Eina_Slice){.len = x11_data->length, .mem = x11_data->data}, mime_type);
|
||||||
const char *file = eina_content_as_file(tmp_container);
|
const char *file = eina_content_as_file(tmp_container);
|
||||||
|
|
|
@ -22,7 +22,7 @@ _deliverty_cb(void *data, const Eina_Value value, const Eina_Future *dead_future
|
||||||
|
|
||||||
content = eina_value_to_content(&value);
|
content = eina_value_to_content(&value);
|
||||||
printf("Got Content of selection %d with type %s\n", buffer, eina_content_type_get(content));
|
printf("Got Content of selection %d with type %s\n", buffer, eina_content_type_get(content));
|
||||||
if (!strncmp(eina_content_type_get(content), "text", strlen("text")))
|
if (eina_str_has_prefix(eina_content_type_get(content),"text"))
|
||||||
{
|
{
|
||||||
printf("Content: %s\n", (char*)eina_content_data_get(content).mem);
|
printf("Content: %s\n", (char*)eina_content_data_get(content).mem);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue