mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
parser: move atoi_n to import-divinglog.cpp
That was the only user of this helper function, so move it there. Moreover, impelement it with the standard function std::from_chars instead of copying the string. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
541abf7ae4
commit
124362caa5
3 changed files with 9 additions and 13 deletions
|
@ -16,6 +16,15 @@
|
|||
#include "membuffer.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include <charconv>
|
||||
|
||||
static int atoi_n(const char *ptr, size_t len)
|
||||
{
|
||||
int res = 0;
|
||||
std::from_chars(ptr, ptr + len, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int divinglog_cylinder(void *param, int, char **data, char **)
|
||||
{
|
||||
struct parser_state *state = (struct parser_state *)param;
|
||||
|
|
|
@ -466,15 +466,3 @@ void add_dive_site(const char *ds_name, struct dive *dive, struct parser_state *
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
int atoi_n(char *ptr, unsigned int len)
|
||||
{
|
||||
if (len < 10) {
|
||||
char buf[10];
|
||||
|
||||
memcpy(buf, ptr, len);
|
||||
buf[len] = 0;
|
||||
return atoi(buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,6 @@ void add_dive_site(const char *ds_name, struct dive *dive, struct parser_state *
|
|||
int trimspace(char *buffer);
|
||||
void start_match(const char *type, const char *name, char *buffer);
|
||||
void nonmatch(const char *type, const char *name, char *buffer);
|
||||
int atoi_n(char *ptr, unsigned int len);
|
||||
|
||||
void parse_xml_init();
|
||||
int parse_xml_buffer(const char *url, const char *buf, int size, struct divelog *log, const struct xml_params *params);
|
||||
|
|
Loading…
Add table
Reference in a new issue