Skip to content

Commit

Permalink
Fix decimal point issue in certain locales
Browse files Browse the repository at this point in the history
Closes #8
  • Loading branch information
HolyWu committed Aug 4, 2019
1 parent 6de8502 commit 2547a95
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions DFTTest/DFTTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

#define _USE_MATH_DEFINES
#include <clocale>
#include <cmath>
#include <cstdio>

Expand Down Expand Up @@ -1078,6 +1079,8 @@ static void VS_CC dfttestCreate(const VSMap * in, VSMap * out, void * userData,
throw std::string{ "malloc failure (sigmas/sigmas2/pmins/pmaxs)" };

if (sstring[0] || ssx[0] || ssy[0] || sst[0]) {
std::setlocale(LC_ALL, "C");

int ndim = 3;
if (d->tbsize == 1)
ndim -= 1;
Expand Down Expand Up @@ -1135,6 +1138,8 @@ static void VS_CC dfttestCreate(const VSMap * in, VSMap * out, void * userData,
delete[] tdata;
delete[] sydata;
delete[] sxdata;

std::setlocale(LC_ALL, "");
} else {
for (int i = 0; i < d->ccnt2; i++)
d->sigmas[i] = sigma / wscalef;
Expand All @@ -1147,6 +1152,7 @@ static void VS_CC dfttestCreate(const VSMap * in, VSMap * out, void * userData,
}

if (nstring[0] && ftype < 2) {
std::setlocale(LC_ALL, "C");
memset(d->sigmas, 0, d->ccnt2 * sizeof(float));

float * VS_RESTRICT hw2 = vs_aligned_malloc<float>((d->bvolume + 7) * sizeof(float), 32);
Expand Down Expand Up @@ -1279,6 +1285,8 @@ static void VS_CC dfttestCreate(const VSMap * in, VSMap * out, void * userData,
} else {
throw std::string{ "no noise blocks in nstring" };
}

std::setlocale(LC_ALL, "");
}
} catch (const std::string & error) {
vsapi->setError(out, ("DFTTest: " + error).c_str());
Expand Down

0 comments on commit 2547a95

Please sign in to comment.