billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=259722a3f325972a38065583dbfd62e10ca7b300

commit 259722a3f325972a38065583dbfd62e10ca7b300
Author: Boris Faure <[email protected]>
Date:   Sun Sep 15 17:47:07 2019 +0200

    move link_is_* to termiolink.c
---
 src/bin/media.c      |  1 +
 src/bin/termiolink.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---
 src/bin/termiolink.h |  5 +++++
 src/bin/utils.c      | 47 ----------------------------------------------
 src/bin/utils.h      |  4 ----
 5 files changed, 56 insertions(+), 54 deletions(-)

diff --git a/src/bin/media.c b/src/bin/media.c
index bda41b4..b43eadc 100644
--- a/src/bin/media.c
+++ b/src/bin/media.c
@@ -9,6 +9,7 @@
 #include "media.h"
 #include "config.h"
 #include "utils.h"
+#include "termiolink.h"
 
 typedef struct _Media Media;
 
diff --git a/src/bin/termiolink.c b/src/bin/termiolink.c
index 9b28648..58a7a6a 100644
--- a/src/bin/termiolink.c
+++ b/src/bin/termiolink.c
@@ -42,8 +42,55 @@ _local_path_get(const Evas_Object *obj, const char *relpath)
      return _cwd_path_get(obj, relpath);
 }
 
-static Eina_Bool
-_is_file(const char *str)
+Eina_Bool
+link_is_protocol(const char *str)
+{
+   const char *p = str;
+   int c = *p;
+
+   if (!isalpha(c))
+     return EINA_FALSE;
+
+   /* Try to follow RFC3986 a bit
+    * URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
+    * hier-part   = "//" authority path-abempty
+    *             [...] other stuff not taken into account
+    * scheme      = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
+    */
+
+   do
+     {
+        p++;
+        c = *p;
+     }
+   while (isalpha(c) || (c == '.') || (c == '-') || (c == '+'));
+
+   return (p[0] == ':') && (p[1] == '/') && (p[2] == '/');
+}
+
+Eina_Bool
+link_is_url(const char *str)
+{
+   if (link_is_protocol(str) ||
+       casestartswith(str, "www.") ||
+       casestartswith(str, "ftp."))
+     return EINA_TRUE;
+   return EINA_FALSE;
+}
+
+Eina_Bool
+link_is_email(const char *str)
+{
+   const char *at = strchr(str, '@');
+   if (at && strchr(at + 1, '.'))
+     return EINA_TRUE;
+   if (casestartswith(str, "mailto:";))
+     return EINA_TRUE;
+   return EINA_FALSE;
+}
+
+Eina_Bool
+link_is_file(const char *str)
 {
    switch (str[0])
      {
@@ -402,7 +449,7 @@ termio_link_find(const Evas_Object *obj, int cx, int cy,
 out:
    if (sb.len)
      {
-        Eina_Bool is_file = _is_file(sb.buf);
+        Eina_Bool is_file = link_is_file(sb.buf);
 
         if (is_file ||
             link_is_email(sb.buf) ||
diff --git a/src/bin/termiolink.h b/src/bin/termiolink.h
index bb97d90..7228119 100644
--- a/src/bin/termiolink.h
+++ b/src/bin/termiolink.h
@@ -2,5 +2,10 @@
 #define _TERMIO_LINK_H__ 1
 
 char *termio_link_find(const Evas_Object *obj, int cx, int cy, int *x1r, int 
*y1r, int *x2r, int *y2r);
+Eina_Bool link_is_protocol(const char *str);
+Eina_Bool link_is_file(const char *str);
+Eina_Bool link_is_url(const char *str);
+Eina_Bool link_is_email(const char *str);
+
 
 #endif
diff --git a/src/bin/utils.c b/src/bin/utils.c
index 9232676..3c5c2d6 100644
--- a/src/bin/utils.c
+++ b/src/bin/utils.c
@@ -180,50 +180,3 @@ utils_need_scale_wizard(void)
 
    return EINA_TRUE;
 }
-
-Eina_Bool
-link_is_protocol(const char *str)
-{
-   const char *p = str;
-   int c = *p;
-
-   if (!isalpha(c))
-     return EINA_FALSE;
-
-   /* Try to follow RFC3986 a bit
-    * URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
-    * hier-part   = "//" authority path-abempty
-    *             [...] other stuff not taken into account
-    * scheme      = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
-    */
-
-   do
-     {
-        p++;
-        c = *p;
-     }
-   while (isalpha(c) || (c == '.') || (c == '-') || (c == '+'));
-
-   return (p[0] == ':') && (p[1] == '/') && (p[2] == '/');
-}
-
-Eina_Bool
-link_is_url(const char *str)
-{
-   if (link_is_protocol(str) ||
-       casestartswith(str, "www.") ||
-       casestartswith(str, "ftp."))
-     return EINA_TRUE;
-   return EINA_FALSE;
-}
-
-Eina_Bool
-link_is_email(const char *str)
-{
-   const char *at = strchr(str, '@');
-   if (at && strchr(at + 1, '.'))
-     return EINA_TRUE;
-   if (casestartswith(str, "mailto:";))
-     return EINA_TRUE;
-   return EINA_FALSE;
-}
diff --git a/src/bin/utils.h b/src/bin/utils.h
index 01318ba..ca5b6e7 100644
--- a/src/bin/utils.h
+++ b/src/bin/utils.h
@@ -14,10 +14,6 @@ const char *theme_path_get(const char *name);
 Eina_Bool homedir_get(char *buf, size_t size);
 Eina_Bool utils_need_scale_wizard(void);
 
-Eina_Bool link_is_protocol(const char *str);
-Eina_Bool link_is_url(const char *str);
-Eina_Bool link_is_email(const char *str);
-
 #define casestartswith(str, constref) \
   (!strncasecmp(str, constref, sizeof(constref) - 1))
 

-- 


Reply via email to