The new FvwmConsole module looked very promising, but when I tried to
use it, it failed to start. Subsequent debugging revealed several
fatal bugs. I attached diffs that fix all of the bugs that I could
find. I did not bother about fixing compiler warning messages, though.
Markus
re -- cut here -- cut here -- cut here -- cut here -- cut here -- cut here -- c
--- ./modules/FvwmConsole/FvwmConsole.c.orig Thu Jun 20 17:03:43 1996
+++ ./modules/FvwmConsole/FvwmConsole.c Thu Jun 20 17:57:27 1996
_at_@ -26,10 +26,11 @@
void main(int argc, char **argv){
char *tmp, *s;
- char client[120];
+ static char client[120];
char **eargv;
int i,j;
char *xterm_a[] = {"-title", name,"-name",name, "-e",client,NULL };
+ #define XARGS (sizeof(xterm_a)/sizeof(char *))
/* initially no child */
pid = 0;
_at_@ -57,17 +58,17 @@
exit(1);
}
- if( ( eargv =(char **)safemalloc((argc-2)*sizeof(char *)) ) == NULL ) {
+ if( ( eargv =(char **)safemalloc((argc-FARGS+XARGS)*sizeof(char *)) ) == NULL ) {
ErrMsg( "allocation" );
}
/* copy arguments */
eargv[0] = XTERM;
j= 1;
- for ( i=FARGS ; i<=argc; i++,j++ ) {
+ for ( i=FARGS ; i<argc; i++,j++ ) {
eargv[j] = argv[i];
}
- j--;
+
for ( i=0 ; xterm_a[i] != NULL ; j++, i++ ) {
eargv[j] = xterm_a[i];
}
--- ./modules/FvwmConsole/FCtest.c.orig Thu Jun 20 17:33:32 1996
+++ ./modules/FvwmConsole/FCtest.c Thu Jun 20 17:57:38 1996
_at_@ -27,10 +27,11 @@
void main(int argc, char **argv){
char *tmp, *s;
- char client[120];
+ static char client[120];
char **eargv;
int i,j;
char *xterm_a[] = {"-title", name,"-name",name, "-e",client,NULL };
+ #define XARGS (sizeof(xterm_a)/sizeof(char *))
/* initially no child */
pid = 0;
_at_@ -58,17 +59,17 @@
exit(1);
}
- if( ( eargv =(char **)safemalloc((argc-2)*sizeof(char *)) ) == NULL ) {
+ if( ( eargv =(char **)safemalloc((argc-FARGS+XARGS)*sizeof(char *)) ) == NULL ) {
ErrMsg( "allocation" );
}
/* copy arguments */
eargv[0] = XTERM;
j= 1;
- for ( i=FARGS ; i<=argc; i++,j++ ) {
+ for ( i=FARGS ; i<argc; i++,j++ ) {
eargv[j] = argv[i];
}
- j--;
+
for ( i=0 ; xterm_a[i] != NULL ; j++, i++ ) {
eargv[j] = xterm_a[i];
}
--- ./modules/FvwmConsole/getline.c.orig Thu Jun 20 17:51:10 1996
+++ ./modules/FvwmConsole/getline.c Thu Jun 20 18:06:16 1996
_at_@ -1,8 +1,9 @@
#include "FvwmConsole.h"
-static char cmd[256];
#ifndef HAVE_READLINE
+static char cmd[256];
+
/* no readline - starts here */
char *getline() {
if( fgets(cmd,256,stdin) == NULL ) {
_at_@ -15,10 +16,10 @@
/* readline - starts here */
#include <readline/readline.h>
-#define PROMPT ""
+#define PROMPT "> "
char *getline() {
- char *line;
+ static char *line = NULL;
/* If the buffer has already been allocated, return the memory to the free pool. */
if (line != (char *)NULL) {
_at_@ -29,19 +30,18 @@
/* Get a line from the user. */
line = readline (PROMPT);
- if( line == NULL ) {
- return(NULL);
- }
+ if( line != NULL ) {
/* If the line has any text in it, save it on the history. */
if (*line != '\0')
add_history (line);
/* add cr at the end*/
- strncpy( cmd, line, 254 );
- strcat( cmd, NEWLINE );
+ if ((line = realloc(line,strlen(line)+2)) != NULL)
+ strcat(line, NEWLINE );
+ }
- return (cmd);
+ return (line);
}
/* readline - end here */
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Thu Jun 20 1996 - 21:07:40 BST