Renamed id to _id for ObjC compatibility.
[ardour.git] / libs / pbd / whitespace.cc
1 #include <pbd/whitespace.h>
2
3 using namespace std;
4
5 void
6 strip_whitespace_edges (string& str)
7 {   
8     string::size_type i; 
9     string::size_type len;    
10     string::size_type s;
11                                     
12     len = str.length();
13
14     /* strip front */
15                                         
16     for (i = 0; i < len; ++i) {
17         if (isgraph (str[i])) {
18             break;
19         }
20     }
21
22     /* strip back */
23     
24     if (len > 1) {
25     
26             s = i;
27             i = len - 1;
28             
29             do {
30                     if (isgraph (str[i]) || i == 0) {
31                             break;
32                     }
33
34                     --i;
35
36             } while (true); 
37             
38             str = str.substr (s, (i - s) + 1);
39
40     } else {
41             str = str.substr (s);
42     }
43 }
44