Tue Nov 2 16:53:56 PST 1999 Michael Jennings <mej@eterm.org>

Several bugs fixed here, most notably a potential seg fault in
	Esetroot, and remembering an Eterm's size works again.  Also a minor
	redraw speedup.  And %exec() now works properly instead of just
	causing Eterm to crash. :-)


SVN revision: 1153
This commit is contained in:
Michael Jennings 1999-11-02 16:08:57 +00:00
parent dfed60dd34
commit e8e8127832
6 changed files with 81 additions and 74 deletions

View File

@ -2721,3 +2721,11 @@ Fri Oct 29 16:43:19 PDT 1999 Michael Jennings <mej@eterm.org>
You'll see what I'm talking about. :-)
-------------------------------------------------------------------------------
Tue Nov 2 16:53:56 PST 1999 Michael Jennings <mej@eterm.org>
Several bugs fixed here, most notably a potential seg fault in
Esetroot, and remembering an Eterm's size works again. Also a minor
redraw speedup. And %exec() now works properly instead of just
causing Eterm to crash. :-)
-------------------------------------------------------------------------------

View File

@ -54,7 +54,7 @@ static unsigned char timeout = 0;
unsigned char
check_for_enlightenment(void)
{
static char have_e = -1;
static signed char have_e = -1;
if (have_e == -1) {
if (XInternAtom(Xdisplay, "ENLIGHTENMENT_COMMS", True) != None) {

View File

@ -1275,9 +1275,44 @@ char *
builtin_exec(char *param)
{
unsigned long fsize;
char *Command, *Output = NULL, *OutFile;
FILE *fp;
D_PARSE(("builtin_exec(%s) called\n", param));
return (param);
Command = (char *) MALLOC(CONFIG_BUFF);
OutFile = tmpnam(NULL);
if (strlen(param) + strlen(OutFile) + 8 > CONFIG_BUFF) {
print_error("Parse error in file %s, line %lu: Cannot execute command, line too long",
file_peek_path(), file_peek_line());
return ((char *) NULL);
}
strcpy(Command, param);
strcat(Command, " >");
strcat(Command, OutFile);
system(Command);
if ((fp = fopen(OutFile, "rb")) != NULL) {
fseek(fp, 0, SEEK_END);
fsize = ftell(fp);
rewind(fp);
if (fsize) {
Output = (char *) MALLOC(fsize + 1);
fread(Output, fsize, 1, fp);
Output[fsize] = 0;
fclose(fp);
remove(OutFile);
Output = CondenseWhitespace(Output);
} else {
print_warning("Command at line %lu of file %s returned no output.", file_peek_line(), file_peek_path());
}
} else {
print_warning("Output file %s could not be created. (line %lu of file %s)", NONULL(OutFile),
file_peek_line(), file_peek_path());
}
FREE(Command);
return (Output);
}
char *
@ -1335,10 +1370,9 @@ shell_expand(char *s)
register unsigned long j, k, l = 0;
char new[CONFIG_BUFF];
unsigned char eval_escape = 1, eval_var = 1, eval_exec = 1, eval_func = 1, in_single = 0, in_double = 0;
unsigned long fsize, cnt1 = 0, cnt2 = 0;
unsigned long cnt1 = 0, cnt2 = 0;
const unsigned long max = CONFIG_BUFF - 1;
char *Command, *Output, *EnvVar, *OutFile;
FILE *fp;
char *Command, *Output, *EnvVar;
ASSERT_RVAL(s != NULL, (char *) NULL);
@ -1455,72 +1489,22 @@ shell_expand(char *s)
Command = (char *) MALLOC(CONFIG_BUFF);
l = 0;
for (pbuff++; *pbuff && *pbuff != '`' && l < max; pbuff++, l++) {
switch (*pbuff) {
case '$':
D_OPTIONS(("Environment variable detected. Evaluating.\n"));
EnvVar = (char *) MALLOC(128);
switch (*(++pbuff)) {
case '{':
for (pbuff++, k = 0; *pbuff != '}' && k < 127; k++, pbuff++)
EnvVar[k] = *pbuff;
break;
case '(':
for (pbuff++, k = 0; *pbuff != ')' && k < 127; k++, pbuff++)
EnvVar[k] = *pbuff;
break;
default:
for (k = 0; (isalnum(*pbuff) || *pbuff == '_') && k < 127; k++, pbuff++)
EnvVar[k] = *pbuff;
break;
}
EnvVar[k] = 0;
if ((tmp = getenv(EnvVar))) {
strncpy(Command + l, tmp, max - l);
cnt1 = strlen(tmp) - 1;
cnt2 = max - l - 1;
l += MIN(cnt1, cnt2);
}
pbuff--;
break;
default:
Command[l] = *pbuff;
}
Command[l] = *pbuff;
}
ASSERT(l < CONFIG_BUFF);
Command[l] = 0;
OutFile = tmpnam(NULL);
if (l + strlen(OutFile) + 8 > CONFIG_BUFF) {
print_error("Parse error in file %s, line %lu: Cannot execute command, line too long",
file_peek_path(), file_peek_line());
return ((char *) NULL);
}
strcat(Command, " >");
strcat(Command, OutFile);
system(Command);
if ((fp = fopen(OutFile, "rb")) != NULL) {
fseek(fp, 0, SEEK_END);
fsize = ftell(fp);
rewind(fp);
if (fsize) {
Output = (char *) MALLOC(fsize + 1);
fread(Output, fsize, 1, fp);
Output[fsize] = 0;
fclose(fp);
remove(OutFile);
Output = CondenseWhitespace(Output);
strncpy(new + j, Output, max - j);
cnt1 = strlen(Output) - 1;
cnt2 = max - j - 1;
j += MIN(cnt1, cnt2);
FREE(Output);
} else {
print_warning("Command at line %lu of file %s returned no output.", file_peek_line(), file_peek_path());
}
} else {
print_warning("Output file %s could not be created. (line %lu of file %s)", NONULL(OutFile),
file_peek_line(), file_peek_path());
}
Command = shell_expand(Command);
Output = builtin_exec(Command);
FREE(Command);
if (Output && *Output) {
l = strlen(Output) - 1;
strncpy(new + j, Output, max - j);
cnt2 = max - j - 1;
j += MIN(l, cnt2);
FREE(Output);
} else {
j--;
}
} else {
new[j] = *pbuff;
}

View File

@ -201,6 +201,8 @@ scrollbar_init(void)
Cursor cursor;
long mask;
D_SCROLLBAR(("scrollbar_init(): Initializing all scrollbar elements.\n"));
Attributes.background_pixel = PixColors[scrollColor];
Attributes.border_pixel = PixColors[bgColor];
Attributes.override_redirect = TRUE;
@ -213,22 +215,26 @@ scrollbar_init(void)
CWOverrideRedirect | CWBackingStore | CWBackPixel | CWBorderPixel | CWColormap, &Attributes);
XDefineCursor(Xdisplay, scrollBar.win, cursor);
XSelectInput(Xdisplay, scrollBar.win, mask);
D_SCROLLBAR(("scrollbar_init(): Created scrollbar window 0x%08x\n", scrollBar.win));
#ifdef PIXMAP_SCROLLBAR
if (scrollbar_uparrow_is_pixmapped()) {
scrollBar.up_win = XCreateWindow(Xdisplay, scrollBar.win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent,
CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap, &Attributes);
XSelectInput(Xdisplay, scrollBar.up_win, mask);
D_SCROLLBAR(("scrollbar_init(): Created scrollbar up arrow window 0x%08x\n", scrollBar.up_win));
}
if (scrollbar_downarrow_is_pixmapped()) {
scrollBar.dn_win = XCreateWindow(Xdisplay, scrollBar.win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent,
CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap, &Attributes);
XSelectInput(Xdisplay, scrollBar.dn_win, mask);
D_SCROLLBAR(("scrollbar_init(): Created scrollbar down arrow window 0x%08x\n", scrollBar.dn_win));
}
if (scrollbar_anchor_is_pixmapped()) {
scrollBar.sa_win = XCreateWindow(Xdisplay, scrollBar.win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent,
CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap, &Attributes);
XSelectInput(Xdisplay, scrollBar.sa_win, mask);
D_SCROLLBAR(("scrollbar_init(): Created scrollbar anchor window 0x%08x\n", scrollBar.sa_win));
}
#endif
@ -237,6 +243,7 @@ scrollbar_init(void)
} else {
scrollbar_set_shadow((Options & Opt_scrollBar_floating) ? 0 : SHADOW);
}
D_SCROLLBAR(("scrollbar_init(): Set scrollbar shadow to %d\n", scrollbar_get_shadow()));
event_register_dispatcher(scrollbar_dispatch_event, scrollbar_event_init_dispatcher);
}
@ -376,9 +383,6 @@ sb_handle_expose(event_t * ev)
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, Expose, &unused_xevent));
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, GraphicsExpose, &unused_xevent));
if (scrollbar_win_is_scrollbar(ev->xany.window)) {
scrollbar_show(0);
}
return 1;
}
@ -613,6 +617,7 @@ scrollbar_mapping(unsigned char show)
D_SCROLLBAR(("scrollbar_mapping(%d)\n", show));
if (show && !scrollbar_visible()) {
D_SCROLLBAR((" -> Mapping all scrollbar windows. Returning 1.\n"));
scrollBar.state = 1;
XMapWindow(Xdisplay, scrollBar.win);
#ifdef PIXMAP_SCROLLBAR
@ -628,6 +633,7 @@ scrollbar_mapping(unsigned char show)
#endif
change = 1;
} else if (!show && scrollbar_visible()) {
D_SCROLLBAR((" -> Unmapping all scrollbar windows. Returning 1.\n"));
scrollBar.state = 0;
#ifdef PIXMAP_SCROLLBAR
if (scrollbar_uparrow_is_pixmapped()) {
@ -642,6 +648,8 @@ scrollbar_mapping(unsigned char show)
#endif
XUnmapWindow(Xdisplay, scrollBar.win);
change = 1;
} else {
D_SCROLLBAR((" -> No action required. Returning 0.\n"));
}
return change;
}

