Mercurial > libjeffpc
changeset 810:cb643e3ad672
sexpr: use size_t in sexpr 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:07:34 -0400 |
parents | 1d716f721c5c |
children | 64ad3a9d4837 |
files | sexpr.l |
diffstat | 1 files changed, 5 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/sexpr.l Sat Apr 18 21:50:06 2020 -0400 +++ b/sexpr.l Sat Jul 18 10:07:34 2020 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2015-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 = sexpr_reader_input_proc(buf, max_size, yyscanner) -int sexpr_reader_input_proc(char *buf, int size, yyscan_t scanner); +static size_t sexpr_reader_input_proc(char *buf, size_t size, yyscan_t scanner); static void inc_lineno(yyscan_t scanner); @@ -160,10 +160,10 @@ out->lineno++; } -int sexpr_reader_input_proc(char *buf, int size, yyscan_t scanner) +static size_t sexpr_reader_input_proc(char *buf, size_t size, yyscan_t scanner) { struct sexpr_parser_state *out; - int num; + ssize_t num; out = (struct sexpr_parser_state *) sexpr_reader_get_extra(scanner); num = out->len - out->pos; @@ -171,8 +171,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;