summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOneric <oneric@oneric.stub>2024-01-03 23:56:28 +0100
committerOneric <oneric@oneric.stub>2024-01-09 02:03:32 +0100
commit344b8a912a1740813738142c90fb45ea87eb1fc4 (patch)
treeffff17f93bd217c20703cff3c18fa2a80a7d800c
parent97435e513f41d5968c1d2a0524e9365b757d9fab (diff)
downloadlibass-344b8a912a1740813738142c90fb45ea87eb1fc4.tar.bz2
libass-344b8a912a1740813738142c90fb45ea87eb1fc4.tar.xz
refactor/drawing: replace magic -1 with INVALID enum
This is clearer and improves type correctness.
-rw-r--r--libass/ass_drawing.c7
-rw-r--r--libass/ass_drawing.h1
2 files changed, 5 insertions, 3 deletions
diff --git a/libass/ass_drawing.c b/libass/ass_drawing.c
index 4e6e932..43cf9c3 100644
--- a/libass/ass_drawing.c
+++ b/libass/ass_drawing.c
@@ -33,7 +33,7 @@
/*
* \brief Check whether a number of items on the list is available
*/
-static bool token_check_values(ASS_DrawingToken *token, int i, int type)
+static bool token_check_values(ASS_DrawingToken *token, int i, ASS_TokenType type)
{
for (int j = 0; j < i; j++) {
if (!token || token->type != type) return false;
@@ -50,7 +50,8 @@ static bool token_check_values(ASS_DrawingToken *token, int i, int type)
static ASS_DrawingToken *drawing_tokenize(const char *str)
{
char *p = (char *) str;
- int type = -1, is_set = 0;
+ ASS_TokenType type = TOKEN_INVALID;
+ int is_set = 0;
double val;
ASS_Vector point = {0, 0};
@@ -102,7 +103,7 @@ static ASS_DrawingToken *drawing_tokenize(const char *str)
if (!got_coord)
is_set = 0;
- if (type != -1 && is_set == 2) {
+ if (type != TOKEN_INVALID && is_set == 2) {
if (root) {
tail->next = calloc(1, sizeof(ASS_DrawingToken));
tail->next->prev = tail;
diff --git a/libass/ass_drawing.h b/libass/ass_drawing.h
index ea65ac6..2c5e921 100644
--- a/libass/ass_drawing.h
+++ b/libass/ass_drawing.h
@@ -24,6 +24,7 @@
#include "ass_bitmap.h"
typedef enum {
+ TOKEN_INVALID,
TOKEN_MOVE,
TOKEN_MOVE_NC,
TOKEN_LINE,