mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 11:39:16 +02:00
Code cleanup
This commit is contained in:
16
src/common/str2int.cpp
Normal file
16
src/common/str2int.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include <cctype>
|
||||
#include "str2int.h"
|
||||
|
||||
int str2int(const char *str, int len)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
for (const char *sp = str; sp < str + len; sp++) {
|
||||
if (::isdigit(*sp))
|
||||
res = res * 10 + *sp - '0';
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
6
src/common/str2int.h
Normal file
6
src/common/str2int.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
int str2int(const char *str, int len);
|
||||
|
||||
#endif // MISC_H
|
Reference in New Issue
Block a user