Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set locale to ensure dots are recognized as decimal points in SWC files #442

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clang_format_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [pull_request, push]
jobs:
build:
name: clang-format-check
runs-on: ubuntu-18.04
runs-on: ubuntu-latest

# Run on external PRs, but not internal PRs as they'll be run by the push
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
jobs:
build:
name: coverage-test
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

# Run on external PRs, but not internal PRs as they'll be run by the push
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/docstring_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,25 @@ on: [pull_request, push]
jobs:
build:
name: docstring-check
runs-on: ubuntu-18.04
runs-on: ubuntu-latest

# Run on external PRs, but not internal PRs as they'll be run by the push
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

steps:
- name: Fetch repository
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install packages
run: sudo apt-get update && sudo apt-get install build-essential libhdf5-dev python3-venv libclang1-9
submodules: 'true'

- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install packages on Linux
run: sudo apt-get update && sudo apt-get install build-essential libhdf5-dev

- name: Check docstrings
run: |
export LIBCLANG_PATH=/usr/lib/x86_64-linux-gnu/libclang-9.so.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-sdist-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-11, windows-2022]
os: [ubuntu-latest, macos-11, windows-2022]

steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 8 additions & 0 deletions src/readers/morphologySWC.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "morphologySWC.h"

#include <cstdint> // uint32_t
#include <cstdio> // sscanf
#include <locale> // std::locale
#include <memory> // std::shared_ptr
#include <sstream> // std::stringstream
#include <string> // std::string
Expand Down Expand Up @@ -29,6 +31,9 @@ morphio::readers::Sample readSample(const char* line, unsigned int lineNumber_)
morphio::floatType radius = -1.;
int int_type = -1;
morphio::readers::Sample sample;

// Set local to classic in order to ensure that dots are recognized as decimal points by sscanf
std::locale prev_locale = std::locale::global(std::locale::classic());
sample.valid = sscanf(line,
format,
&sample.id,
Expand All @@ -39,6 +44,9 @@ morphio::readers::Sample readSample(const char* line, unsigned int lineNumber_)
&radius,
&sample.parentId) == 7;

// Restore locale
std::locale::global(prev_locale);

sample.type = static_cast<morphio::SectionType>(int_type);
sample.diameter = radius * 2; // The point array stores diameters.
sample.lineNumber = lineNumber_;
Expand Down