changeset 36989:0b80003f6542

Relocate the cut functions. Put them into the string functions file.
author ib
date Thu, 27 Mar 2014 09:15:47 +0000
parents c9ccf9b4a43b
children 89c6bf8bea6b
files gui/skin/font.c gui/skin/skin.c gui/util/cut.c gui/util/cut.h gui/util/string.c gui/util/string.h
diffstat 6 files changed, 54 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/gui/skin/font.c	Thu Mar 27 02:22:17 2014 +0000
+++ b/gui/skin/font.c	Thu Mar 27 09:15:47 2014 +0000
@@ -28,7 +28,6 @@
 
 #include "font.h"
 #include "skin.h"
-#include "gui/util/cut.h"
 #include "gui/util/mem.h"
 #include "gui/util/string.h"
 
--- a/gui/skin/skin.c	Thu Mar 27 02:22:17 2014 +0000
+++ b/gui/skin/skin.c	Thu Mar 27 09:15:47 2014 +0000
@@ -30,7 +30,6 @@
 #include "gui/app/app.h"
 #include "gui/app/gui.h"
 #include "gui/dialog/dialog.h"
-#include "gui/util/cut.h"
 #include "gui/util/string.h"
 
 #include "help_mp.h"
--- a/gui/util/cut.c	Thu Mar 27 02:22:17 2014 +0000
+++ b/gui/util/cut.c	Thu Mar 27 09:15:47 2014 +0000
@@ -25,48 +25,3 @@
 #include <string.h>
 
 #include "cut.h"
-
-/**
- * @brief Extract a part of a string delimited by a separator character.
- *
- * @param in string to be analyzed
- * @param out pointer suitable to store the extracted part
- * @param sep separator character
- * @param num number of separator characters to be skipped before extraction starts
- * @param maxout maximum length of extracted part (including the trailing null byte)
- */
-void cutItemString(char *in, char *out, char sep, int num, size_t maxout)
-{
-    int n;
-    unsigned int i, c;
-
-    for (c = 0, n = 0, i = 0; in[i]; i++) {
-        if (in[i] == sep)
-            n++;
-        if (n >= num && in[i] != sep && c + 1 < maxout)
-            out[c++] = in[i];
-        if (n >= num && in[i + 1] == sep)
-            break;
-    }
-
-    if (c < maxout)
-        out[c] = 0;
-}
-
-/**
- * @brief Extract a numeric part of a string delimited by a separator character.
- *
- * @param in string to be analyzed
- * @param sep separator character
- * @param num number of separator characters to be skipped before extraction starts
- *
- * @return extracted number (numeric part)
- */
-int cutItemToInt(char *in, char sep, int num)
-{
-    char tmp[64];
-
-    cutItem(in, tmp, sep, num);
-
-    return atoi(tmp);
-}
--- a/gui/util/cut.h	Thu Mar 27 02:22:17 2014 +0000
+++ b/gui/util/cut.h	Thu Mar 27 09:15:47 2014 +0000
@@ -21,14 +21,4 @@
 
 #include <stddef.h>
 
-/**
- * @brief Wraps #cutItemString():
- *        Extract a part of a string delimited by a separator character
- *        at most the size of @a out.
- */
-#define cutItem(in, out, sep, num) cutItemString(in, out, sep, num, sizeof(out))
-
-void cutItemString(char *in, char *out, char sep, int num, size_t maxout);
-int cutItemToInt(char *in, char sep, int num);
-
 #endif /* MPLAYER_GUI_CUT_H */
--- a/gui/util/string.c	Thu Mar 27 02:22:17 2014 +0000
+++ b/gui/util/string.c	Thu Mar 27 09:15:47 2014 +0000
@@ -169,6 +169,51 @@
 }
 
 /**
+ * @brief Extract a part of a string delimited by a separator character.
+ *
+ * @param in string to be analyzed
+ * @param out pointer suitable to store the extracted part
+ * @param sep separator character
+ * @param num number of separator characters to be skipped before extraction starts
+ * @param maxout maximum length of extracted part (including the trailing null byte)
+ */
+void cutItemString(char *in, char *out, char sep, int num, size_t maxout)
+{
+    int n;
+    unsigned int i, c;
+
+    for (c = 0, n = 0, i = 0; in[i]; i++) {
+        if (in[i] == sep)
+            n++;
+        if (n >= num && in[i] != sep && c + 1 < maxout)
+            out[c++] = in[i];
+        if (n >= num && in[i + 1] == sep)
+            break;
+    }
+
+    if (c < maxout)
+        out[c] = 0;
+}
+
+/**
+ * @brief Extract a numeric part of a string delimited by a separator character.
+ *
+ * @param in string to be analyzed
+ * @param sep separator character
+ * @param num number of separator characters to be skipped before extraction starts
+ *
+ * @return extracted number (numeric part)
+ */
+int cutItemToInt(char *in, char sep, int num)
+{
+    char tmp[64];
+
+    cutItem(in, tmp, sep, num);
+
+    return atoi(tmp);
+}
+
+/**
  * @brief A strchr() that can handle NULL pointers.
  *
  * @param str string to examine
--- a/gui/util/string.h	Thu Mar 27 02:22:17 2014 +0000
+++ b/gui/util/string.h	Thu Mar 27 09:15:47 2014 +0000
@@ -22,6 +22,15 @@
 #include <stddef.h>
 #include <stdio.h>
 
+/**
+ * @brief Wraps #cutItemString():
+ *        Extract a part of a string delimited by a separator character
+ *        at most the size of @a out.
+ */
+#define cutItem(in, out, sep, num) cutItemString(in, out, sep, num, sizeof(out))
+
+void cutItemString(char *in, char *out, char sep, int num, size_t maxout);
+int cutItemToInt(char *in, char sep, int num);
 char *decomment(char *in);
 char *fgetstr(char *str, int size, FILE *file);
 char *gstrchr(const char *str, int c);