Moved strip_whitespace_edges() to pbd/whitespace.h
authorTaybin Rutkin <taybin@taybin.com>
Fri, 13 Jan 2006 19:48:55 +0000 (19:48 +0000)
committerTaybin Rutkin <taybin@taybin.com>
Fri, 13 Jan 2006 19:48:55 +0000 (19:48 +0000)
Gtkmm2ext::Prompter::get_result() calls strip_whitespace_edges(), so you don't have to.
Removed unused/unecessary/forgotten headers from libpbd.

git-svn-id: svn://localhost/trunk/ardour2@270 d708f5d6-7413-0410-9779-e7cbd77b26cf

28 files changed:
gtk2_ardour/audio_time_axis.cc
gtk2_ardour/connection_editor.cc
gtk2_ardour/editor_edit_groups.cc
gtk2_ardour/editor_mouse.cc
gtk2_ardour/editor_selection_list.cc
gtk2_ardour/main.cc
gtk2_ardour/mixer_ui.cc
gtk2_ardour/option_editor.cc
gtk2_ardour/prompter.cc
gtk2_ardour/route_ui.cc
gtk2_ardour/sfdb_ui.cc
gtk2_ardour/utils.cc
gtk2_ardour/utils.h
gtk2_ardour/visual_time_axis.cc
libs/gtkmm2ext/gtkmm2ext/bindable_button.h
libs/gtkmm2ext/gtkmm2ext/prompter.h
libs/gtkmm2ext/prompter.cc
libs/pbd3/SConscript
libs/pbd3/ftw.cc [deleted file]
libs/pbd3/pbd/ftw.h [deleted file]
libs/pbd3/pbd/irix_platform.h [deleted file]
libs/pbd3/pbd/linux_platform.h [deleted file]
libs/pbd3/pbd/platform.h [deleted file]
libs/pbd3/pbd/platform_factory.h [deleted file]
libs/pbd3/pbd/solaris_platform.h [deleted file]
libs/pbd3/pbd/strsub.h [deleted file]
libs/pbd3/pbd/whitespace.h [new file with mode: 0644]
libs/pbd3/whitespace.cc [new file with mode: 0644]

index 5c05c951b62603c43674d3f6f21cac2e85d98433..2adc56e43f4d3ca60eca8fb7347934c3f565315a 100644 (file)
 
 #include <pbd/error.h>
 #include <pbd/stl_delete.h>
+#include <pbd/whitespace.h>
 
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/selector.h>
+#include <gtkmm2ext/bindable_button.h>
 #include <gtkmm2ext/gtk_ui.h>
+#include <gtkmm2ext/selector.h>
 #include <gtkmm2ext/stop_signal.h>
-#include <gtkmm2ext/bindable_button.h>
+#include <gtkmm2ext/utils.h>
 
-#include <ardour/session.h>
-#include <ardour/session_playlist.h>
 #include <ardour/audioplaylist.h>
 #include <ardour/diskstream.h>
-#include <ardour/utils.h>
-#include <ardour/playlist.h>
-#include <ardour/ladspa_plugin.h>
 #include <ardour/insert.h>
+#include <ardour/ladspa_plugin.h>
 #include <ardour/location.h>
 #include <ardour/panner.h>
+#include <ardour/playlist.h>
+#include <ardour/session.h>
+#include <ardour/session_playlist.h>
+#include <ardour/utils.h>
 
 #include "ardour_ui.h"
-#include "public_editor.h"
 #include "audio_time_axis.h"
-#include "streamview.h"
-#include "simplerect.h"
-#include "playlist_selector.h"
-#include "plugin_selector.h"
-#include "plugin_ui.h"
-#include "regionview.h"
 #include "automation_gain_line.h"
 #include "automation_pan_line.h"
 #include "automation_time_axis.h"
-#include "redirect_automation_time_axis.h"
+#include "canvas_impl.h"
+#include "crossfade_view.h"
+#include "enums.h"
 #include "gain_automation_time_axis.h"
+#include "gui_thread.h"
+#include "keyboard.h"
 #include "pan_automation_time_axis.h"
+#include "playlist_selector.h"
+#include "plugin_selector.h"
+#include "plugin_ui.h"
+#include "point_selection.h"
+#include "prompter.h"
+#include "public_editor.h"
 #include "redirect_automation_line.h"
