Changeset 83b8f1f in rtems-tools


Ignore:
Timestamp:
Dec 2, 2019, 5:43:12 AM (8 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
429b747
Parents:
c02459e
git-author:
Sebastian Huber <sebastian.huber@…> (12/02/19 05:43:12)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/02/19 05:44:40)
Message:

bin2c: Improve file name sanitation

Only use alpha-numeric characters for header guards.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • misc/bin2c/rtems-bin2c.c

    rc02459e r83b8f1f  
    4343int createH = 1;
    4444
     45static void sanitize_file_name(char *p)
     46{
     47  while (*p != '\0') {
     48    if (!isalnum((unsigned char)*p)) /* cast to avoid negative indexing */
     49      *p = '_';
     50    ++p;
     51  }
     52}
     53
    4554int myfgetc(FILE *f)
    4655{
     
    5665{
    5766  FILE *ifile, *ocfile, *ohfile;
    58   char buf[PATH_MAX+1], *p;
     67  char buf[PATH_MAX+1];
    5968  char obasename[PATH_MAX+1];
    6069  char ocname[PATH_MAX+5];
     
    133142
    134143  strcpy(buf, ifbasename);
    135   for (p = buf; *p != '\0'; ++p) {
    136     if (!isalnum((unsigned char)*p)) /* cast to avoid negative indexing */
    137       *p = '_';
    138   }
     144  sanitize_file_name(buf);
    139145
    140146  if ( createC ) {
     
    192198    /* print H file header */
    193199    char hbasename[PATH_MAX];
    194     char* p;
    195200    /* Clean up the file name if it is an abs path */
    196201    strcpy(
     
    198203      obasename
    199204    );
    200     p = hbasename;
    201     while (*p != '\0') {
    202       if (*p < '0' || *p > 'z')
    203         *p = '_';
    204       ++p;
    205     }
     205    sanitize_file_name(hbasename);
    206206    fprintf(
    207207      ohfile,
Note: See TracChangeset for help on using the changeset viewer.