Make separator configurable for parsing integers

The separator was hardcoded to ':'. This will allow to reuse the
function to parse sizes as WIDTHxHEIGHT.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
This commit is contained in:
Romain Vimont 2023-08-23 20:22:39 +02:00
parent 7a2b756f1e
commit 3432029a3d
1 changed files with 4 additions and 4 deletions

View File

@ -1204,9 +1204,9 @@ parse_integer_arg(const char *s, long *out, bool accept_suffix, long min,
}
static size_t
parse_integers_arg(const char *s, size_t max_items, long *out, long min,
long max, const char *name) {
size_t count = sc_str_parse_integers(s, ':', max_items, out);
parse_integers_arg(const char *s, const char sep, size_t max_items, long *out,
long min, long max, const char *name) {
size_t count = sc_str_parse_integers(s, sep, max_items, out);
if (!count) {
LOGE("Could not parse %s: %s", name, s);
return 0;
@ -1362,7 +1362,7 @@ parse_window_dimension(const char *s, uint16_t *dimension) {
static bool
parse_port_range(const char *s, struct sc_port_range *port_range) {
long values[2];
size_t count = parse_integers_arg(s, 2, values, 0, 0xFFFF, "port");
size_t count = parse_integers_arg(s, ':', 2, values, 0, 0xFFFF, "port");
if (!count) {
return false;
}