Comments (2)
This is a bug. isalpha and isdigit take an int, but they expect a value of 0..255 (or EOF) and not -128..127
One is supposed to cast a char into unsigned char before putting it into isalpha and the like. This was not fatal before, because -128...-1 are neither alphas nor digits so the function returned 0 for numbers < 0 anyway (EOF may be -1).
But now nano libraries seem to leave out the EOF support and just use the value as index to an array, which can be pretty bad with negative numbers.
If you do a man isalpha, you will see the NOTES:
NOTES
The standards require that the argument c for these functions is either EOF or a value that is representable in the type unsigned char. If the argument c is of type char, it must be cast
to unsigned char, as in the following example:
char c;
...
res = toupper((unsigned char) c);
This is necessary because char may be the equivalent of signed char, in which case a byte where the top bit is set would be sign extended when converting to int, yielding a value that is
outside the range of unsigned char.
The details of what characters belong to which class depend on the locale. For example, isupper() will not recognize an A-umlaut (Ä) as an uppercase letter in the default C locale.
from tinyexpr.
Thanks for the detailed explanation. I will try to fix this in the next update.
from tinyexpr.
Related Issues (20)
- Feature request: add logical operators.
- Feature request : right and left shift operations HOT 4
- Look ahead Variables HOT 4
- Custom infix operators HOT 3
- How about support time expression? HOT 2
- The website says that this is a header-only library, but the actual code isn't HOT 2
- Extraction of tokens HOT 5
- Invalid conversion for custom function in Arduino HOT 6
- Redundant null-pointer check in `te_interp` HOT 1
- Segfault when two variables follow each other HOT 4
- Merging logic branch with ifdefs
- codeblocks compiler issue? HOT 2
- Weird behavior when calling te_free HOT 3
- Feature request: Add define to change return value from double to long double HOT 6
- Usage with different types HOT 2
- Feature Request: Implement ternary evalutation HOT 9
- Error eval expression when initializing te_variable by individual assignment HOT 7
- Function to determine the number of variables in an expression HOT 2
- Possible memory leak in te_compile HOT 1
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 tinyexpr.