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:
parent
7a2b756f1e
commit
3432029a3d
@ -1204,9 +1204,9 @@ parse_integer_arg(const char *s, long *out, bool accept_suffix, long min,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
parse_integers_arg(const char *s, size_t max_items, long *out, long min,
|
parse_integers_arg(const char *s, const char sep, size_t max_items, long *out,
|
||||||
long max, const char *name) {
|
long min, long max, const char *name) {
|
||||||
size_t count = sc_str_parse_integers(s, ':', max_items, out);
|
size_t count = sc_str_parse_integers(s, sep, max_items, out);
|
||||||
if (!count) {
|
if (!count) {
|
||||||
LOGE("Could not parse %s: %s", name, s);
|
LOGE("Could not parse %s: %s", name, s);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1362,7 +1362,7 @@ parse_window_dimension(const char *s, uint16_t *dimension) {
|
|||||||
static bool
|
static bool
|
||||||
parse_port_range(const char *s, struct sc_port_range *port_range) {
|
parse_port_range(const char *s, struct sc_port_range *port_range) {
|
||||||
long values[2];
|
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) {
|
if (!count) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user