summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2014-09-05 13:29:45 +1000
committerChris Johns <chrisj@rtems.org>2014-09-05 13:29:45 +1000
commit960c9f02986308779ae431aca648f7482a3a57d2 (patch)
treed0d1842b566b6087eae1ca60eff1cc29d47bb4c2
parentRegenerate preinstall.am for score/cpu/or1k (diff)
downloadrtems-960c9f02986308779ae431aca648f7482a3a57d2.tar.bz2
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.
-rw-r--r--tools/build/rtems-bin2c.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/tools/build/rtems-bin2c.c b/tools/build/rtems-bin2c.c
index 4e6796aa38..710c97e702 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 *****/
/*****************************************************************/