summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2001-11-26 20:13:29 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2001-11-26 20:13:29 +0000
commitc93c134710bc7d1d8e1abb7a392243d81a5ad70c (patch)
tree201cc5ada8f26e169c70869100198a5e04e377c2 /src
parent8a18013f69710648f701dc6a54307c8bb2ce0f5a (diff)
Bug fixes from Sebastien Recio.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1734 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Help_View.cxx254
-rw-r--r--src/fl_set_fonts.cxx14
-rwxr-xr-xsrc/fl_set_fonts_win32.cxx7
-rw-r--r--src/scandir_win32.c67
4 files changed, 199 insertions, 143 deletions
diff --git a/src/Fl_Help_View.cxx b/src/Fl_Help_View.cxx
index 6d811e237..1183131b9 100644
--- a/src/Fl_Help_View.cxx
+++ b/src/Fl_Help_View.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Help_View.cxx,v 1.1.2.15 2001/11/25 16:38:11 easysw Exp $"
+// "$Id: Fl_Help_View.cxx,v 1.1.2.16 2001/11/26 20:13:29 easysw Exp $"
//
// Fl_Help_View widget routines.
//
@@ -84,6 +84,7 @@ extern "C"
// Local functions...
//
+static int quote_char(const char *);
static void scrollbar_callback(Fl_Widget *s, void *);
static void hscrollbar_callback(Fl_Widget *s, void *);
@@ -661,40 +662,13 @@ Fl_Help_View::draw()
{
ptr ++;
- if (strncasecmp(ptr, "amp;", 4) == 0)
- {
- *s++ = '&';
- ptr += 4;
- }
- else if (strncasecmp(ptr, "lt;", 3) == 0)
- {
- *s++ = '<';
- ptr += 3;
- }
- else if (strncasecmp(ptr, "gt;", 3) == 0)
- {
- *s++ = '>';
- ptr += 3;
- }
- else if (strncasecmp(ptr, "nbsp;", 5) == 0)
- {
- *s++ = ' ';
- ptr += 5;
- }
- else if (strncasecmp(ptr, "copy;", 5) == 0)
- {
- *s++ = '\251';
- ptr += 5;
- }
- else if (strncasecmp(ptr, "reg;", 4) == 0)
- {
- *s++ = '\256';
- ptr += 4;
- }
- else if (strncasecmp(ptr, "quot;", 5) == 0)
- {
- *s++ = '\"';
- ptr += 5;
+ int qch = quote_char(ptr);
+
+ if (qch < 0)
+ *s++ = '&';
+ else {
+ *s++ = qch;
+ ptr = strchr(ptr, ';') + 1;
}
if ((size + 2) > hh)
@@ -1318,40 +1292,13 @@ Fl_Help_View::format()
{
ptr ++;
- if (strncasecmp(ptr, "amp;", 4) == 0)
- {
- *s++ = '&';
- ptr += 4;
- }
- else if (strncasecmp(ptr, "lt;", 3) == 0)
- {
- *s++ = '<';
- ptr += 3;
- }
- else if (strncasecmp(ptr, "gt;", 3) == 0)
- {
- *s++ = '>';
- ptr += 3;
- }
- else if (strncasecmp(ptr, "nbsp;", 5) == 0)
- {
- *s++ = '\240';
- ptr += 5;
- }
- else if (strncasecmp(ptr, "copy;", 5) == 0)
- {
- *s++ = '\251';
- ptr += 5;
- }
- else if (strncasecmp(ptr, "reg;", 4) == 0)
- {
- *s++ = '\256';
- ptr += 4;
- }
- else if (strncasecmp(ptr, "quot;", 5) == 0)
- {
- *s++ = '\"';
- ptr += 5;
+ int qch = quote_char(ptr);
+
+ if (qch < 0)
+ *s++ = '&';
+ else {
+ *s++ = qch;
+ ptr = strchr(ptr, ';') + 1;
}
if ((size + 2) > hh)
@@ -1763,40 +1710,13 @@ Fl_Help_View::format_table(int *table_width, // O - Total table width
{
ptr ++;
- if (strncasecmp(ptr, "amp;", 4) == 0)
- {
- *s++ = '&';
- ptr += 4;
- }
- else if (strncasecmp(ptr, "lt;", 3) == 0)
- {
- *s++ = '<';
- ptr += 3;
- }
- else if (strncasecmp(ptr, "gt;", 3) == 0)
- {
- *s++ = '>';
- ptr += 3;
- }
- else if (strncasecmp(ptr, "nbsp;", 5) == 0)
- {
- *s++ = '\240';
- ptr += 5;
- }
- else if (strncasecmp(ptr, "copy;", 5) == 0)
- {
- *s++ = '\251';
- ptr += 5;
- }
- else if (strncasecmp(ptr, "reg;", 4) == 0)
- {
- *s++ = '\256';
- ptr += 4;
- }
- else if (strncasecmp(ptr, "quot;", 5) == 0)
- {
- *s++ = '\"';
- ptr += 5;
+ int qch = quote_char(ptr);
+
+ if (qch < 0)
+ *s++ = '&';
+ else {
+ *s++ = qch;
+ ptr = strchr(ptr, ';') + 1;
}
}
else
@@ -2475,6 +2395,132 @@ Fl_Help_View::compare_blocks(const void *a, // I - First block
//
+// 'quote_char()' - Return the character code associated with a quoted char.
+//
+
+static int // O - Code or -1 on error
+quote_char(const char *p) { // I - Quoted string
+ int i; // Looping var
+ static struct {
+ const char *name;
+ int namelen;
+ int code;
+ } *nameptr, // Pointer into name array
+ names[] = { // Quoting names
+ { "Aacute;", 7, 193 },
+ { "aacute;", 7, 225 },
+ { "Acirc;", 6, 194 },
+ { "acirc;", 6, 226 },
+ { "acute;", 6, 180 },
+ { "AElig;", 6, 198 },
+ { "aelig;", 6, 230 },
+ { "Agrave;", 7, 192 },
+ { "agrave;", 7, 224 },
+ { "amp;", 4, '&' },
+ { "Aring;", 6, 197 },
+ { "aring;", 6, 229 },
+ { "Atilde;", 7, 195 },
+ { "atilde;", 7, 227 },
+ { "Auml;", 5, 196 },
+ { "auml;", 5, 228 },
+ { "brvbar;", 7, 166 },
+ { "Ccedil;", 7, 199 },
+ { "ccedil;", 7, 231 },
+ { "cedil;", 6, 184 },
+ { "cent;", 5, 162 },
+ { "copy;", 5, 169 },
+ { "curren;", 7, 164 },
+ { "deg;", 4, 176 },
+ { "divide;", 7, 247 },
+ { "Eacute;", 7, 201 },
+ { "eacute;", 7, 233 },
+ { "Ecirc;", 6, 202 },
+ { "ecirc;", 6, 234 },
+ { "Egrave;", 7, 200 },
+ { "egrave;", 7, 232 },
+ { "ETH;", 4, 208 },
+ { "eth;", 4, 240 },
+ { "Euml;", 5, 203 },
+ { "euml;", 5, 235 },
+ { "frac12;", 7, 189 },
+ { "frac14;", 7, 188 },
+ { "frac34;", 7, 190 },
+ { "gt;", 3, '>' },
+ { "Iacute;", 7, 205 },
+ { "iacute;", 7, 237 },
+ { "Icirc;", 6, 206 },
+ { "icirc;", 6, 238 },
+ { "iexcl;", 6, 161 },
+ { "Igrave;", 7, 204 },
+ { "igrave;", 7, 236 },
+ { "iquest;", 7, 191 },
+ { "Iuml;", 5, 207 },
+ { "iuml;", 5, 239 },
+ { "laquo;", 6, 171 },
+ { "lt;", 3, '<' },
+ { "macr;", 5, 175 },
+ { "micro;", 6, 181 },
+ { "middot;", 7, 183 },
+ { "nbsp;", 5, ' ' },
+ { "not;", 4, 172 },
+ { "Ntilde;", 7, 209 },
+ { "ntilde;", 7, 241 },
+ { "Oacute;", 7, 211 },
+ { "oacute;", 7, 243 },
+ { "Ocirc;", 6, 212 },
+ { "ocirc;", 6, 244 },
+ { "Ograve;", 7, 210 },
+ { "ograve;", 7, 242 },
+ { "ordf;", 5, 170 },
+ { "ordm;", 5, 186 },
+ { "Oslash;", 7, 216 },
+ { "oslash;", 7, 248 },
+ { "Otilde;", 7, 213 },
+ { "otilde;", 7, 245 },
+ { "Ouml;", 5, 214 },
+ { "ouml;", 5, 246 },
+ { "para;", 5, 182 },
+ { "plusmn;", 7, 177 },
+ { "pound;", 6, 163 },
+ { "quot;", 5, '\"' },
+ { "raquo;", 6, 187 },
+ { "reg;", 4, 174 },
+ { "sect;", 5, 167 },
+ { "shy;", 4, 173 },
+ { "sup1;", 5, 185 },
+ { "sup2;", 5, 178 },
+ { "sup3;", 5, 179 },
+ { "szlig;", 6, 223 },
+ { "THORN;", 6, 222 },
+ { "thorn;", 6, 254 },
+ { "times;", 6, 215 },
+ { "Uacute;", 7, 218 },
+ { "uacute;", 7, 250 },
+ { "Ucirc;", 6, 219 },
+ { "ucirc;", 6, 251 },
+ { "Ugrave;", 7, 217 },
+ { "ugrave;", 7, 249 },
+ { "uml;", 4, 168 },
+ { "Uuml;", 5, 220 },
+ { "uuml;", 5, 252 },
+ { "Yacute;", 7, 221 },
+ { "yacute;", 7, 253 },
+ { "yen;", 4, 165 },
+ { "yuml;", 5, 255 }
+ };
+
+
+ if (isdigit(*p)) return atoi(p);
+
+ for (i = (int)(sizeof(names) / sizeof(names[0])), nameptr = names; i > 0; i --, nameptr ++)
+ if (strncmp(p, nameptr->name, nameptr->namelen) == 0)
+ return nameptr->code;
+
+ return -1;
+}
+
+
+//
// 'scrollbar_callback()' - A callback for the scrollbar.
//
@@ -2497,5 +2543,5 @@ hscrollbar_callback(Fl_Widget *s, void *)
//
-// End of "$Id: Fl_Help_View.cxx,v 1.1.2.15 2001/11/25 16:38:11 easysw Exp $".
+// End of "$Id: Fl_Help_View.cxx,v 1.1.2.16 2001/11/26 20:13:29 easysw Exp $".
//
diff --git a/src/fl_set_fonts.cxx b/src/fl_set_fonts.cxx
index 8ca14a978..a5c30dcfd 100644
--- a/src/fl_set_fonts.cxx
+++ b/src/fl_set_fonts.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_set_fonts.cxx,v 1.6.2.5 2001/01/22 15:13:41 easysw Exp $"
+// "$Id: fl_set_fonts.cxx,v 1.6.2.5.2.1 2001/11/26 20:13:29 easysw Exp $"
//
// More font utilities for the Fast Light Tool Kit (FLTK).
//
@@ -93,7 +93,10 @@ static int use_registry(const char *p) {
// turn a stored (with *'s) X font name into a pretty name:
const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
const char* p = fl_fonts[fnum].name;
- if (!p) return "";
+ if (!p) {
+ if (ap) *ap = 0;
+ return "";
+ }
static char *buffer; if (!buffer) buffer = new char[128];
char *o = buffer;
@@ -118,7 +121,10 @@ const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
// get the family:
const char *x = fl_font_word(p,2); if (*x) x++; if (*x=='*') x++;
- if (!*x) return p;
+ if (!*x) {
+ if (ap) *ap = 0;
+ return p;
+ }
const char *e = fl_font_word(x,1);
strncpy(o,x,e-x); o += e-x;
@@ -329,5 +335,5 @@ int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
#endif
//
-// End of "$Id: fl_set_fonts.cxx,v 1.6.2.5 2001/01/22 15:13:41 easysw Exp $".
+// End of "$Id: fl_set_fonts.cxx,v 1.6.2.5.2.1 2001/11/26 20:13:29 easysw Exp $".
//
diff --git a/src/fl_set_fonts_win32.cxx b/src/fl_set_fonts_win32.cxx
index b6cc11f73..b99e00d00 100755
--- a/src/fl_set_fonts_win32.cxx
+++ b/src/fl_set_fonts_win32.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5 2001/01/22 15:13:41 easysw Exp $"
+// "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5.2.1 2001/11/26 20:13:29 easysw Exp $"
//
// WIN32 font utilities for the Fast Light Tool Kit (FLTK).
//
@@ -16,7 +16,7 @@
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the Free Software
+// License along with this7 library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
@@ -46,6 +46,7 @@ const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
case 'P': type = FL_BOLD | FL_ITALIC; break;
default: type = 0; break;
}
+ if (ap) *ap = type;
if (!type) return p+1;
static char *buffer; if (!buffer) buffer = new char[128];
strcpy(buffer, p+1);
@@ -90,5 +91,5 @@ int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
}
//
-// End of "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5 2001/01/22 15:13:41 easysw Exp $".
+// End of "$Id: fl_set_fonts_win32.cxx,v 1.5.2.5.2.1 2001/11/26 20:13:29 easysw Exp $".
//
diff --git a/src/scandir_win32.c b/src/scandir_win32.c
index fe8182700..65f02346d 100644
--- a/src/scandir_win32.c
+++ b/src/scandir_win32.c
@@ -1,33 +1,32 @@
-//
-// "$Id: scandir_win32.c,v 1.11.2.4 2001/01/22 15:13:41 easysw Exp $"
-//
-// WIN32 scandir function for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2001 by Bill Spitzak and others.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Library General Public
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Library General Public License for more details.
-//
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-//
-// Please report all bugs and problems to "fltk-bugs@fltk.org".
-//
+/*
+ * "$Id: scandir_win32.c,v 1.11.2.4.2.1 2001/11/26 20:13:29 easysw Exp $"
+ *
+ * WIN32 scandir function for the Fast Light Tool Kit (FLTK).
+ *
+ * Copyright 1998-2001 by Bill Spitzak and others.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ * Please report all bugs and problems to "fltk-bugs@fltk.org".
+ */
#ifndef __CYGWIN__
-// Emulation of posix scandir() call
+/* Emulation of posix scandir() call */
-#include <config.h>
-#include <string.h>
+#include "flstring.h"
#include <windows.h>
#include <stdlib.h>
@@ -46,6 +45,9 @@ int scandir(const char *dirname, struct dirent ***namelist,
len = strlen(dirname);
findIn = malloc(len+5);
+
+ if (!findIn) return 0;
+
strcpy(findIn, dirname);
for (d = findIn; *d; d++) if (*d=='/') *d='\\';
if ((len==0)) { strcpy(findIn, ".\\*"); }
@@ -54,9 +56,10 @@ int scandir(const char *dirname, struct dirent ***namelist,
if ((len>1) && (d[-1]=='.') && (d[-2]=='\\')) { d[-1] = '*'; }
if ((h=FindFirstFile(findIn, &find))==INVALID_HANDLE_VALUE) {
+ free(findIn);
ret = GetLastError();
if (ret != ERROR_NO_MORE_FILES) {
- // TODO: return some error code
+ /* TODO: return some error code */
}
*namelist = dir;
return nDir;
@@ -81,7 +84,7 @@ int scandir(const char *dirname, struct dirent ***namelist,
} while (FindNextFile(h, &find));
ret = GetLastError();
if (ret != ERROR_NO_MORE_FILES) {
- // TODO: return some error code
+ /* TODO: return some error code */
}
FindClose(h);
@@ -100,6 +103,6 @@ int alphasort (struct dirent **a, struct dirent **b) {
#endif
-//
-// End of "$Id: scandir_win32.c,v 1.11.2.4 2001/01/22 15:13:41 easysw Exp $".
-//
+/*
+ * End of "$Id: scandir_win32.c,v 1.11.2.4.2.1 2001/11/26 20:13:29 easysw Exp $".
+ */