summaryrefslogtreecommitdiffstats
path: root/math
diff options
context:
space:
mode:
authormarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2010-01-13 13:40:58 +0800
committermarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2010-01-13 13:40:58 +0800
commit02875dc51fe3be940ae0d8d61dc264731ee12a76 (patch)
tree13aa2c8fbbd385949da9d8c94d8306984fffa590 /math
parent5b5917dab23edb1a27546c878b903a4a5a35ca44 (diff)
downloadmarcuscom-ports-02875dc51fe3be940ae0d8d61dc264731ee12a76.tar
marcuscom-ports-02875dc51fe3be940ae0d8d61dc264731ee12a76.tar.gz
marcuscom-ports-02875dc51fe3be940ae0d8d61dc264731ee12a76.tar.bz2
marcuscom-ports-02875dc51fe3be940ae0d8d61dc264731ee12a76.tar.lz
marcuscom-ports-02875dc51fe3be940ae0d8d61dc264731ee12a76.tar.xz
marcuscom-ports-02875dc51fe3be940ae0d8d61dc264731ee12a76.tar.zst
marcuscom-ports-02875dc51fe3be940ae0d8d61dc264731ee12a76.zip
Add a static getline implementation for FreeBSD < 8.0.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@13447 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'math')
-rw-r--r--math/gcalctool/files/patch-src_gcalccmd.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/math/gcalctool/files/patch-src_gcalccmd.c b/math/gcalctool/files/patch-src_gcalccmd.c
new file mode 100644
index 000000000..7a3c1a7a7
--- /dev/null
+++ b/math/gcalctool/files/patch-src_gcalccmd.c
@@ -0,0 +1,87 @@
+--- src/gcalccmd.c.orig 2010-01-13 00:30:10.000000000 -0500
++++ src/gcalccmd.c 2010-01-13 00:39:51.000000000 -0500
+@@ -22,12 +22,84 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <sys/types.h>
++#include <sys/param.h>
+ #include <time.h>
+
+ #include "mp-equation.h"
+
+ #define MAXLINE 1024
+
++#if __FreeBSD_version < 800067
++static ssize_t
++getline (char **lineptr, size_t *n, FILE *stream)
++{
++ char *line, *p;
++ long size, copy;
++
++ if (lineptr == NULL || n == NULL) {
++ errno = EINVAL;
++ return (ssize_t) -1;
++ }
++
++ if (ferror (stream))
++ return (ssize_t) -1;
++
++ /* Make sure we have a line buffer to start with. */
++ if (*lineptr == NULL || *n < 2) /* !seen and no buf yet need 2 chars. */ {
++#ifndef MAX_CANON
++#define MAX_CANON 256
++#endif
++ if (!*lineptr)
++ line = (char *) malloc (MAX_CANON);
++ else
++ line = (char *) realloc (*lineptr, MAX_CANON);
++ if (line == NULL)
++ return (ssize_t) -1;
++ *lineptr = line;
++ *n = MAX_CANNON;
++ }
++
++ line = *lineptr;
++ size = *n;
++
++ copy = size;
++ p = line;
++
++ while (1) {
++ long len;
++
++ while (--copy > 0) {
++ int c = getc (stream);
++
++ if (c == EOF)
++ goto lose;
++ else if ((*p++ = c) == '\n')
++ goto win;
++ }
++
++ /* Need to enlarge the line buffer. */
++ len = p - line;
++ size *= 2;
++ line = (char *) realloc (line, size);
++ if (line == NULL)
++ goto lose;
++ *lineptr = line;
++ *n = size;
++ p = line + len;
++ copy = size - len;
++ }
++
++lose:
++ if (p == *lineptr)
++ return (ssize_t) -1;
++
++ /* Return a partial line since we got an error in the middle. */
++win:
++ *p = '\0';
++ return p - *lineptr;
++}
++#endif
++
+ static void
+ solve(const char *equation)
+ {