summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-30 11:03:00 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-04-03 14:51:11 +0200
commit11da91898348737b805590581b07bedeeaa90a7c (patch)
tree7c561537450528640cf88d46962dc3d2592a7fdd
parent6fb79af116a7202c997a6799bb479b390e3b4dbd (diff)
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
-rw-r--r--src/lib/eina/eina_abstract_content.c2
-rw-r--r--src/lib/elementary/elc_ctxpopup.c4
-rw-r--r--src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c2
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c2
-rw-r--r--src/modules/ecore_evas/engines/x/ecore_evas_x.c4
-rw-r--r--src/tests/elementary/efl_ui_window_cnp_dnd_slave.c2
6 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/eina/eina_abstract_content.c b/src/lib/eina/eina_abstract_content.c
index a9899cecfe..7f54122a0f 100644
--- a/src/lib/eina/eina_abstract_content.c
+++ b/src/lib/eina/eina_abstract_content.c
@@ -120,7 +120,7 @@ eina_content_new(Eina_Slice data, const char *type)
120{ 120{
121 Eina_Content *content; 121 Eina_Content *content;
122 122
123 if (!strncmp(type, "text", strlen("text"))) 123 if (eina_str_has_prefix(type,"text"))
124 { 124 {
125 //last char in the mem must be \0 125 //last char in the mem must be \0
126 if (((char*)data.mem)[data.len - 1] != '\0') 126 if (((char*)data.mem)[data.len - 1] != '\0')
diff --git a/src/lib/elementary/elc_ctxpopup.c b/src/lib/elementary/elc_ctxpopup.c
index c99ccaeeed..fcf88e3b9d 100644
--- a/src/lib/elementary/elc_ctxpopup.c
+++ b/src/lib/elementary/elc_ctxpopup.c
@@ -681,7 +681,7 @@ _elm_ctxpopup_efl_ui_widget_theme_apply(Eo *obj, Elm_Ctxpopup_Data *sd)
681 681
682 if (sd->list) 682 if (sd->list)
683 { 683 {
684 if (!strncmp(elm_object_style_get(obj), "default", strlen("default"))) 684 if (eina_str_has_prefix(elm_object_style_get(obj),"default"))
685 elm_object_style_set(sd->list, "ctxpopup"); 685 elm_object_style_set(sd->list, "ctxpopup");
686 else 686 else
687 elm_object_style_set(sd->list, elm_object_style_get(obj)); 687 elm_object_style_set(sd->list, elm_object_style_get(obj));
@@ -1480,7 +1480,7 @@ _elm_ctxpopup_item_init(Eo *eo_item,
1480 if (!sd->list) 1480 if (!sd->list)
1481 { 1481 {
1482 sd->list = elm_list_add(obj); 1482 sd->list = elm_list_add(obj);
1483 if (!strncmp(elm_object_style_get(obj), "default", strlen("default"))) 1483 if (eina_str_has_prefix(elm_object_style_get(obj),"default"))
1484 elm_object_style_set(sd->list, "ctxpopup"); 1484 elm_object_style_set(sd->list, "ctxpopup");
1485 else elm_object_style_set(sd->list, elm_object_style_get(obj)); 1485 else elm_object_style_set(sd->list, elm_object_style_get(obj));
1486 elm_list_mode_set(sd->list, ELM_LIST_EXPAND); 1486 elm_list_mode_set(sd->list, ELM_LIST_EXPAND);
diff --git a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
index b876f0da47..05740c306b 100644
--- a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
+++ b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
@@ -518,7 +518,7 @@ _ecore_evas_cocoa_selection_request(Ecore_Evas *ee EINA_UNUSED, unsigned int sea
518 Eina_Rw_Slice slice; 518 Eina_Rw_Slice slice;
519 519
520 data = ecore_cocoa_clipboard_get(&size, mime_type); 520 data = ecore_cocoa_clipboard_get(&size, mime_type);
521 if (!strncmp(mime_type, "text", strlen("text"))) 521 if (eina_str_has_prefix(mime_type,"text"))
522 { 522 {
523 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here. 523 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
524 slice.len = size + 1; 524 slice.len = size + 1;
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
index 67ff8931a9..67a59709bd 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
@@ -2689,7 +2689,7 @@ _wl_selection_receive(void *data, int type EINA_UNUSED, void *event)
2689 //Now deliver the content 2689 //Now deliver the content
2690 Eina_Slice slice; 2690 Eina_Slice slice;
2691 2691
2692 if (!strncmp(ready->mimetype, "text", strlen("text"))) 2692 if (eina_str_has_prefix(ready->mimetype,"text"))
2693 { 2693 {
2694 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here. 2694 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
2695 slice.len = ready->len + 1; 2695 slice.len = ready->len + 1;
diff --git a/src/modules/ecore_evas/engines/x/ecore_evas_x.c b/src/modules/ecore_evas/engines/x/ecore_evas_x.c
index 3a61baaa20..9d95ede114 100644
--- a/src/modules/ecore_evas/engines/x/ecore_evas_x.c
+++ b/src/modules/ecore_evas/engines/x/ecore_evas_x.c
@@ -3862,7 +3862,7 @@ _deliver_content(Ecore_Evas *ee, Ecore_Evas_Engine_Data_X11 *edata, Ecore_Evas_S
3862 Eina_Content *result = NULL; 3862 Eina_Content *result = NULL;
3863 Eina_Stringshare *mime_type = _decrypt_type(edata->selection_data[selection].requested_type); 3863 Eina_Stringshare *mime_type = _decrypt_type(edata->selection_data[selection].requested_type);
3864 3864
3865 if (!strncmp(mime_type, "text", strlen("text"))) 3865 if (eina_str_has_prefix(mime_type,"text"))
3866 { 3866 {
3867 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here. 3867 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
3868 void *null_terminated = eina_memdup(x11_data->data, x11_data->length, EINA_TRUE); 3868 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
3870 result = _create_deliveriy_content(x11_data->length + 1, null_terminated, mime_type); 3870 result = _create_deliveriy_content(x11_data->length + 1, null_terminated, mime_type);
3871 free(null_terminated); 3871 free(null_terminated);
3872 } 3872 }
3873 else if (!strncmp(mime_type, "image", strlen("image"))) 3873 else if (eina_str_has_prefix(mime_type,"image"))
3874 { 3874 {
3875 Eina_Content *tmp_container = eina_content_new((Eina_Slice){.len = x11_data->length, .mem = x11_data->data}, mime_type); 3875 Eina_Content *tmp_container = eina_content_new((Eina_Slice){.len = x11_data->length, .mem = x11_data->data}, mime_type);
3876 const char *file = eina_content_as_file(tmp_container); 3876 const char *file = eina_content_as_file(tmp_container);
diff --git a/src/tests/elementary/efl_ui_window_cnp_dnd_slave.c b/src/tests/elementary/efl_ui_window_cnp_dnd_slave.c
index bf8c6d50bd..43aafa5470 100644
--- a/src/tests/elementary/efl_ui_window_cnp_dnd_slave.c
+++ b/src/tests/elementary/efl_ui_window_cnp_dnd_slave.c
@@ -22,7 +22,7 @@ _deliverty_cb(void *data, const Eina_Value value, const Eina_Future *dead_future
22 22
23 content = eina_value_to_content(&value); 23 content = eina_value_to_content(&value);
24 printf("Got Content of selection %d with type %s\n", buffer, eina_content_type_get(content)); 24 printf("Got Content of selection %d with type %s\n", buffer, eina_content_type_get(content));
25 if (!strncmp(eina_content_type_get(content), "text", strlen("text"))) 25 if (eina_str_has_prefix(eina_content_type_get(content),"text"))
26 { 26 {
27 printf("Content: %s\n", (char*)eina_content_data_get(content).mem); 27 printf("Content: %s\n", (char*)eina_content_data_get(content).mem);
28 } 28 }