mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-23 04:38:37 -05:00
Use local 8-bit strings for paths passed to Fortran
By using the local 8-bit character set we can allow local non-ASCII characters in file paths, for example user account names on MS Windows with characters in the default code page.
This commit is contained in:
parent
8cbf31ebdf
commit
8794bad146
@ -443,7 +443,7 @@ void EqualizationToolsDialog::impl::plot_current ()
|
|||||||
plot_.graph (3)->rescaleValueAxis ();
|
plot_.graph (3)->rescaleValueAxis ();
|
||||||
|
|
||||||
QFileInfo refspec_file_info {data_directory_.absoluteFilePath ("refspec.dat")};
|
QFileInfo refspec_file_info {data_directory_.absoluteFilePath ("refspec.dat")};
|
||||||
std::ifstream refspec_file (refspec_file_info.absoluteFilePath ().toLatin1 ().constData (), std::ifstream::in);
|
std::ifstream refspec_file (refspec_file_info.absoluteFilePath ().toLocal8Bit ().constData (), std::ifstream::in);
|
||||||
unsigned n;
|
unsigned n;
|
||||||
if (refspec_file >> amp_poly_low_ >> amp_poly_high_ >> n)
|
if (refspec_file >> amp_poly_low_ >> amp_poly_high_ >> n)
|
||||||
{
|
{
|
||||||
@ -499,7 +499,7 @@ void EqualizationToolsDialog::impl::plot_phase ()
|
|||||||
, "Phase Coefficient Files (*.pcoeff)");
|
, "Phase Coefficient Files (*.pcoeff)");
|
||||||
if (!phase_file_name.size ()) return;
|
if (!phase_file_name.size ()) return;
|
||||||
|
|
||||||
std::ifstream phase_file (phase_file_name.toLatin1 ().constData (), std::ifstream::in);
|
std::ifstream phase_file (phase_file_name.toLocal8Bit ().constData (), std::ifstream::in);
|
||||||
int n;
|
int n;
|
||||||
float chi;
|
float chi;
|
||||||
float rmsdiff;
|
float rmsdiff;
|
||||||
|
@ -12,8 +12,8 @@ subroutine calibrate(data_dir,iz,a,b,rms,sigmaa,sigmab,irc)
|
|||||||
real*8 fd(NZ),deltaf(NZ),r(NZ),rmsd(NZ)
|
real*8 fd(NZ),deltaf(NZ),r(NZ),rmsd(NZ)
|
||||||
integer nn(NZ)
|
integer nn(NZ)
|
||||||
|
|
||||||
infile=trim(data_dir)//'fmt.all'
|
infile=trim(data_dir)//'/'//'fmt.all'
|
||||||
outfile=trim(data_dir)//'fcal2.out'
|
outfile=trim(data_dir)//'/'//'fcal2.out'
|
||||||
|
|
||||||
open(10,file=trim(infile),status='old',err=996)
|
open(10,file=trim(infile),status='old',err=996)
|
||||||
open(12,file=trim(outfile),status='unknown',err=997)
|
open(12,file=trim(outfile),status='unknown',err=997)
|
||||||
|
@ -20,7 +20,7 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,bmsk144, &
|
|||||||
|
|
||||||
parameter (JZ=703)
|
parameter (JZ=703)
|
||||||
character*80 line1
|
character*80 line1
|
||||||
character*512 datadir
|
character*(*) datadir
|
||||||
character*12 mycall,hiscall
|
character*12 mycall,hiscall
|
||||||
integer*2 id2(0:120*12000-1)
|
integer*2 id2(0:120*12000-1)
|
||||||
logical*1 bmsk144,bshmsg,btrain,bswl
|
logical*1 bmsk144,bshmsg,btrain,bswl
|
||||||
|
@ -9,7 +9,7 @@ subroutine msk144signalquality(cframe,snr,freq,t0,softbits,msg,dxcall, &
|
|||||||
character*8 date
|
character*8 date
|
||||||
character*10 time
|
character*10 time
|
||||||
character*5 zone
|
character*5 zone
|
||||||
character*512 datadir
|
character*(*) datadir
|
||||||
|
|
||||||
complex cframe(864)
|
complex cframe(864)
|
||||||
complex cross(864)
|
complex cross(864)
|
||||||
@ -191,9 +191,7 @@ subroutine msk144signalquality(cframe,snr,freq,t0,softbits,msg,dxcall, &
|
|||||||
write(pcoeff_filename,'(i2.2,i2.2,i2.2,"_",i2.2,i2.2,i2.2)') &
|
write(pcoeff_filename,'(i2.2,i2.2,i2.2,"_",i2.2,i2.2,i2.2)') &
|
||||||
values(1)-2000,values(2),values(3),values(5),values(6),values(7)
|
values(1)-2000,values(2),values(3),values(5),values(6),values(7)
|
||||||
pcoeff_filename=trim(trained_dxcall)//"_"//trim(pcoeff_filename)//".pcoeff"
|
pcoeff_filename=trim(trained_dxcall)//"_"//trim(pcoeff_filename)//".pcoeff"
|
||||||
l1=index(datadir,char(0))-1
|
pcoeff_filename=datadir//'/'//trim(pcoeff_filename)
|
||||||
datadir(l1+1:l1+1)="/"
|
|
||||||
pcoeff_filename=datadir(1:l1+1)//trim(pcoeff_filename)
|
|
||||||
!write(*,*) 'trained - writing coefficients to: ',pcoeff_filename
|
!write(*,*) 'trained - writing coefficients to: ',pcoeff_filename
|
||||||
open(17,file=pcoeff_filename,status='new')
|
open(17,file=pcoeff_filename,status='new')
|
||||||
write(17,'(i4,2f10.2,3i5,5e25.16)') navg,sqrt(chisqr),rmsdiff,NFREQLOW,NFREQHIGH,nterms,a
|
write(17,'(i4,2f10.2,3i5,5e25.16)') navg,sqrt(chisqr),rmsdiff,NFREQLOW,NFREQHIGH,nterms,a
|
||||||
|
@ -19,7 +19,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,hiscall, &
|
|||||||
character*80 line !Formatted line with UTC dB T Freq Msg
|
character*80 line !Formatted line with UTC dB T Freq Msg
|
||||||
character*12 mycall,hiscall
|
character*12 mycall,hiscall
|
||||||
character*37 recent_shmsgs(NSHMEM)
|
character*37 recent_shmsgs(NSHMEM)
|
||||||
character*512 datadir
|
character*(*) datadir
|
||||||
|
|
||||||
complex cdat(NFFT1) !Analytic signal
|
complex cdat(NFFT1) !Analytic signal
|
||||||
complex c(NSPM) !Coherently averaged complex data
|
complex c(NSPM) !Coherently averaged complex data
|
||||||
|
@ -18,7 +18,7 @@ void getfile(QString fname, bool xpol, int dbDgrd)
|
|||||||
|
|
||||||
memset(id,0,2*npts);
|
memset(id,0,2*npts);
|
||||||
char name[80];
|
char name[80];
|
||||||
strcpy(name,fname.toLatin1());
|
strcpy(name,fname.toLocal8Bit());
|
||||||
FILE* fp=fopen(name,"rb");
|
FILE* fp=fopen(name,"rb");
|
||||||
|
|
||||||
if(fp != NULL) {
|
if(fp != NULL) {
|
||||||
@ -61,7 +61,7 @@ void savetf2(QString fname, bool xpol)
|
|||||||
|
|
||||||
qint16* buf=(qint16*)malloc(2*npts);
|
qint16* buf=(qint16*)malloc(2*npts);
|
||||||
char name[80];
|
char name[80];
|
||||||
strcpy(name,fname.toLatin1());
|
strcpy(name,fname.toLocal8Bit());
|
||||||
FILE* fp=fopen(name,"wb");
|
FILE* fp=fopen(name,"wb");
|
||||||
|
|
||||||
if(fp != NULL) {
|
if(fp != NULL) {
|
||||||
|
@ -118,8 +118,8 @@ auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const
|
|||||||
&azmoondx, &elmoondx, &ntsky, &m_dop, &m_dop00, &ramoon, &decmoon,
|
&azmoondx, &elmoondx, &ntsky, &m_dop, &m_dop00, &ramoon, &decmoon,
|
||||||
&dgrd, &poloffset, &xnr, &techo, &width1, &width2,
|
&dgrd, &poloffset, &xnr, &techo, &width1, &width2,
|
||||||
bTx,
|
bTx,
|
||||||
AzElFileName.toLatin1().data(),
|
AzElFileName.toLocal8Bit ().constData (),
|
||||||
jpleph.toLatin1().data());
|
jpleph.toLocal8Bit ().constData ());
|
||||||
|
|
||||||
if(!hisgrid.size ()) {
|
if(!hisgrid.size ()) {
|
||||||
azmoondx=0.0;
|
azmoondx=0.0;
|
||||||
@ -229,7 +229,7 @@ auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const
|
|||||||
&dgrd, &poloffset, &xnr, &techo, &width1, &width2,
|
&dgrd, &poloffset, &xnr, &techo, &width1, &width2,
|
||||||
bTx,
|
bTx,
|
||||||
nullptr, // don't overwrite azel.dat
|
nullptr, // don't overwrite azel.dat
|
||||||
jpleph.toLatin1().data());
|
jpleph.toLocal8Bit ().constData ());
|
||||||
FrequencyDelta offset {0};
|
FrequencyDelta offset {0};
|
||||||
switch (m_DopplerMethod)
|
switch (m_DopplerMethod)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +98,8 @@ extern "C" {
|
|||||||
|
|
||||||
void hspec_(short int d2[], int* k, int* nutc0, int* ntrperiod, int* nrxfreq, int* ntol,
|
void hspec_(short int d2[], int* k, int* nutc0, int* ntrperiod, int* nrxfreq, int* ntol,
|
||||||
bool* bmsk144, bool* btrain, double const pcoeffs[], int* ingain,
|
bool* bmsk144, bool* btrain, double const pcoeffs[], int* ingain,
|
||||||
char mycall[], char hiscall[], bool* bshmsg, bool* bswl, char ddir[], float green[],
|
char const * mycall, char const * hiscall, bool* bshmsg, bool* bswl,
|
||||||
|
char const * ddir, float green[],
|
||||||
float s[], int* jh, float *pxmax, float *rmsNoGain, char line[],
|
float s[], int* jh, float *pxmax, float *rmsNoGain, char line[],
|
||||||
fortran_charlen_t, fortran_charlen_t, fortran_charlen_t, fortran_charlen_t);
|
fortran_charlen_t, fortran_charlen_t, fortran_charlen_t, fortran_charlen_t);
|
||||||
|
|
||||||
@ -150,7 +151,7 @@ extern "C" {
|
|||||||
|
|
||||||
void wspr_downsample_(short int d2[], int* k);
|
void wspr_downsample_(short int d2[], int* k);
|
||||||
|
|
||||||
int savec2_(char* fname, int* TR_seconds, double* dial_freq, fortran_charlen_t);
|
int savec2_(char const * fname, int* TR_seconds, double* dial_freq, fortran_charlen_t);
|
||||||
|
|
||||||
void avecho_( short id2[], int* dop, int* nfrit, int* nqual, float* f1,
|
void avecho_( short id2[], int* dop, int* nfrit, int* nqual, float* f1,
|
||||||
float* level, float* sigdb, float* snr, float* dfreq,
|
float* level, float* sigdb, float* snr, float* dfreq,
|
||||||
@ -171,7 +172,7 @@ extern "C" {
|
|||||||
|
|
||||||
void fix_contest_msg_(char* MyGrid, char* msg, fortran_charlen_t, fortran_charlen_t);
|
void fix_contest_msg_(char* MyGrid, char* msg, fortran_charlen_t, fortran_charlen_t);
|
||||||
|
|
||||||
void calibrate_(char data_dir[], int* iz, double* a, double* b, double* rms,
|
void calibrate_(char const * data_dir, int* iz, double* a, double* b, double* rms,
|
||||||
double* sigmaa, double* sigmab, int* irc, fortran_charlen_t);
|
double* sigmaa, double* sigmab, int* irc, fortran_charlen_t);
|
||||||
|
|
||||||
void foxgen_();
|
void foxgen_();
|
||||||
@ -919,9 +920,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
|
|||||||
proc_jt9.start(QDir::toNativeSeparators (m_appDir) + QDir::separator () +
|
proc_jt9.start(QDir::toNativeSeparators (m_appDir) + QDir::separator () +
|
||||||
"jt9", jt9_args, QIODevice::ReadWrite | QIODevice::Unbuffered);
|
"jt9", jt9_args, QIODevice::ReadWrite | QIODevice::Unbuffered);
|
||||||
|
|
||||||
QString fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("wsjtx_wisdom.dat"))};
|
auto fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("wsjtx_wisdom.dat"))};
|
||||||
QByteArray cfname=fname.toLocal8Bit();
|
fftwf_import_wisdom_from_filename (fname.toLocal8Bit ());
|
||||||
fftwf_import_wisdom_from_filename(cfname);
|
|
||||||
|
|
||||||
m_ntx = 6;
|
m_ntx = 6;
|
||||||
ui->txrb6->setChecked(true);
|
ui->txrb6->setChecked(true);
|
||||||
@ -1075,9 +1075,8 @@ void MainWindow::on_the_minute ()
|
|||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
m_astroWidget.reset ();
|
m_astroWidget.reset ();
|
||||||
QString fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("wsjtx_wisdom.dat"))};
|
auto fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("wsjtx_wisdom.dat"))};
|
||||||
QByteArray cfname=fname.toLocal8Bit();
|
fftwf_export_wisdom_to_filename (fname.toLocal8Bit ());
|
||||||
fftwf_export_wisdom_to_filename(cfname);
|
|
||||||
m_audioThread.quit ();
|
m_audioThread.quit ();
|
||||||
m_audioThread.wait ();
|
m_audioThread.wait ();
|
||||||
remove_child_from_event_filter (this);
|
remove_child_from_event_filter (this);
|
||||||
@ -1428,10 +1427,7 @@ void MainWindow::dataSink(qint64 frames)
|
|||||||
static float s[NSMAX];
|
static float s[NSMAX];
|
||||||
char line[80];
|
char line[80];
|
||||||
int k(frames);
|
int k(frames);
|
||||||
QString fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("refspec.dat"))};
|
auto fname {QDir::toNativeSeparators(m_config.writeable_data_dir ().absoluteFilePath ("refspec.dat")).toLocal8Bit ()};
|
||||||
QByteArray bafname = fname.toLatin1();
|
|
||||||
const char *c_fname = bafname.data();
|
|
||||||
int len=fname.length();
|
|
||||||
|
|
||||||
if(m_diskData) {
|
if(m_diskData) {
|
||||||
dec_data.params.ndiskdat=1;
|
dec_data.params.ndiskdat=1;
|
||||||
@ -1443,7 +1439,7 @@ void MainWindow::dataSink(qint64 frames)
|
|||||||
m_bUseRef=m_wideGraph->useRef();
|
m_bUseRef=m_wideGraph->useRef();
|
||||||
if(!m_diskData) {
|
if(!m_diskData) {
|
||||||
refspectrum_(&dec_data.d2[k-m_nsps/2],&m_bClearRefSpec,&m_bRefSpec,
|
refspectrum_(&dec_data.d2[k-m_nsps/2],&m_bClearRefSpec,&m_bRefSpec,
|
||||||
&m_bUseRef,c_fname,len);
|
&m_bUseRef, fname.constData (), fname.size ());
|
||||||
}
|
}
|
||||||
m_bClearRefSpec=false;
|
m_bClearRefSpec=false;
|
||||||
|
|
||||||
@ -1598,14 +1594,11 @@ void MainWindow::dataSink(qint64 frames)
|
|||||||
this, m_fnameWE, &dec_data.d2[0], samples, m_config.my_callsign(),
|
this, m_fnameWE, &dec_data.d2[0], samples, m_config.my_callsign(),
|
||||||
m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall, m_hisGrid)));
|
m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall, m_hisGrid)));
|
||||||
if (m_mode=="WSPR") {
|
if (m_mode=="WSPR") {
|
||||||
QString c2name_string {m_fnameWE + ".c2"};
|
auto c2name {(m_fnameWE + ".c2").toLocal8Bit ()};
|
||||||
int len1=c2name_string.length();
|
|
||||||
char c2name[80];
|
|
||||||
strcpy(c2name,c2name_string.toLatin1 ().constData ());
|
|
||||||
int nsec=120;
|
int nsec=120;
|
||||||
int nbfo=1500;
|
int nbfo=1500;
|
||||||
double f0m1500=m_freqNominal/1000000.0 + nbfo - 1500;
|
double f0m1500=m_freqNominal/1000000.0 + nbfo - 1500;
|
||||||
int err = savec2_(c2name,&nsec,&f0m1500,len1);
|
int err = savec2_(c2name.constData (),&nsec,&f0m1500, c2name.size ());
|
||||||
if (err!=0) MessageBox::warning_message (this, tr ("Error saving c2 file"), c2name);
|
if (err!=0) MessageBox::warning_message (this, tr ("Error saving c2 file"), c2name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1721,17 +1714,14 @@ void MainWindow::fastSink(qint64 frames)
|
|||||||
// ::memcpy(dec_data.params.hiscall,(Radio::base_callsign (hisCall) + " ").toLatin1 ().constData (), sizeof dec_data.params.hiscall);
|
// ::memcpy(dec_data.params.hiscall,(Radio::base_callsign (hisCall) + " ").toLatin1 ().constData (), sizeof dec_data.params.hiscall);
|
||||||
::memcpy(dec_data.params.hiscall,(hisCall + " ").toLatin1 ().constData (), sizeof dec_data.params.hiscall);
|
::memcpy(dec_data.params.hiscall,(hisCall + " ").toLatin1 ().constData (), sizeof dec_data.params.hiscall);
|
||||||
::memcpy(dec_data.params.mygrid, (m_config.my_grid()+" ").toLatin1(), sizeof dec_data.params.mygrid);
|
::memcpy(dec_data.params.mygrid, (m_config.my_grid()+" ").toLatin1(), sizeof dec_data.params.mygrid);
|
||||||
QString dataDir;
|
auto data_dir {m_config.writeable_data_dir ().absolutePath ().toLocal8Bit ()};
|
||||||
dataDir = m_config.writeable_data_dir ().absolutePath ();
|
|
||||||
char ddir[512];
|
|
||||||
::strncpy(ddir,dataDir.toLatin1(), sizeof (ddir) - 1);
|
|
||||||
float pxmax = 0;
|
float pxmax = 0;
|
||||||
float rmsNoGain = 0;
|
float rmsNoGain = 0;
|
||||||
int ftol = ui->sbFtol->value ();
|
int ftol = ui->sbFtol->value ();
|
||||||
hspec_(dec_data.d2,&k,&nutc0,&nTRpDepth,&RxFreq,&ftol,&bmsk144,
|
hspec_(dec_data.d2,&k,&nutc0,&nTRpDepth,&RxFreq,&ftol,&bmsk144,
|
||||||
&m_bTrain,m_phaseEqCoefficients.constData(),&m_inGain,&dec_data.params.mycall[0],
|
&m_bTrain,m_phaseEqCoefficients.constData(),&m_inGain,&dec_data.params.mycall[0],
|
||||||
&dec_data.params.hiscall[0],&bshmsg,&bswl,
|
&dec_data.params.hiscall[0],&bshmsg,&bswl,
|
||||||
&ddir[0],fast_green,fast_s,&fast_jh,&pxmax,&rmsNoGain,&line[0],12,12,512,80);
|
data_dir.constData (),fast_green,fast_s,&fast_jh,&pxmax,&rmsNoGain,&line[0],12,12,data_dir.size (),80);
|
||||||
float px = fast_green[fast_jh];
|
float px = fast_green[fast_jh];
|
||||||
QString t;
|
QString t;
|
||||||
t = t.asprintf(" Rx noise: %5.1f ",px);
|
t = t.asprintf(" Rx noise: %5.1f ",px);
|
||||||
@ -2543,16 +2533,13 @@ void MainWindow::on_actionFast_Graph_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionSolve_FreqCal_triggered()
|
void MainWindow::on_actionSolve_FreqCal_triggered()
|
||||||
{
|
{
|
||||||
QString dpath{QDir::toNativeSeparators(m_config.writeable_data_dir().absolutePath()+"/")};
|
auto data_dir {QDir::toNativeSeparators(m_config.writeable_data_dir().absolutePath()).toLocal8Bit ()};
|
||||||
char data_dir[512];
|
|
||||||
int len=dpath.length();
|
|
||||||
int iz,irc;
|
int iz,irc;
|
||||||
double a,b,rms,sigmaa,sigmab;
|
double a,b,rms,sigmaa,sigmab;
|
||||||
strncpy(data_dir,dpath.toLatin1(),len);
|
calibrate_(data_dir.constData (),&iz,&a,&b,&rms,&sigmaa,&sigmab,&irc,data_dir.size ());
|
||||||
calibrate_(data_dir,&iz,&a,&b,&rms,&sigmaa,&sigmab,&irc,len);
|
|
||||||
QString t2;
|
QString t2;
|
||||||
if(irc==-1) t2="Cannot open " + dpath + "fmt.all";
|
if(irc==-1) t2="Cannot open " + data_dir + "/fmt.all";
|
||||||
if(irc==-2) t2="Cannot open " + dpath + "fcal2.out";
|
if(irc==-2) t2="Cannot open " + data_dir + "/fcal2.out";
|
||||||
if(irc==-3) t2="Insufficient data in fmt.all";
|
if(irc==-3) t2="Insufficient data in fmt.all";
|
||||||
if(irc==-4) t2 = tr ("Invalid data in fmt.all at line %1").arg (iz);
|
if(irc==-4) t2 = tr ("Invalid data in fmt.all at line %1").arg (iz);
|
||||||
if(irc>0 or rms>1.0) t2="Check fmt.all for possible bad data.";
|
if(irc>0 or rms>1.0) t2="Check fmt.all for possible bad data.";
|
||||||
|
Loading…
Reference in New Issue
Block a user