rtoss

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/satoriya-utf8/ @ 29  →  /satoriya-utf8/ @ 30
/satoriya-utf8/satori/ssu.cpp
@@ -104,7 +104,7 @@
static const char zen_kana_2[] = "ガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポ";
static const char han_kana_2[] = "ガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポ";
 
extern bool calc(string& ioString);
extern bool calc(string& ioString,bool isStrict = false);
extern bool calc_float(string& ioString);
 
static string zen2han_internal(string &str,unsigned int flag = 0xffffU);
@@ -206,62 +206,62 @@
case 'c':
case 'C':
{
os << (char)atoi(str.c_str());
os << (char)zen2int(str);
break;
}
case 'd':
{
os << atoi(str.c_str());
os << zen2int(str);
break;
}
case 'i':
{
os << oct << atoi(str.c_str());
os << oct << zen2int(str);
break;
}
case 'o':
{
os << oct << strtoul(str.c_str(),NULL,10);
os << oct << strtoul(zen2han_internal(str).c_str(),NULL,10);
break;
}
case 'u':
{
os << strtoul(str.c_str(),NULL,10);
os << strtoul(zen2han_internal(str).c_str(),NULL,10);
break;
}
case 'x':
{
os << hex << nouppercase << strtoul(str.c_str(),NULL,10);
os << hex << nouppercase << strtoul(zen2han_internal(str).c_str(),NULL,10);
break;
}
case 'X':
{
os << hex << uppercase << strtoul(str.c_str(),NULL,10);
os << hex << uppercase << strtoul(zen2han_internal(str).c_str(),NULL,10);
break;
}
case 'e':
{
os << scientific << nouppercase << strtod(str.c_str(),NULL);
os << scientific << nouppercase << strtod(zen2han_internal(str).c_str(),NULL);
break;
}
case 'E':
{
os << scientific << uppercase << strtod(str.c_str(),NULL);
os << scientific << uppercase << strtod(zen2han_internal(str).c_str(),NULL);
break;
}
case 'g':
{
os << scientific << fixed << nouppercase << strtod(str.c_str(),NULL);
os << scientific << fixed << nouppercase << strtod(zen2han_internal(str).c_str(),NULL);
break;
}
case 'G':
{
os << scientific << fixed << uppercase << strtod(str.c_str(),NULL);
os << scientific << fixed << uppercase << strtod(zen2han_internal(str).c_str(),NULL);
break;
}
case 'f':
{
os << fixed << strtod(str.c_str(),NULL);
os << fixed << strtod(zen2han_internal(str).c_str(),NULL);
break;
}
case 'n': break;
@@ -319,7 +319,7 @@
string exp = iArguments[0];
if ( !calc(exp) )
return SRV(400, string()+"'"+iArguments[0]+"' 式が計算不能です。");
if ( exp!="0" )
if ( zen2int(exp) != 0 )
return iArguments[1]; // 真
else
if ( iArguments.size()==3 )
@@ -346,10 +346,8 @@
SRV _nswitch(deque<string>& iArguments, deque<string>& oValues) {
if ( iArguments.size()<2 )
return SRV(400, "引数が足りません。");
if ( !calc(iArguments[0]) )
return SRV(400, string()+"'"+iArguments[0]+"' 式が計算不能です。");
 
int n = stoi(iArguments[0]);
int n = zen2int(iArguments[0]);
//iArguments.pop_front();
//if ( iArguments.size()>n )
if ( n>0 && iArguments.size()>n )
@@ -370,7 +368,7 @@
string exp = string("(") + lhs + ")==(" + iArguments[i] + ")";
if ( !calc(exp) )
return SRV(400, string()+"switchの"+itos((i-1)/2+1)+"個目、式 '"+exp+"' は計算不能でした。");
if ( exp!="0" )
if ( zen2int(exp) != 0 )
return SRV(200, iArguments[i+1]);
}
return SRV(204);
@@ -388,7 +386,7 @@
string exp = lhs + iArguments[i];
if ( !calc(exp) )
return SRV(400, string()+"iflistの"+itos((i-1)/2+1)+"個目、式 '"+exp+"' は計算不能でした。");
if ( exp!="0" )
if ( zen2int(exp) != 0 )
return SRV(200, iArguments[i+1]);
}
return SRV(204);
@@ -408,12 +406,12 @@
const int len = sjis_strlen(p);
 
// 始点
int start = atoi(iArguments[1].c_str());
int start = zen2int(iArguments[1]);
if ( start < 0 )
start = len + start;
 
// 始点からのオフセット値
int offset = (iArguments.size()<=2) ? len : atoi(iArguments[2].c_str());
int offset = (iArguments.size()<=2) ? len : zen2int(iArguments[2]);
if ( offset==0 || offset==INT_MIN ) // INT_MINの時は符号反転が効かないので0扱い。
return SRV(204);
if ( offset<0 ) {
@@ -446,9 +444,7 @@
split(iArguments[0],iArguments[1],vec);
}
else {
if ( !calc(iArguments[2]) )
return SRV(400, "splitの第3引数は式または数値である必要があります。");
split(iArguments[0],iArguments[1],vec,stoi(iArguments[2]));
split(iArguments[0],iArguments[1],vec,zen2int(iArguments[2]));
}
 
