| File src/builtin_functions.c changed (mode: 100644) (index c4b9a87e8..dc2737360) |
| ... |
... |
escape_builtin(const call_info_t *call_info) |
| 178 |
178 |
return var_error(); |
return var_error(); |
| 179 |
179 |
} |
} |
| 180 |
180 |
|
|
| 181 |
|
var_t result = var_from_str(escaped); |
|
| 182 |
|
free(escaped); |
|
| 183 |
|
|
|
| 184 |
|
return result; |
|
|
181 |
|
return var_out_of_str(escaped); |
| 185 |
182 |
} |
} |
| 186 |
183 |
|
|
| 187 |
184 |
/* Checks whether executable exists at absolute path or in directories listed in |
/* Checks whether executable exists at absolute path or in directories listed in |
| |
| ... |
... |
expand_builtin(const call_info_t *call_info) |
| 222 |
219 |
char *macro_expanded = ma_expand(env_expanded, NULL, NULL, MER_DISPLAY); |
char *macro_expanded = ma_expand(env_expanded, NULL, NULL, MER_DISPLAY); |
| 223 |
220 |
free(env_expanded); |
free(env_expanded); |
| 224 |
221 |
|
|
| 225 |
|
var_t result = var_from_str(macro_expanded); |
|
| 226 |
|
free(macro_expanded); |
|
| 227 |
|
|
|
| 228 |
|
return result; |
|
|
222 |
|
return var_out_of_str(macro_expanded); |
| 229 |
223 |
} |
} |
| 230 |
224 |
|
|
| 231 |
225 |
/* Returns cached value of an external command. Cache validity is bound to a |
/* Returns cached value of an external command. Cache validity is bound to a |
| |
| ... |
... |
type_of_link_target(const dir_entry_t *entry) |
| 412 |
406 |
static var_t |
static var_t |
| 413 |
407 |
fnameescape_builtin(const call_info_t *call_info) |
fnameescape_builtin(const call_info_t *call_info) |
| 414 |
408 |
{ |
{ |
| 415 |
|
var_t result; |
|
| 416 |
|
|
|
| 417 |
409 |
char *const str_val = var_to_str(call_info->argv[0]); |
char *const str_val = var_to_str(call_info->argv[0]); |
| 418 |
410 |
char *const escaped = posix_like_escape(str_val, /*type=*/1); |
char *const escaped = posix_like_escape(str_val, /*type=*/1); |
| 419 |
411 |
free(str_val); |
free(str_val); |
| 420 |
412 |
|
|
| 421 |
|
result = var_from_str(escaped); |
|
| 422 |
|
free(escaped); |
|
| 423 |
|
return result; |
|
|
413 |
|
return var_out_of_str(escaped); |
| 424 |
414 |
} |
} |
| 425 |
415 |
|
|
| 426 |
416 |
/* Retrieves type of current pane as a string. */ |
/* Retrieves type of current pane as a string. */ |
| |
| ... |
... |
input_builtin(const call_info_t *call_info) |
| 469 |
459 |
|
|
| 470 |
460 |
/* Not returning var_error() on cancellation to allow handling of it by the |
/* Not returning var_error() on cancellation to allow handling of it by the |
| 471 |
461 |
* user. */ |
* user. */ |
| 472 |
|
var_t result = var_from_str(cb_data.response == NULL ? "" : cb_data.response); |
|
| 473 |
|
|
|
| 474 |
|
free(cb_data.response); |
|
| 475 |
|
|
|
| 476 |
|
return result; |
|
|
462 |
|
return (cb_data.response == NULL) ? var_from_str("") |
|
463 |
|
: var_out_of_str(cb_data.response); |
| 477 |
464 |
|
|
| 478 |
465 |
fail: |
fail: |
| 479 |
466 |
free(prompt); |
free(prompt); |
| |
| ... |
... |
term_builtin(const call_info_t *call_info) |
| 667 |
654 |
static var_t |
static var_t |
| 668 |
655 |
execute_cmd(var_t cmd_arg, int interactive, int preserve_stdin) |
execute_cmd(var_t cmd_arg, int interactive, int preserve_stdin) |
| 669 |
656 |
{ |
{ |
| 670 |
|
var_t result; |
|
| 671 |
657 |
char *cmd; |
char *cmd; |
| 672 |
658 |
FILE *cmd_stream; |
FILE *cmd_stream; |
| 673 |
659 |
size_t cmd_out_len; |
size_t cmd_out_len; |
| |
| ... |
... |
execute_cmd(var_t cmd_arg, int interactive, int preserve_stdin) |
| 703 |
689 |
--cmd_out_len; |
--cmd_out_len; |
| 704 |
690 |
} |
} |
| 705 |
691 |
|
|
| 706 |
|
result = var_from_str(result_str); |
|
| 707 |
|
free(result_str); |
|
| 708 |
|
return result; |
|
|
692 |
|
return var_out_of_str(result_str); |
| 709 |
693 |
} |
} |
| 710 |
694 |
|
|
| 711 |
695 |
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ |
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ |
| File src/engine/var.c changed (mode: 100644) (index 423cb5e20..aa33ffd6e) |
| ... |
... |
var_from_str(const char str_val[]) |
| 60 |
60 |
return var_new(VTYPE_STRING, value); |
return var_new(VTYPE_STRING, value); |
| 61 |
61 |
} |
} |
| 62 |
62 |
|
|
|
63 |
|
var_t |
|
64 |
|
var_out_of_str(char str_val[]) |
|
65 |
|
{ |
|
66 |
|
/* Alternatively, could return var_error() in this case. */ |
|
67 |
|
assert(str_val != NULL && "Can't make a NULL string variable."); |
|
68 |
|
|
|
69 |
|
var_t new_var = { .type = VTYPE_STRING, { .string = str_val } }; |
|
70 |
|
return new_var; |
|
71 |
|
} |
|
72 |
|
|
| 63 |
73 |
var_t |
var_t |
| 64 |
74 |
var_error(void) |
var_error(void) |
| 65 |
75 |
{ |
{ |