commands.cc
/*
** expand_percent - expand any percent signs in cmd to file.  The result is
**                  stored in volatile storage.
*/
expand any percent signs in cmd to file.  The result is
stored in volatile storage.
expand any percent signs in cmd to file . The result is stored in volatile storage .
static const char *expand_percent(const char *cmd, const char *file)
{
    static char *expanded_cmd;
    DELETE expanded_cmd;
    if (!strchr(cmd, '%')) return cmd;
    expanded_cmd  = new char[strlen(cmd) + 1];
    (void)strcpy(expanded_cmd, cmd);
    char *pos = strchr(expanded_cmd, '%');
    while (pos)
    {
        char *full_cmd = new char[strlen(expanded_cmd) + strlen(file)];
        (void)strncpy(full_cmd, expanded_cmd, pos - expanded_cmd);
        full_cmd[pos - expanded_cmd] = '\0';
        (void)strcat(full_cmd, file);
        (void)strcat(full_cmd, pos + 1);
        DELETE expanded_cmd;
        expanded_cmd = full_cmd;
        pos = strchr(expanded_cmd, '%');
    }
    return expanded_cmd;
}
static const char * expand_percent ( const char * cmd , const char * file ) { static char * expanded_cmd ; DELETE expanded_cmd ; if ( ! strchr ( cmd , ' ' ) ) return cmd ; expanded_cmd = new char [ strlen ( cmd ) + 1 ] ; ( void ) strcpy ( expanded_cmd , cmd ) ; char * pos = strchr ( expanded_cmd , ' ' ) ; while ( pos ) { char * full_cmd = new char [ strlen ( expanded_cmd ) + strlen ( file ) ] ; ( void ) strncpy ( full_cmd , expanded_cmd , pos - expanded_cmd ) ; full_cmd [ pos - expanded_cmd ] = ' \0 ' ; ( void ) strcat ( full_cmd , file ) ; ( void ) strcat ( full_cmd , pos + 1 ) ; DELETE expanded_cmd ; expanded_cmd = full_cmd ; pos = strchr ( expanded_cmd , ' ' ) ; } return expanded_cmd ; }
expand_percent - expand any percent signs in cmd to file.
expand_percent - expand any percent signs in cmd to file .