yumetodoの旅とプログラミングとかの記録

旅や登山の記録やプログラミング関連の話とかフリーソフト紹介とか

Re:ある「プロ」の書いた、初心者向けc言語入門プログラム

きっかけ

ある「プロ」の書いた、初心者向けc言語入門プログラム: わき道

見てみると、コードの書き方云々の前にアルゴリズムがあかん。テーブル全数探査とか馬鹿げている。

全部書き直した

というわけで書き直した。

使用例。

気になる実装

まずアルゴリズムを変更した。

  1. 母音
  2. 子音+母音
  3. 子音+(y)+母音
  4. 子音+(y/h)+母音

この4つのテーブルに分けて、先頭文字からどのパターン化を判別し、変換するようにした。

元のプログラムではバッファーの大きさを取ってないわ、変換終了時のソースと出力の変換後の位置は取れないわでお話にならないので、strtol関数を参考に書き換えた。

内部ではC++イテレータのように作業位置のポインタと終端のポインタを持つようにした。下手にindexに変換するとsigned/unsignedが面倒だからだ。

エラー処理は、enumを書いてそれのformatterをつくるというありきたりな実装にした。その気になればstd::error_codeでのラップも簡単だろう。

VPS上のLinuxのユーザー空間にArch Linuxの環境を構築する話(2)

はじめに

まあまずは
VPS上のLinuxのユーザー空間にArch Linuxの環境を構築する話 — 173210's Blog
をみてもらうとして、これをmsys2上からやるときにどうするかという問題がある。

とりあえずそのままでは動かないので手順を書いておく。なおprootはサーバー管理者が上記記事のように入れてくれていることを前提にする。

msys2上での作業

まずこんなファイルを適当な場所に作っておく。

%echo Generating pacman keyring master key...
Key-Type: RSA
Key-Length: 2048
Key-Usage: sign
Name-Real: Pacman Keyring Master Key
Name-Email: pacman@localhost
Expire-Date: 0
%no-protection
%commit
%echo Done
EOF

次に秘密鍵を生成してサーバーに転送する。

$gpg --homedir gnupg --gen-key --batch < tmp.txt
$tar cf gnupg.tar gnupg
$scp -P 110 gnupg.tar yumetodo@kagucho.net:

VPN上での作業

まずはbootstrap用imageを落としてくる。

bootstrap用イメージはArch Linux - Downloadsからテキトーなミラーのリンクを踏めば見つかる. 試しにftp.tsukuba.wide.ad.jpに行ってみると無造作にファイルが置かれた中にarchlinux-bootstrap-2016.11.01-x86_64.tar.gzがあるのでこれを使う.
$ cd ~
$ wget http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/iso/2016.11.01/archlinux-bootstrap-2016.11.01-x86_64.tar.gz -O - | tar xz

