@@ -248,35 +248,35 @@ static bool compare_prefix(std::string const &str,
248248 return std::strncmp (str.c_str (), prefix.c_str (), prefix.size ()) == 0 ;
249249}
250250
251- std::string database_options_t::conninfo () const
251+ std::string build_conninfo ( database_options_t const &opt)
252252{
253- if (compare_prefix (db, " postgresql://" ) ||
254- compare_prefix (db, " postgres://" )) {
255- return db;
253+ if (compare_prefix (opt. db , " postgresql://" ) ||
254+ compare_prefix (opt. db , " postgres://" )) {
255+ return opt. db ;
256256 }
257257
258258 std::string out{" fallback_application_name='osm2pgsql'" };
259259
260- if (std::strchr (db.c_str (), ' =' ) != nullptr ) {
260+ if (std::strchr (opt. db .c_str (), ' =' ) != nullptr ) {
261261 out += " " ;
262- out += db;
262+ out += opt. db ;
263263 return out;
264264 }
265265
266- if (!db.empty ()) {
267- out += " dbname='{}'" _format (db);
266+ if (!opt. db .empty ()) {
267+ out += " dbname='{}'" _format (opt. db );
268268 }
269- if (!username.empty ()) {
270- out += " user='{}'" _format (username);
269+ if (!opt. username .empty ()) {
270+ out += " user='{}'" _format (opt. username );
271271 }
272- if (!password.empty ()) {
273- out += " password='{}'" _format (password);
272+ if (!opt. password .empty ()) {
273+ out += " password='{}'" _format (opt. password );
274274 }
275- if (!host.empty ()) {
276- out += " host='{}'" _format (host);
275+ if (!opt. host .empty ()) {
276+ out += " host='{}'" _format (opt. host );
277277 }
278- if (!port.empty ()) {
279- out += " port='{}'" _format (port);
278+ if (!opt. port .empty ()) {
279+ out += " port='{}'" _format (opt. port );
280280 }
281281
282282 return out;
@@ -347,6 +347,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
347347 return ;
348348 }
349349
350+ database_options_t database_options;
350351 bool help_verbose = false ; // Will be set when -v/--verbose is set
351352
352353 int c = 0 ;
@@ -646,6 +647,8 @@ options_t::options_t(int argc, char *argv[]) : options_t()
646647 if (pass_prompt) {
647648 database_options.password = util::get_password ();
648649 }
650+
651+ conninfo = build_conninfo (database_options);
649652}
650653
651654void options_t::check_options ()
0 commit comments