mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
merge + no c_extensions
This commit is contained in:
commit
0d51f62224
|
@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8.5)
|
||||||
project(sway C)
|
project(sway C)
|
||||||
set(CMAKE_C_FLAGS "-g")
|
set(CMAKE_C_FLAGS "-g")
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
SET(CMAKE_C_EXTENSIONS OFF)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/")
|
||||||
add_definitions("-Wall -Wextra -Wno-unused-parameter")
|
add_definitions("-Wall -Wextra -Wno-unused-parameter")
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake)
|
||||||
|
|
|
@ -2,8 +2,13 @@
|
||||||
#define _SWAY_STRINGOP_H
|
#define _SWAY_STRINGOP_H
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
|
#if !HAVE_DECL_SETENV
|
||||||
|
// Not sure why we need to provide this
|
||||||
|
extern int setenv(const char *, const char *, int);
|
||||||
|
#endif
|
||||||
|
|
||||||
// array of whitespace characters to use for delims
|
// array of whitespace characters to use for delims
|
||||||
extern const char *whitespace;
|
extern const char whitespace[];
|
||||||
|
|
||||||
char *strip_whitespace(char *str);
|
char *strip_whitespace(char *str);
|
||||||
char *strip_comments(char *str);
|
char *strip_comments(char *str);
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
|
@ -193,7 +195,7 @@ static enum cmd_status cmd_exec_always(int argc, char **argv) {
|
||||||
sway_log(L_DEBUG, "Executing %s", cmd);
|
sway_log(L_DEBUG, "Executing %s", cmd);
|
||||||
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
if ((pid = vfork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
execv("/bin/sh", args);
|
execv("/bin/sh", args);
|
||||||
_exit(-1);
|
_exit(-1);
|
||||||
} else if (pid < 0) {
|
} else if (pid < 0) {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#include <string.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "stringop.h"
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
|
|
|
@ -80,9 +80,7 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) {
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
fprintf(stderr, ": ");
|
fprintf(stderr, ": ");
|
||||||
char error[256];
|
fprintf(stderr, "%s", strerror(errno));
|
||||||
strerror_r(errno, error, sizeof(error));
|
|
||||||
fprintf(stderr, "%s", error);
|
|
||||||
|
|
||||||
if (colored && isatty(STDERR_FILENO)) {
|
if (colored && isatty(STDERR_FILENO)) {
|
||||||
fprintf(stderr, "\x1B[0m");
|
fprintf(stderr, "\x1B[0m");
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <wlc/wlc.h>
|
#include <wlc/wlc.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
#include "stringop.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "readline.h"
|
#include "readline.h"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
@ -7,7 +8,7 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
const char *whitespace = " \f\n\r\t\v";
|
const char whitespace[] = " \f\n\r\t\v";
|
||||||
|
|
||||||
/* Note: This returns 8 characters for trimmed_start per tab character. */
|
/* Note: This returns 8 characters for trimmed_start per tab character. */
|
||||||
char *strip_whitespace(char *_str) {
|
char *strip_whitespace(char *_str) {
|
||||||
|
@ -313,13 +314,16 @@ char *join_list(list_t *list, char *separator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *cmdsep(char **stringp, const char *delim) {
|
char *cmdsep(char **stringp, const char *delim) {
|
||||||
char *head = strsep(stringp, delim);
|
// skip over leading delims
|
||||||
// But skip over trailing delims. '3 tokens here' -> '3' 'tokens here'
|
char *head = *stringp + strspn(*stringp, delim);
|
||||||
if (*stringp) {
|
// Find end token
|
||||||
*stringp += strspn(*stringp, delim);
|
char *tail = *stringp += strcspn(*stringp, delim);
|
||||||
// If skiping over delims brings us to the end of string, set to NULL
|
// Set stringp to begining of next token
|
||||||
if (!**stringp) *stringp = NULL;
|
*stringp += strspn(*stringp, delim);
|
||||||
}
|
// Set stringp to null if last token
|
||||||
|
if (!**stringp) *stringp = NULL;
|
||||||
|
// Nullify end of first token
|
||||||
|
*tail = 0;
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,3 +362,12 @@ char *argsep(char **stringp, const char *delim) {
|
||||||
found:
|
found:
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *strdup(const char *str) {
|
||||||
|
char *dup = malloc(strlen(str) + 1);
|
||||||
|
if (dup) {
|
||||||
|
strcpy(dup, str);
|
||||||
|
}
|
||||||
|
return dup;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <wlc/wlc.h>
|
#include <wlc/wlc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
Loading…
Reference in a new issue