diff options
author | Joe Marcus Clarke <marcus@FreeBSD.org> | 2003-06-03 19:30:00 +0000 |
---|---|---|
committer | Joe Marcus Clarke <marcus@FreeBSD.org> | 2003-06-03 19:30:00 +0000 |
commit | c639d1ee55c27543e99f8b99a76b9a3428ae11b4 (patch) | |
tree | 2b3a66586b31420fe78ba6eb4ab6a1c357391d91 /devel/anjuta-devel | |
parent | New port portaudio version 18: Portable cross-platform Audio API (diff) |
Fix the getline() function so anjuta properly detects glade2, and removes some
memory leaks and corruption.
Submitted by: Alexander Nedotsukov <bland@mail.ru>
Notes
Notes:
svn path=/head/; revision=82208
Diffstat (limited to 'devel/anjuta-devel')
-rw-r--r-- | devel/anjuta-devel/Makefile | 1 | ||||
-rw-r--r-- | devel/anjuta-devel/files/patch-src_getline.c | 80 |
2 files changed, 81 insertions, 0 deletions
diff --git a/devel/anjuta-devel/Makefile b/devel/anjuta-devel/Makefile index 329f04142c03..137360cd6e9b 100644 --- a/devel/anjuta-devel/Makefile +++ b/devel/anjuta-devel/Makefile @@ -7,6 +7,7 @@ PORTNAME= anjuta PORTVERSION= 1.1.1 +PORTREVISION= 1 CATEGORIES= devel gnome MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= anjuta diff --git a/devel/anjuta-devel/files/patch-src_getline.c b/devel/anjuta-devel/files/patch-src_getline.c new file mode 100644 index 000000000000..847ab8d9e82e --- /dev/null +++ b/devel/anjuta-devel/files/patch-src_getline.c @@ -0,0 +1,80 @@ +--- src/getline.c.orig Tue Mar 25 14:58:33 2003 ++++ src/getline.c Sun May 18 14:45:40 2003 +@@ -1,5 +1,5 @@ + /* +- * getline.c Copyright (C) 2003 Michael Tindal ++ * getline.c Copyright (C) 2003 Alexander Nedotsukov + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free +@@ -20,35 +20,48 @@ + #include <stdio.h> + #include <string.h> + #include <stdlib.h> ++#include <errno.h> + +-int getline (char** line, int* size, int fd) ++/* GNU libc getline() compatibility */ ++ ++int ++getline(char** line, size_t* size, FILE* fp) + { +- int len, res; +- short brk = 0; +- char* buf = malloc(2096); +- char buf2[1]; +- +- strcpy (buf, ""); ++ static const size_t line_grow_by = 80; /* in most texts line fits console */ ++ int ch; ++ size_t i; + +- while (!brk) +- { +- if ((res = read(fd, buf2, 1)) < 0) +- return -1; +- if (res != 0) // check for end-of-line +- strcat(buf, buf2); +- if (buf2[0] == '\n' || res == 0) +- brk = 1; ++ if (line == NULL || size == NULL || fp == NULL) { /* illegal call */ ++ errno = EINVAL; ++ return -1; + } +- +- if (*line == NULL) +- { +- *line = (char*)malloc(strlen(buf)); ++ if (*line == NULL && *size) { /* logically incorrect */ ++ errno = EINVAL; ++ return -1; ++ } ++ ++ i = 0; ++ while (1) { ++ ch = fgetc(fp); ++ if (ch == EOF) ++ break; ++ /* ensure bufer still large enough for ch and trailing null */ ++ if ((*size - i) <= 1) { ++ *line = (char*)realloc(*line, *size += line_grow_by); ++ if (*line == NULL) { ++ errno = ENOMEM; ++ return -1; ++ } ++ } ++ *(*line + i++) = (char)ch; ++ if (ch == '\n') ++ break; + } + +- strcpy(*line, buf); +- *size = strlen(*line); ++ *(*line + i) = 0; + +- return *size; ++ return ferror(fp) ? -1 : i; + } + + #endif ++ |