Improve spacing in comments in convbdf; rename a local variable which can be confused with 1 (one)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26117 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Alexander Levin 2010-05-17 20:55:55 +00:00
parent 88c55d7290
commit 949d99546e

View file

@ -15,7 +15,7 @@
#define ROTATE /* define this for the new, rotated format */ #define ROTATE /* define this for the new, rotated format */
/* BEGIN font.h*/ /* BEGIN font.h */
/* loadable font magic and version number */ /* loadable font magic and version number */
#ifdef ROTATE #ifdef ROTATE
#define VERSION "RB12" /* newer version */ #define VERSION "RB12" /* newer version */
@ -76,7 +76,7 @@ struct font {
/* default width in pixels (can be overwritten at char level) */ /* default width in pixels (can be overwritten at char level) */
int default_width; int default_width;
}; };
/* END font.h*/ /* END font.h */
/* Description of how the ascent/descent is allowed to grow */ /* Description of how the ascent/descent is allowed to grow */
struct stretch { struct stretch {
@ -201,7 +201,7 @@ void parse_ascent_opt(char *val, struct stretch *opt) {
opt->value = atoi(buf); opt->value = atoi(buf);
} }
/* parse command line options*/ /* parse command line options */
void getopts(int *pac, char ***pav) void getopts(int *pac, char ***pav)
{ {
char *p; char *p;
@ -676,7 +676,7 @@ int bdf_read_header(FILE *fp, struct font* pf)
break; break;
} }
/* calc font height*/ /* calc font height */
if (pf->ascent < 0 || pf->descent < 0 || firstchar < 0) { if (pf->ascent < 0 || pf->descent < 0 || firstchar < 0) {
print_error("Invalid BDF file, requires FONT_ASCENT/FONT_DESCENT/ENCODING\n"); print_error("Invalid BDF file, requires FONT_ASCENT/FONT_DESCENT/ENCODING\n");
return 0; return 0;
@ -712,7 +712,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
int bbw, bbh, bbx, bby; int bbw, bbh, bbx, bby;
int proportional = 0; int proportional = 0;
int encodetable = 0; int encodetable = 0;
int l; int offset;
char buf[256]; char buf[256];
bitmap_t *ch_bitmap; bitmap_t *ch_bitmap;
int ch_words; int ch_words;
@ -773,7 +773,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
if (width < 0 && pf->default_width > 0) if (width < 0 && pf->default_width > 0)
width = pf->default_width; width = pf->default_width;
/* set bits offset in encode map*/ /* set bits offset in encode map */
if (pf->offset[encoding-pf->firstchar] != -1) { if (pf->offset[encoding-pf->firstchar] != -1) {
print_error("duplicate encoding for character %d (0x%02x), ignoring duplicate\n", print_error("duplicate encoding for character %d (0x%02x), ignoring duplicate\n",
encoding, encoding); encoding, encoding);
@ -888,22 +888,22 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
/* determine whether font doesn't require encode table */ /* determine whether font doesn't require encode table */
#ifdef ROTATE #ifdef ROTATE
l = 0; offset = 0;
for (i=0; i<pf->size; ++i) { for (i=0; i<pf->size; ++i) {
if ((int)pf->offrot[i] != l) { if ((int)pf->offrot[i] != offset) {
encodetable = 1; encodetable = 1;
break; break;
} }
l += pf->maxwidth * ((pf->height + 7) / 8); offset += pf->maxwidth * ((pf->height + 7) / 8);
} }
#else #else
l = 0; offset = 0;
for (i=0; i<pf->size; ++i) { for (i=0; i<pf->size; ++i) {
if (pf->offset[i] != l) { if (pf->offset[i] != offset) {
encodetable = 1; encodetable = 1;
break; break;
} }
l += BITMAP_WORDS(pf->width[i]) * pf->height; offset += BITMAP_WORDS(pf->width[i]) * pf->height;
} }
#endif #endif
if (!encodetable) { if (!encodetable) {
@ -1092,7 +1092,7 @@ int adjust_ascent(int ascent, int overflow, struct stretch *stretch) {
} }
/* return hex value of portion of buffer*/ /* return hex value of portion of buffer */
bitmap_t bdf_hexval(unsigned char *buf, int ndx1, int ndx2) bitmap_t bdf_hexval(unsigned char *buf, int ndx1, int ndx2)
{ {
bitmap_t val = 0; bitmap_t val = 0;
@ -1151,20 +1151,20 @@ int rotleft(unsigned char *dst, /* output buffer */
return -1; return -1;
} }
/* calc words of input image*/ /* calc words of input image */
src_words = BITMAP_WORDS(width) * height; src_words = BITMAP_WORDS(width) * height;
/* clear background*/ /* clear background */
memset(dst, 0, needed_size); memset(dst, 0, needed_size);
dst_mask = 1; dst_mask = 1;
for (i=0; i < src_words; i++) { for (i=0; i < src_words; i++) {
/* calc src input bit*/ /* calc src input bit */
src_mask = 1 << (sizeof (bitmap_t) * 8 - 1); src_mask = 1 << (sizeof (bitmap_t) * 8 - 1);
/* for each input column...*/ /* for each input column... */
for(j=0; j < width; j++) { for(j=0; j < width; j++) {
if (src_mask == 0) /* input word done? */ if (src_mask == 0) /* input word done? */
@ -1193,7 +1193,7 @@ int rotleft(unsigned char *dst, /* output buffer */
#endif /* ROTATE */ #endif /* ROTATE */
/* generate C source from in-core font*/ /* generate C source from in-core font */
int gen_c_source(struct font* pf, char *path) int gen_c_source(struct font* pf, char *path)
{ {
FILE *ofp; FILE *ofp;
@ -1251,7 +1251,7 @@ int gen_c_source(struct font* pf, char *path)
pf->width? "yes": "no", pf->width? "yes": "no",
pf->copyright? pf->copyright: ""); pf->copyright? pf->copyright: "");
/* generate bitmaps*/ /* generate bitmaps */
for (i=0; i<pf->size; ++i) { for (i=0; i<pf->size; ++i) {
int x; int x;
int bitcount = 0; int bitcount = 0;
@ -1341,7 +1341,7 @@ int gen_c_source(struct font* pf, char *path)
fprintf(ofp, "};\n\n"); fprintf(ofp, "};\n\n");
if (pf->offset) { if (pf->offset) {
/* output offset table*/ /* output offset table */
fprintf(ofp, "/* Character->glyph mapping. */\n" fprintf(ofp, "/* Character->glyph mapping. */\n"
"static const unsigned short _sysfont_offset[] = {\n"); "static const unsigned short _sysfont_offset[] = {\n");
@ -1362,7 +1362,7 @@ int gen_c_source(struct font* pf, char *path)
fprintf(ofp, "};\n\n"); fprintf(ofp, "};\n\n");
} }
/* output width table for proportional fonts*/ /* output width table for proportional fonts */
if (pf->width) { if (pf->width) {
fprintf(ofp, "/* Character width data. */\n" fprintf(ofp, "/* Character width data. */\n"
"static const unsigned char _sysfont_width[] = {\n"); "static const unsigned char _sysfont_width[] = {\n");
@ -1373,7 +1373,7 @@ int gen_c_source(struct font* pf, char *path)
fprintf(ofp, "};\n\n"); fprintf(ofp, "};\n\n");
} }
/* output struct font struct*/ /* output struct font struct */
if (pf->offset) if (pf->offset)
sprintf(obuf, "_sysfont_offset,"); sprintf(obuf, "_sysfont_offset,");
else else
@ -1419,7 +1419,7 @@ int gen_c_source(struct font* pf, char *path)
return 0; return 0;
} }
/* generate C header from in-core font*/ /* generate C header from in-core font */
int gen_h_header(struct font* pf, char *path) int gen_h_header(struct font* pf, char *path)
{ {
FILE *ofp; FILE *ofp;
@ -1429,7 +1429,7 @@ int gen_h_header(struct font* pf, char *path)
"/* Generated by convbdf on %s. */\n" "/* Generated by convbdf on %s. */\n"
"#ifdef HAVE_LCD_BITMAP\n" "#ifdef HAVE_LCD_BITMAP\n"
"\n" "\n"
"/* Font information*/\n" "/* Font information */\n"
"#define SYSFONT_NAME %s\n" "#define SYSFONT_NAME %s\n"
"#define SYSFONT_FACENAME %s\n" "#define SYSFONT_FACENAME %s\n"
"#define SYSFONT_WIDTH %d\n" "#define SYSFONT_WIDTH %d\n"
@ -1517,7 +1517,7 @@ static int writestrpad(FILE *fp, char *str, int totlen)
} }
#endif #endif
/* generate .fnt format file from in-core font*/ /* generate .fnt format file from in-core font */
int gen_fnt_file(struct font* pf, char *path) int gen_fnt_file(struct font* pf, char *path)
{ {
FILE *ofp; FILE *ofp;
@ -1532,16 +1532,16 @@ int gen_fnt_file(struct font* pf, char *path)
return 1; return 1;
} }
/* write magic and version #*/ /* write magic and version number */
writestr(ofp, VERSION, 4); writestr(ofp, VERSION, 4);
#ifndef ROTATE #ifndef ROTATE
/* internal font name*/ /* internal font name */
writestrpad(ofp, pf->name, 64); writestrpad(ofp, pf->name, 64);
/* copyright*/ /* copyright */
writestrpad(ofp, pf->copyright, 256); writestrpad(ofp, pf->copyright, 256);
#endif #endif
/* font info*/ /* font info */
writeshort(ofp, pf->maxwidth); writeshort(ofp, pf->maxwidth);
writeshort(ofp, pf->height); writeshort(ofp, pf->height);
writeshort(ofp, pf->ascent); writeshort(ofp, pf->ascent);
@ -1550,11 +1550,11 @@ int gen_fnt_file(struct font* pf, char *path)
writeint(ofp, pf->defaultchar); writeint(ofp, pf->defaultchar);
writeint(ofp, pf->size); writeint(ofp, pf->size);
/* variable font data sizes*/ /* variable font data sizes */
writeint(ofp, pf->bits_size); /* # words of bitmap_t*/ writeint(ofp, pf->bits_size); /* # words of bitmap_t */
writeint(ofp, pf->offset? pf->size: 0); /* # ints of offset*/ writeint(ofp, pf->offset? pf->size: 0); /* # ints of offset */
writeint(ofp, pf->width? pf->size: 0); /* # bytes of width*/ writeint(ofp, pf->width? pf->size: 0); /* # bytes of width */
/* variable font data*/ /* variable font data */
#ifdef ROTATE #ifdef ROTATE
for (i=0; i<pf->size; ++i) for (i=0; i<pf->size; ++i)
{ {
@ -1585,13 +1585,13 @@ int gen_fnt_file(struct font* pf, char *path)
{ {
/* bitmap offset is small enough, use unsigned short for offset */ /* bitmap offset is small enough, use unsigned short for offset */
if (ftell(ofp) & 1) if (ftell(ofp) & 1)
writebyte(ofp, 0); /* pad to 16-bit boundary*/ writebyte(ofp, 0); /* pad to 16-bit boundary */
} }
else else
{ {
/* bitmap offset is large then 64K, use unsigned int for offset */ /* bitmap offset is large then 64K, use unsigned int for offset */
while (ftell(ofp) & 3) while (ftell(ofp) & 3)
writebyte(ofp, 0); /* pad to 32-bit boundary*/ writebyte(ofp, 0); /* pad to 32-bit boundary */
} }
if (pf->offset) if (pf->offset)
@ -1616,7 +1616,7 @@ int gen_fnt_file(struct font* pf, char *path)
for (i=0; i<pf->bits_size; ++i) for (i=0; i<pf->bits_size; ++i)
writeshort(ofp, pf->bits[i]); writeshort(ofp, pf->bits[i]);
if (ftell(ofp) & 2) if (ftell(ofp) & 2)
writeshort(ofp, 0); /* pad to 32-bit boundary*/ writeshort(ofp, 0); /* pad to 32-bit boundary */
if (pf->offset) if (pf->offset)
for (i=0; i<pf->size; ++i) { for (i=0; i<pf->size; ++i) {