[MPlayer-cvslog] r37085 - in trunk/gui: skin/font.c skin/skin.c util/cut.c util/cut.h util/string.c util/string.h
ib
subversion at mplayerhq.hu
Thu Mar 27 10:15:48 CET 2014
Author: ib
Date: Thu Mar 27 10:15:47 2014
New Revision: 37085
Log:
Relocate the cut functions.
Put them into the string functions file.
Modified:
trunk/gui/skin/font.c
trunk/gui/skin/skin.c
trunk/gui/util/cut.c
trunk/gui/util/cut.h
trunk/gui/util/string.c
trunk/gui/util/string.h
Modified: trunk/gui/skin/font.c
==============================================================================
--- trunk/gui/skin/font.c Thu Mar 27 03:22:17 2014 (r37084)
+++ trunk/gui/skin/font.c Thu Mar 27 10:15:47 2014 (r37085)
@@ -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"
Modified: trunk/gui/skin/skin.c
==============================================================================
--- trunk/gui/skin/skin.c Thu Mar 27 03:22:17 2014 (r37084)
+++ trunk/gui/skin/skin.c Thu Mar 27 10:15:47 2014 (r37085)
@@ -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"
Modified: trunk/gui/util/cut.c
==============================================================================
--- trunk/gui/util/cut.c Thu Mar 27 03:22:17 2014 (r37084)
+++ trunk/gui/util/cut.c Thu Mar 27 10:15:47 2014 (r37085)
@@ -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);
-}
Modified: trunk/gui/util/cut.h
==============================================================================
--- trunk/gui/util/cut.h Thu Mar 27 03:22:17 2014 (r37084)
+++ trunk/gui/util/cut.h Thu Mar 27 10:15:47 2014 (r37085)
@@ -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 */
Modified: trunk/gui/util/string.c
==============================================================================
--- trunk/gui/util/string.c Thu Mar 27 03:22:17 2014 (r37084)
+++ trunk/gui/util/string.c Thu Mar 27 10:15:47 2014 (r37085)
@@ -169,6 +169,51 @@ char *decomment(char *in)
}
/**
+ * @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
Modified: trunk/gui/util/string.h
==============================================================================
--- trunk/gui/util/string.h Thu Mar 27 03:22:17 2014 (r37084)
+++ trunk/gui/util/string.h Thu Mar 27 10:15:47 2014 (r37085)
@@ -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);
More information about the MPlayer-cvslog
mailing list