for ( strvec::iterator i=vec.begin() ; i!=vec.end() ; ++i )
@@ -503,19 +499,19 @@
SRV _compare(deque<string>& iArguments, deque<string>& oValues) {
if ( iArguments.size()!=2 )
return SRV(400, "引数の個数が正しくありません。");
return (strcmp(iArguments[0].c_str(), iArguments[1].c_str())==0) ? "1" : "0";
return (stricmp(zen2han_internal(iArguments[0]).c_str(), zen2han_internal(iArguments[1]).c_str())==0) ? "1" : "0";
}
 
SRV _compare_head(deque<string>& iArguments, deque<string>& oValues) {
if ( iArguments.size()!=2 )
return SRV(400, "引数の個数が正しくありません。");
return compare_head(iArguments[0], iArguments[1]) ? "1" : "0";
return compare_head(zen2han_internal(iArguments[0]), zen2han_internal(iArguments[1])) ? "1" : "0";
}
 
SRV _compare_tail(deque<string>& iArguments, deque<string>& oValues) {
if ( iArguments.size()!=2 )
return SRV(400, "引数の個数が正しくありません。");
return compare_tail(iArguments[0], iArguments[1]) ? "1" : "0";
return compare_tail(zen2han_internal(iArguments[0]), zen2han_internal(iArguments[1])) ? "1" : "0";
}
 
