aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar taiyu <taiyu.len@gmail.com>2015-09-18 07:23:04 -0700
committerLibravatar taiyu <taiyu.len@gmail.com>2015-09-18 07:23:04 -0700
commit0d51f62224a3c2e65894f1725076a588b172447c (patch)
tree35529e2a7888e4d3af0997371efd1da5bbf2ad15 /sway
parentminor fix (diff)
parentFix warnings introduced by prior commit (diff)
downloadsway-0d51f62224a3c2e65894f1725076a588b172447c.tar.gz
sway-0d51f62224a3c2e65894f1725076a588b172447c.tar.zst
sway-0d51f62224a3c2e65894f1725076a588b172447c.zip
merge + no c_extensions
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c4
-rw-r--r--sway/container.c2
-rw-r--r--sway/log.c4
-rw-r--r--sway/main.c2
-rw-r--r--sway/stringop.c29
-rw-r--r--sway/workspace.c1
6 files changed, 30 insertions, 12 deletions
diff --git a/sway/commands.c b/sway/commands.c
index f2ee0184..80770e87 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -5,8 +5,10 @@
5#include <stdlib.h> 5#include <stdlib.h>
6#include <errno.h> 6#include <errno.h>
7#include <string.h> 7#include <string.h>
8#include <strings.h>
8#include <unistd.h> 9#include <unistd.h>
9#include <ctype.h> 10#include <ctype.h>
11#include <sys/types.h>
10#include "stringop.h" 12#include "stringop.h"
11#include "layout.h" 13#include "layout.h"
12#include "focus.h" 14#include "focus.h"
@@ -193,7 +195,7 @@ static enum cmd_status cmd_exec_always(int argc, char **argv) {
193 sway_log(L_DEBUG, "Executing %s", cmd); 195 sway_log(L_DEBUG, "Executing %s", cmd);
194 196
195 pid_t pid; 197 pid_t pid;
196 if ((pid = vfork()) == 0) { 198 if ((pid = fork()) == 0) {
197 execv("/bin/sh", args); 199 execv("/bin/sh", args);
198 _exit(-1); 200 _exit(-1);
199 } else if (pid < 0) { 201 } else if (pid < 0) {
diff --git a/sway/container.c b/sway/container.c
index d6bcc4c2..4c523827 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -1,7 +1,9 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdbool.h> 2#include <stdbool.h>
3#include <strings.h> 3#include <strings.h>
4#include <string.h>
4#include "config.h" 5#include "config.h"
6#include "stringop.h"
5#include "container.h" 7#include "container.h"
6#include "workspace.h" 8#include "workspace.h"
7#include "focus.h" 9#include "focus.h"
diff --git a/sway/log.c b/sway/log.c
index 3859fd92..a206d971 100644
--- a/sway/log.c
+++ b/sway/log.c
@@ -80,9 +80,7 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) {
80 va_end(args); 80 va_end(args);
81 81
82 fprintf(stderr, ": "); 82 fprintf(stderr, ": ");
83 char error[256]; 83 fprintf(stderr, "%s", strerror(errno));
84 strerror_r(errno, error, sizeof(error));
85 fprintf(stderr, "%s", error);
86 84
87 if (colored && isatty(STDERR_FILENO)) { 85 if (colored && isatty(STDERR_FILENO)) {
88 fprintf(stderr, "\x1B[0m"); 86 fprintf(stderr, "\x1B[0m");
diff --git a/sway/main.c b/sway/main.c
index e03588ea..66921184 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -3,9 +3,11 @@
3#include <stdbool.h> 3#include <stdbool.h>
4#include <wlc/wlc.h> 4#include <wlc/wlc.h>
5#include <sys/wait.h> 5#include <sys/wait.h>
6#include <sys/types.h>
6#include <signal.h> 7#include <signal.h>
7#include <getopt.h> 8#include <getopt.h>
8#include "layout.h" 9#include "layout.h"
10#include "stringop.h"
9#include "config.h" 11#include "config.h"
10#include "log.h" 12#include "log.h"
11#include "readline.h" 13#include "readline.h"
diff --git a/sway/stringop.c b/sway/stringop.c
index 90f963d6..31a036c3 100644
--- a/sway/stringop.c
+++ b/sway/stringop.c
@@ -1,5 +1,6 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3#include <string.h>
3#include <strings.h> 4#include <strings.h>
4#include <ctype.h> 5#include <ctype.h>
5#include "stringop.h" 6#include "stringop.h"
@@ -7,7 +8,7 @@
7#include "string.h" 8#include "string.h"
8#include "list.h" 9#include "list.h"
9 10
10const char *whitespace = " \f\n\r\t\v"; 11const char whitespace[] = " \f\n\r\t\v";
11 12
12/* Note: This returns 8 characters for trimmed_start per tab character. */ 13/* Note: This returns 8 characters for trimmed_start per tab character. */
13char *strip_whitespace(char *_str) { 14char *strip_whitespace(char *_str) {
@@ -313,13 +314,16 @@ char *join_list(list_t *list, char *separator) {
313} 314}
314 315
315char *cmdsep(char **stringp, const char *delim) { 316char *cmdsep(char **stringp, const char *delim) {
316 char *head = strsep(stringp, delim); 317 // skip over leading delims
317 // But skip over trailing delims. '3 tokens here' -> '3' 'tokens here' 318 char *head = *stringp + strspn(*stringp, delim);
318 if (*stringp) { 319 // Find end token
319 *stringp += strspn(*stringp, delim); 320 char *tail = *stringp += strcspn(*stringp, delim);
320 // If skiping over delims brings us to the end of string, set to NULL 321 // Set stringp to begining of next token
321 if (!**stringp) *stringp = NULL; 322 *stringp += strspn(*stringp, delim);
322 } 323 // Set stringp to null if last token
324 if (!**stringp) *stringp = NULL;
325 // Nullify end of first token
326 *tail = 0;
323 return head; 327 return head;
324} 328}
325 329
@@ -358,3 +362,12 @@ char *argsep(char **stringp, const char *delim) {
358 found: 362 found:
359 return start; 363 return start;
360} 364}
365
366char *strdup(const char *str) {
367 char *dup = malloc(strlen(str) + 1);
368 if (dup) {
369 strcpy(dup, str);
370 }
371 return dup;
372}
373
diff --git a/sway/workspace.c b/sway/workspace.c
index 658f79bc..c169c1cb 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -2,6 +2,7 @@
2#include <stdbool.h> 2#include <stdbool.h>
3#include <wlc/wlc.h> 3#include <wlc/wlc.h>
4#include <string.h> 4#include <string.h>
5#include <strings.h>
5#include "workspace.h" 6#include "workspace.h"
6#include "layout.h" 7#include "layout.h"
7#include "list.h" 8#include "list.h"