From 3bb70e4308fd20000bc69db797c1d8ff4e4818ba Mon Sep 17 00:00:00 2001 From: Remi Chateauneu Date: Sat, 1 Jun 2013 02:41:39 -0500 Subject: [PATCH] Port to MXE / MingW * Wefax destination directory now ended by one slash only. * Use PRId64 for printing long long. * Set right pthread library for mingw. * Fixed include files in debug build mode. * This commit does not include modifications specific to SYNOP commit, due to reordering of commits submitted by Remi during branch merging. --- m4/np-compat.m4 | 3 ++- src/misc/log.cxx | 2 +- src/misc/macros.cxx | 4 ++-- src/misc/nls.cxx | 2 +- src/rigcontrol/rigio.cxx | 2 +- src/spot/notify.cxx | 4 ++-- src/spot/pskrep.cxx | 6 +++--- src/wefax/wefax-pic.cxx | 12 +++++++----- src/wefax/wefax.cxx | 6 +++--- src/widgets/FTextRXTX.cxx | 2 +- 10 files changed, 23 insertions(+), 20 deletions(-) diff --git a/m4/np-compat.m4 b/m4/np-compat.m4 index bd16c640..c4e7f8d4 100644 --- a/m4/np-compat.m4 +++ b/m4/np-compat.m4 @@ -5,7 +5,8 @@ AC_DEFUN([AC_FLDIGI_NP_COMPAT], [ AM_CONDITIONAL([COMPAT_REGEX], [test "x$ac_cv_header_regex_h" != "xyes"]) if test "x$target_mingw32" = "xyes"; then - sem_libs="pthreadGC2" + # Newer versions of mingw32 comes with pthread. + sem_libs="pthreadGC2 pthread" else sem_libs="pthread rt" fi diff --git a/src/misc/log.cxx b/src/misc/log.cxx index fcba7964..b6a107fb 100644 --- a/src/misc/log.cxx +++ b/src/misc/log.cxx @@ -74,7 +74,7 @@ void cLogfile::log_to_file(log_t type, const string& s) gmtime_r(&t, &tm); strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%MZ", &tm); char freq[20]; - snprintf(freq, sizeof(freq), "%lld", wf->rfcarrier() + (wf->USB() + snprintf(freq, sizeof(freq), "%" PRId64, wf->rfcarrier() + (wf->USB() ? active_modem->get_freq() : -active_modem->get_freq())); const char *logmode = mode_info[active_modem->get_mode()].adif_name; diff --git a/src/misc/macros.cxx b/src/misc/macros.cxx index 472f1531..8c0aa472 100644 --- a/src/misc/macros.cxx +++ b/src/misc/macros.cxx @@ -1788,13 +1788,13 @@ void set_macro_env(void) // frequencies char dial_freq[20]; - snprintf(dial_freq, sizeof(dial_freq), "%lld", wf->rfcarrier()); + snprintf(dial_freq, sizeof(dial_freq), "%" PRId64, wf->rfcarrier()); env[FLDIGI_DIAL_FREQUENCY].val = dial_freq; char audio_freq[6]; snprintf(audio_freq, sizeof(audio_freq), "%d", active_modem->get_freq()); env[FLDIGI_AUDIO_FREQUENCY].val = audio_freq; char freq[20]; - snprintf(freq, sizeof(freq), "%lld", wf->rfcarrier() + (wf->USB() + snprintf(freq, sizeof(freq), "%" PRId64, wf->rfcarrier() + (wf->USB() ? active_modem->get_freq() : -active_modem->get_freq())); env[FLDIGI_FREQUENCY].val = freq; diff --git a/src/misc/nls.cxx b/src/misc/nls.cxx index 0bcc173c..20acc20c 100644 --- a/src/misc/nls.cxx +++ b/src/misc/nls.cxx @@ -76,7 +76,7 @@ int get_ui_lang(const char* homedir) string::size_type u = string::npos; while (in >> lang) { - if (lang[0] != '\n' & lang[0] != '#' && (u = lang.find('_')) != string::npos) + if ( (lang[0] != '\n') & (lang[0] != '#') && ( (u = lang.find('_')) != string::npos) ) break; } in.close(); diff --git a/src/rigcontrol/rigio.cxx b/src/rigcontrol/rigio.cxx index fb98ae47..907b5eb9 100644 --- a/src/rigcontrol/rigio.cxx +++ b/src/rigcontrol/rigio.cxx @@ -391,7 +391,7 @@ long long rigCAT_getfreq(int retries, bool &failed) f = fm_freqdata(rTemp.data, pData); if ( f >= rTemp.data.min && f <= rTemp.data.max) return f; - LOG_VERBOSE("freq: %lld", f); + LOG_VERBOSE("freq: %" PRId64, f); retry_get_freq: ; } } diff --git a/src/spot/notify.cxx b/src/spot/notify.cxx index 8ec66d10..03eb92b3 100644 --- a/src/spot/notify.cxx +++ b/src/spot/notify.cxx @@ -339,7 +339,7 @@ void notify_change_callsign(void) void notify_rsid(trx_mode mode, int afreq) { const char* mode_name = mode_info[mode].name; - regmatch_t sub[2] = { { 0, strlen(mode_name) } }; + regmatch_t sub[2] = { { 0, (regoff_t)strlen(mode_name) } }; sub[1] = sub[0]; for (notify_list_t::iterator i = notify_list.begin(); i != notify_list.end(); ++i) if (i->event == NOTIFY_EVENT_RSID) @@ -1253,7 +1253,7 @@ static void notify_test_cb(Fl_Widget* w, void* arg) if (notify_tmp.event == NOTIFY_EVENT_RSID) { notify_tmp.mode = active_modem->get_mode(); - regmatch_t sub[2] = { { 0, strlen(mode_info[notify_tmp.mode].name) } }; + regmatch_t sub[2] = { { 0, (regoff_t)strlen(mode_info[notify_tmp.mode].name) } }; sub[1] = sub[0]; notify_recv(notify_tmp.mode, active_modem->get_freq(), mode_info[notify_tmp.mode].name, sub, 2, ¬ify_tmp); diff --git a/src/spot/pskrep.cxx b/src/spot/pskrep.cxx index 3d3e5850..575613b1 100644 --- a/src/spot/pskrep.cxx +++ b/src/spot/pskrep.cxx @@ -404,7 +404,7 @@ void pskrep::append(string call, const char* loc, long long freq, trx_mode mode, band_map_t& bandq = queue[call][band(freq)]; if (bandq.empty() || rtime - bandq.back().rtime >= DUP_INTERVAL) { // add new bandq.push_back(rcpt_report_t(mode, freq, rtime, rtype, loc)); - LOG_VERBOSE("Added (call=\"%s\", loc=\"%s\", mode=\"%s\", freq=%lld, time=%jd, type=%u)", + LOG_VERBOSE("Added (call=\"%s\", loc=\"%s\", mode=\"%s\", freq=%" PRId64 ", time=%" PRIdMAX ", type=%u)", call.c_str(), loc, mode_info[mode].adif_name, freq, (intmax_t)rtime, rtype); new_count++; save_queue(); @@ -414,7 +414,7 @@ void pskrep::append(string call, const char* loc, long long freq, trx_mode mode, if (r.status != PSKR_STATUS_SENT && *loc && r.locator != loc) { // update last r.locator = loc; r.rtype = rtype; - LOG_VERBOSE("Updated (call=\"%s\", loc=\"%s\", mode=\"%s\", freq=%lld, time=%jd, type=%u)", + LOG_VERBOSE("Updated (call=\"%s\", loc=\"%s\", mode=\"%s\", freq=%" PRId64 ", time=%" PRIdMAX ", type=%u)", call.c_str(), loc, mode_info[r.mode].adif_name, r.freq, (intmax_t)r.rtime, rtype); save_queue(); } @@ -732,7 +732,7 @@ bool pskrep_sender::append(const string& callsign, const band_map_t::value_type& return false; - LOG_INFO("Appending report (call=%s mode=%s freq=%lld time=%jd type=%u)", + LOG_INFO("Appending report (call=%s mode=%s freq=%" PRId64 " time=%" PRIdMAX " type=%u)", callsign.c_str(), mode_info[r.mode].adif_name, r.freq, (intmax_t)r.rtime, r.rtype); unsigned char* start = dgram + dgram_size; diff --git a/src/wefax/wefax-pic.cxx b/src/wefax/wefax-pic.cxx index a780cf0e..eadf565d 100644 --- a/src/wefax/wefax-pic.cxx +++ b/src/wefax/wefax-pic.cxx @@ -678,13 +678,15 @@ static void wefax_cb_pic_rx_auto_center( Fl_Widget *, void *) } /// This gets the directory where images are accessed by default. -static const std::string & default_dir_get( const std::string & config_dir ) +static std::string default_dir_get( const std::string & config_dir ) { - if( config_dir.empty() ) { - return PicsDir ; - } else { - return config_dir ; + std::string tmp_dir = config_dir.empty() ? PicsDir : config_dir ; + /// Valid dir names must end with a slash. + if( ! tmp_dir.empty() ) { + char termin = tmp_dir[ tmp_dir.size() - 1 ]; + if( ( termin != '/' ) && ( termin != '\\' ) ) tmp_dir += '/'; } + return tmp_dir ; } /// This sets the directory where images are accessed by default. diff --git a/src/wefax/wefax.cxx b/src/wefax/wefax.cxx index 2dac2208..cab23384 100644 --- a/src/wefax/wefax.cxx +++ b/src/wefax/wefax.cxx @@ -846,7 +846,7 @@ public: /// If the delay is exceeded, returns with an error message. std::string send_file( const std::string & filnam, double max_seconds ) { - LOG_INFO("%s rf_carried=%lld carrier=%d", filnam.c_str(), wf->rfcarrier(), m_carrier ); + LOG_INFO("%s rf_carried=%" PRId64 " carrier=%d", filnam.c_str(), wf->rfcarrier(), m_carrier ); bool is_acquired = transmit_lock_acquire(filnam, max_seconds); if( ! is_acquired ) return "Timeout sending " + filnam ; @@ -1237,7 +1237,7 @@ public: { /// Displays the messages once only. if( total_img_rows != 0 ) { - LOG_INFO("Setting m_carrier=%d curr_rfcarr=%lld total_img_rows=%d", + LOG_INFO("Setting m_carrier=%d curr_rfcarr=%" PRId64 " total_img_rows=%d", m_carrier, curr_rfcarr, total_img_rows ); } total_img_rows = 0 ; @@ -1680,7 +1680,7 @@ std::string fax_implementation::generate_filename( const char *extra_msg ) const char buf_fil_nam[256] ; long long tmp_fl = wf->rfcarrier() ; snprintf( buf_fil_nam, sizeof(buf_fil_nam), - "wefax_%04d%02d%02d_%02d%02d%02d_%lld_%s.png", + "wefax_%04d%02d%02d_%02d%02d%02d_%" PRId64 "_%s.png", 1900 + tmp_tm.tm_year, 1 + tmp_tm.tm_mon, tmp_tm.tm_mday, diff --git a/src/widgets/FTextRXTX.cxx b/src/widgets/FTextRXTX.cxx index 2c289a47..d7281bd8 100644 --- a/src/widgets/FTextRXTX.cxx +++ b/src/widgets/FTextRXTX.cxx @@ -263,7 +263,7 @@ void FTextRX::add(unsigned int c, int attr) if (c == '\r') return; - char s[] = { '\0', '\0', FTEXT_DEF + attr, '\0' }; + char s[] = { '\0', '\0', char( FTEXT_DEF + attr ), '\0' }; const char *cp = &s[0]; // The user may have moved the cursor by selecting text or