Skip to content

Commit 804520d

Browse files
committed
softIoc re-add -D
1 parent cb0262d commit 804520d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

modules/database/src/std/softIoc/softMain.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ void errIf(int ret, const std::string& msg)
9696
throw std::runtime_error(msg);
9797
}
9898

99+
bool lazy_dbd_loaded;
100+
99101
void lazy_dbd(const std::string& dbd_file) {
100-
static bool loaded;
101-
if(loaded) return;
102-
loaded = true;
102+
if(lazy_dbd_loaded) return;
103+
lazy_dbd_loaded = true;
103104

104105
errIf(dbLoadDatabase(dbd_file.c_str(), NULL, NULL),
105106
std::string("Failed to load DBD file: ")+dbd_file);
@@ -142,7 +143,7 @@ int main(int argc, char *argv[])
142143

143144
int opt;
144145

145-
while ((opt = getopt(argc, argv, "ha:d:m:Ssx:")) != -1) {
146+
while ((opt = getopt(argc, argv, "ha:D:d:m:Ssx:")) != -1) {
146147
switch (opt) {
147148
case 'h': /* Print usage */
148149
usage(argv[0], dbd_file);
@@ -164,6 +165,12 @@ int main(int argc, char *argv[])
164165
throw std::bad_alloc();
165166
std::cout<<"asSetFilename(\""<<optarg<<"\")\n";
166167
break;
168+
case 'D':
169+
if(lazy_dbd_loaded) {
170+
throw std::runtime_error("-D specified too late. softIoc.dbd already loaded.\n");
171+
}
172+
dbd_file = optarg;
173+
break;
167174
case 'd':
168175
lazy_dbd(dbd_file);
169176
errIf(dbLoadRecords(optarg, macros.c_str()),

0 commit comments

Comments
 (0)