summaryrefslogtreecommitdiffstats
path: root/libass/ass_utils.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@chown.ath.cx>2011-08-15 22:04:02 +0200
committerGrigori Goronzy <greg@chown.ath.cx>2015-07-10 10:42:40 +0200
commit1fbe520d41d8a92082826b15dbd1cc54a067fa48 (patch)
tree9580e0cab8e4170caf0f4b2f1971bb50d5143fbe /libass/ass_utils.c
parentc22a4ff9a395546637dbe0f1e9d0ee549dd0069a (diff)
downloadlibass-1fbe520d41d8a92082826b15dbd1cc54a067fa48.tar.bz2
libass-1fbe520d41d8a92082826b15dbd1cc54a067fa48.tar.xz
Trim spaces of font family strings
This adds a trimming utility function that is used for trimming strings of font requests in the font sorter.
Diffstat (limited to 'libass/ass_utils.c')
-rw-r--r--libass/ass_utils.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c
index a6a063b1..0fc8b2a5 100644
--- a/libass/ass_utils.c
+++ b/libass/ass_utils.c
@@ -24,7 +24,7 @@
#include <stdint.h>
#include <inttypes.h>
#include <strings.h>
-#include <limits.h>
+#include <ctype.h>
#include "ass_library.h"
#include "ass.h"
@@ -331,6 +331,24 @@ void ass_msg(ASS_Library *priv, int lvl, char *fmt, ...)
va_end(va);
}
+char *trim_space(char *str)
+{
+ int i;
+ int left = 0;
+ int right = strlen(str) - 1;
+
+ while (isspace(str[left])) left++;
+ while (isspace(str[right])) right--;
+
+ if (left > 0)
+ for (i = 0; i <= right - left; i++)
+ str[i] = str[left+i];
+
+ str[right-left+1] = '\0';
+
+ return str;
+}
+
unsigned ass_utf8_get_char(char **str)
{
uint8_t *strp = (uint8_t *) * str;