Removed some static buffer, and replaced by a dynamic memory allocation
in order to support bigger text.

Comments are welcome.

BR
G.Baroncelli

Signed-off-by: Goffredo Baroncelli <[email protected]>

---
 helpextract.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/helpextract.c b/helpextract.c
index a729074..e708b9e 100644
--- a/helpextract.c
+++ b/helpextract.c
@@ -9,7 +9,7 @@
 #define PREFIX_END     " ****"
 #define PREFIX_SKIP    " * "
 
-#define LINEBUF                1024
+#define LINEBUF                4024
 
 char **msgs=0;
 int nmsg=0;
@@ -188,7 +188,9 @@ static int search_in_file(char *nf){
 /* remove all the escape sequence except \\ */
 static char * my_escape(char *src, char *filters[] ){
 
-       static char buffer[LINEBUF*5];
+       char *buffer=NULL;
+
+       buffer = xrealloc(buffer, strlen(src)*2+1);
 
        int     i=0;
        while(*src){
@@ -387,14 +389,15 @@ static void dump_man_page(){
        fmt = find_section("man btrfs command format");
        for(i = 0; i < nmsg && fmt>=0; i++ ){
 
-               char big2[LINEBUF*5];
+               char *big2;
                if( strncmp("btrfs ",msgs[i*4], 6) ||
                    !strcmp("btrfs introduction", msgs[i*4] ) ||
                    !strcmp("btrfs notes", msgs[i*4] ) )
                                continue;
                
-               strcpy(big2, escape_man_page(msgs[i*4+3]));
+               big2 = xstrdup(escape_man_page(msgs[i*4+3]));
                printf(msgs[fmt*4+3], escape_man_page(msgs[i*4+1]), big2);
+               free(big2);
 
        }
 

-- 
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <[email protected]>
Key fingerprint = 4769 7E51 5293 D36C 814E  C054 BF04 F161 3DC5 0512
diff --git a/helpextract.c b/helpextract.c
index a729074..e708b9e 100644
--- a/helpextract.c
+++ b/helpextract.c
@@ -9,7 +9,7 @@
 #define PREFIX_END 	" ****"
 #define PREFIX_SKIP	" * "
 
-#define LINEBUF		1024
+#define LINEBUF		4024
 
 char **msgs=0;
 int nmsg=0;
@@ -188,7 +188,9 @@ static int search_in_file(char *nf){
 /* remove all the escape sequence except \\ */
 static char * my_escape(char *src, char *filters[] ){
 
-	static char buffer[LINEBUF*5];
+	char *buffer=NULL;
+
+	buffer = xrealloc(buffer, strlen(src)*2+1);
 
 	int	i=0;
 	while(*src){
@@ -387,14 +389,15 @@ static void dump_man_page(){
 	fmt = find_section("man btrfs command format");
 	for(i = 0; i < nmsg && fmt>=0; i++ ){
 
-		char big2[LINEBUF*5];
+		char *big2;
 		if( strncmp("btrfs ",msgs[i*4], 6) ||
 		    !strcmp("btrfs introduction", msgs[i*4] ) ||
 		    !strcmp("btrfs notes", msgs[i*4] ) )
 		    		continue;
 		
-		strcpy(big2, escape_man_page(msgs[i*4+3]));
+		big2 = xstrdup(escape_man_page(msgs[i*4+3]));
 		printf(msgs[fmt*4+3], escape_man_page(msgs[i*4+1]), big2);
+		free(big2);
 
 	}
 

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to