Mercurial > blahgd > experimental
changeset 1026:3e753e62ea5d
post fmt3: use size_t in lexer input function
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sat, 18 Jul 2020 10:46:14 -0400 |
parents | 3f5fdd9f1be5 |
children | 7bedc9c2eca6 |
files | post_fmt3.l |
diffstat | 1 files changed, 5 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/post_fmt3.l Sat Jul 18 11:01:47 2020 -0400 +++ b/post_fmt3.l Sat Jul 18 10:46:14 2020 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2011-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -37,7 +37,7 @@ #define YY_INPUT(buf, result, max_size) \ result = fmt3_input_proc(buf, max_size, yyscanner) -int fmt3_input_proc(char *buf, int size, yyscan_t scanner); +static size_t fmt3_input_proc(char *buf, size_t size, yyscan_t scanner); static void inc_lineno(yyscan_t scanner); %} @@ -124,10 +124,10 @@ out->lineno++; } -int fmt3_input_proc(char *buf, int size, yyscan_t scanner) +static size_t fmt3_input_proc(char *buf, size_t size, yyscan_t scanner) { struct parser_output *out; - int num; + ssize_t num; out = (struct parser_output *) fmt3_get_extra(scanner); num = out->len - out->pos; @@ -135,8 +135,7 @@ if (num <= 0) return 0; - if (num > size) - num = size; + num = MIN(num, size); memcpy(buf, out->input + out->pos, num); out->pos += num;