Comments (2)
Why not just create wrappers that set and restore the locale around cyaml load/save calls?
For example something like this (untested):
bool my_yaml_loader(
const char *path,
my_data_t **data_out)
{
char *old_locale, *saved_locale;
unsigned sequence_count;
bool ret = false;
my_data_t *data;
cyaml_err_t err;
/* Get the name of the current locale. */
old_locale = setlocale (LC_ALL, NULL);
/* Copy the name so it won’t be clobbered by setlocale. */
saved_locale = strdup(old_locale);
if (saved_locale == NULL) {
fprintf(stderr, "Out of memory\n");
return false;
}
/* Now change the locale to the one we want for loading. */
setlocale (LC_ALL, "C");
/* Do the load. */
err = cyaml_load_file(path, config, schema, &data, &sequence_count);
if (err != CYAML_OK) {
fprintf(stderr, "Error loading %s: %s\n",
path, cyaml_strerror(err));
goto restore;
}
*data_out = data;
ret = true;
restore:
/* Restore the original locale. */
setlocale (LC_ALL, saved_locale);
free(saved_locale);
return ret;
}
from libcyaml.
It is a work-around. I was hoping on using float parsing library that is not dependant on locale. To remove additional complexitz of setting locale.
from libcyaml.
Related Issues (20)
- Make install step fails on macOS HOT 4
- add array value HOT 2
- How to know if an optional field was provided? HOT 2
- .mem_fn = cyaml_mem Method or interface written to shared memory HOT 3
- cyaml_load_data(*, cyaml_data_t **data_out, *); data_out parameter Length ? HOT 4
- Do not detect invalid float values HOT 2
- Reject integer values with trailing junk
- When is next bugfix release going to be released HOT 1
- Improve logging in enum handling - print out available values HOT 3
- Need to show that main branch is now for v2
- How to use CYAML_FIELD_BITFIELDS in case of variables declared in structure HOT 2
- CMake File HOT 1
- How to parse nameless list of map? HOT 3
- Long string causing `malloc(): invalid next size (unsorted)` HOT 2
- Dependency on libyaml not documented HOT 5
- loading data appended to sequence fails HOT 2
- failed to install on MacOS HOT 2
- Handling Dynamic In-Memory Serialization/Deserialization of Specific YAML Sections HOT 2
- Coverity issue HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libcyaml.