Browse Source

Use const char *argv[] signatures

C is really weird about this stuff, but this makes more sense to me.
June 1 month ago
parent
commit
36ec6cf258
Signed by: Curtis McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
4 changed files with 9 additions and 10 deletions
  1. 2
    2
      chat.h
  2. 4
    4
      event.c
  3. 1
    2
      input.c
  4. 2
    2
      url.c

+ 2
- 2
chat.h View File

@@ -40,8 +40,8 @@ void selfNick(const char *nick);
40 40
 void selfUser(const char *user);
41 41
 void selfJoin(const char *join);
42 42
 
43
-void eventWait(char *const argv[]);
44
-void eventPipe(char *const argv[]);
43
+void eventWait(const char *argv[static 2]);
44
+void eventPipe(const char *argv[static 2]);
45 45
 void eventLoop(int ui, int irc);
46 46
 
47 47
 struct Tag {

+ 4
- 4
event.c View File

@@ -33,18 +33,18 @@ static struct {
33 33
 	int fd;
34 34
 } spawn;
35 35
 
36
-void eventWait(char *const argv[]) {
36
+void eventWait(const char *argv[static 2]) {
37 37
 	uiHide();
38 38
 	pid_t pid = fork();
39 39
 	if (pid < 0) err(EX_OSERR, "fork");
40 40
 	if (!pid) {
41
-		execvp(argv[0], argv);
41
+		execvp(argv[0], (char *const *)argv);
42 42
 		err(EX_CONFIG, "%s", argv[0]);
43 43
 	}
44 44
 	spawn.wait = true;
45 45
 }
46 46
 
47
-void eventPipe(char *const argv[]) {
47
+void eventPipe(const char *argv[static 2]) {
48 48
 	if (spawn.pipe) {
49 49
 		uiLog(TagStatus, UIHot, L"event: existing pipe");
50 50
 		return;
@@ -62,7 +62,7 @@ void eventPipe(char *const argv[]) {
62 62
 		dup2(rw[1], STDOUT_FILENO);
63 63
 		dup2(rw[1], STDERR_FILENO);
64 64
 		close(rw[1]);
65
-		execvp(argv[0], argv);
65
+		execvp(argv[0], (char *const *)argv);
66 66
 		perror(argv[0]);
67 67
 		exit(EX_CONFIG);
68 68
 	}

+ 1
- 2
input.c View File

@@ -144,8 +144,7 @@ static void inputClose(struct Tag tag, char *params) {
144 144
 static void inputMan(struct Tag tag, char *params) {
145 145
 	(void)tag;
146 146
 	(void)params;
147
-	char *argv[] = { "man", "1", "chatte", NULL };
148
-	eventWait(argv);
147
+	eventWait((const char *[]) { "man", "1", "chatte", NULL });
149 148
 }
150 149
 
151 150
 static const struct {

+ 2
- 2
url.c View File

@@ -91,14 +91,14 @@ void urlOpenMatch(struct Tag tag, const char *substr) {
91 91
 		struct Entry entry = ringEntry(i);
92 92
 		if (!entry.url || entry.tag != tag.id) continue;
93 93
 		if (!strstr(entry.url, substr)) continue;
94
-		eventPipe((char *[]) { "open", entry.url, NULL });
94
+		eventPipe((const char *[]) { "open", entry.url, NULL });
95 95
 		break;
96 96
 	}
97 97
 }
98 98
 
99 99
 void urlOpenRange(struct Tag tag, size_t at, size_t to) {
100 100
 	size_t argc = 1;
101
-	char *argv[2 + RingLen] = { "open" };
101
+	const char *argv[2 + RingLen] = { "open" };
102 102
 	size_t tagIndex = 0;
103 103
 	for (size_t i = RingLen - 1; i < RingLen; --i) {
104 104
 		struct Entry entry = ringEntry(i);

Loading…
Cancel
Save