X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fphosphor.c;h=c01f5a5a17b7e37aaac8b749483f1c49720ef078;hb=3f438031d610c7e15fd33876a879b97e290e05fb;hp=5132cadd8001cf9c26117a207d52bf7b4cbac85d;hpb=e4fa2ac140f7bc56571373a7b7eb585fa4500e38;p=xscreensaver diff --git a/hacks/phosphor.c b/hacks/phosphor.c index 5132cadd..c01f5a5a 100644 --- a/hacks/phosphor.c +++ b/hacks/phosphor.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1999, 2000, 2004 Jamie Zawinski +/* xscreensaver, Copyright (c) 1999-2005 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -27,7 +27,13 @@ #include #ifdef HAVE_FORKPTY -# include +# include +# ifdef HAVE_PTY_H +# include +# endif +# ifdef HAVE_UTIL_H +# include +# endif #endif /* HAVE_FORKPTY */ extern XtAppContext app; @@ -1136,6 +1142,13 @@ launch_text_generator (p_state *state) { char buf[255]; char *oprogram = get_string_resource ("program", "Program"); + char *program = (char *) malloc (strlen (oprogram) + 50); + + /* oprogram contains a "%d" where the current number of columns goes + */ + strcpy (program, "( "); + sprintf (program + strlen(program), oprogram, state->grid_width-1); + strcat (program, " ) 2>&1"); #ifdef HAVE_FORKPTY if(state->mode == 1) @@ -1158,9 +1171,15 @@ launch_text_generator (p_state *state) else if(!state->pid) { /* This is the child fork. */ + char *av[10]; + int i = 0; if (putenv("TERM=vt100")) abort(); - execl("/bin/sh", "/bin/sh", "-c", oprogram, NULL); + av[i++] = "/bin/sh"; + av[i++] = "-c"; + av[i++] = program; + av[i] = 0; + execvp (av[0], av); sprintf (buf, "%.100s: %.100s", progname, oprogram); perror(buf); exit(1); @@ -1178,12 +1197,6 @@ launch_text_generator (p_state *state) else #endif /* HAVE_FORKPTY */ { - char *program = (char *) malloc (strlen (oprogram) + 10); - - strcpy (program, "( "); - strcat (program, oprogram); - strcat (program, " ) 2>&1"); - /* don't mess up controlling terminal if someone dumbly does "-pipe -program tcsh". */ fclose (stdin); @@ -1201,6 +1214,8 @@ launch_text_generator (p_state *state) perror (buf); } } + + free (program); } @@ -1380,7 +1395,7 @@ char *defaults [] = { "*ticks: 20", "*delay: 50000", "*cursor: 333", - "*program: " FORTUNE_PROGRAM, + "*program: xscreensaver-text --cols %d", "*relaunch: 5", "*metaSendsESC: True", "*swapBSDEL: True",