tools: fix nxstyle errors

Fix nxstyle errors to pass CI

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
Alin Jerpelea
2021-02-19 11:29:43 +01:00
committed by David Sidrane
parent 911bc68833
commit 00ac789e4e
11 changed files with 166 additions and 118 deletions
+53 -44
View File
@@ -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. * Version 2.2, by Adobe Systems Incorporated.
*
*/ */
/**************************************************************************** /****************************************************************************
@@ -60,9 +58,9 @@
#endif #endif
/* BDF Specification Version 2.2: /* BDF Specification Version 2.2:
* This version lifts the restriction on line length. In this version, the new * This version lifts the restriction on line length. In this version,
* maximum length of a value of the type string is 65535 characters, and hence * the new maximum length of a value of the type string is 65535 characters,
* lines may now be at least this long. * and hence lines may now be at least this long.
*/ */
#define BDF_MAX_LINE_LENGTH 65535 #define BDF_MAX_LINE_LENGTH 65535
@@ -117,7 +115,7 @@ typedef struct nx_fontmetric_s
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: MY_strtok_r * Name: my_strtok_r
* *
* Description: * Description:
* MinGW does not seem to provide strtok_r * MinGW does not seem to provide strtok_r
@@ -125,7 +123,7 @@ typedef struct nx_fontmetric_s
****************************************************************************/ ****************************************************************************/
#ifndef HAVE_STRTOK_R #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 *pbegin;
char *pend = NULL; char *pend = NULL;
@@ -187,15 +185,16 @@ static char *MY_strtok_r(char *str, const char *delim, char **saveptr)
{ {
*saveptr = pend; *saveptr = pend;
} }
return pbegin; return pbegin;
} }
#undef strtok_r #undef strtok_r
#define strtok_r MY_strtok_r #define strtok_r my_strtok_r
#endif #endif
/**************************************************************************** /****************************************************************************
* Name: trimLine * Name: trimline
* *
* Description: * Description:
* Trims the line removing space characters at the front and at the end * 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; char *str;
str = line; str = line;
char *strEnd; char *strend;
for (strEnd = str + strlen(str) - 1; for (strend = str + strlen(str) - 1;
strEnd >= str && isspace((int)(*strEnd)); strend >= str && isspace((int)(*strend));
strEnd--); strend--);
*(strEnd + 1) = 0; *(strend + 1) = 0;
} }
/**************************************************************************** /****************************************************************************
@@ -240,7 +239,9 @@ static void trimLine(char *line)
static void bdf_parseintline(char *line, unsigned int count, int *info) static void bdf_parseintline(char *line, unsigned int count, int *info)
{ {
char *str, *token, *saveptr1; char *str;
char *token;
char *saveptr1;
str = line; str = line;
/* Ignore the key */ /* 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) static void bdf_getglyphinfo(FILE *file, glyphinfo_t *ginfo)
{ {
char line[BDF_MAX_LINE_LENGTH]; char line[BDF_MAX_LINE_LENGTH];
char lineCopy[BDF_MAX_LINE_LENGTH]; char linecopy[BDF_MAX_LINE_LENGTH];
char *str, *token, *saveptr1; char *str;
char *token;
char *saveptr1;
bool done; bool done;
done = false; done = false;
while (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL && !done) while (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL && !done)
{ {
trimLine(line); trimline(line);
strcpy(lineCopy, line); strcpy(linecopy, line);
str = line; str = line;
while ((token = (char *)strtok_r(str, " ", &saveptr1))) while ((token = (char *)strtok_r(str, " ", &saveptr1)))
{ {
/* ENCODING information */ /* ENCODING information */
if (strcmp(token, "ENCODING") == 0) if (strcmp(token, "ENCODING") == 0)
@@ -369,13 +371,13 @@ static void bdf_getglyphinfo(FILE *file, glyphinfo_t *ginfo)
else if (strcmp(token, "BBX") == 0) else if (strcmp(token, "BBX") == 0)
{ {
int bbxinfo[4]; int bbxinfo[4];
bdf_parseintline(lineCopy, 4, bbxinfo); bdf_parseintline(linecopy, 4, bbxinfo);
ginfo->bb_w = bbxinfo[0]; ginfo->bb_w = bbxinfo[0];
ginfo->bb_h = bbxinfo[1]; ginfo->bb_h = bbxinfo[1];
ginfo->bb_x_off = bbxinfo[2]; ginfo->bb_x_off = bbxinfo[2];
ginfo->bb_y_off = bbxinfo[3]; ginfo->bb_y_off = bbxinfo[3];
/* This is the last BDF property of interest*/ /* This is the last BDF property of interest */
done = true; done = true;
} }
@@ -411,7 +413,7 @@ static void bdf_getglyphbitmap(FILE *file, glyphinfo_t *ginfo)
{ {
if (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL) if (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL)
{ {
trimLine(line); trimline(line);
if (strcmp(line, "ENDCHAR") == 0) if (strcmp(line, "ENDCHAR") == 0)
{ {
@@ -446,6 +448,7 @@ static void bdf_getglyphbitmap(FILE *file, glyphinfo_t *ginfo)
* return the stride. * return the stride.
* *
****************************************************************************/ ****************************************************************************/
static void bdf_getstride(glyphinfo_t *ginfo, uint32_t *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; *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. * nxmetric - A nx_fontmetric_t struct with the glyph's information.
* *
****************************************************************************/ ****************************************************************************/
static void bdf_printoutput(FILE *out, static void bdf_printoutput(FILE *out,
glyphinfo_t *ginfo, glyphinfo_t *ginfo,
nx_fontmetric_t *nxmetric) nx_fontmetric_t *nxmetric)
{ {
int i;
int j;
/* Only interested in the 7 and 8 bit ranges */ /* Only interested in the 7 and 8 bit ranges */
@@ -505,7 +511,7 @@ static void bdf_printoutput(FILE *out,
/* Glyph bitmap */ /* Glyph bitmap */
fprintf(out, "#define NXFONT_BITMAP_%d {", ginfo->encoding); fprintf(out, "#define NXFONT_BITMAP_%d {", ginfo->encoding);
int i, j;
for (i = 0; i < ginfo->bb_h - 1; i++) for (i = 0; i < ginfo->bb_h - 1; i++)
{ {
for (j = 1; j <= nxmetric->stride; j++) for (j = 1; j <= nxmetric->stride; j++)
@@ -557,17 +563,21 @@ int main(int argc, char **argv)
{ {
FILE *file, *out; FILE *file, *out;
char line[BDF_MAX_LINE_LENGTH]; char line[BDF_MAX_LINE_LENGTH];
char lineCopy[BDF_MAX_LINE_LENGTH]; char linecopy[BDF_MAX_LINE_LENGTH];
char *str, *token, *saveptr1; char *str;
char *input, *output; char *token;
char *saveptr1;
char *input;
char *output;
/* FONTBOUNDINGBOX properties*/ /* FONTBOUNDINGBOX properties */
int fbb_x = 0; int fbb_x = 0;
int fbb_y = 0; int fbb_y = 0;
//int fbb_x_off = 0;
int fbb_y_off = 0; int fbb_y_off = 0;
/* int fbb_x_off = 0; */
/* Input BDF file */ /* Input BDF file */
input = argv[1]; input = argv[1];
@@ -615,32 +625,32 @@ int main(int argc, char **argv)
{ {
while (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL) while (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL)
{ {
#ifdef DBG #ifdef DBG
printf("--\n"); printf("--\n");
#endif /* DBG */ #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; str = line;
while ((token = (char *)strtok_r(str, " ", &saveptr1))) while ((token = (char *)strtok_r(str, " ", &saveptr1)))
{ {
/* FONTBOUNDINGBOX - Global font information */ /* FONTBOUNDINGBOX - Global font information */
if (strcmp(token, "FONTBOUNDINGBOX") == 0) if (strcmp(token, "FONTBOUNDINGBOX") == 0)
{ {
int fbbinfo[4]; int fbbinfo[4];
bdf_parseintline(lineCopy, 4, fbbinfo); bdf_parseintline(linecopy, 4, fbbinfo);
fbb_x = fbbinfo[0]; fbb_x = fbbinfo[0];
fbb_y = fbbinfo[1]; fbb_y = fbbinfo[1];
//fbb_x_off = fbbinfo[2];
/* fbb_x_off = fbbinfo[2]; */
fbb_y_off = fbbinfo[3]; fbb_y_off = fbbinfo[3];
/* Print FONTBOUNDINGBOX information */ /* Print FONTBOUNDINGBOX information */
@@ -699,7 +709,8 @@ int main(int argc, char **argv)
nxmetric.height = ginfo.bb_h; nxmetric.height = ginfo.bb_h;
/* The NuttX font format does not support /* The NuttX font format does not support
* negative X offsets. */ * negative X offsets.
*/
if (ginfo.bb_x_off < 0) if (ginfo.bb_x_off < 0)
{ {
@@ -727,7 +738,8 @@ int main(int argc, char **argv)
if (ginfo.encoding == 32) if (ginfo.encoding == 32)
{ {
fprintf(out, "/* The width of a space */\n\n"); 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 else
{ {
@@ -737,12 +749,10 @@ int main(int argc, char **argv)
/* Free memory */ /* Free memory */
free(ginfo.bitmap); free(ginfo.bitmap);
} }
str = NULL; str = NULL;
} }
} }
fclose(file); fclose(file);
@@ -751,7 +761,6 @@ int main(int argc, char **argv)
/* The End */ /* The End */
printf("Generated \"%s\"\n", output); printf("Generated \"%s\"\n", output);
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
+2 -2
View File
@@ -53,10 +53,10 @@
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
extern char line[LINESIZE+1]; extern char line[LINESIZE + 1];
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions Definitions
****************************************************************************/ ****************************************************************************/
void generate_definitions(FILE *stream); void generate_definitions(FILE *stream);
+7 -4
View File
@@ -51,7 +51,7 @@
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
char line[LINESIZE+1]; char line[LINESIZE + 1];
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@@ -93,6 +93,7 @@ static char *find_value_end(char *ptr)
do ptr++; while (*ptr && !isspace((int)*ptr) && *ptr != '"'); do ptr++; while (*ptr && !isspace((int)*ptr) && *ptr != '"');
} }
} }
return ptr; return ptr;
} }
@@ -102,7 +103,7 @@ static char *read_line(FILE *stream)
{ {
char *ptr; char *ptr;
for (;;) for (; ; )
{ {
line[LINESIZE] = '\0'; line[LINESIZE] = '\0';
if (!fgets(line, LINESIZE, stream)) if (!fgets(line, LINESIZE, stream))
@@ -239,7 +240,8 @@ void parse_file(FILE *stream, struct variable_s **list)
* variable name and the value. * variable name and the value.
*/ */
curr = (struct variable_s *)malloc(sizeof(struct variable_s) + varlen + vallen - 1); curr = (struct variable_s *)malloc(sizeof(struct variable_s) +
varlen + vallen - 1);
if (curr) if (curr)
{ {
/* Add the variable to the list */ /* Add the variable to the list */
@@ -279,7 +281,8 @@ void parse_file(FILE *stream, struct variable_s **list)
while (ptr); while (ptr);
} }
struct variable_s *find_variable(const char *varname, struct variable_s *list) struct variable_s *find_variable(const char *varname,
struct variable_s *list)
{ {
while (list) while (list)
{ {
+4 -3
View File
@@ -65,13 +65,14 @@ struct variable_s
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
extern char line[LINESIZE+1]; extern char line[LINESIZE + 1];
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions Definitions
****************************************************************************/ ****************************************************************************/
void parse_file(FILE *stream, struct variable_s **list); void parse_file(FILE *stream, struct variable_s **list);
struct variable_s *find_variable(const char *varname, struct variable_s *list); struct variable_s *find_variable(const char *varname,
struct variable_s *list);
#endif /* __TOOLS_CFGPARSER_H */ #endif /* __TOOLS_CFGPARSER_H */
+6 -3
View File
@@ -117,7 +117,8 @@ static bool dequote_path(const char *winpath)
while (*src && len < MAX_PATH) while (*src && len < MAX_PATH)
{ {
if (src[0] != '\\' || (src[1] != ' ' && src[1] != '(' && src[1] != ')')) if (src[0] != '\\' || (src[1] != ' ' &&
src[1] != '(' && src[1] != ')'))
{ {
*dest++ = *src; *dest++ = *src;
len++; len++;
@@ -148,7 +149,8 @@ static bool convert_path(const char *winpath)
quoted = dequote_path(winpath); quoted = dequote_path(winpath);
size = cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE, g_dequoted, NULL, 0); size = cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE,
g_dequoted, NULL, 0);
if (size > MAX_PATH) if (size > MAX_PATH)
{ {
fprintf(stderr, "%lu: POSIX path too long: %lu\n", fprintf(stderr, "%lu: POSIX path too long: %lu\n",
@@ -156,7 +158,8 @@ static bool convert_path(const char *winpath)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
ret = cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE, g_dequoted, g_posix, MAX_PATH); ret = cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE,
g_dequoted, g_posix, MAX_PATH);
if (ret < 0) if (ret < 0)
{ {
fprintf(stderr, "%lu: cygwin_conv_path '%s' failed: %s\n", fprintf(stderr, "%lu: cygwin_conv_path '%s' failed: %s\n",
+18 -12
View File
@@ -52,8 +52,8 @@
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
static char g_lineA[LINESIZE + 3]; static char g_linea[LINESIZE + 3];
static char g_lineB[LINESIZE + 3]; static char g_lineb[LINESIZE + 3];
static char g_iobuffer[LINESIZE]; static char g_iobuffer[LINESIZE];
/**************************************************************************** /****************************************************************************
@@ -108,8 +108,8 @@ int main(int argc, char **argv)
/* Prime the pump */ /* Prime the pump */
g_line0 = g_lineA; g_line0 = g_linea;
g_line1 = g_lineB; g_line1 = g_lineb;
wasblank = true; wasblank = true;
wascomment = false; wascomment = false;
lastindent = 0; lastindent = 0;
@@ -214,13 +214,17 @@ int main(int argc, char **argv)
} }
else else
{ {
/* Check for a C++ style comment at this indentation in line n + 1 */ /* Check for a C++ style comment
* at this indentation in line n + 1
*/
willbeblank = false; willbeblank = false;
willbecomment = strncmp(ptr, "//", 2) == 0; willbecomment = strncmp(ptr, "//", 2) == 0;
} }
/* Check for a C++ style comment at this indentation in line n + 1 */ /* Check for a C++ style comment
* at this indentation in line n + 1
*/
willbecomment = strncmp(ptr, "//", 2) == 0; willbecomment = strncmp(ptr, "//", 2) == 0;
} }
@@ -231,8 +235,8 @@ int main(int argc, char **argv)
nextindent = 0; nextindent = 0;
} }
/* If current line is not a comment line, then check for a C++ style comment at the /* If current line is not a comment line, then check for a C++ style
* end of the line. * comment at the end of the line.
*/ */
if (!iscomment) if (!iscomment)
@@ -253,7 +257,8 @@ int main(int argc, char **argv)
} }
} }
printf("*****************************************************************************\n"); printf("***************************************
**************************************\n");
printf("* %5lu. %s\n", lineno, g_line0); printf("* %5lu. %s\n", lineno, g_line0);
printf("* indent: last=%u curr=%u next=%u\n", printf("* indent: last=%u curr=%u next=%u\n",
lastindent, indent, nextindent); lastindent, indent, nextindent);
@@ -261,7 +266,8 @@ int main(int argc, char **argv)
wascomment, iscomment, willbecomment); wascomment, iscomment, willbecomment);
printf("* blank: last=%u curr=%u next=%u\n", printf("* blank: last=%u curr=%u next=%u\n",
wasblank, isblank, willbeblank); wasblank, isblank, willbeblank);
printf("*****************************************************************************\n"); printf("***************************************
**************************************\n");
/* Does line n start with a comment */ /* Does line n start with a comment */
@@ -367,8 +373,8 @@ int main(int argc, char **argv)
} }
else if (wascomment) else if (wascomment)
{ {
/* Line n is not a comment, but line n - 1 was. Output a closing on a /* Line n is not a comment, but line n - 1 was.
* newline at the same indentation. * Output a closing on a newline at the same indentation.
*/ */
memset(g_iobuffer, ' ', LINESIZE); memset(g_iobuffer, ' ', LINESIZE);
+10 -5
View File
@@ -59,7 +59,7 @@
****************************************************************************/ ****************************************************************************/
bool g_debug; bool g_debug;
char g_line[LINESIZE+1]; char g_line[LINESIZE + 1];
char g_parm[MAX_FIELDS][MAX_PARMSIZE]; char g_parm[MAX_FIELDS][MAX_PARMSIZE];
int g_lineno; int g_lineno;
@@ -97,7 +97,8 @@ static char *copy_parm(char *src, char *dest)
} }
else if (*src == '\n' || *src == '\0') else if (*src == '\n' || *src == '\0')
{ {
fprintf(stderr, "%d: Unexpected end of line: \"%s\"\n", g_lineno, start); fprintf(stderr, "%d: Unexpected end of line: \"%s\"\n",
g_lineno, start);
exit(4); exit(4);
} }
else else
@@ -123,6 +124,7 @@ static char *find_parm(char *ptr)
fprintf(stderr, "%d: I'm confused: \"%s\"\n", g_lineno, start); fprintf(stderr, "%d: I'm confused: \"%s\"\n", g_lineno, start);
exit(5); exit(5);
} }
ptr++; ptr++;
ptr = skip_space(ptr); ptr = skip_space(ptr);
@@ -135,6 +137,7 @@ static char *find_parm(char *ptr)
fprintf(stderr, "%d: Expected ',': \"%s\"\n", g_lineno, start); fprintf(stderr, "%d: Expected ',': \"%s\"\n", g_lineno, start);
exit(6); exit(6);
} }
ptr++; ptr++;
ptr = skip_space(ptr); ptr = skip_space(ptr);
@@ -143,6 +146,7 @@ static char *find_parm(char *ptr)
fprintf(stderr, "%d: Expected \": \"%s\"\n", g_lineno, start); fprintf(stderr, "%d: Expected \": \"%s\"\n", g_lineno, start);
exit(7); exit(7);
} }
ptr++; ptr++;
return ptr; return ptr;
@@ -160,7 +164,7 @@ char *read_line(FILE *stream)
{ {
char *ptr; char *ptr;
for (;;) for (; ; )
{ {
g_line[LINESIZE] = '\0'; g_line[LINESIZE] = '\0';
if (!fgets(g_line, LINESIZE, stream)) if (!fgets(g_line, LINESIZE, stream))
@@ -215,7 +219,8 @@ int parse_csvline(char *ptr)
{ {
if (nparms >= MAX_FIELDS) if (nparms >= MAX_FIELDS)
{ {
fprintf(stderr, "%d: Too many Parameters: \"%s\"\n", g_lineno, g_line); fprintf(stderr, "%d: Too many Parameters: \"%s\"\n",
g_lineno, g_line);
exit(8); exit(8);
} }
@@ -232,7 +237,7 @@ int parse_csvline(char *ptr)
printf("Parameters: %d\n", nparms); printf("Parameters: %d\n", nparms);
for (i = 0; i < nparms; i++) for (i = 0; i < nparms; i++)
{ {
printf(" Parm%d: \"%s\"\n", i+1, g_parm[i]); printf(" Parm%d: \"%s\"\n", i + 1, g_parm[i]);
} }
} }
+2 -1
View File
@@ -80,7 +80,8 @@ int main(int argc, char **argv, char **envp)
if (strcmp(argv[1], "-4") != 0) if (strcmp(argv[1], "-4") != 0)
{ {
fprintf(stderr, "ERROR: Unrecognized option\n"); fprintf(stderr, "ERROR: Unrecognized option\n");
fprintf(stderr, "Usage: %s [-4] <source-file> <out-file>\n", argv[0]); fprintf(stderr, "Usage: %s [-4] <source-file> <out-file>\n",
argv[0]);
return 1; return 1;
} }
+28 -12
View File
@@ -71,16 +71,29 @@ static int nhdrfiles;
static void show_usage(const char *progname) static void show_usage(const char *progname)
{ {
fprintf(stderr, "USAGE: %s [-d] <cvs-file> <symtab-file> [<symtab-name> [<nsymbols-name>]]\n\n", fprintf(stderr,
"USAGE:\n");
fprintf(stderr,
"%s [-d] <cvs-file> <symtab-file> [<symtab-name> [<nsymbols-name>]]\n\n",
progname); progname);
fprintf(stderr, "Where:\n\n"); fprintf(stderr,
fprintf(stderr, " <cvs-file> : The path to the input CSV file (required)\n"); "Where:\n\n");
fprintf(stderr, " <symtab-file> : The path to the output symbol table file (required)\n"); fprintf(stderr,
fprintf(stderr, " <symtab-name> : Optional name for the symbol table variable\n"); " <cvs-file> : The path to the input CSV file (required)\n");
fprintf(stderr, " Default: \"%s\"\n", SYMTAB_NAME); fprintf(stderr,
fprintf(stderr, " <nsymbols-name> : Optional name for the symbol table variable\n"); " <symtab-file> : The path to the output symbol table file\n");
fprintf(stderr, " Default: \"%s\"\n", NSYMBOLS_NAME); fprintf(stderr,
fprintf(stderr, " -d : Enable debug output\n"); "(required)\n");
fprintf(stderr,
" <symtab-name> : Optional name for the symbol table variable\n");
fprintf(stderr,
" Default: \"%s\"\n", SYMTAB_NAME);
fprintf(stderr,
" <nsymbols-name> : Optional name for the symbol table variable\n");
fprintf(stderr,
" Default: \"%s\"\n", NSYMBOLS_NAME);
fprintf(stderr,
" -d : Enable debug output\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@@ -107,7 +120,8 @@ static void add_hdrfile(const char *hdrfile)
{ {
if (nhdrfiles > MAX_HEADER_FILES) if (nhdrfiles > MAX_HEADER_FILES)
{ {
fprintf(stderr, "ERROR: Too man header files. Increase MAX_HEADER_FILES\n"); fprintf(stderr,
"ERROR: Too man header files. Increase MAX_HEADER_FILES\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@@ -242,7 +256,8 @@ int main(int argc, char **argv, char **envp)
/* Output up-front file boilerplate */ /* Output up-front file boilerplate */
fprintf(outstream, "/* %s: Auto-generated symbol table. Do not edit */\n\n", sympath); fprintf(outstream,
"/* %s: Auto-generated symbol table. Do not edit */\n\n", sympath);
fprintf(outstream, "#include <nuttx/config.h>\n"); fprintf(outstream, "#include <nuttx/config.h>\n");
fprintf(outstream, "#include <nuttx/compiler.h>\n"); fprintf(outstream, "#include <nuttx/compiler.h>\n");
fprintf(outstream, "#include <nuttx/symtab.h>\n\n"); fprintf(outstream, "#include <nuttx/symtab.h>\n\n");
@@ -302,7 +317,8 @@ int main(int argc, char **argv, char **envp)
} }
fprintf(outstream, "%s};\n\n", finalterm); fprintf(outstream, "%s};\n\n", finalterm);
fprintf(outstream, "#define NSYMBOLS (sizeof(%s) / sizeof (struct symtab_s))\n", symtab); fprintf(outstream,
"#define NSYMBOLS (sizeof(%s) / sizeof (struct symtab_s))\n", symtab);
fprintf(outstream, "int %s = NSYMBOLS;\n", nsymbols); fprintf(outstream, "int %s = NSYMBOLS;\n", nsymbols);
/* Close the CSV and symbol table files and exit */ /* Close the CSV and symbol table files and exit */
+4
View File
@@ -58,6 +58,10 @@ static char g_line[LINESIZE];
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
FILE *instream; FILE *instream;