Skip to content

Commit

Permalink
refactor/drawing: replace magic -1 with INVALID enum
Browse files Browse the repository at this point in the history
This is clearer and improves type correctness.
  • Loading branch information
TheOneric committed Jan 9, 2024
1 parent 97435e5 commit 344b8a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libass/ass_drawing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};

Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libass/ass_drawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "ass_bitmap.h"

typedef enum {
TOKEN_INVALID,
TOKEN_MOVE,
TOKEN_MOVE_NC,
TOKEN_LINE,
Expand Down

0 comments on commit 344b8a9

Please sign in to comment.