summarylogtreecommitdiffstats
path: root/getdelim.patch
diff options
context:
space:
mode:
authorBenoit Favre2015-06-26 07:57:32 +0200
committerBenoit Favre2015-06-26 07:57:32 +0200
commit0d80284fa082cc0f32ac15dade00fd301747543a (patch)
treed8556efdb090c48f36226e5750b87130c240a98a /getdelim.patch
downloadaur-mingw-w64-gfsm.tar.gz
Initial import
Diffstat (limited to 'getdelim.patch')
-rw-r--r--getdelim.patch80
1 files changed, 80 insertions, 0 deletions
diff --git a/getdelim.patch b/getdelim.patch
new file mode 100644
index 000000000000..c3f023f7b448
--- /dev/null
+++ b/getdelim.patch
@@ -0,0 +1,80 @@
+diff -rupN old/src/libgfsm/getdelim.c new/src/libgfsm/getdelim.c
+--- old/src/libgfsm/getdelim.c 1970-01-01 01:00:00.000000000 +0100
++++ new/src/libgfsm/getdelim.c 2015-03-01 21:23:17.381413359 +0100
+@@ -0,0 +1,54 @@
++/* Copyright (c) 2009-2013, Kevin Lawler <k.concerns@gmail.com>
++
++Permission to use, copy, modify, and/or distribute this software for any
++purpose with or without fee is hereby granted, provided that the above
++copyright notice and this permission notice appear in all copies.
++
++THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++
++This file is borrowed from https://github.com/asalac/kona-mingw
++*/
++
++#define _GNU_SOURCE
++#include <stdlib.h>
++#include <stdio.h>
++#include <sys/types.h>
++#include <errno.h>
++
++
++signed int getdelim(char **lineptr, size_t *n, int delim, FILE *stream) {
++ size_t i;
++ if (!lineptr || !n) {
++ errno=EINVAL;
++ return -1;
++ }
++ if (!*lineptr) *n=0;
++ for (i=0; ; ) {
++ int x;
++ if (i>=*n) {
++ int tmp=*n+100;
++ char* new=realloc(*lineptr,tmp);
++ if (!new) return -1;
++ *lineptr=new; *n=tmp;
++ }
++ x=fgetc(stream);
++ if (x==EOF) { if (!i) return -1; (*lineptr)[i]=0; return i; }
++ (*lineptr)[i]=x;
++ ++i;
++ if (x==delim || i>=*n) break;
++ }
++ (*lineptr)[i]=0;
++ return i;
++}
++
++signed int getline(char **lineptr, size_t *n, FILE *stream) {
++ return getdelim(lineptr,n,'\n',stream);
++}
++
++
+diff -rupN old/src/libgfsm/Makefile.am new/src/libgfsm/Makefile.am
+--- old/src/libgfsm/Makefile.am 2014-08-22 11:17:56.000000000 +0200
++++ new/src/libgfsm/Makefile.am 2015-03-01 21:18:26.890095396 +0100
+@@ -92,7 +92,8 @@ libgfsm_la_SOURCES = \
+ gfsmRegex.tab.y \
+ gfsmRegexCompiler.c \
+ gfsmIndexed.c \
+- gfsmIndexedIO.c
++ gfsmIndexedIO.c \
++ getdelim.c
+
+ sources_argh = \
+ gfsmIndexed.c \
+@@ -210,7 +211,7 @@ gfsmRegexCompiler.o: gfsmRegexCompiler.c
+ AM_CPPFLAGS = -I. -I$(SRCDIR)/gnulib
+
+ ## --- compiler flags (cc)
+-AM_CFLAGS = $(gfsm_WFLAGS) $(gfsm_OFLAGS)
++AM_CFLAGS = $(gfsm_WFLAGS) $(gfsm_OFLAGS) -D_GNU_SOURCE
+
+ ##-----------------------------------------------------------------------
+ ## Additional variable: library versioning