[rtems commit] tools: Remove invalid cpp characters from the header guards.
Chris Johns
chrisj at rtems.org
Fri Sep 5 03:21:56 UTC 2014
Module: rtems
Branch: master
Commit: 960c9f02986308779ae431aca648f7482a3a57d2
Changeset: http://git.rtems.org/rtems/commit/?id=960c9f02986308779ae431aca648f7482a3a57d2
Author: Chris Johns <chrisj at rtems.org>
Date: Fri Sep 5 13:29:45 2014 +1000
tools: Remove invalid cpp characters from the header guards.
The waf converter in examples-v2 uses an absolute path and this
creates defines with invalid characters.
---
tools/build/rtems-bin2c.c | 29 +++++++++++++++++++++--------
1 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/tools/build/rtems-bin2c.c b/tools/build/rtems-bin2c.c
index 4e6796a..710c97e 100644
--- a/tools/build/rtems-bin2c.c
+++ b/tools/build/rtems-bin2c.c
@@ -98,7 +98,7 @@ void process(const char *ifname, const char *ofname)
fprintf(stderr, "cannot open %s for reading\n", ifname);
exit(1);
}
-
+
if ( createC ) {
ocfile = fopen(ocname, "wb");
if (ocfile == NULL) {
@@ -106,7 +106,7 @@ void process(const char *ifname, const char *ofname)
exit(1);
}
}
-
+
if ( createH ) {
ohfile = fopen(ohname, "wb");
if (ohfile == NULL) {
@@ -114,11 +114,11 @@ void process(const char *ifname, const char *ofname)
exit(1);
}
}
-
+
/* find basename */
char *ifbasename = strdup(ifname);
ifbasename = basename(ifbasename);
-
+
strcpy(buf, ifbasename);
for (p = buf; *p != '\0'; ++p)
if (!isalnum(*p))
@@ -170,13 +170,26 @@ void process(const char *ifname, const char *ofname)
buf
);
} /* createC */
-
+
/*****************************************************************/
/****** END OF C FILE *****/
/*****************************************************************/
if ( createH ) {
/* print H file header */
+ char hbasename[PATH_MAX];
+ char* p;
+ /* Clean up the file name if it is an abs path */
+ strcpy(
+ hbasename,
+ obasename
+ );
+ p = hbasename;
+ while (*p != '\0') {
+ if (*p < '0' || *p > 'z')
+ *p = '_';
+ ++p;
+ }
fprintf(
ohfile,
"/*\n"
@@ -191,8 +204,8 @@ void process(const char *ifname, const char *ofname)
"#include <sys/types.h>\n"
"\n",
ifbasename, /* header */
- obasename, /* ifndef */
- obasename /* define */
+ hbasename, /* ifndef */
+ hbasename /* define */
);
/* print structure */
@@ -219,7 +232,7 @@ void process(const char *ifname, const char *ofname)
"#endif\n"
);
} /* createH */
-
+
/*****************************************************************/
/****** END OF H FILE *****/
/*****************************************************************/
More information about the vc
mailing list