parse_cmd now using file name strings rather than file struct
This commit is contained in:
@@ -81,26 +81,24 @@ char* smartstrcasestr(const char *haystack, const char *needle){
|
||||
}
|
||||
|
||||
|
||||
char* parse_cmd(const char *cmd, file *f){
|
||||
char* parse_cmd(const char *cmd, char *file_name){
|
||||
char *out;
|
||||
if (f == NULL) {
|
||||
out = malloc(strlen(cmd)+1);
|
||||
memcpy(out, cmd, strlen(cmd)+1);
|
||||
return out;
|
||||
if (file_name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
const char *offset = strstr(cmd, SETTINGS_COMMAND_REPLACE_STR);
|
||||
|
||||
int count = 0;
|
||||
char *pos;
|
||||
unsigned long i = 0;
|
||||
while(f->file_name[i]) {
|
||||
if (f->file_name[i] == '\'') {
|
||||
while(file_name[i]) {
|
||||
if (file_name[i] == '\'') {
|
||||
count++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
out = malloc(strlen(cmd) + 1 + (strlen(f->file_name)+(count*3)) + 3);
|
||||
out = malloc(strlen(cmd) + 1 + (strlen(file_name)+(count*3)) + 3);
|
||||
|
||||
pos = out;
|
||||
if (offset) {
|
||||
@@ -115,13 +113,13 @@ char* parse_cmd(const char *cmd, file *f){
|
||||
pos++;
|
||||
|
||||
i = 0;
|
||||
while(f->file_name[i]) {
|
||||
if (f->file_name[i] == '\'') {
|
||||
while(file_name[i]) {
|
||||
if (file_name[i] == '\'') {
|
||||
*pos++ = '\'';
|
||||
*pos++ = '\\';
|
||||
*pos++ = '\'';
|
||||
}
|
||||
*pos = f->file_name[i];
|
||||
*pos = file_name[i];
|
||||
pos++;
|
||||
i++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user