openbsd-ports/x11/i3/patches/patch-i3-config-wizard_main_c
2011-12-01 16:00:01 +00:00

55 lines
1.2 KiB
Plaintext

$OpenBSD: patch-i3-config-wizard_main_c,v 1.2 2011/12/01 16:00:01 dcoppa Exp $
getline() is a GNU extension
--- i3-config-wizard/main.c.orig Fri Nov 11 23:41:20 2011
+++ i3-config-wizard/main.c Wed Nov 30 15:44:09 2011
@@ -296,6 +296,47 @@ static void finish() {
fputs("# this file and re-run i3-config-wizard(1).\n", ks_config);
fputs("#\n", ks_config);
+#if defined(__OpenBSD__)
+
+ssize_t
+getline(char ** __restrict buf, size_t * __restrict buflen,
+ FILE * __restrict fp)
+{
+ size_t bytes, newlen;
+ char *newbuf, *p;
+
+ if (buf == NULL || buflen == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (*buf == NULL)
+ *buflen = 0;
+
+ bytes = 0;
+ do {
+ if (feof(fp))
+ break;
+ if (*buf == NULL || bytes != 0) {
+ newlen = *buflen + BUFSIZ;
+ newbuf = realloc(*buf, newlen);
+ if (newbuf == NULL)
+ return -1;
+ *buf = newbuf;
+ *buflen = newlen;
+ }
+ p = *buf + bytes;
+ memset(p, 0, BUFSIZ);
+ if (fgets(p, BUFSIZ, fp) == NULL)
+ break;
+ bytes += strlen(p);
+ } while (bytes == 0 || *(*buf + (bytes - 1)) != '\n');
+ if (bytes == 0)
+ return -1;
+ return bytes;
+}
+
+#endif
+
#if defined(__APPLE__)
while ((line = fgetln(kc_config, &len)) != NULL) {
#else