+#include "redirect_automation_time_axis.h"
+#include "regionview.h"
+#include "rgb_macros.h"
 #include "selection.h"
-#include "point_selection.h"
-#include "enums.h"
+#include "simplerect.h"
+#include "streamview.h"
 #include "utils.h"
-#include "keyboard.h"
-#include "rgb_macros.h"
-#include "prompter.h"
-#include "crossfade_view.h"
-#include "gui_thread.h"
-#include "canvas_impl.h"
 
 #include <ardour/audio_track.h>
 
@@ -834,7 +835,7 @@ AudioTimeAxisView::rename_current_playlist ()
        prompter.set_initial_text (pl->name());
 
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                prompter.get_result (name);
                pl->set_name (name);
                break;
@@ -873,7 +874,7 @@ AudioTimeAxisView::use_copy_playlist ()
        prompter.show_all ();
 
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                prompter.get_result (name);
                ds->use_copy_playlist ();
                pl = ds->playlist();
@@ -903,7 +904,7 @@ AudioTimeAxisView::use_new_playlist ()
        prompter.set_initial_text (new_name);
        
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                prompter.get_result (name);
                ds->use_new_playlist ();
                pl = ds->playlist();
index 938be6763e6d85396140cdb12abc65ef72fd186b..596029eeb3f37fd5155536b4ba7b8c7a7ae16ac6 100644 (file)
@@ -658,7 +658,7 @@ ConnectionEditor::new_connection (bool for_input)
        prompter.done.connect (Gtk::Main::quit.slot());
 
        switch (prompter.run()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                prompter.get_result (name);
                push_at_front = true;
                if (name.length()) {
index d66b313ac046fba4eb7ae0988a0ba436a92a09df..d9728345c8f97a4d1274846c20e8409f28bbd5cc 100644 (file)
@@ -88,7 +88,7 @@ Editor::new_edit_group ()
        prompter.show_all ();
 
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                prompter.get_result (result);
                if (result.length()) {
                        session->add_edit_group (result);
index 64d00f56abde860886e2c9de472c58bbcf53a382..c92eadc284b8b099ed4cb4e7d956a3b30dd5f79b 100644 (file)
@@ -4464,7 +4464,7 @@ Editor::mouse_rename_region (ArdourCanvas::Item* item, GdkEvent* event)
        prompter.set_initial_text (clicked_regionview->region.name());
        prompter.show_all ();
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                string str;
                prompter.get_result(str);
                if (str.length()) {
index 64e184151ee201f7e190c55a786f68e1453419d1..90ff2027b7eec9da1daab7fbc59ec78467c56c30 100644 (file)
@@ -112,7 +112,7 @@ Editor::name_selection ()
        p.show_all ();
 
        switch (p.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
          string name;
                p.get_result (name);
                if (name.length()) {
index 3dc751de880d5687ad2d8fc36cc9bd88f758bc07..183729d960df5d0c9bbcc34eeebf2655f4e0c15d 100644 (file)
@@ -31,8 +31,6 @@
 
 #include <pbd/error.h>
 #include <pbd/textreceiver.h>
-#include <pbd/platform.h>
-#include <pbd/platform_factory.h>
 #include <pbd/failed_constructor.h>
 #include <pbd/pthread_utils.h>
 
index cdd20e55cfb0a2ea1b5c9d81f4f6196279b64011..317f3831707c4e69df9ba3690c0d1f2e175da7d7 100644 (file)
@@ -690,7 +690,7 @@ Mixer_UI::new_mix_group ()
        prompter.show_all ();
        
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                prompter.get_result (result);
                if (result.length()) {
                        session->add_mix_group (result);
index c31fdb98f540e6a1c5cb626d830999b746a333f4..491579b286f38841e33dd6054ad06f6280752a71 100644 (file)
@@ -18,6 +18,8 @@
     $Id$
 */
 
+#include <pbd/whitespace.h>
+
 #include <ardour/session.h>
 #include <ardour/audioengine.h>
 #include <ardour/configuration.h>
index 08f089f404c06327dd452903ff9a67c175f221cd..a10bd92f72a4c1ae9ba9fcfbc2e3d5b18e8f7f0d 100644 (file)
@@ -19,9 +19,6 @@
 */
 
 #include "prompter.h"
-#include "ardour_ui.h"
-
-using namespace sigc;
 
 ArdourPrompter::ArdourPrompter (bool modal)
        : Gtkmm2ext::Prompter (modal)
index 82b6cac3bdc18635f4e28164d0e9bc10d1052a01..ed93c55811dc5aedf0943d0621fa54f8f58134b9 100644 (file)
@@ -740,10 +740,9 @@ RouteUI::route_rename ()
 
        switch (name_prompter.run ()) {
 
-       case GTK_RESPONSE_ACCEPT:
-               name_prompter.get_result (result);
-               if (result.length()) {
-                       strip_whitespace_edges (result);
+       case Gtk::RESPONSE_ACCEPT:
+        name_prompter.get_result (result);
+        if (result.length()) {
                        _route.set_name (result, this);
                }       
                break;
index c79ad5c12831025ec9b7102f706c3201bbbae3a7..891a8dad19da2b15efeee314848fbc0b36ac4f22 100644 (file)
@@ -20,7 +20,7 @@
 */
 
 #include <map>
-#include <errno.h>
+#include <cerrno>
 
 #include <sndfile.h>
 
@@ -34,8 +34,9 @@
 #include <ardour/sndfile_helpers.h>
 #include <ardour/sndfilesource.h>
 
-#include "sfdb_ui.h"
 #include "gui_thread.h"
+#include "prompter.h"
+#include "sfdb_ui.h"
 
 #include "i18n.h"
 
@@ -235,7 +236,24 @@ SoundFileBox::stop_btn_clicked ()
 
 void
 SoundFileBox::add_field_clicked ()
-{}
+{
+    ArdourPrompter prompter (true);
+    string name;
+
+    prompter.set_prompt (_("Name for field"));
+
+    switch (prompter.run ()) {
+               case Gtk::RESPONSE_ACCEPT:
+                       cout << name << endl;
+               prompter.get_result (name);
+                       Library->add_field (name);
+                       Library->save_changes ();
+               break;
+
+           default:
+               break;
+    }
+}
 
 void
 SoundFileBox::remove_field_clicked ()
index 1c4fc2a4526d40fbb590d28d9b5735ead616add7..acc9574a182a2694483c7420f0088649c460af81 100644 (file)
@@ -147,32 +147,6 @@ atof (const string& s)
        return atof (s.c_str());
 }
 
-void
-strip_whitespace_edges (string& str)
-{
-       string::size_type i;
-       string::size_type len;
-       string::size_type s;
-
-       len = str.length();
-
-       for (i = 0; i < len; ++i) {
-               if (isgraph (str[i])) {
-                       break;
-               }
-       }
-
-       s = i;
-
-       for (i = len - 1; i >= 0; --i) {
-               if (isgraph (str[i])) {
-                       break;
-               }
-       }
-
-       str = str.substr (s, (i - s) + 1);
-}
-
 vector<string>
 internationalize (const char **array)
 {
index 221329727e0512e393d0b5029459b44080856168..b6f3e0563a0304841f52ce2d480be71a1e4c7111 100644 (file)
@@ -55,7 +55,6 @@ std::string fit_to_pixels (const std::string &, int pixel_width, const std::stri
 
 int    atoi (const std::string&);
 double atof (const std::string&);
-void   strip_whitespace_edges (std::string& str);
 void   url_decode (std::string&);
 gint   just_hide_it (GdkEventAny*, Gtk::Window*);
 void   allow_keyboard_focus (bool);
index 9782a8c9f6f8e2cb6c3cf6a663f7167bddd4111f..b282b239e96062c6e8780b5340618ee62df07d38 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <pbd/error.h>
 #include <pbd/stl_delete.h>
+#include <pbd/whitespace.h>
 
 #include <gtkmm2ext/utils.h>
 #include <gtkmm2ext/selector.h>
@@ -361,7 +362,7 @@ VisualTimeAxis::start_time_axis_rename()
        name_prompter->show_all() ;
 
        switch (name_prompter->run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
          string result;
          name_prompter->get_result (result);
          if (editor.get_named_time_axis(result) != 0) {
index 4b97403eee558461bab2f67d34c538f3234a292f..7400cf15d092416362d76a8f9f4f9a549961037a 100644 (file)
 #ifndef __pbd_gtkmm_bindable_button_h__
 #define __pbd_gtkmm_bindable_button_h__
 
+#include <string>
+
 #include <gtkmm2ext/stateful_button.h>
 #include <gtkmm2ext/popup.h>
 
-
 namespace MIDI {
        class Controllable;
 }
 
-
 namespace Gtkmm2ext {
 
 class BindableToggleButton : public Gtk::ToggleButton
@@ -41,7 +41,7 @@ class BindableToggleButton : public Gtk::ToggleButton
        //- You won't be able
        //- to add a widget in this button since it already has a {\class Gtk_Label}
        //- in it.
-       explicit BindableToggleButton(MIDI::Controllable *, const string &label);
+       explicit BindableToggleButton(MIDI::Controllable *, const std::string &label);
 
        virtual ~BindableToggleButton() {}
        
index 8d092f6992603b2c8fa4a60971252d70530b39ff..795d982295f818ba48284f0eb709e381d6c8ff90 100644 (file)
@@ -53,7 +53,7 @@ class Prompter : public Gtk::Dialog
 
        void change_labels (std::string ok, std::string cancel);
 
-       void get_result (std::string &str);
+       void get_result (std::string &str, bool strip=true);
 
   protected:
        Gtk::Entry& the_entry() { return entry; }
index 5dd3367380dd3dcfd17a99964520aad49991581e..f61d0930833bb61a42d2410e63fdf12df8924053 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <string>
 
+#include <pbd/whitespace.h>
+
 #include <gtkmm/stock.h>
 #include <gtkmm2ext/prompter.h>
 
@@ -74,8 +76,10 @@ Prompter::change_labels (string okstr, string cancelstr)
 }
 
 void
-Prompter::get_result (string &str)
-
+Prompter::get_result (string &str, bool strip)
 {
        str = entry.get_text ();
+       if (strip) {
+               strip_whitespace_edges (str);
+       }
 }
index 47aff4c0083723dcab3c2a463be3a7ee8c40ef51..f4b7bf24a8a2cbed0d5ef4b717fb8ab274a4ca72 100644 (file)
@@ -7,13 +7,12 @@ Import('env libraries')
 pbd3 = env.Copy()
 
 domain = 'libpbd'
-pbd3.Append(DOMAIN=domain,MAJOR=3,MINOR=1,MICRO=0)
+pbd3.Append(DOMAIN=domain,MAJOR=3,MINOR=2,MICRO=0)
 
 pbd3_files = Split("""
 basename.cc
 dirname.cc
 dmalloc.cc
-ftw.cc
 mountpoint.cc
 pathscanner.cc
 pool.cc
@@ -25,6 +24,7 @@ transmitter.cc
 undo.cc
 unescape.cc
 version.cc
+whitespace.cc
 xml++.cc
 """)
 
diff --git a/libs/pbd3/ftw.cc b/libs/pbd3/ftw.cc
deleted file mode 100644 (file)
index ea7162c..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
-   Copyright (c) 2003 by Joel Baker.
-   All rights reserved.
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-
-   1. Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-   2. Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in the
-      documentation and/or other materials provided with the distribution.
-   3. Neither the name of the Author nor the names of any contributors
-      may be used to endorse or promote products derived from this software
-      without specific prior written permission.
-                           
-   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-   SUCH DAMAGE.
-*/
-
-#include <string>
-#include <sys/types.h> /* Because fts(3) says so */
-#include <sys/stat.h>
-#include <fts.h>
-#include <alloca.h>
-
-#include <unistd.h> /* We want strcpy */
-
-#include <cerrno> /* Because errno is our friend */
-
-#ifndef __USE_XOPEN_EXTENDED /* We need nftw values, since we implement it */
-#define __USE_XOPEN_EXTENDED
-#endif
-
-#include <pbd/ftw.h>
-
-/* I like symbolic values - this is only used in this file. */
-
-enum __ftw_modes {
-    MODE_FTW,
-    MODE_NFTW
-};
-
-/* Prototype this so that we can have it later */
-
-static int __ftw_core(const char *, void*, int, int, enum __ftw_modes);
-
-/*
- * The external function calls are really just wrappers around __ftw_core,
- * since the work they do is 90% the same.
- */
-
-int ftw (const char *dir, __ftw_func_t func, int descr) {
-    return __ftw_core(dir, (void*)func, descr, 0, MODE_FTW);
-}
-
-int nftw (const char *dir, __nftw_func_t func, int descr, int flags) {
-    return __ftw_core(dir, (void*)func, descr, flags, MODE_NFTW);
-}
-
-/*
-typedef int (*__ftw_func_t) \
-    (const char *file, const struct stat status, int flag);
-typedef int (*__nftw_func_t) \
-    (const char *file, const struct stat status, int flag, struct FTW detail);
-*/
-
-static int __ftw_core(const char *dir, void* func, int descr, int flags,
-                      enum __ftw_modes mode) {
-    FTS *hierarchy = 0;
-    FTSENT *entry = 0;
-    int fts_options;
-    char *paths[2];
-    int ftw_flag = 0, func_ret = 0;
-    struct FTW ftw_st;
-    int skip_entry;
-    __ftw_func_t ftw_func;
-    __nftw_func_t nftw_func;
-
-    /* We need at least one descriptor to call fts */
-
-    if (descr < 1) {
-        errno = EINVAL;
-        return -1;
-    }
-
-    /* Decide which mode we're running in, and set the FTS options suitably. */
-
-    if (MODE_NFTW == mode) { /* NFTW mode, with all the bells and whistles. */
-        fts_options = (flags & FTW_PHYS) ? FTS_PHYSICAL : FTS_LOGICAL;
-        fts_options |= (flags & FTW_CHDIR) ? FTS_NOCHDIR : 0;
-        fts_options |= (flags & FTW_MOUNT) ? FTS_XDEV : 0;
-    } else { /* We must be in FTW mode. Nothing else makes sense. */
-        fts_options = FTS_LOGICAL;
-    }
-
-    /* FTW gets a const char *, but FTS expects a null-term array of them. */
-
-    if (!(paths[0] = (char*) alloca(strlen(dir) + 1))) {
-        errno = ENOMEM; /* This is stack... we probably just died anyway. */
-        return -1;
-    }
-
-    strcpy(paths[0], dir);
-    paths[1] = 0; /* null */
-
-    /* Open the file hierarchy. */
-
-    if (!(hierarchy = fts_open(paths, fts_options, 0))) {
-        if (EACCES == errno) {
-            return 0;
-        } else {
-            return -1;
-        }
-    }
-
-    /* The main loop. Is it not nifty? Worship the loop. */
-
-       bool first = true;
-    while ((entry = fts_read(hierarchy))) {
-        skip_entry = 0;
-               std::string path_name = entry->fts_path;
-
-        switch (entry->fts_info) {
-
-            case FTS_D:
-                if ((MODE_NFTW != mode) || !(flags & FTW_DEPTH)) {
-                                       if (first) {
-                                               path_name = path_name.substr(0, path_name.size() - 1);
-                                               first = false;
-                                       }
-                    ftw_flag = FTW_D;
-                } else {
-                    skip_entry = 1;
-                }
-                break;
-
-            case FTS_DNR:
-                ftw_flag = FTW_DNR;
-                break;
-
-            case FTS_F:
-                ftw_flag = FTW_F;
-                break;
-
-            case FTS_SL:
-                ftw_flag = FTW_SL;
-                break;
-
-            case FTS_NS:
-                ftw_flag = FTW_NS;
-                break;
-
-            /* Values that should only occur in nftw mode */
-
-            case FTS_SLNONE:
-                if (MODE_NFTW == mode) {
-                    ftw_flag = FTW_SLN;
-                } else {
-                    ftw_flag = FTW_SL;
-                }
-                break;
-
-            case FTS_DP:
-                if ((MODE_NFTW == mode) && (flags & FTW_DEPTH)) {
-                    ftw_flag = FTW_D;
-                } else {
-                    skip_entry = 1;
-                }
-                break;
-
-            default:
-                /* I'm not sure this is right, but we don't have a valid FTW
-                 * type to call with, so cowardice seems the better part of
-                 * guessing.
-                 */
-
-                skip_entry = 1;
-        }
-
-        if (MODE_FTW == mode) {
-            ftw_func = (__ftw_func_t) func;
-            func_ret = (*ftw_func) 
-                (path_name.c_str(), entry->fts_statp, ftw_flag);
-        } else if (MODE_NFTW == mode) {
-            ftw_st.base = (entry->fts_pathlen - entry->fts_namelen);
-            ftw_st.level = entry->fts_level;
-
-            nftw_func = (__nftw_func_t) func;
-            func_ret = (*nftw_func)
-                (path_name.c_str(), entry->fts_statp, ftw_flag, &ftw_st);
-        }
-
-        if (0 != func_ret) {
-            return func_ret;
-        }
-    }
-
-    if (0 != errno) { /* fts_read returned NULL, and set errno - bail */
-        return -1;
-    }
-
-    /* The janitors will be upset if we don't clean up after ourselves. */
-
-    if (0 != fts_close(hierarchy)) {
-        return -1;
-    }
-
-    return 0;
-}
diff --git a/libs/pbd3/pbd/ftw.h b/libs/pbd3/pbd/ftw.h
deleted file mode 100644 (file)
index 9acf8a6..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-   Copyright (c) 2003 by Joel Baker.
-   All rights reserved.
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-
-   1. Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-   2. Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in the
-      documentation and/or other materials provided with the distribution.
-   3. Neither the name of the Author nor the names of any contributors
-      may be used to endorse or promote products derived from this software
-      without specific prior written permission.
-                           
-   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-   SUCH DAMAGE.
-*/
-
-#ifndef _FTW_H
-#define _FTW_H
-
-#include <sys/stat.h>
-
-/* Enumerated values for 'flag' when calling [n]ftw */
-
-enum {
-    FTW_D,   /* Directories */
-    FTW_DNR, /* Unreadable directory */
-    FTW_F,   /* Regular files */
-    FTW_SL,  /* Symbolic link */
-    FTW_NS,  /* stat(2) failed */
-
-#ifdef __USE_XOPEN_EXTENDED /* X/Open */
-
-/* Flags for nftw only */
-
-    FTW_DP, /* Directory, subdirs visited */
-    FTW_SLN, /* Dangling symlink */
-
-#endif /* __USE_XOPEN_EXTENDED */
-};
-
-#ifdef __USE_XOPEN_EXTENDED /* X/Open */
-
-/* Enumerated values for 'flags' when calling nftw */
-
-enum {
-    FTW_CHDIR = 1, /* Do a chdir(2) when entering a directory */
-    FTW_DEPTH = 2, /* Report files first (before directory) */
-    FTW_MOUNT = 4, /* Single filesystem */
-    FTW_PHYS  = 8  /* Physical walk; ignore symlinks */
-};
-
-#define FTW_PHYS FTW_PHYS
-#define FTW_MOUNT FTW_MOUNT
-#define FTW_CHDIR FTW_CHDIR
-#define FTW_DEPTH FTW_DEPTH
-
-/* FTW struct for callbacks from nftw */
-
-struct FTW {
-    int base;
-    int level;
-};
-
-#endif /* __USE_XOPEN_EXTENDED */
-
-/* Typecasts for callback functions */
-
-typedef int (*__ftw_func_t) \
-    (const char *file, const struct stat *status, int flag);
-
-#ifdef __USE_XOPEN_EXTENDED /* X/Open */
-
-typedef int (*__nftw_func_t) \
-    (const char *file, const struct stat *status, int flag, struct FTW *detail);
-
-#endif /* __USE_XOPEN_EXTENDED */
-
-/* ftw: walk a directory tree, calling a function for each element */
-
-extern int ftw (const char *dir, __ftw_func_t func, int descr);
-
-#ifdef __USE_XOPEN_EXTENDED /* X/Open */
-
-/* nftw: walk a directory tree, calling a function for each element; much
- * like ftw, but with behavior flags and minty freshness.
- */
-
-extern int nftw (const char *dir, __nftw_func_t func, int descr, int flags);
-
-#endif /* __USE_XOPEN_EXTENDED */
-
-#endif /* _FTW_H */
diff --git a/libs/pbd3/pbd/irix_platform.h b/libs/pbd3/pbd/irix_platform.h
deleted file mode 100644 (file)
index f948554..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __irix_platform__
-#define __irix_platform__
-
-#include <pbd/platform.h>
-
-class IrixPlatform : public Platform {
-  public:
-       IrixPlatform () : Platform () {};
-       virtual ~IrixPlatform ();
-
-       virtual int pre_config ();
-       virtual int post_config ();
-       virtual int pre_ui ();
-       virtual int post_ui ();
-       
-       virtual int dsp_startup();
-};
-
-
-#endif // __irix_platform__
diff --git a/libs/pbd3/pbd/linux_platform.h b/libs/pbd3/pbd/linux_platform.h
deleted file mode 100644 (file)
index 74822a9..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-    Copyright (C) 1999 Paul Barton-Davis 
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program 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 General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-    $Id$
-*/
-
-#ifndef __linux_platform_h__
-#define __linux_platform_h__
-
-#include <pbd/platform.h>
-
-class LinuxPlatform : public Platform
-
-{
-  public:
-       LinuxPlatform ();
-       ~LinuxPlatform () {};
-
-       int pre_config ();
-       int post_config ();
-       int pre_ui ();
-       int post_ui ();
-
-       int dsp_startup() { return 0; }
-};
-
-#endif // __linux_platform_h__
diff --git a/libs/pbd3/pbd/platform.h b/libs/pbd3/pbd/platform.h
deleted file mode 100644 (file)
index 761195a..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-    Copyright (C) 1999 Paul Barton-Davis 
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program 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 General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-    $Id$
-*/
-
-#ifndef __qm_platform_h__
-#define __qm_platform_h__
-
-class Platform 
-
-{
-  public:
-       Platform () { 
-               thePlatform = this; 
-       }
-       virtual ~Platform () {}
-
-       virtual int pre_config () { return 0;}
-       virtual int post_config () { return 0;}
-       virtual int pre_ui () { return 0; }
-       virtual int post_ui () { return 0; }
-       virtual int dsp_startup() { return 0; }
-       
-       static Platform *instance() { return thePlatform; }
-
-  private:
-       static Platform *thePlatform;
-};
-
-#endif // __qm_platform_h__
diff --git a/libs/pbd3/pbd/platform_factory.h b/libs/pbd3/pbd/platform_factory.h
deleted file mode 100644 (file)
index d5255ea..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __platform_factory__
-#define __platform_factory__
-
-#include <pbd/platform.h>
-
-class PlatformFactory {
-public:
-       static Platform* create_platform ();
-};
-
-
-#endif // __platform_factory__
diff --git a/libs/pbd3/pbd/solaris_platform.h b/libs/pbd3/pbd/solaris_platform.h
deleted file mode 100644 (file)
index 6f39a77..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-    Copyright (C) 1999 Paul Barton-Davis 
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program 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 General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-    $Id$
-*/
-
-#ifndef __solaris_platform_h__
-#define __solaris_platform_h__
-
-#include <pbd/platform.h>
-
-class SolarisPlatform : public Platform
-{
-  public:
-       SolarisPlatform () : Platform () {};
-       ~SolarisPlatform () {};
-
-       int pre_config ();
-       int post_config ();
-       int pre_ui ();
-       int post_ui ();
-
-       int dsp_startup() { return 0; }
-
-};
-
-#endif // __solaris_platform_h__
diff --git a/libs/pbd3/pbd/strsub.h b/libs/pbd3/pbd/strsub.h
deleted file mode 100644 (file)
index c5bfb1a..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-    Copyright (C) 1998-99 Paul Barton-Davis 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program 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 General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-    $Id$
-*/
-
-#ifndef __libmisc_strsub_h__
-#define __libmisc_strsub_h__
-
-extern char *strsub (char *str, const char *target, const char *replacement);
-
-#endif // __libmisc_strsub_h__
diff --git a/libs/pbd3/pbd/whitespace.h b/libs/pbd3/pbd/whitespace.h
new file mode 100644 (file)
index 0000000..6620a8f
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __pbd_whitespace_h__
+#define __pbd_whitespace_h__
+
+#include <string>
+
+extern void strip_whitespace_edges (std::string& str);
+
+#endif // __pbd_whitespace_h__
diff --git a/libs/pbd3/whitespace.cc b/libs/pbd3/whitespace.cc
new file mode 100644 (file)
index 0000000..7f74940
--- /dev/null
@@ -0,0 +1,30 @@
+#include <pbd/whitespace.h>
+
+using namespace std;
+
+void
+strip_whitespace_edges (string& str)
+{   
+    string::size_type i; 
+    string::size_type len;    
+       string::size_type s;
+                                   
+    len = str.length();
+                                       
+    for (i = 0; i < len; ++i) {
+        if (isgraph (str[i])) {
+            break;
+        }
+    }
+
+    s = i;
+
+    for (i = len - 1; i >= 0; --i) {
+        if (isgraph (str[i])) {
+            break;
+        }
+    }
+
+    str = str.substr (s, (i - s) + 1);
+}
+