SRV _length(deque<string>& iArguments, deque<string>& oValues) {
@@ -779,7 +775,7 @@
SRV _at(deque<string>& iArguments, deque<string>& oValues) {
 
if ( iArguments.size()==2 ) {
const char* p = sjis_at(iArguments.at(0).c_str(), stoi(iArguments.at(1)));
const char* p = sjis_at(iArguments.at(0).c_str(), zen2int(iArguments.at(1)));
return (p==NULL || *p=='\0') ? "" : string(p, _ismbblead(*p)?2:1);
}
//else if ( iArguments.size()==3 ) {
/satoriya-utf8/satori/SaoriClient.cpp
@@ -59,9 +59,9 @@
const string& key = i->first;
const string& value = i->second;
 
if ( compare_head(key, "Value") && isdigit(key[strlen("Value")]) )
if ( compare_head(key, "Value") && isdigit(key[const_strlen("Value")]) )
{
const int pos = atoi(key.c_str() + strlen("Value"));
const int pos = atoi(key.c_str() + const_strlen("Value"));
if ( pos<0 || pos>65536 )
{
continue;
/satoriya-utf8/satori/satori_load_unload.cpp
@@ -18,6 +18,7 @@
#include <fstream>
#include <cassert>
#include <ctime> // for randomize
#include <locale.h>
 
#include "../_/Utilities.h"
#include "../_/random.h"
@@ -277,13 +278,13 @@
reload_flag = false;
 
if ( variables.find("ゴースト起動時間累計ミリ秒") != variables.end() ) {
tick_count_total = stoi(variables["ゴースト起動時間累計ミリ秒"]);
tick_count_total = zen2int(variables["ゴースト起動時間累計ミリ秒"]);
}
else {
tick_count_total = stoi(variables["ゴースト起動時間累計(ms)"]);
tick_count_total = zen2int(variables["ゴースト起動時間累計(ms)"]);
variables.erase("ゴースト起動時間累計(ms)");
}
variables["起動回数"] = itos( stoi(variables["起動回数"])+1 );
variables["起動回数"] = itos( zen2int(variables["起動回数"])+1 );
 
// 「単語の追加」で登録された単語を覚えておく
const map< string, Family<Word> >& m = words.compatible();
@@ -369,7 +370,6 @@
 
out << ENCODE(line) << endl;
for (strmap::const_iterator it=variables.begin() ; it!=variables.end() ; ++it) {
string zen2han(string str);
string str = zen2han(it->first);
if ( str[0]=='S' && aredigits(str.c_str()+1) )
continue;
/satoriya-utf8/satori/makefile.mingw
@@ -58,7 +58,7 @@
SakuraDLLHost.o \
SaoriHost.o \
ssu.o \
TimeCommands.o \
TimeCommands.o
 
DYLIB_NAME = $(DYLIB_NAME_PREFIX)satori$(DYLIB_NAME_POSTFIX)
 
/satoriya-utf8/satori/satori_Kakko.cpp
@@ -62,7 +62,7 @@
if ( iCallName == "バイト値" ) {
if ( iArgv.size() ) {
char bytes[2] = {0,0};
bytes[0] = stoi(iArgv[0]);
bytes[0] = zen2int(iArgv[0]);
return bytes;
}
else {
@@ -125,15 +125,15 @@
if ( iCallName=="loop" ) {
int init=1, max=0, step=1, arg_size=iArgv.size();
if ( arg_size==2 )
max=stoi(iArgv[1]);
max=zen2int(iArgv[1]);
else if ( arg_size==3 ) {
init=stoi(iArgv[1]);
max=stoi(iArgv[2]);
init=zen2int(iArgv[1]);
max=zen2int(iArgv[2]);
}
else if ( arg_size==4 ) {
init=stoi(iArgv[1]);
max=stoi(iArgv[2]);
step=stoi(iArgv[3]);
init=zen2int(iArgv[1]);
max=zen2int(iArgv[2]);
step=zen2int(iArgv[3]);
}
else
return "";
@@ -180,7 +180,7 @@
if ( iCallName=="remember" ) {
if ( iArgv.size() == 1 ) {
int n = stoi(iArgv[0]);
int n = zen2int(iArgv[0]);
if ( mResponseHistory.size() > n ) {
return mResponseHistory[n];
}
@@ -304,7 +304,7 @@
oIsSysValue = true;
 
// Event通知時の引数取得
int ref=atoi(hankaku.c_str()+1);
int ref=stoi(hankaku.c_str()+1);
if (ref>=0 && ref<mReferences.size()) {
return &(mReferences[ref]);
}
@@ -325,7 +325,7 @@
 
strvec& khr = kakko_replace_history.top();
 
int ref = atoi(hankaku.c_str() +1) - 1;
int ref = stoi(hankaku.c_str() +1) - 1;
if ( ref>=0 && ref < khr.size() ) {
return &(khr[ref]);
}
@@ -339,7 +339,7 @@
if ( mCallStack.empty() ) { return NULL; }
 
// callによる呼び出しの引数を参照S
int ref = atoi(hankaku.c_str() +1);
int ref = stoi(hankaku.c_str() +1);
strvec& v = mCallStack.top();
if ( ref >= 0 && ref < v.size() ) {
return &(v[ref]);
@@ -352,7 +352,7 @@
oIsSysValue = true;
 
// SAORIなどコール時の結果処理
int ref=atoi(hankaku.c_str()+1);
int ref=stoi(hankaku.c_str()+1);
if (ref>=0 && ref<mKakkoCallResults.size()) {
return &(mKakkoCallResults[ref]);
}
@@ -495,9 +495,8 @@
continue;
}
 
bool calc(string&); // declare
string exp = *i;
if ( calc(exp) )
if ( calc(exp,true) )
*i=exp;
}
}
@@ -582,15 +581,24 @@
oResult = "※ 乱数の指定が変です ※";
}
else {
int bottom = stoi(zen2han(vec[0]));
int top = stoi(zen2han(vec[1]));
string vec0 = zen2han(vec[0]);
int bottom = stoi(vec0);
int top = zen2int(vec[1]);
if ( bottom > top )
Swap(&bottom, &top);
 
if ( bottom == top )
oResult = int2zen(top);
else
oResult = int2zen( random(top-bottom+1) + bottom );
if ( vec0 != vec[0] ) {
if ( bottom == top )
oResult = int2zen(top);
else
oResult = int2zen( random(top-bottom+1) + bottom );
}
else {
if ( bottom == top )
oResult = itos(top);
else
oResult = itos( random(top-bottom+1) + bottom );
}
}
}
else if ( iName == "里々のバージョン" ) {
@@ -667,17 +675,17 @@
else if ( iName == "単純起動分" ) { oResult=int2zen( (::GetTickCount()-tick_count_at_load)/1000/60 ); }
#endif
#ifdef POSIX
else if (iName == "OS起動時" || iName == "OS起動分" || iName == "OS起動秒" ||
iName == "単純OS起動秒" || iName == "単純OS起動分") {
else if (hankaku == "OS起動時" || hankaku == "OS起動分" || hankaku == "OS起動秒" ||
hankaku == "単純OS起動秒" || hankaku == "単純OS起動分") {
// 取得する方法が無い。
oResult = int2zen(0);
}
#else
else if ( iName == "OS起動時" ) { oResult=int2zen(DwordToSystemTime(::GetTickCount()).wHour); }
else if ( iName == "OS起動分" ) { oResult=int2zen(DwordToSystemTime(::GetTickCount()).wMinute); }
else if ( iName == "OS起動秒" ) { oResult=int2zen(DwordToSystemTime(::GetTickCount()).wSecond); }
else if ( iName == "単純OS起動秒" ) { oResult=int2zen( ::GetTickCount() / 1000 ); }
else if ( iName == "単純OS起動分" ) { oResult=int2zen( ::GetTickCount() / 1000/60 ); }
else if ( hankaku == "OS起動時" ) { oResult=int2zen(DwordToSystemTime(::GetTickCount()).wHour); }
else if ( hankaku == "OS起動分" ) { oResult=int2zen(DwordToSystemTime(::GetTickCount()).wMinute); }
else if ( hankaku == "OS起動秒" ) { oResult=int2zen(DwordToSystemTime(::GetTickCount()).wSecond); }
else if ( hankaku == "単純OS起動秒" ) { oResult=int2zen( ::GetTickCount() / 1000 ); }
else if ( hankaku == "単純OS起動分" ) { oResult=int2zen( ::GetTickCount() / 1000/60 ); }
#endif
#ifdef POSIX
else if (iName == "累計時") {
@@ -716,19 +724,19 @@
else if ( iName == "単純累計秒" ) { oResult=int2zen( (::GetTickCount() - tick_count_at_load + tick_count_total)/1000 ); }
else if ( iName == "単純累計分" ) { oResult=int2zen( (::GetTickCount() - tick_count_at_load + tick_count_total)/1000/60 ); }
#endif
else if ( iName == "time_t" ) { time_t tm; time(&tm); oResult=itos(tm); }
else if ( iName == "最終トークからの経過秒" ) { oResult=itos(second_from_last_talk); }
else if ( hankaku == "time_t" ) { time_t tm; time(&tm); oResult=int2zen(tm); }
else if ( iName == "最終トークからの経過秒" ) { oResult=int2zen(second_from_last_talk); }
 
else if ( compare_head(iName, "サーフェス") && aredigits(iName.c_str()+15) ) {
oResult=itos(cur_surface[ atoi(iName.c_str()+15) ]);
oResult=itos(cur_surface[ zen2int(iName.c_str()+15) ]);
}
else if ( compare_head(iName, "前回終了時サーフェス") && iName.length() > 30 ) {
oResult=itos(last_talk_exiting_surface[ stoi(zen2han(iName.c_str()+30)) ]);
oResult=itos(last_talk_exiting_surface[ zen2int(iName.c_str()+30) ]);
}
 
#ifndef POSIX
else if ( compare_head(iName, "ウィンドウハンドル") && iName.length() > 27 ) {
int character = stoi(zen2han(iName.c_str()+27));
int character = zen2int(iName.c_str()+27);
map<int,HWND>::iterator found = characters_hwnd.find(character);
if ( found != characters_hwnd.end() ) {
oResult = uitos((unsigned int)characters_hwnd[character]);
@@ -742,7 +750,7 @@
}
else if ( iName == "起動しているゴースト数" ) {
updateGhostsInfo(); // ゴースト情報を更新
oResult = itos(ghosts_info.size());
oResult = int2zen(ghosts_info.size());
}
else if ( compare_head(iName, "isempty") && iName.size()>=8 ) {
const char* p = iName.c_str()+7;
@@ -783,7 +791,7 @@
count += f->size_of_element();
}
 
oResult = itos(count);
oResult = int2zen(count);
}
}
 
@@ -821,34 +829,34 @@
oResult = "-1";
}
}
else if ( compare_head(iName, "FMO") && iName.size()>4 ) { // FMO?head
else if ( compare_head(hankaku, "FMO") && hankaku.size()>4 ) { // FMO?head
updateGhostsInfo(); // ゴースト情報を更新
unsigned int digit = 3;
while ( isdigit(iName[digit]) ) { ++digit; }
while ( isdigit(hankaku[digit]) ) { ++digit; }
 
if ( digit > 3 ) {
unsigned int index = strtoul(iName.c_str()+3,NULL,10);
unsigned int index = strtoul(hankaku.c_str()+3,NULL,10);
if ( index < ghosts_info.size() ) {
strmap& m=ghosts_info[index];
string value(iName.c_str()+digit);
string value(hankaku.c_str()+digit);
if ( m.find(value) != m.end() ) {
oResult = m[value];
}
}
}
}
else if ( compare_head(iName, "count") )
else if ( compare_head(hankaku, "count") )
{
string name(iName.c_str()+5);
if ( name=="Words" ) { oResult = itos( words.size_of_family() ); }
else if ( name=="Variable" ) { oResult = itos( variables.size() ); }
else if ( name=="Anchor" ) { oResult = itos( anchors.size() ); }
else if ( name=="Talk" ) { oResult = itos( talks.size_of_element() ); }
else if ( name=="Word" ) { oResult = itos( words.size_of_element() ); }
string name(hankaku.c_str()+5);
if ( name=="Words" ) { oResult = int2zen( words.size_of_family() ); }
else if ( name=="Variable" ) { oResult = int2zen( variables.size() ); }
else if ( name=="Anchor" ) { oResult = int2zen( anchors.size() ); }
else if ( name=="Talk" ) { oResult = int2zen( talks.size_of_element() ); }
else if ( name=="Word" ) { oResult = int2zen( words.size_of_element() ); }
else if ( name=="NoNameTalk" )
{
Family<Talk>* f = talks.get_family("");
oResult = itos( ( f==0 ) ? 0 : f->size_of_element() );
oResult = int2zen( ( f==0 ) ? 0 : f->size_of_element() );
}
else if ( name=="EventTalk" )
{
@@ -856,7 +864,7 @@
for ( map< string, Family<Talk> >::const_iterator it = talks.compatible().begin() ; it != talks.compatible().end() ; ++it )
if ( compare_head(it->first, "On") )
n += it->second.size_of_element();
oResult = itos(n);
oResult = int2zen(n);
}
else if ( name=="OtherTalk" )
{
@@ -864,7 +872,7 @@
for ( map< string, Family<Talk> >::const_iterator it = talks.compatible().begin() ; it != talks.compatible().end() ; ++it )
if ( !compare_head(it->first, "On") && !it->first.empty() )
n += it->second.size_of_element();
oResult = itos(n);
oResult = int2zen(n);
}
else if ( name=="Line" )
{
@@ -882,7 +890,7 @@
{
n += it->second.size_of_element();
}
oResult = itos(n);
oResult = int2zen(n);
}
else if ( name=="Parenthesis" )
{
@@ -908,7 +916,7 @@
n += count(**el_it, "(");
}
}
oResult = itos(n);
oResult = int2zen(n);
}
}
else if ( iName=="次のトーク" ) {
@@ -917,10 +925,11 @@
oResult = it->second;
}
else if ( compare_head(iName,"次から") && compare_tail(iName,"回目のトーク") ) {
int count = stoi( zen2han( string(iName.c_str()+9, iName.length()-9-18) ) );
int count = zen2int( string(iName.c_str()+9, iName.length()-9-18) );
map<int,string>::iterator it = reserved_talk.find(count);
if ( it != reserved_talk.end() )
if ( it != reserved_talk.end() ) {
oResult = it->second;
}
}
else if ( compare_head(iName, "トーク「") && compare_tail(iName, "」の予約有無") ) { // 「約」には\が含まれる。
string str(iName, 12, iName.length()-12-18);
@@ -933,11 +942,11 @@
}
}
else if ( iName == "予約トーク数" ) { // 「約」には\が含まれる。
oResult = itos( reserved_talk.size() );
oResult = int2zen( reserved_talk.size() );
}
else if ( iName == "イベント名" ) { oResult=mRequestID; }
else if ( iName == "直前の選択肢名" ) { oResult=last_choice_name; }
else if ( iName == "pwd" ) { oResult=mBaseFolder; }
else if ( hankaku == "pwd" ) { oResult=mBaseFolder; }
else if ( iName == "本体の所在" ) { oResult=mExeFolder; }
else if ( mRequestMap.find(iName) != mRequestMap.end() ) {
oResult = mRequestMap[iName];
/satoriya-utf8/satori/Selector.h
@@ -2,6 +2,9 @@
#include <list>
#include <exception>
#include <stdexcept>
#ifndef __MINGW32__
# include <typeinfo.h>
#endif
using namespace std;
 
#include "OverlapController.h"
/satoriya-utf8/satori/satori_sentence.cpp
@@ -300,7 +300,7 @@
string r;
if ( !calculate(words[1], r) )
break;
if ( r=="0" || r=="0" ) {
if ( zen2int(r) == 0 ) {
sender << "*計算結果が0だったため、続行します。" << endl;
continue;
}
@@ -397,7 +397,7 @@
c=get_a_chr(p);
if ( c=="\x01" ) { //0xff0x01=スコープ切り替え 後に半角数値が1文字続く
c=get_a_chr(p);
int speaker_tmp = atoi(c.c_str());
int speaker_tmp = stoi(c.c_str());
if ( is_speaked(speaker) && speaker != speaker_tmp ) {
result += append_at_scope_change;
chars_spoken += 2;
/satoriya-utf8/satori/satori.h
@@ -400,14 +400,10 @@
};
 
//---------------------------------------------------------------------------
string int2zen(int i);
string zen2han(string str);
bool calc(string&);
 
bool calc(string&,bool isStrict = false);
void diet_script(string&);
 
 
 
 
//---------------------------------------------------------------------------
#endif
 
/satoriya-utf8/satori/satori_tool.cpp
@@ -141,41 +141,6 @@
#endif
#endif
 
string zen2han(string str)
{
static const char before[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-+";
static const char after[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-+";
char buf1[4]="\0\0\0", buf2[2]="\0";
for (int n=0 ; n<sizeof(after) ; ++n) {
buf1[0]=before[n*3];
buf1[1]=before[n*3+1];
buf1[2]=before[n*3+2];
buf2[0]=after[n];
replace(str, buf1, buf2);
}
return str;
}
 
string int2zen(int i) {
static const char* ary[] = {"0","1","2","3","4","5","6","7","8","9"};
string zen;
if ( i<0 ) {
zen += "-";
i = -i; // INT_MINの時は符号が反転しない
}
string han=itos(i);
const char* p=han.c_str();
if ( i==INT_MIN )
++p;
for ( ; *p != '\0' ; ++p ) {
assert(*p>='0' && *p<='9');
zen += ary[*p-'0'];
}
return zen;
}
 
 
string Satori::GetWord(const string& name) {
return "いぬ";
}
@@ -362,7 +327,7 @@
// mapにしようよ。
 
if ( key == "喋り間隔" ) {
talk_interval = stoi( zen2han(value) );
talk_interval = zen2int(value);
if ( talk_interval<3 ) talk_interval=0; // 3未満は喋らない
// 喋りカウント初期化
@@ -373,7 +338,7 @@
}
if ( key == "喋り間隔誤差" ) {
talk_interval_random = stoi( zen2han(value) );
talk_interval_random = zen2int(value);
if ( talk_interval_random>100 ) talk_interval_random=100;
if ( talk_interval_random<0 ) talk_interval_random=0;
@@ -400,13 +365,13 @@
}
 
if ( key == "呼び出し回数制限" ) {
m_nest_limit = stoi( zen2han(value) );
m_nest_limit = zen2int(value);
if ( m_nest_limit < 0 ) { m_nest_limit = 0; }
return true;
}
 
if ( key == "ジャンプ回数制限" ) {
m_jump_limit = stoi( zen2han(value) );
m_jump_limit = zen2int(value);
if ( m_jump_limit < 0 ) { m_jump_limit = 0; }
return true;
}
@@ -455,26 +420,26 @@
}
 
if ( compare_head(key, "サーフェス加算値") && aredigits(key.c_str() + const_strlen("サーフェス加算値")) ) {
int n = atoi(key.c_str() + strlen("サーフェス加算値"));
surface_add_value[n]=stoi( zen2han(value) );
int n = zen2int(key.c_str() + const_strlen("サーフェス加算値"));
surface_add_value[n]= zen2int(value);
variables[string()+"デフォルトサーフェス"+itos(n)] = value;
next_default_surface[n]=stoi( zen2han(value) );
next_default_surface[n] = zen2int(value);
if ( !is_speaked_anybody() )
default_surface[n]=next_default_surface[n];
return true;
}
 
if ( compare_head(key, "デフォルトサーフェス") && aredigits(key.c_str() + const_strlen("デフォルトサーフェス")) ) {
int n = atoi(key.c_str() + strlen("デフォルトサーフェス"));
next_default_surface[n]=stoi( zen2han(value) );
int n = zen2int(key.c_str() + const_strlen("デフォルトサーフェス"));
next_default_surface[n]= zen2int(value);
if ( !is_speaked_anybody() )
default_surface[n]=next_default_surface[n];
return true;
}
 
if ( compare_head(key, "BalloonOffset") && aredigits(key.c_str() + const_strlen("BalloonOffset")) ) {
int n = atoi(key.c_str() + strlen("BalloonOffset"));
int n = stoi(key.c_str() + const_strlen("BalloonOffset"));
BalloonOffset[n] = value;
validBalloonOffset[n] = true;
return true;
@@ -486,12 +451,12 @@
}
if ( key == "なでられ持続秒数") {
nade_valid_time_initializer = stoi( zen2han(value) );
nade_valid_time_initializer = zen2int(value);
return true;
}
 
if ( key == "なでられ反応回数") {
nade_sensitivity = stoi( zen2han(value) );
nade_sensitivity = zen2int(value);
return true;
}
 
@@ -516,9 +481,9 @@
}
if ( key == "自動挿入ウェイトの倍率" ) {
rate_of_auto_insert_wait=stoi( zen2han(value) );
rate_of_auto_insert_wait= zen2int(value);
rate_of_auto_insert_wait = min(1000, max(0, rate_of_auto_insert_wait));
variables["自動挿入ウェイトの倍率"] = itos(rate_of_auto_insert_wait);
variables["自動挿入ウェイトの倍率"] = int2zen(rate_of_auto_insert_wait);
return true;
}
@@ -552,13 +517,13 @@
if ( compare_head(key,"単語群「") && compare_tail(key,"」の重複回避") ) {
variables.erase(key);
words.setOC( string(key.c_str()+8, key.length()-8-12), value );
words.setOC( string(key.c_str()+12, key.length()-12-18), value );
return true;
}
 
if ( compare_head(key,"文「") && compare_tail(key,"」の重複回避") ) {
variables.erase(key);
talks.setOC( string(key.c_str()+4, key.length()-4-12), value );
talks.setOC( string(key.c_str()+6, key.length()-6-18), value );
return true;
}
@@ -574,7 +539,7 @@
if ( compare_head(key,"次から") && compare_tail(key,"回目のトーク") ) {
variables.erase(key);
int count = stoi( zen2han( string(key.c_str()+6, key.length()-6-12) ) );
int count = zen2int( string(key.c_str()+9, key.length()-9-18) );
if ( count<=0 ) {
sender << "トーク予約、設定値がヘンです。" << endl;
}
@@ -624,7 +589,7 @@
}
if ( key == "自動セーブ間隔" ) {
mAutoSaveInterval = stoi(zen2han(value));
mAutoSaveInterval = zen2int(value);
mAutoSaveCurrentCount = mAutoSaveInterval;
if ( mAutoSaveInterval > 0 )
sender << "" << itos(mAutoSaveInterval) << "秒間隔で自動セーブを行います。" << endl;
@@ -649,14 +614,14 @@
return true;
}
if ( key.size()>6 && compare_tail(key, "タイマ") ) {
string name(key.c_str(), strlen(key.c_str())-6);
if ( key.size()>9 && compare_tail(key, "タイマ") ) {
string name(key.c_str(), strlen(key.c_str())-9);
/*if ( sentences.find(name) == sentences.end() ) {
result = string("※ タイマ終了時のジャンプ先 *")+name+" がありません ※";
// セーブデータ復帰時を考慮
}
else */{
int sec = stoi(zen2han(value));
int sec = zen2int(value);
if ( sec < 1 ) {
variables.erase(key);
if ( timer.find(name)!=timer.end() ) {
/satoriya-utf8/satori/satori.cpp
@@ -13,7 +13,7 @@
const char* gSatoriNameW = "里々";
const char* gSatoriCraftman = "Yagi Kushigahama/The Maintenance Shop";
const char* gSatoriCraftmanW = "櫛ヶ浜やぎ/整備班";
const char* gSatoriVersion = "phase Mc143-3";
const char* gSatoriVersion = "phase Mc143-10";
const char* gShioriVersion = "3.0";
const char* gSaoriVersion = "1.0";
 
@@ -76,5 +76,5 @@
// 計算失敗
return false;
}
return ( r!="0" && r!="0" );
return ( zen2int(r) != 0 );
}
File deleted
/satoriya-utf8/_/calc_int.cpp
/satoriya-utf8/_/Sender.cpp
@@ -1,12 +1,13 @@
#include "Sender.h"
#ifdef POSIX
# include "Utilities.h"
# include <stdio.h>
# include <stdarg.h>
#else
# include "Utilities.h"
//# include <mbctype.h> // for _ismbblead()
#endif
#include <locale.h>
#include <stdio.h>
#include <stdarg.h>
 
//////////DEBUG/////////////////////////
#ifdef _WINDOWS
/satoriya-utf8/_/Sender.h
@@ -6,6 +6,7 @@
*/
 
#include <iostream>
#include <stdio.h>
using namespace std;
 
#ifndef POSIX
/satoriya-utf8/_/calc_float.cpp
@@ -1,6 +1,7 @@
#include "stltool.h"
#include "simple_stack.h"
 
#include <ctype.h>
 
 
typedef double VALUE_TYPE;
/satoriya-utf8/_/stltool.cpp
@@ -755,4 +755,47 @@
return buf;
}
 
string zen2han(const char *s)
{
string str(s);
 
static const char before[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-+";
static const char after[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-+";
char buf1[4]="\0\0\0", buf2[2]="\0";
for (int n=0 ; n<sizeof(after) ; ++n) {
buf1[0]=before[n*3];
buf1[1]=before[n*3+1];
buf1[2]=before[n*3+2];
buf2[0]=after[n];
replace(str, buf1, buf2);
}
return str;
}
 
string int2zen(int i) {
static const char* ary[] = {"0","1","2","3","4","5","6","7","8","9"};
string zen;
if ( i<0 ) {
zen += "-";
i = -i; // INT_MINの時は符号が反転しない
}
string han=itos(i);
const char* p=han.c_str();
if ( i==INT_MIN )
++p;
for ( ; *p != '\0' ; ++p ) {
assert(*p>='0' && *p<='9');
zen += ary[*p-'0'];
}
return zen;
}
 
int zen2int(const char *str)
{
return stoi(zen2han(str));
}
 
 
 
 
/satoriya-utf8/_/calc.cpp
@@ -34,9 +34,9 @@
// 文字列 !~ 文字列
 
// 全て半角であること。空白等は認めない
extern bool calc(const char* iExpression, string& oResult);
extern bool calc(const char* iExpression, string& oResult,bool isStrict);
// 半角全角スペースとタブ記号の消去、数字・記号の半角化まで全部やったげる
extern bool calc(string& ioString);
extern bool calc(string& ioString,bool isStrict = false);
 
 
struct calc_element {
@@ -183,7 +183,7 @@
}
 
 
static bool calc_polish(simple_stack<calc_element>& polish, string& oResult) {
static bool calc_polish(simple_stack<calc_element>& polish, string& oResult,bool isStrict) {
simple_stack<string> stack;
for ( int n=0 ; n<polish.size()-1 ; n++ ) {
calc_element& el=polish[n];
@@ -205,13 +205,14 @@
string rhs=stack.pop(), lhs=stack.pop();
if ( aredigits(lhs) && aredigits(rhs) ) {
stack.push(itos( stoi(lhs)*stoi(rhs) ));
} else if ( aredigits(rhs) ) {
} else if ( aredigits(rhs) && ! isStrict ) {
int num = stoi(rhs);
stack.push("");
for (int i=0;i<num;++i)
stack.top() += lhs;
} else
} else {
return false;
}
}
a_op_b(/)
a_op_b(%)
@@ -220,8 +221,10 @@
string rhs=stack.pop(), lhs=stack.pop();
if ( aredigits(lhs) && aredigits(rhs) ) {
stack.push(itos( stoi(lhs)+stoi(rhs) ));
} else if ( ! isStrict ) {
stack.push(lhs+rhs);
} else {
stack.push(lhs+rhs);
return false;
}
}
else if ( el.str == "-" ) {
@@ -229,9 +232,11 @@
string rhs=stack.pop(), lhs=stack.pop();
if ( aredigits(lhs) && aredigits(rhs) ) {
stack.push(itos( stoi(lhs)-stoi(rhs) ));
} else {
} else if ( ! isStrict ) {
erase(lhs, rhs);
stack.push(lhs);
} else {
return false;
}
}
else if ( el.str == "=~" || el.str == "!~" ) {
@@ -258,7 +263,7 @@
return true;
}
 
bool calc(const char* iExpression, string& oResult) {
bool calc(const char* iExpression, string& oResult,bool isStrict) {
deque<calc_element> org;
if ( !make_deque(iExpression, org) )
return false;
@@ -280,48 +285,56 @@
polish.push(stack.pop());
 
// 計算
return calc_polish(polish, oResult);
return calc_polish(polish, oResult,isStrict);
}
 
 
bool calc(string& ioString) {
erase(ioString, " ");
erase(ioString, " ");
erase(ioString, "\t");
bool calc(string& ioString,bool isStrict)
{
string iString = ioString;
 
// ニョロは単体で演算子にはしたくないー
replace(ioString, "=~", "=~");
replace(ioString, "!~", "!~");
erase(iString, " ");
erase(iString, " ");
erase(iString, "\t");
 
replace(ioString, "+", "+");
replace(ioString, "-", "-");
replace(ioString, "*", "*");
replace(ioString, "×", "*");
replace(ioString, "/", "/");
replace(ioString, "÷", "/");
replace(ioString, "%", "%");
replace(ioString, "^", "^");
replace(ioString, "<", "<");
replace(ioString, ">", ">");
replace(ioString, "=", "=");
replace(ioString, "!", "!");
replace(ioString, "&", "&");
replace(ioString, "|", "|");
replace(ioString, "(", "(");
replace(ioString, ")", ")");
replace(ioString, "0", "0");
replace(ioString, "1", "1");
replace(ioString, "2", "2");
replace(ioString, "3", "3");
replace(ioString, "4", "4");
replace(ioString, "5", "5");
replace(ioString, "6", "6");
replace(ioString, "7", "7");
replace(ioString, "8", "8");
replace(ioString, "9", "9");
// ニョロは単体で演算子にはしたくないー
replace(iString, "=~", "=~");
replace(iString, "!~", "!~");
 
replace(iString, "+", "+");
replace(iString, "-", "-");
replace(iString, "*", "*");
replace(iString, "×", "*");
replace(iString, "/", "/");
replace(iString, "÷", "/");
replace(iString, "%", "%");
replace(iString, "^", "^");
replace(iString, "<", "<");
replace(iString, ">", ">");
replace(iString, "=", "=");
replace(iString, "!", "!");
replace(iString, "&", "&");
replace(iString, "|", "|");
replace(iString, "(", "(");
replace(iString, ")", ")");
replace(iString, "0", "0");
replace(iString, "1", "1");
replace(iString, "2", "2");
replace(iString, "3", "3");
replace(iString, "4", "4");
replace(iString, "5", "5");
replace(iString, "6", "6");
replace(iString, "7", "7");
replace(iString, "8", "8");
replace(iString, "9", "9");
string theResult;
if ( !calc(ioString.c_str(), theResult) )
if ( !calc(iString.c_str(), theResult, isStrict) ) {
return false;
ioString = theResult;
}
 
//全角・半角とかをむやみに変換しないように気をつける
if ( theResult != iString ) {
ioString = theResult;
}
return true;
}
/satoriya-utf8/_/Dialog.h
@@ -5,6 +5,7 @@
#include <commctrl.h>
#include <stdarg.h>
#include <stdio.h>
#include <string>
 
// ダイアログボックスの基底クラス。
// 使い方は下の方に。
@@ -57,24 +58,22 @@
int GetPos( LPARAM lParam ) { return ::SendMessage( (HWND)lParam, TBM_GETPOS, 0 ,0 ); }
void SetPos( int id, int pos ) { ::SendMessage( toHWND(id), TBM_SETPOS, (WPARAM)TRUE , (LPARAM)pos ); }
 
int GetTextLength(int id) { return ::SendMessage(toHWND(id), WM_GETTEXTLENGTH, 0, 0); }
void GetText( int id, LPSTR str, int max ) { ::GetDlgItemText( m_hDlg, id, str, max ); }
void SetText( int id, const char* format, ... );
void SetSel( int id, int nStart, int nEnd ) { ::SendDlgItemMessage( m_hDlg, id, EM_SETSEL, (WPARAM)nStart, (LPARAM)nEnd ); }
void SelAll( int id ) { SetSel( id, 0, -1 ); }
 
#ifdef _STRING_
void GetText(int id, string& str) {
void GetText(int id, std::string& str) {
int len = GetTextLength(id);
char* buf = new char[len+1];
GetText(id, buf, len+1);
str=buf;
delete [] buf;
}
string GetText(int id) { string str; GetText(id, str); return str; }
void SetText(int id, const string& str) { ::SetDlgItemText(m_hDlg, id, str.c_str()); }
#endif
std::string GetText(int id) { std::string str; GetText(id, str); return str; }
void SetText(int id, const std::string& str) { ::SetDlgItemText(m_hDlg, id, str.c_str()); }
 
int GetTextLength(int id) { return ::SendMessage(toHWND(id), WM_GETTEXTLENGTH, 0, 0); }
void GetText( int id, LPSTR str, int max ) { ::GetDlgItemText( m_hDlg, id, str, max ); }
void SetText( int id, const char* format, ... );
void SetSel( int id, int nStart, int nEnd ) { ::SendDlgItemMessage( m_hDlg, id, EM_SETSEL, (WPARAM)nStart, (LPARAM)nEnd ); }
void SelAll( int id ) { SetSel( id, 0, -1 ); }
 
void End( int nResult ) { ::EndDialog( m_hDlg, nResult ); }
 
void LB_ResetContent( int id ) { ::SendDlgItemMessage( m_hDlg, id, LB_RESETCONTENT, 0, 0 ); }
/satoriya-utf8/_/Win32.h
@@ -12,7 +12,7 @@
// 文字列を設定する。hWndはNULLでも構わない。
bool SetClipBoard(HWND iWnd, const char* iFormat, ...);
#ifdef _STRING_
string GetClipBoard();
std::string GetClipBoard();
#endif
 
//----------------------------------------------------------
/satoriya-utf8/_/stltool.h
@@ -23,6 +23,7 @@
#include <fstream>
#include <deque>
#include <cassert>
#include <stdio.h>
using namespace std;
 
 
@@ -483,11 +484,20 @@
return num;
}
 
string int2zen(int i);
 
int zen2int(const char *str);
inline int zen2int(const string &s)
{
return zen2int(s.c_str());
}
 
string zen2han(const char *str);
inline string zen2han(const string &s)
{
return zen2han(s.c_str());
}
 
 
 
// ディレクトリ区切り
#ifdef POSIX
#define DIR_CHAR '/'