forked from Imagelibrary/rtems
2010-07-30 Ralf Corsépius <ralf.corsepius@rtems.org>
* configure.ac: Check for libgen.h, basename. * rtems-bin2c.c: Use basename(3) instead of strrchr cascade. Introduce ifbasename. Use ifbasename in generated files.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2010-07-30 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* configure.ac: Check for libgen.h, basename.
|
||||
* rtems-bin2c.c: Use basename(3) instead of strrchr cascade.
|
||||
Introduce ifbasename. Use ifbasename in generated files.
|
||||
|
||||
2010-07-29 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* rtems-bin2c.c: Add -C and -H options.
|
||||
|
||||
@@ -13,8 +13,8 @@ AM_INIT_AUTOMAKE([no-define foreign 1.10])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_CC
|
||||
AC_CHECK_HEADERS([getopt.h])
|
||||
AC_CHECK_FUNCS(strerror strtol)
|
||||
AC_CHECK_HEADERS([getopt.h libgen.h])
|
||||
AC_CHECK_FUNCS(strerror strtol basename)
|
||||
|
||||
RTEMS_PATH_KSH
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
@@ -111,15 +112,10 @@ void process(const char *ifname, const char *ofname)
|
||||
}
|
||||
|
||||
/* find basename */
|
||||
if ((cp = strrchr(ifname, '/')) != NULL)
|
||||
++cp;
|
||||
else {
|
||||
if ((cp = strrchr(ifname, '\\')) != NULL)
|
||||
++cp;
|
||||
else
|
||||
cp = ifname;
|
||||
}
|
||||
strcpy(buf, cp);
|
||||
char *ifbasename = strdup(ifname);
|
||||
ifbasename = basename(ifbasename);
|
||||
|
||||
strcpy(buf, ifbasename);
|
||||
for (p = buf; *p != '\0'; ++p)
|
||||
if (!isalnum(*p))
|
||||
*p = '_';
|
||||
@@ -136,7 +132,7 @@ void process(const char *ifname, const char *ofname)
|
||||
"\n"
|
||||
"#include <sys/types.h>\n"
|
||||
"\n",
|
||||
ifname
|
||||
ifbasename
|
||||
);
|
||||
|
||||
/* print structure */
|
||||
@@ -190,7 +186,7 @@ void process(const char *ifname, const char *ofname)
|
||||
"\n"
|
||||
"#include <sys/types.h>\n"
|
||||
"\n",
|
||||
obasename, /* header */
|
||||
ifbasename, /* header */
|
||||
obasename, /* ifndef */
|
||||
obasename /* define */
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user