From: Mikko Rasa Date: Wed, 31 Mar 2021 11:16:13 +0000 (+0300) Subject: Accept 0 as a valid code point X-Git-Url: http://git.tdb.fi/?p=ttf2png.git;a=commitdiff_plain;h=e80f88a25e4c1e3f91be435636be4267ba6ab9ec Accept 0 as a valid code point I don't expect any fonts to have an actual glyph there, but it is technically valid. --- diff --git a/ttf2png.c b/ttf2png.c index 0c1c09a..2783811 100644 --- a/ttf2png.c +++ b/ttf2png.c @@ -73,7 +73,7 @@ typedef unsigned char bool; void usage(void); int convert_numeric_option(char, int); void convert_code_point_range(char, Range *); -unsigned str_to_code_point(const char *, char **); +int str_to_code_point(const char *, char **); void convert_size(char, unsigned *, unsigned *); void sort_and_compact_ranges(Range *, unsigned *); int range_cmp(const void *, const void *); @@ -344,11 +344,11 @@ void convert_code_point_range(char opt, Range *range) } value = str_to_code_point(optarg, &ptr); - if(value>0 && *ptr==',') + if(value>=0 && *ptr==',') { range->first = value; value = str_to_code_point(ptr+1, &ptr); - if(value>0 && !*ptr) + if(value>=0 && !*ptr) { range->last = value; return; @@ -359,7 +359,7 @@ void convert_code_point_range(char opt, Range *range) exit(1); } -unsigned str_to_code_point(const char *nptr, char **endptr) +int str_to_code_point(const char *nptr, char **endptr) { if(nptr[0]=='U' && nptr[1]=='+') return strtoul(nptr+2, endptr, 16); @@ -374,9 +374,9 @@ unsigned str_to_code_point(const char *nptr, char **endptr) for(bytes=1; (bytes<4 && (nptr[0]&(0x80>>bytes))); ++bytes) if((nptr[bytes]&0xC0)!=0x80) - return 0; + return -1; if(bytes<2) - return 0; + return -1; code = nptr[0]&(0x3F>>bytes); for(i=1; i