Comments (4)
Thanks for digging into this. It seems to me that the whole code could probably be simpler overall since it doesn't need to worry about partial digits like the <hex>
syntax does.
for( n=0; !eof && n < S.comp_.sz; n++ ){
do (c[0] = xpost_file_getc(f)) == EOF && ++eof; while( ! (eof || strchr(hex, c[0])) );
if( !eof ){
do (c[1] = xpost_file_getc(f)) == EOF && ++eof; while( ! (eof || strchr(hex, c[1])) );
if( !eof ) s[n] = ((strchr(hex, toupper(c[0])) - hex) << 4)
| (strchr(hex, toupper(c[1])) - hex);
}
}
S.comp_.sz = n;
This version seems more correct given your analysis but I'll put it through some tests before committing. And probably the style I have here is too compact per our style rules. The do...while loops could probably be factored into a helper function with a descriptive name.
from xpost.
Oops. This still has the n++
problem you already diagnosed.
from xpost.
Take 2.
int readhexdigit( Xpost_File *f, int *p ){
int eof = 0;
do (*p = xpost_file_getc(f)) == EOF && ++eof;
while( ! (eof || strchr(hex, *p)) );
return eof;
}
for( n = 0; !eof && n < S.comp_.sz; n++ ){
eof += readhexdigit(f, &c[0]);
if( !eof ) eof += readhexdigit(f, &c[1]);
if( eof ) break;
s[n] = ((strchr(hex, toupper(c[0])) - hex) << 4) | (strchr(hex, toupper(c[1])) - hex);
}
S.comp_.sz = n;
from xpost.
Written, tested, committed, pushed.
from xpost.
Related Issues (20)
- Increase performance of the hash tables HOT 1
- use the same random filename sequence in lmem* gmem* and xdump* HOT 2
- create dumper utility to convert lmem* gmem* and xdump* to a text format HOT 3
- optimize typechecks and polymorphic dispatch from procedure bodies in `bind`
- unit tests do not compile on Windows HOT 3
- color space not changing naturally
- Increase array and string max size
- Simplify operator execution by pushing args backwards HOT 1
- Remove integer automaton from grok()
- kshow ignores proc
- devices which output to file only output a single file (jpeg png pgm ppm) HOT 4
- PS interpreter HOT 6
- Completion of error handling HOT 16
- [discussion] meson build system HOT 2
- xpost_file_read(), and hence readstring, doesn't deal with end of file HOT 2
- -Wall has a new nuisance warning HOT 18
- is dirname really needed ? HOT 4
- Configuration parameters HOT 2
- Can't install HOT 2
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 xpost.