Thu Apr 24 14:29:05 2003 Michael Jennings (mej)

Fixed seg fault caused by people who neglect to grow the multichar
font list in parallel with the normal font list.

Also tweaked the default fonts to be less error-prone.


SVN revision: 6878
This commit is contained in:
Michael Jennings 2003-04-24 18:30:17 +00:00
parent 8ae4b7db7e
commit 847cd7f032
3 changed files with 60 additions and 20 deletions

View File

@ -5039,3 +5039,10 @@ Wed Apr 23 12:14:00 2003 Michael Jennings (mej)
Apparently some versions of gcc (or maybe ld?) don't like duplicate
libraries on the link line. Fix provided by Mark <somnione@gmx.net>.
----------------------------------------------------------------------
Thu Apr 24 14:29:05 2003 Michael Jennings (mej)
Fixed seg fault caused by people who neglect to grow the multichar
font list in parallel with the normal font list.
Also tweaked the default fonts to be less error-prone.
----------------------------------------------------------------------

View File

@ -151,21 +151,21 @@ struct defaultfont {
#define DEF_10646 2
#define NFONT_LIST_10646 "5x7", "6x10", "fixed", "8x13", "9x15"
#define MFONT_LIST_10646 \
"-misc-fixed-medium-r-normal--7-70-75-75-c-50-iso10646-1",\
"-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso10646-1",\
"-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1",\
"-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1",\
"-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1"
"-misc-fixed-medium-r-normal--7-*-*-*-c-*-iso10646-1",\
"-misc-fixed-medium-r-normal--10-*-*-*-c-*-iso10646-1",\
"-misc-fixed-medium-r-semicondensed--13-*-*-*-c-*-iso10646-1",\
"-misc-fixed-medium-r-normal--14-*-*-*-c-*-iso10646-1",\
"-misc-fixed-medium-r-normal--15-*-*-*-c-*-iso10646-1"
/* special common rule for ISO-8859-* */
#define DEF_8859 2
#define NFONT_LIST_ISO8859X \
"-misc-fixed-medium-r-normal--7-70-75-75-c-50-iso8859-%d",\
"-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-%d",\
"-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-%d",\
"-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-%d",\
"-misc-fixed-medium-r-normal--18-120-75-75-c-90-iso8859-%d"
"-misc-fixed-medium-r-normal--7-*-*-*-c-*-iso8859-%d",\
"-misc-fixed-medium-r-normal--10-*-*-*-c-*-iso8859-%d",\
"-misc-fixed-medium-r-semicondensed--13-*-*-*-c-*-iso8859-%d",\
"-misc-fixed-medium-r-normal--13-*-*-*-c-*-iso8859-%d",\
"-misc-fixed-medium-r-normal--18-*-*-*-c-*-iso8859-%d"
#endif /* _DEFAULTFONT_H_ */

View File

@ -2484,24 +2484,29 @@ init_defaults(void)
#ifndef NO_BRIGHTCOLOR
colorfgbg = DEFAULT_RSTYLE;
#endif
/* Font stuff. */
MEMSET(rs_font, 0, sizeof(char *) * NFONTS);
#if AUTO_ENCODING
#ifdef MULTI_CHARSET
/* Auto-encoding means the default fonts are chosen by locale. */
# ifdef MULTI_CHARSET
eterm_default_font_locale(&etfonts, &etmfonts, &rs_multichar_encoding, &def_font_idx);
#else
# else
eterm_default_font_locale(&etfonts, NULL, NULL, &def_font_idx);
#endif
# endif
#else
/* No auto-encoding, so use built-in ISO-8859-1 fonts. */
for (i = 0; i < NFONTS; i++) {
eterm_font_add(&etfonts, def_fontName[i], i);
#ifdef MULTI_CHARSET
# ifdef MULTI_CHARSET
eterm_font_add(&etmfonts, def_mfontName[i], i);
#endif
# endif
}
#ifdef MULTI_CHARSET
# ifdef MULTI_CHARSET
rs_multichar_encoding = STRDUP(MULTICHAR_ENCODING);
# endif
#endif
#endif
TermWin.internalBorder = DEFAULT_BORDER_WIDTH;
/* Initialize the parser */
@ -2595,12 +2600,19 @@ post_parse(void)
rs_boldFont = NULL;
}
#endif
/* Add any fonts we got from the command line. */
for (i = 0; i < NFONTS; i++) {
if (rs_font[i]) {
if (def_font_idx == 0) {
eterm_font_add(&etfonts, rs_font[i], i);
RESET_AND_ASSIGN(rs_font[i], NULL);
} else {
/* If they changed the default font index to something other than 0,
put rs_font[0] in that position. Any indexes less than that are
reduced by one so that rs_font[1-n] (n being the default font
index) will be assigned to etfonts[0-(n-1)], and rs_font[0] will
be etfonts[n]. Anything higher than n stays as is. */
eterm_font_add(&etfonts, rs_font[i], ((i == 0) ? def_font_idx : ((i <= def_font_idx) ? (i - 1) : i)));
RESET_AND_ASSIGN(rs_font[i], NULL);
}
@ -2614,12 +2626,33 @@ post_parse(void)
eterm_font_add(&etmfonts, rs_mfont[i], ((i == 0) ? def_font_idx : ((i <= def_font_idx) ? (i - 1) : i)));
RESET_AND_ASSIGN(rs_mfont[i], NULL);
}
}
if (rs_multichar_encoding != NULL) {
set_multichar_encoding(rs_multichar_encoding);
} else {
eterm_font_add(&etmfonts, etfonts[i], i);
}
#endif
}
/* Make sure all fonts 0 through font_cnt are populated for both normal
and multi-byte font structures. */
for (; i < font_cnt; i++) {
if (!etfonts[i]) {
eterm_font_add(&etfonts, etfonts[def_font_idx], i);
}
#ifdef MULTI_CHARSET
if (!etmfonts[i]) {
if (etmfonts[def_font_idx]) {
eterm_font_add(&etmfonts, etmfonts[def_font_idx], i);
} else {
eterm_font_add(&etmfonts, etfonts[i], i);
}
}
#endif
}
#ifdef MULTI_CHARSET
if (rs_multichar_encoding != NULL) {
set_multichar_encoding(rs_multichar_encoding);
}
#endif
if (rs_font_effects) {
if (parse_font_fx(rs_font_effects) != 1) {
print_error("Syntax error in the font effects specified on the command line.\n");