mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
tools: fix nxstyle errors
Fix nxstyle errors to pass CI Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
committed by
David Sidrane
parent
911bc68833
commit
00ac789e4e
+57
-48
@@ -33,10 +33,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Based one the "Glyph Bitmap Distribution Format (BDF) Specification",
|
||||
/* Based one the "Glyph Bitmap Distribution Format (BDF) Specification",
|
||||
* Version 2.2, by Adobe Systems Incorporated.
|
||||
*
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
@@ -60,9 +58,9 @@
|
||||
#endif
|
||||
|
||||
/* BDF Specification Version 2.2:
|
||||
* This version lifts the restriction on line length. In this version, the new
|
||||
* maximum length of a value of the type string is 65535 characters, and hence
|
||||
* lines may now be at least this long.
|
||||
* This version lifts the restriction on line length. In this version,
|
||||
* the new maximum length of a value of the type string is 65535 characters,
|
||||
* and hence lines may now be at least this long.
|
||||
*/
|
||||
|
||||
#define BDF_MAX_LINE_LENGTH 65535
|
||||
@@ -117,7 +115,7 @@ typedef struct nx_fontmetric_s
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: MY_strtok_r
|
||||
* Name: my_strtok_r
|
||||
*
|
||||
* Description:
|
||||
* MinGW does not seem to provide strtok_r
|
||||
@@ -125,7 +123,7 @@ typedef struct nx_fontmetric_s
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef HAVE_STRTOK_R
|
||||
static char *MY_strtok_r(char *str, const char *delim, char **saveptr)
|
||||
static char *my_strtok_r(char *str, const char *delim, char **saveptr)
|
||||
{
|
||||
char *pbegin;
|
||||
char *pend = NULL;
|
||||
@@ -187,15 +185,16 @@ static char *MY_strtok_r(char *str, const char *delim, char **saveptr)
|
||||
{
|
||||
*saveptr = pend;
|
||||
}
|
||||
|
||||
return pbegin;
|
||||
}
|
||||
|
||||
#undef strtok_r
|
||||
#define strtok_r MY_strtok_r
|
||||
#define strtok_r my_strtok_r
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: trimLine
|
||||
* Name: trimline
|
||||
*
|
||||
* Description:
|
||||
* Trims the line removing space characters at the front and at the end
|
||||
@@ -206,15 +205,15 @@ static char *MY_strtok_r(char *str, const char *delim, char **saveptr)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void trimLine(char *line)
|
||||
static void trimline(char *line)
|
||||
{
|
||||
char *str;
|
||||
str = line;
|
||||
char *strEnd;
|
||||
for (strEnd = str + strlen(str) - 1;
|
||||
strEnd >= str && isspace((int)(*strEnd));
|
||||
strEnd--);
|
||||
*(strEnd + 1) = 0;
|
||||
char *strend;
|
||||
for (strend = str + strlen(str) - 1;
|
||||
strend >= str && isspace((int)(*strend));
|
||||
strend--);
|
||||
*(strend + 1) = 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -240,7 +239,9 @@ static void trimLine(char *line)
|
||||
|
||||
static void bdf_parseintline(char *line, unsigned int count, int *info)
|
||||
{
|
||||
char *str, *token, *saveptr1;
|
||||
char *str;
|
||||
char *token;
|
||||
char *saveptr1;
|
||||
str = line;
|
||||
|
||||
/* Ignore the key */
|
||||
@@ -331,21 +332,22 @@ static void bdf_printnxmetricinfo(const nx_fontmetric_t *info)
|
||||
static void bdf_getglyphinfo(FILE *file, glyphinfo_t *ginfo)
|
||||
{
|
||||
char line[BDF_MAX_LINE_LENGTH];
|
||||
char lineCopy[BDF_MAX_LINE_LENGTH];
|
||||
char *str, *token, *saveptr1;
|
||||
char linecopy[BDF_MAX_LINE_LENGTH];
|
||||
char *str;
|
||||
char *token;
|
||||
char *saveptr1;
|
||||
bool done;
|
||||
|
||||
done = false;
|
||||
|
||||
while (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL && !done)
|
||||
{
|
||||
trimLine(line);
|
||||
strcpy(lineCopy, line);
|
||||
trimline(line);
|
||||
strcpy(linecopy, line);
|
||||
str = line;
|
||||
|
||||
while ((token = (char *)strtok_r(str, " ", &saveptr1)))
|
||||
{
|
||||
|
||||
/* ENCODING information */
|
||||
|
||||
if (strcmp(token, "ENCODING") == 0)
|
||||
@@ -369,13 +371,13 @@ static void bdf_getglyphinfo(FILE *file, glyphinfo_t *ginfo)
|
||||
else if (strcmp(token, "BBX") == 0)
|
||||
{
|
||||
int bbxinfo[4];
|
||||
bdf_parseintline(lineCopy, 4, bbxinfo);
|
||||
bdf_parseintline(linecopy, 4, bbxinfo);
|
||||
ginfo->bb_w = bbxinfo[0];
|
||||
ginfo->bb_h = bbxinfo[1];
|
||||
ginfo->bb_x_off = bbxinfo[2];
|
||||
ginfo->bb_y_off = bbxinfo[3];
|
||||
|
||||
/* This is the last BDF property of interest*/
|
||||
/* This is the last BDF property of interest */
|
||||
|
||||
done = true;
|
||||
}
|
||||
@@ -411,7 +413,7 @@ static void bdf_getglyphbitmap(FILE *file, glyphinfo_t *ginfo)
|
||||
{
|
||||
if (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL)
|
||||
{
|
||||
trimLine(line);
|
||||
trimline(line);
|
||||
|
||||
if (strcmp(line, "ENDCHAR") == 0)
|
||||
{
|
||||
@@ -446,6 +448,7 @@ static void bdf_getglyphbitmap(FILE *file, glyphinfo_t *ginfo)
|
||||
* return the stride.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void bdf_getstride(glyphinfo_t *ginfo, uint32_t *stride)
|
||||
{
|
||||
*stride = (ginfo->bb_w % 8 == 0) ? ginfo->bb_w / 8 : ginfo->bb_w / 8 + 1;
|
||||
@@ -464,10 +467,13 @@ static void bdf_getstride(glyphinfo_t *ginfo, uint32_t *stride)
|
||||
* nxmetric - A nx_fontmetric_t struct with the glyph's information.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void bdf_printoutput(FILE *out,
|
||||
glyphinfo_t *ginfo,
|
||||
nx_fontmetric_t *nxmetric)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
/* Only interested in the 7 and 8 bit ranges */
|
||||
|
||||
@@ -505,7 +511,7 @@ static void bdf_printoutput(FILE *out,
|
||||
/* Glyph bitmap */
|
||||
|
||||
fprintf(out, "#define NXFONT_BITMAP_%d {", ginfo->encoding);
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < ginfo->bb_h - 1; i++)
|
||||
{
|
||||
for (j = 1; j <= nxmetric->stride; j++)
|
||||
@@ -557,17 +563,21 @@ int main(int argc, char **argv)
|
||||
{
|
||||
FILE *file, *out;
|
||||
char line[BDF_MAX_LINE_LENGTH];
|
||||
char lineCopy[BDF_MAX_LINE_LENGTH];
|
||||
char *str, *token, *saveptr1;
|
||||
char *input, *output;
|
||||
char linecopy[BDF_MAX_LINE_LENGTH];
|
||||
char *str;
|
||||
char *token;
|
||||
char *saveptr1;
|
||||
char *input;
|
||||
char *output;
|
||||
|
||||
/* FONTBOUNDINGBOX properties*/
|
||||
/* FONTBOUNDINGBOX properties */
|
||||
|
||||
int fbb_x = 0;
|
||||
int fbb_y = 0;
|
||||
//int fbb_x_off = 0;
|
||||
int fbb_y_off = 0;
|
||||
|
||||
/* int fbb_x_off = 0; */
|
||||
|
||||
/* Input BDF file */
|
||||
|
||||
input = argv[1];
|
||||
@@ -615,32 +625,32 @@ int main(int argc, char **argv)
|
||||
{
|
||||
while (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL)
|
||||
{
|
||||
|
||||
#ifdef DBG
|
||||
printf("--\n");
|
||||
#endif /* DBG */
|
||||
|
||||
// Save a copy of the line
|
||||
/* Save a copy of the line */
|
||||
|
||||
strcpy(lineCopy,line);
|
||||
strcpy(linecopy, line);
|
||||
|
||||
// Clean it
|
||||
/* Clean it */
|
||||
|
||||
trimLine(line);
|
||||
trimline(line);
|
||||
str = line;
|
||||
|
||||
while ((token = (char *)strtok_r(str, " ", &saveptr1)))
|
||||
{
|
||||
|
||||
/* FONTBOUNDINGBOX - Global font information */
|
||||
|
||||
if (strcmp(token, "FONTBOUNDINGBOX") == 0)
|
||||
{
|
||||
int fbbinfo[4];
|
||||
bdf_parseintline(lineCopy, 4, fbbinfo);
|
||||
bdf_parseintline(linecopy, 4, fbbinfo);
|
||||
fbb_x = fbbinfo[0];
|
||||
fbb_y = fbbinfo[1];
|
||||
//fbb_x_off = fbbinfo[2];
|
||||
|
||||
/* fbb_x_off = fbbinfo[2]; */
|
||||
|
||||
fbb_y_off = fbbinfo[3];
|
||||
|
||||
/* Print FONTBOUNDINGBOX information */
|
||||
@@ -666,10 +676,10 @@ int main(int argc, char **argv)
|
||||
#endif /* VERBOSE */
|
||||
|
||||
/* Glyph information:
|
||||
* ENCODING
|
||||
* DWIDTH
|
||||
* BBX
|
||||
*/
|
||||
* ENCODING
|
||||
* DWIDTH
|
||||
* BBX
|
||||
*/
|
||||
|
||||
ginfo.encoding = 0;
|
||||
ginfo.dw_x0 = 0;
|
||||
@@ -699,7 +709,8 @@ int main(int argc, char **argv)
|
||||
nxmetric.height = ginfo.bb_h;
|
||||
|
||||
/* The NuttX font format does not support
|
||||
* negative X offsets. */
|
||||
* negative X offsets.
|
||||
*/
|
||||
|
||||
if (ginfo.bb_x_off < 0)
|
||||
{
|
||||
@@ -727,7 +738,8 @@ int main(int argc, char **argv)
|
||||
if (ginfo.encoding == 32)
|
||||
{
|
||||
fprintf(out, "/* The width of a space */\n\n");
|
||||
fprintf(out, "#define NXFONT_SPACEWIDTH %d\n\n", ginfo.dw_x0);
|
||||
fprintf(out, "#define NXFONT_SPACEWIDTH %d\n\n",
|
||||
ginfo.dw_x0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -737,12 +749,10 @@ int main(int argc, char **argv)
|
||||
/* Free memory */
|
||||
|
||||
free(ginfo.bitmap);
|
||||
|
||||
}
|
||||
|
||||
str = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
@@ -751,7 +761,6 @@ int main(int argc, char **argv)
|
||||
/* The End */
|
||||
|
||||
printf("Generated \"%s\"\n", output);
|
||||
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user