1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1508, Refactor srs_is_digital, support all zeros.

This commit is contained in:
winlin 2019-12-20 14:49:25 +08:00
parent cee4feda61
commit 4382ced3bf
5 changed files with 38 additions and 18 deletions

View file

@ -29,7 +29,6 @@
#include <arpa/inet.h>
#include <signal.h>
#include <sys/wait.h>
#include <math.h>
#include <netdb.h>
#ifdef SRS_OSX
@ -1158,17 +1157,6 @@ string srs_get_peer_ip(int fd)
return std::string(saddr);
}
bool srs_is_digit_number(const string& str)
{
if (str.empty()) {
return false;
}
int v = ::atoi(str.c_str());
int powv = (int)pow(10, str.length() - 1);
return v / powv >= 1 && v / powv <= 9;
}
bool srs_is_boolean(const string& str)
{
return str == "true" || str == "false";