Mercurial > libedl
comparison src/datatypes.c @ 14:2d7c810a1ac2 default tip
*: misc. cleanup
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Fri, 03 May 2024 22:40:28 -0400 |
parents | 0cc2555db371 |
children |
comparison
equal
deleted
inserted
replaced
13:41b74137e201 | 14:2d7c810a1ac2 |
---|---|
19 | 19 |
20 return s; | 20 return s; |
21 } | 21 } |
22 | 22 |
23 size_t EDL_internal_parse_int(const char* input, size_t offset, size_t length, int* int_return) { | 23 size_t EDL_internal_parse_int(const char* input, size_t offset, size_t length, int* int_return) { |
24 char* ptr_return = input; | |
25 | |
24 if (offset > length) | 26 if (offset > length) |
25 return 0; | 27 return 0; |
26 | 28 |
27 { | 29 *int_return = strtol(&input[offset], &ptr_return, 10); |
28 char* ptr_return; | |
29 *int_return = strtol(&input[offset], &ptr_return, 10); | |
30 | 30 |
31 if (!ptr_return) | 31 if (ptr_return == input) |
32 return 0; | 32 return 0; |
33 } | |
34 | 33 |
35 return EDL_internal_append_offset(input, offset, length); | 34 return EDL_internal_append_offset(input, offset, length); |
36 } | 35 } |
37 | 36 |
38 size_t EDL_internal_parse_double(const char* input, size_t offset, size_t length, double* double_return) { | 37 size_t EDL_internal_parse_double(const char* input, size_t offset, size_t length, double* double_return) { |
38 char* ptr_return = input; | |
39 | |
39 if (offset > length) | 40 if (offset > length) |
40 return 0; | 41 return 0; |
41 | 42 |
42 { | 43 *double_return = strtod(&input[offset], &ptr_return); |
43 char* ptr_return; | |
44 *double_return = strtod(&input[offset], &ptr_return); | |
45 | 44 |
46 if (!ptr_return) | 45 if (ptr_return == input) |
47 return 0; | 46 return 0; |
48 } | |
49 | 47 |
50 return EDL_internal_append_offset(input, offset, length); | 48 return EDL_internal_append_offset(input, offset, length); |
51 } | 49 } |
52 | 50 |
53 size_t EDL_internal_parse_bool(const char* input, size_t offset, size_t length, bool* bool_return) { | 51 size_t EDL_internal_parse_bool(const char* input, size_t offset, size_t length, bool* bool_return) { |
77 } | 75 } |
78 | 76 |
79 size_t EDL_internal_parse_string(const char* input, size_t offset, size_t length, char** string_return) { | 77 size_t EDL_internal_parse_string(const char* input, size_t offset, size_t length, char** string_return) { |
80 size_t start, s_length; | 78 size_t start, s_length; |
81 | 79 |
82 /* will most definitely break on good filesystems */ | 80 /* will definitely break on any good filesystem */ |
83 if (offset > length) | 81 if (offset > length) |
84 return 0; | 82 return 0; |
85 | 83 |
86 start = strchr(&input[offset], '\"') - &input[offset] + 1; | 84 start = strchr(&input[offset], '\"') - &input[offset] + 1; |
87 if (start + offset > length) | 85 if (start + offset > length) |