Merge lp:~mordred/drizzle/bug667006 into lp:drizzle/7.0

Proposed by Monty Taylor
Status: Merged
Approved by: Brian Aker
Approved revision: 1908
Merged at revision: 1919
Proposed branch: lp:~mordred/drizzle/bug667006
Merge into: lp:drizzle/7.0
Diff against target: 93 lines (+30/-20)
2 files modified
drizzled/module/loader.cc (+29/-19)
plugin/utility_dictionary/tests/t/master.opt (+1/-1)
To merge this branch: bzr merge lp:~mordred/drizzle/bug667006
Reviewer Review Type Date Requested Status
Drizzle Developers Pending
Review via email: mp+40372@code.launchpad.net

Description of the change

Makes the plugin-add option a little less brittle.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/module/loader.cc'
2--- drizzled/module/loader.cc 2010-10-28 16:52:12 +0000
3+++ drizzled/module/loader.cc 2010-11-08 19:52:48 +0000
4@@ -355,6 +355,26 @@
5 return false;
6 }
7
8+
9+inline static void dashes_to_underscores(std::string &name_in,
10+ char from= '-', char to= '_')
11+{
12+ for (string::iterator p= name_in.begin();
13+ p != name_in.end();
14+ ++p)
15+ {
16+ if (*p == from)
17+ {
18+ *p= to;
19+ }
20+ }
21+}
22+
23+inline static void underscores_to_dashes(std::string &name_in)
24+{
25+ return dashes_to_underscores(name_in, '_', '-');
26+}
27+
28 static void compose_plugin_options(vector<string> &target,
29 vector<string> options)
30 {
31@@ -364,6 +384,12 @@
32 {
33 tokenize(*it, target, ",", true);
34 }
35+ for (vector<string>::iterator it= target.begin();
36+ it != target.end();
37+ ++it)
38+ {
39+ dashes_to_underscores(*it);
40+ }
41 }
42
43 void compose_plugin_add(vector<string> options)
44@@ -825,13 +851,7 @@
45 varname.push_back('_');
46 varname.append(name);
47
48- for (string::iterator p= varname.begin() + 1; p != varname.end(); ++p)
49- {
50- if (*p == '-')
51- {
52- *p= '_';
53- }
54- }
55+ dashes_to_underscores(varname);
56 return varname;
57 }
58
59@@ -1422,11 +1442,7 @@
60 string name(plugin_name);
61 transform(name.begin(), name.end(), name.begin(), ::tolower);
62
63- for (string::iterator iter= name.begin(); iter != name.end(); ++iter)
64- {
65- if (*iter == '_')
66- *iter= '-';
67- }
68+ underscores_to_dashes(name);
69
70 /*
71 Two passes as the 2nd pass will take pointer addresses for use
72@@ -1691,13 +1707,7 @@
73 vname.push_back('-');
74 vname.append(o->name);
75 transform(vname.begin(), vname.end(), vname.begin(), ::tolower);
76- string::iterator p= vname.begin();
77- while (p != vname.end())
78- {
79- if (*p == '-')
80- *p= '_';
81- ++p;
82- }
83+ dashes_to_underscores(vname);
84
85 v= new sys_var_pluginvar(vname, o);
86 }
87
88=== modified file 'plugin/utility_dictionary/tests/t/master.opt'
89--- plugin/utility_dictionary/tests/t/master.opt 2010-09-30 03:36:05 +0000
90+++ plugin/utility_dictionary/tests/t/master.opt 2010-11-08 19:52:48 +0000
91@@ -1,1 +1,1 @@
92---plugin-add=utility_dictionary
93+--plugin-add=utility-dictionary

Subscribers

People subscribed via source and target branches