LIBEDIT_OBJS = \
lib/buf.o \
lib/utf8.o \
- lib/utils.o \
lib/job.o \
lib/view.o \
lib/x11.o \
-/* Utility Functions
- *****************************************************************************/
-char* stringdup(const char* str);
-char* strmcat(char* first, ...);
-
/* Buffer management functions
*****************************************************************************/
/* undo/redo list item */
typedef uintptr_t uintptr;
typedef intptr_t intptr;
-/* Generic Death Function
- *****************************************************************************/
-void die(const char* msgfmt, ...) __attribute__((__noreturn__));
-
/* Option Parsing
*
* This following macros implement a simple POSIX-style option parsing strategy.
+++ /dev/null
-#define _XOPEN_SOURCE 700
-#include <stdc.h>
-#include <utf.h>
-#include <edit.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <time.h>
-#include <sys/time.h>
-
-void die(const char* msgfmt, ...) {
- va_list args;
- va_start(args, msgfmt);
- fprintf(stderr, "error: ");
- vfprintf(stderr, msgfmt, args);
- va_end(args);
- if (*msgfmt && msgfmt[strlen(msgfmt)-1] == ':')
- fprintf(stderr, " %s", strerror(errno));
- fprintf(stderr, "\n");
- exit(EXIT_FAILURE);
-}
-
-char* strmcat(char* first, ...) {
- va_list args;
- /* calculate the length of the final string */
- size_t len = strlen(first);
- va_start(args, first);
- for (char* s = NULL; (s = va_arg(args, char*));)
- len += strlen(s);
- va_end(args);
- /* allocate the final string and copy the args into it */
- char *str = malloc(len+1), *curr = str;
- while (first && *first) *(curr++) = *(first++);
- va_start(args, first);
- for (char* s = NULL; (s = va_arg(args, char*));)
- while (s && *s) *(curr++) = *(s++);
- va_end(args);
- /* null terminate and return */
- *curr = '\0';
- return str;
-}
#undef Region
/******************************************************************************/
+static void die(const char* msg);
static uint32_t special_keys(uint32_t key);
static uint32_t getkey(XEvent* e);
die("Could not init fontconfig.\n");
FcPattern* pattern = FcNameParse((FcChar8 *)name);
if (!pattern)
- die("can't open font %s\n", name);
+ die("could not parse font name\n");
/* load the base font */
FcResult result;
FcPattern* match = XftFontMatch(X.display, X.screen, pattern, &result);
if (!match || !(font->base.match = XftFontOpenPattern(X.display, match)))
- die("could not load default font: %s", name);
+ die("could not load base font");
/* get base font extents */
XGlyphInfo extents;
eol = false, rlen -= numspecs;
}
}
+
+static void die(const char* msg) {
+ perror(msg);
+ exit(EXIT_FAILURE);
+}
job_start(execcmd, input, len, (op != '<' ? curr : edit));
}
+static char* strmcat(char* first, ...) {
+ va_list args;
+ /* calculate the length of the final string */
+ size_t len = strlen(first);
+ va_start(args, first);
+ for (char* s = NULL; (s = va_arg(args, char*));)
+ len += strlen(s);
+ va_end(args);
+ /* allocate the final string and copy the args into it */
+ char *str = malloc(len+1), *curr = str;
+ while (first && *first) *(curr++) = *(first++);
+ va_start(args, first);
+ for (char* s = NULL; (s = va_arg(args, char*));)
+ while (s && *s) *(curr++) = *(s++);
+ va_end(args);
+ /* null terminate and return */
+ *curr = '\0';
+ return str;
+}
+
static void cmd_execwitharg(char* cmd, char* arg) {
cmd = (arg ? strmcat(cmd, " '", arg, "'", 0) : strmcat(cmd));
cmd_exec(cmd);