View File

@ -205,8 +205,8 @@ eterm_bootstrap(int argc, char *argv[])
Create_Windows(argc, argv);
scr_reset(); /* initialize screen */
/* add scrollBar, do it directly to avoid resize() */
scrollbar_mapping(Options & Opt_scrollBar);
scrollbar_resize(szHint.width, szHint.height);
#if DEBUG >= DEBUG_X
if (debug_level >= DEBUG_X) {
@ -276,7 +276,6 @@ eterm_bootstrap(int argc, char *argv[])
D_CMD(("init_command()\n"));
init_command(rs_execArgs);
parent_resize();
main_loop();

View File

@ -169,9 +169,17 @@ main(int argc, char *argv[])
params.flags = PARAMS_VISUALID;
params.visualid = (DefaultVisual(Xdisplay, screen))->visualid;
id = Imlib_init_with_params(Xdisplay, &params);
im = Imlib_load_image(id, fname);
if (debug) {
if (id == NULL) {
fprintf(stderr, "%s: Unable to initialize Imlib.\n", *argv);
exit(1);
} else if (debug) {
fprintf(stderr, "%s:%d: The Imlib Data is at %8p\n", __FILE__, __LINE__, id);
}
im = Imlib_load_image(id, fname);
if (im == NULL) {
fprintf(stderr, "%s: Unable to load image file \"%s\".\n", *argv, fname);
exit(1);
} else if (debug) {
fprintf(stderr, "%s:%d: The Imlib Image is at %8p\n", __FILE__, __LINE__, im);
}
if (scale) {