blob: 53198df26ddab5fde07b86699fcf4e8c3a9a7d6c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <libterm/terminal.h>
#include <knob/file.h>
#include "line.h"
#include "vars.h"
void source(const char *path) {
struct file *f = open_file(path);
if (!f) {
term_addf("Could not open %s.\n", path);
return;
}
char buf[128];
while (read_line_from_file(f, buf, 127))
run_line(buf);
close_file(f);
}
void set(const char *arg) {
const char *space = arg;
while (*space != ' ')
if (*space)
++space;
else {
struct no_null_sn vname = {
.data = arg,
.length = space - arg
};
del_var(vname);
return;
}
struct no_null_sn vname = {
.data = arg,
.length = space - arg
};
const char *vstart = space + 1,
*vend = vstart;
while (*vend)
++vend;
struct no_null_sn vval = {
.data = vstart,
.length = vend - vstart
};
set_var(vname, vval);
}
|