From: pcg Date: Mon, 22 Mar 2004 15:15:04 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=8f1cd4a16080c040f41366f4e6214b8ac2d73f58;p=dana%2Furxvt.git *** empty log message *** --- diff --git a/src/defaultfont.C b/src/defaultfont.C index e10f7b20..93cf1d9b 100644 --- a/src/defaultfont.C +++ b/src/defaultfont.C @@ -413,13 +413,13 @@ struct rxvt_font_x11 : rxvt_font { codeset cs; bool enc2b, encm; - const char *get_property (XFontStruct *f, const char *property, const char *repl) const; + char *get_property (XFontStruct *f, const char *property, const char *repl) const; bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); bool set_properties (rxvt_fontprop &p, XFontStruct *f); bool set_properties (rxvt_fontprop &p, const char *name); }; -const char * +char * rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const { unsigned long value; @@ -427,7 +427,7 @@ rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *r if (XGetFontProperty (f, XInternAtom (DISPLAY, property, 0), &value)) return XGetAtomName (DISPLAY, value); else - return repl; + return rxvt_strdup (repl); } rxvt_fontprop @@ -452,9 +452,6 @@ rxvt_font_x11::set_properties (rxvt_fontprop &p, int height, const char *weight, bool rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) { - const char *weight = get_property (f, "WEIGHT_NAME", "medium"); - const char *slant = get_property (f, "SLANT", "r"); - unsigned long height; if (!XGetFontProperty (f, XInternAtom (DISPLAY, "PIXEL_SIZE", 0), &height)) return false; @@ -463,7 +460,15 @@ rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) if (!XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth)) avgwidth = 0; - return set_properties (p, height, weight, slant, avgwidth); + char *weight = get_property (f, "WEIGHT_NAME", "medium"); + char *slant = get_property (f, "SLANT", "r"); + + set_properties (p, height, weight, slant, avgwidth); + + free (weight); + free (slant); + + return true; } bool @@ -577,8 +582,8 @@ rxvt_font_x11::load (const rxvt_fontprop &prop) if (!f) return false; - const char *registry = get_property (f, "CHARSET_REGISTRY", 0); - const char *encoding = get_property (f, "CHARSET_ENCODING", 0); + char *registry = get_property (f, "CHARSET_REGISTRY", 0); + char *encoding = get_property (f, "CHARSET_ENCODING", 0); if (registry && encoding) { @@ -602,6 +607,9 @@ rxvt_font_x11::load (const rxvt_fontprop &prop) cs = codeset_from_name (charset); } + free (registry); + free (encoding); + if (cs == CS_UNICODE) cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font diff --git a/src/rxvt.h b/src/rxvt.h index 4aedf532..49b98a17 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -31,7 +31,6 @@ # define __sun__ #endif - #ifndef HAVE_XPOINTER typedef char *XPointer; #endif @@ -587,7 +586,7 @@ enum { #define PrivMode_smoothScroll (1LU<<18) #define PrivMode_vt52 (1LU<<19) /* too annoying to implement X11 highlight tracking */ -/* #define PrivMode_MouseX11Track (1LU<<18) */ +/* #define PrivMode_MouseX11Track (1LU<<20) */ #define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11) #define PrivMode(test,bit) \ @@ -606,11 +605,10 @@ enum { #define XCMAP display->cmap #define XVISUAL display->visual -#define IMBUFSIZ 128 /* input modifier buffer sizes */ -#ifndef BUFSIZ -# define BUFSIZ 4096 -#endif -#define KBUFSZ 512 /* size of keyboard mapping buffer */ +#define IMBUFSIZ 128 // input modifier buffer sizes +#define KBUFSZ 512 // size of keyboard mapping buffer +#define CBUFSIZ 4096 // size of command buffer +#define UBUFSIZ 4096 // character buffer /* ***************************************************************************** @@ -790,6 +788,19 @@ enum { # define D_X(x) #endif +extern class rxvt_failure_exception { } rxvt_failure_exception; + +typedef callback1 log_callback; + +extern void rxvt_vlog (const char *fmt, va_list arg_ptr); +extern void rxvt_log (const char *fmt, ...); +extern void rxvt_warn (const char *fmt, ...); +extern void rxvt_fatal (const char *fmt, ...) __attribute__ ((noreturn)); +extern void rxvt_exit_failure () __attribute__ ((noreturn)); + +#define SET_LOCALE(locale) rxvt_set_locale (locale) +extern void rxvt_set_locale (const char *locale); + /* ***************************************************************************** * VARIABLES @@ -859,6 +870,8 @@ extern class rxvt_composite_vec rxvt_composite; struct rxvt_term : rxvt_vars { + log_callback *log_hook; + struct mbstate mbstate; unsigned char want_refresh:1, @@ -883,8 +896,8 @@ struct rxvt_term : rxvt_vars { hidden_pointer:1, #endif parsed_geometry:1, - seen_input:1, /* wether any input has been seen so far */ - enc_utf8:1; /* wether terminal reads/writes utf-8 */ +// enc_utf8:1, /* wether terminal reads/writes utf-8 */ + seen_input:1; /* wether any input has been seen so far */ unsigned char refresh_type, #ifdef UTMP_SUPPORT @@ -1056,13 +1069,16 @@ struct rxvt_term : rxvt_vars { struct timeval lastmotion; #endif -/* these three don't need to be kept but do so to placate some mem checkers */ + vector allocated; // free these memory blocks + char *env_windowid; /* environmental variable WINDOWID */ char *env_display; /* environmental variable DISPLAY */ char *env_term; /* environmental variable TERM */ char *env_colorfgbg; char *locale; +#if 0 char *codeset; +#endif char charsets[4]; unsigned char *v_buffer; /* pointer to physical buffer */ unsigned int v_buflen; /* size of area to write */ @@ -1071,9 +1087,9 @@ struct rxvt_term : rxvt_vars { const unsigned char *Keysym_map[256]; #endif const char *rs[NUM_RESOURCES]; -/* command input buffering */ + /* command input buffering */ unsigned char *cmdbuf_ptr, *cmdbuf_endp; - unsigned char cmdbuf_base[BUFSIZ]; + unsigned char cmdbuf_base[CBUFSIZ]; rxvt_salloc *ralloc; rxvt_salloc *talloc; @@ -1203,12 +1219,12 @@ struct rxvt_term : rxvt_vars { int pclose_printer (FILE *stream); #endif void process_print_pipe (); - void process_nonprinting (unsigned char ch); - void process_escape_vt52 (unsigned char ch); + void process_nonprinting (unicode_t ch); + void process_escape_vt52 (unicode_t ch); void process_escape_seq (); void process_csi_seq (); void process_window_ops (const int *args, unsigned int nargs); - unsigned char * get_to_st (unsigned char *ends_how); + unsigned char *get_to_st (unicode_t &ends_how); void process_dcs_seq (); void process_osc_seq (); void xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))); @@ -1229,7 +1245,7 @@ struct rxvt_term : rxvt_vars { bool change_font (const char *fontname); bool font_up_down (int n, int direction); void set_title (const char *str); - void set_iconName (const char *str); + void set_icon_name (const char *str); void set_window_color (int idx, const char *color); void set_colorfgbg (); int rXParseAllocColor (rxvt_color * screen_in_out, const char *colour); @@ -1356,9 +1372,6 @@ struct rxvt_term : rxvt_vars { Pixmap set_bgPixmap (const char *file); }; -#define SET_LOCALE(locale) rxvt_set_locale (locale) -extern void rxvt_set_locale (const char *locale); - /* ***************************************************************************** * PROTOTYPES diff --git a/src/xdefaults.C b/src/xdefaults.C index 4c77158a..b1873633 100644 --- a/src/xdefaults.C +++ b/src/xdefaults.C @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: xdefaults.c *----------------------------------------------------------------------* - * $Id: xdefaults.C,v 1.17 2004-03-14 17:33:08 pcg Exp $ + * $Id: xdefaults.C,v 1.19 2004-03-22 15:15:04 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1994 Robert Nation @@ -342,16 +342,15 @@ static const char optionsstring[] = "Options: " static void rxvt_usage (int type) { - unsigned int i, col; + unsigned int i, col; - write (STDERR_FILENO, releasestring, sizeof (releasestring) - 1); - write (STDERR_FILENO, optionsstring, sizeof (optionsstring) - 1); - write (STDERR_FILENO, RESNAME, sizeof (RESNAME) - 1); + rxvt_log ("%s%s%s", releasestring, optionsstring, RESNAME); switch (type) { case 0: /* brief listing */ - fprintf (stderr, " [-help] [--help]\n"); + rxvt_log (" [-help] [--help]\n"); + for (col = 1, i = 0; i < optList_size (); i++) if (optList[i].desc != NULL) { @@ -370,59 +369,59 @@ rxvt_usage (int type) col += len; if (col > 79) { /* assume regular width */ - putc ('\n', stderr); + rxvt_log ("\n"); col = 1 + len; } - fprintf (stderr, " [-%s%s", (optList_isBool (i) ? "/+" : ""), - optList[i].opt); + + rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt); if (optList_strlen (i)) - fprintf (stderr, " %s]", optList[i].arg); + rxvt_log (" %s]", optList[i].arg); else - fprintf (stderr, "]"); + rxvt_log ("]"); } break; case 1: /* full command-line listing */ - fprintf (stderr, " [options] [-e command args]\n\n" - "where options include:\n"); + rxvt_log (" [options] [-e command args]\n\nwhere options include:\n"); + for (i = 0; i < optList_size (); i++) if (optList[i].desc != NULL) { #ifdef DEBUG_STRICT assert (optList[i].opt != NULL); #endif - fprintf (stderr, " %s%s %-*s%s%s\n", - (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, - (INDENT - STRLEN (optList[i].opt) - + (optList_isBool (i) ? 0 : 2)), - (optList[i].arg ? optList[i].arg : ""), - (optList_isBool (i) ? "turn on/off " : ""), - optList[i].desc); + rxvt_log (" %s%s %-*s%s%s\n", + (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, + (INDENT - STRLEN (optList[i].opt) + + (optList_isBool (i) ? 0 : 2)), + (optList[i].arg ? optList[i].arg : ""), + (optList_isBool (i) ? "turn on/off " : ""), + optList[i].desc); } - fprintf (stderr, "\n --help to list long-options"); + rxvt_log ("\n --help to list long-options"); break; case 2: /* full resource listing */ - fprintf (stderr, - " [options] [-e command args]\n\n" - "where resources (long-options) include:\n"); + rxvt_log (" [options] [-e command args]\n\n" + "where resources (long-options) include:\n"); for (i = 0; i < optList_size (); i++) if (optList[i].kw != NULL) - fprintf (stderr, " %s: %*s%s\n", + rxvt_log (" %s: %*s%s\n", optList[i].kw, (INDENT - STRLEN (optList[i].kw)), "", /* XXX */ (optList_isBool (i) ? "boolean" : optList[i].arg)); #ifdef KEYSYM_RESOURCE - fprintf (stderr, " " "keysym.sym" ": %*s%s\n", + rxvt_log (" " "keysym.sym" ": %*s%s\n", (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */ "keysym"); #endif - fprintf (stderr, "\n -help to list options"); + rxvt_log ("\n -help to list options"); break; } - fprintf (stderr, "\n\n"); - exit (EXIT_FAILURE); + + rxvt_log ("\n\n"); + rxvt_exit_failure (); /* NOTREACHED */ } @@ -459,7 +458,7 @@ rxvt_term::get_options (int argc, const char *const *argv) else { bad_option = 1; - rxvt_print_error ("bad option \"%s\"", opt); + rxvt_warn ("\"%s\": malformed option.\n", opt); continue; } @@ -526,14 +525,17 @@ rxvt_term::get_options (int argc, const char *const *argv) /* if (!STRNCMP (opt, "keysym.", sizeof ("keysym.") - 1)) */ if (rxvt_Str_match (opt, "keysym.")) { - const char *str = argv[++i]; + const char *str = argv[++i]; if (str != NULL) parse_keysym (opt + sizeof ("keysym.") - 1, str); } else #endif - bad_option = 1; + { + bad_option = 1; + rxvt_warn ("\"%s\": unknown or malformed option.\n", opt); + } } if (bad_option) @@ -670,6 +672,7 @@ rxvt_term::get_xdefaults (FILE *stream, const char *name) if (stream == NULL) return; + len = STRLEN (name); while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) { @@ -688,10 +691,11 @@ rxvt_term::get_xdefaults (FILE *stream, const char *name) # endif /* KEYSYM_RESOURCE */ for (entry = 0; entry < optList_size (); entry++) { - const char *kw = optList[entry].kw; + const char *kw = optList[entry].kw; if (kw == NULL) continue; + n = STRLEN (kw); if (str[n] == ':' && rxvt_Str_match (str, kw)) { @@ -725,24 +729,30 @@ rxvt_term::get_xdefaults (FILE *stream, const char *name) } rs[optList[entry].doff] = p; + allocated.push_back (p); + if (optList_isBool (entry)) { s = STRCASECMP (str, "TRUE") == 0 || STRCASECMP (str, "YES") == 0 || STRCASECMP (str, "ON") == 0 || STRCASECMP (str, "1") == 0; + if (optList_isReverse (entry)) s = !s; + if (s) - Options |= (optList[entry].flag); + Options |= optList[entry].flag; else - Options &= ~ (optList[entry].flag); + Options &= ~optList[entry].flag; } } + break; } } } + rewind (stream); } @@ -763,7 +773,7 @@ rxvt_term::extract_resources (Display *display __attribute__ ((unused)), const c # if defined XAPPLOADDIR # if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) /* Compute the path of the possibly available localized Rxvt file */ - char *localepath = NULL; + char *localepath = NULL; if (locale != NULL) { /* XXX: must limit length of string */ @@ -781,15 +791,15 @@ rxvt_term::extract_resources (Display *display __attribute__ ((unused)), const c /* * get resources using the X library function */ - int entry; + int entry; # ifdef XrmEnumOneLevel - int i; - char *displayResource, *xe; - XrmName name_prefix[3]; - XrmClass class_prefix[3]; - XrmDatabase database, rdb1; - char fname[1024]; + int i; + char *displayResource, *xe; + XrmName name_prefix[3]; + XrmClass class_prefix[3]; + XrmDatabase database, rdb1; + char fname[1024]; XrmInitialize (); database = NULL; @@ -812,7 +822,7 @@ rxvt_term::extract_resources (Display *display __attribute__ ((unused)), const c { sprintf (fname, "%-.*s/%s", sizeof (fname) - STRLEN (xnames[i]) - 2, ptr, xnames[i]); - if ((rdb1 = XrmGetFileDatabase (fname)) != NULL) + if ((rdb1 = XrmGetFileDatabase (fname))) { XrmMergeDatabases (rdb1, &database); # ifndef HAVE_BOTH_XRESOURCE_FILES