diff options
author | Thomas White <taw@physics.org> | 2021-04-01 12:18:22 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-04-01 15:08:14 +0200 |
commit | 211535aa1d46b4f1ec1a5976be60a4c135605b90 (patch) | |
tree | 2dad13e276db43b9c6edbbfa2a34b4d129cd3aa1 /src/gui_index.c | |
parent | c5f62f02be9fd29eb3f8f7831ac98617752ea789 (diff) |
GUI: Wrap filenames in job scripts in quotes, where appropriate
This makes it work when the filenames contain spaces.
Diffstat (limited to 'src/gui_index.c')
-rw-r--r-- | src/gui_index.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/gui_index.c b/src/gui_index.c index 6ce406e3..ba9302a3 100644 --- a/src/gui_index.c +++ b/src/gui_index.c @@ -641,9 +641,31 @@ gint index_one_sig(GtkWidget *widget, struct crystfelproject *proj) } +static int contains_spaces(const char *str) +{ + int i; + size_t len; + len = strlen(str); + for ( i=0; i<len; i++ ) { + if ( str[i] == ' ' ) return 1; + } + return 0; +} + + static void add_arg(char **args, int pos, const char *label) { - args[pos] = strdup(label); + if ( contains_spaces(label) ) { + size_t len = strlen(label)+3; + args[pos] = malloc(len); + args[pos][0] = '"'; + args[pos][1] = '\0'; + strcat(args[pos], label); + args[pos][len-2] = '"'; + args[pos][len-1] = '\0'; + } else { + args[pos] = strdup(label); + } } |