proot上のpacman用のmirrorlistを編集する。すでに用意されているmirrorlistのうち近そうなサーバーのコメントアウト(#)を外せば良い。もちろんテキストエディタは好きなものを使えば良い。nanoの場合はCtrl+OEnterすれば保存、Ctrl+Xで終了だ。

$ nano root.x86_64/etc/pacman.d/mirrorlist

先程転送した秘密鍵を展開する。

$ tar -C root.x86_64/etc/pacman.d -xf gnupg.tar

準備が整ったのでprootでArch Linuxを開始するのだが、起動コマンドが長すぎてやってられないので、aliasを貼る。.bashrc

alias 'archlinux=proot -0 -b /etc/resolv.conf -m /dev -m /sys -m /proc -w / -r root.x86_64'

としておく。.bashrcを反映するためにsshし直すとかなんかして、

archlinux

で起動する。

proot上での作業

まずはgpgの初期化をする。

# pacman-key --init
# pacman-key --populate archlinux

さて、ここまでくればmsys2ユーザーにとっては日常だ。

# pacman -Syuu
# pacman -S base-devel git clang openmp gdb lldb

しばらく時間がかかるので放置したのち、動作確認だ。

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release

Thread model: posix
gcc version 6.2.1 20160830 (GCC)
# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release

Thread model: posix
gcc version 6.2.1 20160830 (GCC)
# clang -v
clang version 3.9.0 (tags/RELEASE_390/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/6.2.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.2.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
# clang++ -v
clang version 3.9.0 (tags/RELEASE_390/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/6.2.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.2.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
# gdb -v
GNU gdb (GDB) 7.12
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
# lldb -v
lldb version 3.9.0 ( revision )
# python --version
Python 3.5.2
# python2 --version
Python 2.7.12
# git --version
git version 2.10.2

試しにhttps://github.com/yumetodo/string_splitでもビルドしてみるか。

# cd ~
# git clone https://github.com/yumetodo/string_split.git
Cloning into 'string_split'...
remote: Counting objects: 310, done.
remote: Total 310 (delta 0), reused 0 (delta 0), pack-reused 310
Receiving objects: 100% (310/310), 50.20 KiB | 0 bytes/s, done.
Resolving deltas: 100% (174/174), done.
# cd string_split/
# git submodule update --init
Submodule 'iutest' (https://github.com/srz-zumix/iutest.git) registered for path 'iutest'
Cloning into '/home/yumetodo/string_split/iutest'...
Submodule path 'iutest': checked out '3db6d7339ad8171cb742ee90bae02fc20cca5ad4'
# make Release -j2
g++ --version
g++ (GCC) 6.2.1 20160830
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

cd test; make Release
make[1]: Entering directory '/home/yumetodo/string_split/test'
g++ --version;
g++ (GCC) 6.2.1 20160830
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

g++ test.cpp -o test.out -O2 -Wall -Wextra -std=c++14
mkdir -p bin/g++/Linux/Release && cp test.out bin/g++/Linux/Release/test.out
make[1]: Leaving directory '/home/yumetodo/string_split/test'
cd sample; make Release
make[1]: Entering directory '/home/yumetodo/string_split/sample'
g++ --version
g++ (GCC) 6.2.1 20160830
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

g++ sample.cpp -o sample.out -O2 -Wall -Wextra -std=c++11
mkdir -p bin/g++/Linux/Release && cp sample.out bin/g++/Linux/Release/sample.out
make[1]: Leaving directory '/home/yumetodo/string_split/sample'
cd benchmark; make Release
make[1]: Entering directory '/home/yumetodo/string_split/benchmark'
g++ --version
g++ (GCC) 6.2.1 20160830
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

g++ benchmark.cpp -o benchmark.out -O2 -Wall -Wextra -std=c++14 -Wunused
mkdir -p bin/g++/Linux/Release && cp benchmark.out bin/g++/Linux/Release/benchmark.out
make[1]: Leaving directory '/home/yumetodo/string_split/benchmark'
# cd test/
# ./test.out
[==========] Running 72 tests from 24 test cases.
[----------] Global test environment set-up.
[----------] 4 tests from ExtractLvalueBySingeCharTest
[ RUN      ] ExtractLvalueBySingeCharTest.type_char
[       OK ] ExtractLvalueBySingeCharTest.type_char (20ms)
[ RUN      ] ExtractLvalueBySingeCharTest.type_wchar_t
[       OK ] ExtractLvalueBySingeCharTest.type_wchar_t (119ms)
[ RUN      ] ExtractLvalueBySingeCharTest.type_char16_t
[       OK ] ExtractLvalueBySingeCharTest.type_char16_t (0ms)
[ RUN      ] ExtractLvalueBySingeCharTest.type_char32_t
[       OK ] ExtractLvalueBySingeCharTest.type_char32_t (0ms)
[----------] 4 tests from ExtractLvalueBySingeCharTest(141ms total)

[----------] 4 tests from ExtractLvalueByCStrTest
[ RUN      ] ExtractLvalueByCStrTest.type_char
[       OK ] ExtractLvalueByCStrTest.type_char (0ms)
[ RUN      ] ExtractLvalueByCStrTest.type_wchar_t
[       OK ] ExtractLvalueByCStrTest.type_wchar_t (0ms)
[ RUN      ] ExtractLvalueByCStrTest.type_char16_t
[       OK ] ExtractLvalueByCStrTest.type_char16_t (0ms)
[ RUN      ] ExtractLvalueByCStrTest.type_char32_t
[       OK ] ExtractLvalueByCStrTest.type_char32_t (1ms)
[----------] 4 tests from ExtractLvalueByCStrTest(1ms total)

[----------] 4 tests from ExtractLvalueByStlStrTest
[ RUN      ] ExtractLvalueByStlStrTest.type_char
[       OK ] ExtractLvalueByStlStrTest.type_char (0ms)
[ RUN      ] ExtractLvalueByStlStrTest.type_wchar_t
[       OK ] ExtractLvalueByStlStrTest.type_wchar_t (0ms)
[ RUN      ] ExtractLvalueByStlStrTest.type_char16_t
[       OK ] ExtractLvalueByStlStrTest.type_char16_t (0ms)
[ RUN      ] ExtractLvalueByStlStrTest.type_char32_t
[       OK ] ExtractLvalueByStlStrTest.type_char32_t (0ms)
[----------] 4 tests from ExtractLvalueByStlStrTest(0ms total)

[----------] 4 tests from SplitLvalueBySingeCharTest
[ RUN      ] SplitLvalueBySingeCharTest.type_char
[       OK ] SplitLvalueBySingeCharTest.type_char (0ms)
[ RUN      ] SplitLvalueBySingeCharTest.type_wchar_t
[       OK ] SplitLvalueBySingeCharTest.type_wchar_t (0ms)
[ RUN      ] SplitLvalueBySingeCharTest.type_char16_t
[       OK ] SplitLvalueBySingeCharTest.type_char16_t (0ms)
[ RUN      ] SplitLvalueBySingeCharTest.type_char32_t
[       OK ] SplitLvalueBySingeCharTest.type_char32_t (0ms)
[----------] 4 tests from SplitLvalueBySingeCharTest(0ms total)

[----------] 4 tests from SplitLvalueByCStrTest
[ RUN      ] SplitLvalueByCStrTest.type_char
[       OK ] SplitLvalueByCStrTest.type_char (0ms)
[ RUN      ] SplitLvalueByCStrTest.type_wchar_t
[       OK ] SplitLvalueByCStrTest.type_wchar_t (0ms)
[ RUN      ] SplitLvalueByCStrTest.type_char16_t
[       OK ] SplitLvalueByCStrTest.type_char16_t (0ms)
[ RUN      ] SplitLvalueByCStrTest.type_char32_t
[       OK ] SplitLvalueByCStrTest.type_char32_t (0ms)
[----------] 4 tests from SplitLvalueByCStrTest(0ms total)

[----------] 4 tests from SplitLvalueByStlStrTest
[ RUN      ] SplitLvalueByStlStrTest.type_char
[       OK ] SplitLvalueByStlStrTest.type_char (1ms)
[ RUN      ] SplitLvalueByStlStrTest.type_wchar_t
[       OK ] SplitLvalueByStlStrTest.type_wchar_t (0ms)
[ RUN      ] SplitLvalueByStlStrTest.type_char16_t
[       OK ] SplitLvalueByStlStrTest.type_char16_t (0ms)
[ RUN      ] SplitLvalueByStlStrTest.type_char32_t
[       OK ] SplitLvalueByStlStrTest.type_char32_t (0ms)
[----------] 4 tests from SplitLvalueByStlStrTest(1ms total)

[----------] 2 tests from SplitLvalueCovertToIntBySingeCharTest
[ RUN      ] SplitLvalueCovertToIntBySingeCharTest.type_char
[       OK ] SplitLvalueCovertToIntBySingeCharTest.type_char (0ms)
[ RUN      ] SplitLvalueCovertToIntBySingeCharTest.type_wchar_t
[       OK ] SplitLvalueCovertToIntBySingeCharTest.type_wchar_t (14ms)
[----------] 2 tests from SplitLvalueCovertToIntBySingeCharTest(14ms total)

[----------] 2 tests from SplitLvalueCovertToIntByCStrTest
[ RUN      ] SplitLvalueCovertToIntByCStrTest.type_char
[       OK ] SplitLvalueCovertToIntByCStrTest.type_char (0ms)
[ RUN      ] SplitLvalueCovertToIntByCStrTest.type_wchar_t
[       OK ] SplitLvalueCovertToIntByCStrTest.type_wchar_t (0ms)
[----------] 2 tests from SplitLvalueCovertToIntByCStrTest(0ms total)

[----------] 2 tests from SplitLvalueCovertToIntByStlStrTest
[ RUN      ] SplitLvalueCovertToIntByStlStrTest.type_char
[       OK ] SplitLvalueCovertToIntByStlStrTest.type_char (0ms)
[ RUN      ] SplitLvalueCovertToIntByStlStrTest.type_wchar_t
[       OK ] SplitLvalueCovertToIntByStlStrTest.type_wchar_t (0ms)
[----------] 2 tests from SplitLvalueCovertToIntByStlStrTest(0ms total)

[----------] 2 tests from SplitLvalueCovertToIntNoReturnBySingeCharTest
[ RUN      ] SplitLvalueCovertToIntNoReturnBySingeCharTest.type_char
[       OK ] SplitLvalueCovertToIntNoReturnBySingeCharTest.type_char (0ms)
[ RUN      ] SplitLvalueCovertToIntNoReturnBySingeCharTest.type_wchar_t
[       OK ] SplitLvalueCovertToIntNoReturnBySingeCharTest.type_wchar_t (0ms)
[----------] 2 tests from SplitLvalueCovertToIntNoReturnBySingeCharTest(0ms total)

[----------] 2 tests from SplitLvalueCovertToIntNoReturnByCStrTest
[ RUN      ] SplitLvalueCovertToIntNoReturnByCStrTest.type_char
[       OK ] SplitLvalueCovertToIntNoReturnByCStrTest.type_char (0ms)
[ RUN      ] SplitLvalueCovertToIntNoReturnByCStrTest.type_wchar_t
[       OK ] SplitLvalueCovertToIntNoReturnByCStrTest.type_wchar_t (0ms)
[----------] 2 tests from SplitLvalueCovertToIntNoReturnByCStrTest(0ms total)

[----------] 2 tests from SplitLvalueCovertToIntNoReturnByStlStrTest
[ RUN      ] SplitLvalueCovertToIntNoReturnByStlStrTest.type_char
[       OK ] SplitLvalueCovertToIntNoReturnByStlStrTest.type_char (0ms)
[ RUN      ] SplitLvalueCovertToIntNoReturnByStlStrTest.type_wchar_t
[       OK ] SplitLvalueCovertToIntNoReturnByStlStrTest.type_wchar_t (0ms)
[----------] 2 tests from SplitLvalueCovertToIntNoReturnByStlStrTest(0ms total)

[----------] 4 tests from ExtractRvalueBySingeCharTest
[ RUN      ] ExtractRvalueBySingeCharTest.type_char
[       OK ] ExtractRvalueBySingeCharTest.type_char (0ms)
[ RUN      ] ExtractRvalueBySingeCharTest.type_wchar_t
[       OK ] ExtractRvalueBySingeCharTest.type_wchar_t (0ms)
[ RUN      ] ExtractRvalueBySingeCharTest.type_char16_t
[       OK ] ExtractRvalueBySingeCharTest.type_char16_t (0ms)
[ RUN      ] ExtractRvalueBySingeCharTest.type_char32_t
[       OK ] ExtractRvalueBySingeCharTest.type_char32_t (0ms)
[----------] 4 tests from ExtractRvalueBySingeCharTest(0ms total)

[----------] 4 tests from ExtractRvalueByCStrTest
[ RUN      ] ExtractRvalueByCStrTest.type_char
[       OK ] ExtractRvalueByCStrTest.type_char (0ms)
[ RUN      ] ExtractRvalueByCStrTest.type_wchar_t
[       OK ] ExtractRvalueByCStrTest.type_wchar_t (0ms)
[ RUN      ] ExtractRvalueByCStrTest.type_char16_t
[       OK ] ExtractRvalueByCStrTest.type_char16_t (0ms)
[ RUN      ] ExtractRvalueByCStrTest.type_char32_t
[       OK ] ExtractRvalueByCStrTest.type_char32_t (0ms)
[----------] 4 tests from ExtractRvalueByCStrTest(1ms total)

[----------] 4 tests from ExtractRvalueByStlStrTest
[ RUN      ] ExtractRvalueByStlStrTest.type_char
[       OK ] ExtractRvalueByStlStrTest.type_char (0ms)
[ RUN      ] ExtractRvalueByStlStrTest.type_wchar_t
[       OK ] ExtractRvalueByStlStrTest.type_wchar_t (0ms)
[ RUN      ] ExtractRvalueByStlStrTest.type_char16_t
[       OK ] ExtractRvalueByStlStrTest.type_char16_t (0ms)
[ RUN      ] ExtractRvalueByStlStrTest.type_char32_t
[       OK ] ExtractRvalueByStlStrTest.type_char32_t (0ms)
[----------] 4 tests from ExtractRvalueByStlStrTest(0ms total)

[----------] 4 tests from SplitRvalueBySingeCharTest
[ RUN      ] SplitRvalueBySingeCharTest.type_char
[       OK ] SplitRvalueBySingeCharTest.type_char (0ms)
[ RUN      ] SplitRvalueBySingeCharTest.type_wchar_t
[       OK ] SplitRvalueBySingeCharTest.type_wchar_t (0ms)
[ RUN      ] SplitRvalueBySingeCharTest.type_char16_t
[       OK ] SplitRvalueBySingeCharTest.type_char16_t (0ms)
[ RUN      ] SplitRvalueBySingeCharTest.type_char32_t
[       OK ] SplitRvalueBySingeCharTest.type_char32_t (0ms)
[----------] 4 tests from SplitRvalueBySingeCharTest(0ms total)

[----------] 4 tests from SplitRvalueByCStrTest
[ RUN      ] SplitRvalueByCStrTest.type_char
[       OK ] SplitRvalueByCStrTest.type_char (0ms)
[ RUN      ] SplitRvalueByCStrTest.type_wchar_t
[       OK ] SplitRvalueByCStrTest.type_wchar_t (0ms)
[ RUN      ] SplitRvalueByCStrTest.type_char16_t
[       OK ] SplitRvalueByCStrTest.type_char16_t (0ms)
[ RUN      ] SplitRvalueByCStrTest.type_char32_t
[       OK ] SplitRvalueByCStrTest.type_char32_t (0ms)
[----------] 4 tests from SplitRvalueByCStrTest(0ms total)

[----------] 4 tests from SplitRvalueByStlStrTest
[ RUN      ] SplitRvalueByStlStrTest.type_char
[       OK ] SplitRvalueByStlStrTest.type_char (0ms)
[ RUN      ] SplitRvalueByStlStrTest.type_wchar_t
[       OK ] SplitRvalueByStlStrTest.type_wchar_t (0ms)
[ RUN      ] SplitRvalueByStlStrTest.type_char16_t
[       OK ] SplitRvalueByStlStrTest.type_char16_t (0ms)
[ RUN      ] SplitRvalueByStlStrTest.type_char32_t
[       OK ] SplitRvalueByStlStrTest.type_char32_t (0ms)
[----------] 4 tests from SplitRvalueByStlStrTest(1ms total)

[----------] 2 tests from SplitRvalueCovertToIntBySingeCharTest
[ RUN      ] SplitRvalueCovertToIntBySingeCharTest.type_char
[       OK ] SplitRvalueCovertToIntBySingeCharTest.type_char (0ms)
[ RUN      ] SplitRvalueCovertToIntBySingeCharTest.type_wchar_t
[       OK ] SplitRvalueCovertToIntBySingeCharTest.type_wchar_t (0ms)
[----------] 2 tests from SplitRvalueCovertToIntBySingeCharTest(0ms total)

[----------] 2 tests from SplitRvalueCovertToIntByCStrTest
[ RUN      ] SplitRvalueCovertToIntByCStrTest.type_char
[       OK ] SplitRvalueCovertToIntByCStrTest.type_char (0ms)
[ RUN      ] SplitRvalueCovertToIntByCStrTest.type_wchar_t
[       OK ] SplitRvalueCovertToIntByCStrTest.type_wchar_t (0ms)
[----------] 2 tests from SplitRvalueCovertToIntByCStrTest(0ms total)

[----------] 2 tests from SplitRvalueCovertToIntByStlStrTest
[ RUN      ] SplitRvalueCovertToIntByStlStrTest.type_char
[       OK ] SplitRvalueCovertToIntByStlStrTest.type_char (0ms)
[ RUN      ] SplitRvalueCovertToIntByStlStrTest.type_wchar_t
[       OK ] SplitRvalueCovertToIntByStlStrTest.type_wchar_t (0ms)
[----------] 2 tests from SplitRvalueCovertToIntByStlStrTest(0ms total)

[----------] 2 tests from SplitRvalueCovertToIntNoReturnBySingeCharTest
[ RUN      ] SplitRvalueCovertToIntNoReturnBySingeCharTest.type_char
[       OK ] SplitRvalueCovertToIntNoReturnBySingeCharTest.type_char (0ms)
[ RUN      ] SplitRvalueCovertToIntNoReturnBySingeCharTest.type_wchar_t
[       OK ] SplitRvalueCovertToIntNoReturnBySingeCharTest.type_wchar_t (0ms)
[----------] 2 tests from SplitRvalueCovertToIntNoReturnBySingeCharTest(0ms total)

[----------] 2 tests from SplitRvalueCovertToIntNoReturnByCStrTest
[ RUN      ] SplitRvalueCovertToIntNoReturnByCStrTest.type_char
[       OK ] SplitRvalueCovertToIntNoReturnByCStrTest.type_char (0ms)
[ RUN      ] SplitRvalueCovertToIntNoReturnByCStrTest.type_wchar_t
[       OK ] SplitRvalueCovertToIntNoReturnByCStrTest.type_wchar_t (0ms)
[----------] 2 tests from SplitRvalueCovertToIntNoReturnByCStrTest(0ms total)

[----------] 2 tests from SplitRvalueCovertToIntNoReturnByStlStrTest
[ RUN      ] SplitRvalueCovertToIntNoReturnByStlStrTest.type_char
[       OK ] SplitRvalueCovertToIntNoReturnByStlStrTest.type_char (0ms)
[ RUN      ] SplitRvalueCovertToIntNoReturnByStlStrTest.type_wchar_t
[       OK ] SplitRvalueCovertToIntNoReturnByStlStrTest.type_wchar_t (0ms)
[----------] 2 tests from SplitRvalueCovertToIntNoReturnByStlStrTest(0ms total)

[----------] Global test environment tear-down.
[==========] 72 tests from 24 testcase ran. (159ms total)
[  PASSED  ] 72 tests.

いいね。

余談

どういうわけかどこの.bashrcも読み込んでくれないようなのので、root.x86_64/etc/bash.bashrc

source "${HOME}/.bashrc"

を追加するといいかもしれない。msys2で使っていたものがほぼそのまま使える。例えば

export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[m\]\[\e[36m\]\w\[\e[m\]\[\e[0m\]\n$'

とか書いて置くと見た目がきれいでいい。

Kaspersky Internet Security 2016 16.0.1.445 のセルフディフェンス機能は盛大にバグっている(修正バッチが出たっぽい)

遭遇した現象

だいたいこんな感じで再現できる

  1. LinuxなどでWindows10を導入するパーティションを0クリアしてフォーマット(念のため)
  2. Windwos10 Install Disk(MSのサイトにて配布していたものをDVD-RWに焼いたもの)からWindwos10をインストール。念のためこちらでもインストール先のパーティションをフォーマット
  3. driver導入
  4. MSのサイトにて配布されているVisual Studio 2013, 2015のiso(2016/07/31時点の最新)をマウントし、順にインストール
  5. Kaspersky Internet Security 2016 16.0.1.445をインストール
  6. VSがハングする!!!

解決の糸口

こんなStack Overflowをみつけた

Visual Studio freezes or hangs on startup

When it hangs on the splash screen:

It could be that an anti-virus solution is blocking Visual Studio.

Kaspersky Internet Security 16.0.1.445 makes Visual Studio 2015 hang on the splash screen. The older version 16.0.0.614 works fine.

ほう・・・?

Kaspersky のサポートに問い合わせた

これではいまいち何が原因かわからないし、第一16.0.0.614はどっから手に入れればいいんだ。というわけで問い合わせた。

全文掲載すると長くてやっていられないので、要約すると

ということらしい。

具体的な対処手順については
【参考:カスペルスキー インターネット セキュリティ 2016 (16.0.1.445)をインストール後、アプリケーションのインストールが途中で停止してしまい完了しない、またはアプリケーションが正常に動かない】
を参照のこと。

感想

原因がわかってよかったけど、Windows10を10回も再インストールするはめになったので辛い

追記

いつの間にかKasperskyの公式サイトが更新されている。それによれば、修正バッチが出たっぽい。定義データベースをアップデート後にOSを再起動することでバッチが適用されるっぽいけどまだ試せていない。