summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-01 16:47:40 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-01 16:47:40 +0000
commitb3cd8b1cfdd406fcd4054b2e47291fd437e63830 (patch)
tree32402b0f290f6060fbc1f81a81a372f07673181f /nuttx
parent051bb22c7ba05bd5578c1e6104c498e08b3a5235 (diff)
downloadpx4-nuttx-b3cd8b1cfdd406fcd4054b2e47291fd437e63830.tar.gz
px4-nuttx-b3cd8b1cfdd406fcd4054b2e47291fd437e63830.tar.bz2
px4-nuttx-b3cd8b1cfdd406fcd4054b2e47291fd437e63830.zip
mksymtab: Fix handling of final comma. Some C compilers can't handle them; Also add macro to provide the size of the symbol table
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5077 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/tools/mksymtab.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/nuttx/tools/mksymtab.c b/nuttx/tools/mksymtab.c
index 01404bc97..c5a46a92b 100644
--- a/nuttx/tools/mksymtab.c
+++ b/nuttx/tools/mksymtab.c
@@ -51,6 +51,7 @@
****************************************************************************/
#define MAX_HEADER_FILES 500
+#define SYMTAB_NAME "g_symtab"
/****************************************************************************
* Private Types
@@ -118,7 +119,8 @@ int main(int argc, char **argv, char **envp)
{
char *csvpath;
char *symtab;
- char *terminator;
+ char *nextterm;
+ char *finalterm;
char *ptr;
bool cond;
FILE *instream;
@@ -231,12 +233,14 @@ int main(int argc, char **argv, char **envp)
/* Now the symbol table itself */
- fprintf(outstream, "\nstruct symtab_s g_symtab[] =\n");
+ fprintf(outstream, "\nstruct symtab_s %s[] =\n", SYMTAB_NAME);
fprintf(outstream, "{\n");
/* Parse each line in the CVS file */
- terminator = "";
+ nextterm = "";
+ finalterm = "";
+
while ((ptr = read_line(instream)) != NULL)
{
/* Parse the line from the CVS file */
@@ -253,24 +257,29 @@ int main(int argc, char **argv, char **envp)
cond = (g_parm[COND_INDEX] && strlen(g_parm[COND_INDEX]) > 0);
if (cond)
{
- fprintf(outstream, "%s#if %s\n", terminator, g_parm[COND_INDEX]);
- terminator = "";
+ fprintf(outstream, "%s#if %s\n", nextterm, g_parm[COND_INDEX]);
+ nextterm = "";
}
/* Output the symbol table entry */
fprintf(outstream, "%s { \"%s\", (FAR const void *)%s }",
- terminator, g_parm[NAME_INDEX], g_parm[NAME_INDEX]);
- terminator = ",\n";
+ nextterm, g_parm[NAME_INDEX], g_parm[NAME_INDEX]);
if (cond)
{
- fprintf(outstream, "%s#endif", terminator);
- terminator = "\n";
+ nextterm = ",\n#endif\n";
+ finalterm = "\n#endif\n";
+ }
+ else
+ {
+ nextterm = ",\n";
+ finalterm = "\n";
}
}
- fprintf(outstream, "\n};\n");
+ fprintf(outstream, "%s};\n\n", finalterm);
+ fprintf(outstream, "#define NSYMBOLS (sizeof(%s) / sizeof (struct symtab_s))\n", SYMTAB_NAME);
/* Close the CSV and symbol table files and exit */