From c90c981570c974935953cc3ee742a4d009c31301 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Wed, 24 Apr 2002 12:14:57 +0000 Subject: [PATCH] Add -g option to fltk-config. Fix NULL filename bug in fl_file_chooser(). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2103 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 4 ++++ documentation/fltk-config.man | 9 +++++++-- fltk-config.in | 11 ++++++++--- src/fl_file_dir.cxx | 26 +++++++++++++++++--------- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index 4037c98a4..2656e8e22 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,9 @@ CHANGES IN FLTK 1.1.0rc1 + - fl_file_chooser() could cause a segfault when passed a + NULL filename parameter in some situations. + - Added a "-g" option to fltk-config to support quick + compiling with debugging enabled. - Fixed redraw problem with Fl_Input and anti-aliased text. - Added threading support for MacOS X and Darwin. diff --git a/documentation/fltk-config.man b/documentation/fltk-config.man index 9c1fb7f41..9a19f8cd4 100644 --- a/documentation/fltk-config.man +++ b/documentation/fltk-config.man @@ -1,4 +1,4 @@ -.TH fltk-config 1 "Fast Light Tool Kit" "6 January 2002" +.TH fltk-config 1 "Fast Light Tool Kit" "24 April 2002" .SH NAME fltk-config \- script to get information about the installed version of fltk. .sp @@ -9,7 +9,7 @@ fltk-config [ --prefix .I [=DIR] ] [ --version ] [ --api-version ] [ --use-gl ] [ --use-images ] [ --use-glut ] [ --cflags ] [ --cxxflags ] [ --ldflags ] [ --ldstaticflags ] [ --libs ] -[ --compile +[ -g ] [ --compile .I program.cxx ] [ --post .I program @@ -38,6 +38,11 @@ files that use FLTK. Compiles the source file \fIprogram.cxx\fR into \fIprogram\fR. This option implies "--post \fIprogram\fR". .TP 5 +-g +.br +Enables debugging information when compiling with the \fI--compile\fR +option. +.TP 5 --ldflags .br Displays the linker options to use when linking a FLTK diff --git a/fltk-config.in b/fltk-config.in index 4cf8949d8..eb40f8b5d 100755 --- a/fltk-config.in +++ b/fltk-config.in @@ -1,6 +1,6 @@ #! /bin/sh # -# "$Id: fltk-config.in,v 1.12.2.9 2002/03/25 21:39:01 easysw Exp $" +# "$Id: fltk-config.in,v 1.12.2.10 2002/04/24 12:14:57 easysw Exp $" # # FLTK configuration utility. # @@ -85,6 +85,7 @@ Options telling what information we request: [--libs] return FLTK libraries full path for dependencies Option to compile and link an application: + [-g] compile the program with debugging information [--compile program.cxx] [--post program] " @@ -97,6 +98,7 @@ fi no_plugins=no compile= post= +debug= # Parse command line options while test $# -gt 0 @@ -153,6 +155,9 @@ do --libs) echo_libs=yes ;; + -g) + debug=-g + ;; --compile) compile=$2 post=$2 @@ -230,8 +235,8 @@ if test -n "$compile"; then post=$prog - echo $CXX $CXXFLAGS -o $prog $compile $LDSTATIC - $CXX $CXXFLAGS -o $prog $compile $LDSTATIC + echo $CXX $CXXFLAGS $debug -o $prog $compile $LDSTATIC + $CXX $CXXFLAGS $debug -o $prog $compile $LDSTATIC fi if test -n "$post" -a "$POSTBUILD" != ":"; then diff --git a/src/fl_file_dir.cxx b/src/fl_file_dir.cxx index 714d0e7f4..56fbf9cfe 100644 --- a/src/fl_file_dir.cxx +++ b/src/fl_file_dir.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_file_dir.cxx,v 1.1.2.7 2002/03/25 21:08:42 easysw Exp $" +// "$Id: fl_file_dir.cxx,v 1.1.2.8 2002/04/24 12:14:57 easysw Exp $" // // File chooser widget for the Fast Light Tool Kit (FLTK). // @@ -55,16 +55,24 @@ char* fl_file_chooser(const char* message, const char* pat, const char* fname) } else { if (!fname || !*fname) { if (fc->filter() != pat && (!pat || !fc->filter() || - strcmp(pat, fc->filter()))) { + strcmp(pat, fc->filter())) && fc->value()) { // if pattern is different, remove name but leave old directory: - char* p = (char *)fc->value(); - const char* q = fl_filename_name(p); - int i; + strncpy(retname, fc->value(), sizeof(retname) - 1); + retname[sizeof(retname) - 1] = '\0'; - if (q == NULL) i = 0; - else i = strlen(q); + char *p = strrchr(retname, '/'); - p[i] = 0; + if (p) { + // If the filename is "/foo", then the directory will be "/", not + // ""... + if (p == retname) + retname[1] = '\0'; + else + *p = '\0'; + } + + // Set the directory... + fc->directory(retname); } } else @@ -119,5 +127,5 @@ char* fl_dir_chooser(const char* message, const char* fname) // -// End of "$Id: fl_file_dir.cxx,v 1.1.2.7 2002/03/25 21:08:42 easysw Exp $". +// End of "$Id: fl_file_dir.cxx,v 1.1.2.8 2002/04/24 12:14:57 easysw Exp $". //