Changeset 88c93c31 in rtems for tools/build/rtems-bin2c.c


Ignore:
Timestamp:
Jul 30, 2010, 12:09:38 PM (10 years ago)
Author:
Ralf Corsepius <ralf.corsepius@…>
Branches:
4.11, master
Children:
b3ef1322
Parents:
e1b8e8e
Message:

2010-07-30 Ralf Corsépius <ralf.corsepius@…>

  • configure.ac: Check for libgen.h, basename.
  • rtems-bin2c.c: Use basename(3) instead of strrchr cascade. Introduce ifbasename. Use ifbasename in generated files.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/build/rtems-bin2c.c

    re1b8e8e r88c93c31  
    3030#include <stdlib.h>
    3131#include <string.h>
     32#include <libgen.h>
    3233
    3334#ifndef PATH_MAX
     
    112113 
    113114  /* find basename */
    114   if ((cp = strrchr(ifname, '/')) != NULL)
    115     ++cp;
    116   else {
    117     if ((cp = strrchr(ifname, '\\')) != NULL)
    118       ++cp;
    119     else
    120       cp = ifname;
    121   }
    122   strcpy(buf, cp);
     115  char *ifbasename = strdup(ifname);
     116  ifbasename = basename(ifbasename);
     117 
     118  strcpy(buf, ifbasename);
    123119  for (p = buf; *p != '\0'; ++p)
    124120    if (!isalnum(*p))
     
    137133    "#include <sys/types.h>\n"
    138134    "\n",
    139     ifname
     135    ifbasename
    140136  );
    141137
     
    191187    "#include <sys/types.h>\n"
    192188    "\n",
    193     obasename,  /* header */
     189    ifbasename,  /* header */
    194190    obasename,  /* ifndef */
    195191    obasename   /* define */
Note: See TracChangeset for help on using the changeset viewer.