Index: basis.cpp =================================================================== --- basis.cpp (revision 46) +++ basis.cpp (working copy) @@ -143,9 +143,9 @@ } // モジュールハンドルの取得は出来ないので、力技で位置を知る。 // このディレクトリにある全ての*.dll(case insensitive)を探し、 - // 中身にaya5.dllという文字列を含んでいたら、それを選ぶ。 + // 中身にyaya.dllという文字列を含んでいたら、それを選ぶ。 // ただし対応する*.txtが無ければdllの中身は見ずに次へ行く。 - modulename = L"aya5"; + modulename = L"yaya"; DIR* dh = opendir(narrow(path).c_str()); if (dh == NULL) { std::cerr << narrow(path) << "is not a directory!" << std::endl; @@ -162,8 +162,8 @@ struct stat sb; if (::stat(txt_file.c_str(), &sb) == 0) { // txtファイルがあるので、中身を見てみる。 - if (file_content_search(narrow(path) + fname, "aya5.dll") != std::string::npos) { - // これは文のDLLである。 + if (file_content_search(narrow(path) + fname, "yaya.dll") != std::string::npos) { + // これはYAYAのDLLである。 modulename = widen(drop_extension(fname)); break; } Index: ccct.cpp =================================================================== --- ccct.cpp (revision 46) +++ ccct.cpp (working copy) @@ -20,6 +20,10 @@ #include "manifest.h" #include "globaldef.h" +#ifdef POSIX +# include +#endif + /* #define PRIMARYLANGID(lgid) ((WORD)(lgid) & 0x3ff) */ @@ -34,6 +38,53 @@ //////////////////////////////////////// +#ifdef POSIX +namespace { + int wcsicmp(const wchar_t* a, const wchar_t* b) { + size_t lenA = wcslen(a); + size_t lenB = wcslen(b); + + if (lenA != lenB) { + return lenA - lenB; + } + else { + for (size_t i = 0; i < lenA; i++) { + wchar_t A = tolower(a[i]); + wchar_t B = tolower(b[i]); + + if (A != B) { + return A - B; + } + } + + return 0; + } + } + + int stricmp(const char* a, const char* b) { + size_t lenA = strlen(a); + size_t lenB = strlen(b); + + if (lenA != lenB) { + return lenA - lenB; + } + else { + for (size_t i = 0; i < lenA; i++) { + wchar_t A = tolower(a[i]); + wchar_t B = tolower(b[i]); + + if (A != B) { + return A - B; + } + } + + return 0; + } + } +} +#endif + + /* ----------------------------------------------------------------------- * 関数名 : Ccct::CheckCharset * 機能概要: Charset IDのチェック @@ -111,6 +162,7 @@ * (written by umeici) * ----------------------------------------------------------------------- */ +#ifndef POSIX char *Ccct::Ucs2ToMbcs(const yaya::char_t *wstr, int charset) { if (charset == CHARSET_UTF8) @@ -125,6 +177,7 @@ { return Ucs2ToMbcs(wstr.c_str(), charset); } +#endif /* ----------------------------------------------------------------------- * 関数名 : Ccct::MbcsToUcs2 @@ -133,6 +186,7 @@ * (written by umeici) * ----------------------------------------------------------------------- */ +#ifndef POSIX yaya::char_t *Ccct::MbcsToUcs2(const char *mstr, int charset) { if (charset == CHARSET_UTF8) @@ -147,12 +201,14 @@ { return MbcsToUcs2(mstr.c_str(), charset); } +#endif /* ----------------------------------------------------------------------- * 関数名 : Ccct::utf16be_to_sjis * 機能概要: UTF-16BE -> MBCS へ文字列のコード変換 * ----------------------------------------------------------------------- */ +#ifndef POSIX char *Ccct::utf16be_to_mbcs(const yaya::char_t *pUcsStr, int charset) { char *pAnsiStr = NULL; @@ -207,12 +263,14 @@ if (charset == CHARSET_SJIS) sys_setlocale(LC_ALL); return pAnsiStr; } +#endif /* ----------------------------------------------------------------------- * 関数名 : Ccct::mbcs_to_utf16be * 機能概要: MBCS -> UTF-16 へ文字列のコード変換 * ----------------------------------------------------------------------- */ +#ifndef POSIX yaya::char_t *Ccct::mbcs_to_utf16be(const char *pAnsiStr, int charset) { if (!pAnsiStr) @@ -239,12 +297,14 @@ if (charset == CHARSET_SJIS) sys_setlocale(LC_ALL); return pUcsStr; } +#endif /* ----------------------------------------------------------------------- * 関数名 : Ccct::utf16be_to_utf8 * 機能概要: UTF-16 -> UTF-8 へ文字列のコード変換 * ----------------------------------------------------------------------- */ +#ifndef POSIX char *Ccct::utf16be_to_utf8(const yaya::char_t *pUcsStr) { size_t nUcsNum = wcslen(pUcsStr); @@ -254,12 +314,14 @@ return pUtf8Str; } +#endif /* ----------------------------------------------------------------------- * 関数名 : Ccct::utf16be_to_utf8_sub * 機能概要: UTF-16 -> UTF-8変換(utf16be_to_utf8で使用します) * ----------------------------------------------------------------------- */ +#ifndef POSIX size_t Ccct::utf16be_to_utf8_sub( char *pUtf8, const yaya::char_t *pUcs2, size_t nUcsNum) { size_t nUtf8 = 0; @@ -284,12 +346,14 @@ return nUtf8; } +#endif /* ----------------------------------------------------------------------- * 関数名 : Ccct::utf8_to_utf16be * 機能概要: UTF-8 -> UTF-16BE へ文字列のコード変換 * ----------------------------------------------------------------------- */ +#ifndef POSIX yaya::char_t *Ccct::utf8_to_utf16be(const char *pUtf8Str) { size_t nUtf8Num = strlen(pUtf8Str); // UTF-8文字列には,'\0' がない @@ -299,12 +363,14 @@ return pUcsStr; } +#endif /* ----------------------------------------------------------------------- * 関数名 : Ccct::utf8_to_utf16be_sub * 機能概要: UTF-8 -> UTF-16BE変換(utf16be_to_utf8で使用します) * ----------------------------------------------------------------------- */ +#ifndef POSIX size_t Ccct::utf8_to_utf16be_sub( yaya::char_t *pUcs2, const char *pUtf8, size_t nUtf8Num) { size_t nUcs2 = 0; @@ -331,19 +397,17 @@ return nUcs2; } +#endif /* ----------------------------------------------------------------------- * 関数名 : Ccct::sys_setlocale * 機能概要: OSデフォルトの言語IDでロケール設定する * ----------------------------------------------------------------------- */ +#ifndef POSIX char *Ccct::sys_setlocale(int category) { -#ifdef POSIX - return setlocale(category,""); -#else return setlocale(category,".OCP"); -#endif /*switch(PRIMARYLANGID(GetSystemDefaultLangID())) { case LANG_JAPANESE: @@ -366,4 +430,4 @@ return setlocale(category, "English"); };*/ } - +#endif Index: makefile.posix =================================================================== --- makefile.posix (revision 46) +++ makefile.posix (working copy) @@ -7,7 +7,7 @@ MKDEP = mkdep # 作るライブラリ名の設定 -# これはdarwin用の設定で、libaya5.bundleを生成する。 +# これはdarwin用の設定で、libyaya.bundleを生成する。 # LinuxやBSDならpostfixを.soにする必要がある筈。 DYLIB_NAME_PREFIX = lib DYLIB_NAME_POSTFIX = .bundle @@ -15,7 +15,8 @@ # boostの場所を指定。 BOOST_INCLUDES = /sw/include # libboost_regex.aの場所を設定。 -LIBBOOST_REGEX_A = /sw/lib/libboost_regex-1_32.a +#LIBBOOST_REGEX_A = /sw/lib/libboost_regex-1_32.a +LIBBOOST_REGEX_A = ./libboost_regex.a # 注意: # このプログラムは wstring を使用しています。 @@ -24,15 +25,18 @@ # 追加するフラグ。 # CXXFLAGSは必要無ければ空でも良いが、LDFLAGSはdlopen可能なライブラリを # 作れる設定にしなければならない。darwinなら-bundle、LinuxやBSDなら-shared。 -CXXFLAGS = -O3 -Wno-long-double -LDFLAGS = -bundle +ARCH_FLAGS = -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk +CXXFLAGS = -O3 -Wno-long-double $(ARCH_FLAGS) +LDFLAGS = -bundle $(ARCH_FLAGS) ################## これより下は弄らなくてもコンパイル出来ます ################## -CXXFLAGS_ADD = -DPOSIX -I. -I$(BOOST_INCLUDES) +CXXFLAGS_ADD = -DPOSIX -I. -Itinyxpath -I$(BOOST_INCLUDES) LD_ADD = $(LIBBOOST_REGEX_A) LIBAYA5_OBJ = \ aya5.o \ + ayavm.o \ basis.o \ + ccct.o \ comment.o \ duplevinfo.o \ file.o \ @@ -44,8 +48,9 @@ localvariable.o \ log.o \ logexcode.o \ + manifest.o \ + misc.o \ mt19937ar.o \ - misc.o \ parser0.o \ parser1.o \ selecter.o \ @@ -57,9 +62,26 @@ posix_charconv.o \ strconv.o \ strconv_cp932.o \ - wordmatch.o + wordmatch.o \ + tinyxpath/action_store.o \ + tinyxpath/htmlutil.o \ + tinyxpath/lex_util.o \ + tinyxpath/node_set.o \ + tinyxpath/tinystr.o \ + tinyxpath/tinyxml.o \ + tinyxpath/tinyxmlerror.o \ + tinyxpath/tinyxmlparser.o \ + tinyxpath/tokenlist.o \ + tinyxpath/xml_util.o \ + tinyxpath/xpath_expression.o \ + tinyxpath/xpath_processor.o \ + tinyxpath/xpath_stack.o \ + tinyxpath/xpath_static.o \ + tinyxpath/xpath_stream.o \ + tinyxpath/xpath_syntax.o \ + $(NULL) -LIBAYA5 = $(DYLIB_NAME_PREFIX)aya5$(DYLIB_NAME_POSTFIX) +LIBAYA5 = $(DYLIB_NAME_PREFIX)yaya$(DYLIB_NAME_POSTFIX) all: $(LIBAYA5) @@ -73,6 +95,14 @@ $(LD) -o $@ $(LIBAYA5_OBJ) $(LDFLAGS) $(LD_ADD) $(STRIP) -x $@ +DISTDIR = yaya-src +dist: + rm -rf $(DISTDIR) + mkdir -p $(DISTDIR) + cp *.cpp *.h *.dsp *.dsw *.rc *.txt makefile.* $(DISTDIR) + zip -r $(DISTDIR).zip $(DISTDIR) + rm -rf $(DISTDIR) + .cpp.o: $(CXX) $(CXXFLAGS) $(CXXFLAGS_ADD) -o $@ -c $< Index: ayavm.cpp =================================================================== --- ayavm.cpp (revision 46) +++ ayavm.cpp (working copy) @@ -59,19 +59,19 @@ // ちょっとひどいハックですが…… #define FACTORY_DEFINE_THIS(classt,deft) \ - classt ## & CAyaVM:: ## deft ## () { \ - if ( m_ ## deft ## .get() == NULL ) { \ - m_ ## deft ## .reset(new classt ## (*this)); \ + classt & CAyaVM:: deft () { \ + if ( m_ ## deft .get() == NULL ) { \ + m_ ## deft .reset(new classt (*this)); \ } \ - return *(m_ ## deft ## .get()); \ + return *(m_ ## deft .get()); \ } #define FACTORY_DEFINE_PLAIN(classt,deft) \ - classt ## & CAyaVM:: ## deft ## () { \ - if ( m_ ## deft ## .get() == NULL ) { \ - m_ ## deft ## .reset(new classt ## ); \ + classt & CAyaVM:: deft () { \ + if ( m_ ## deft .get() == NULL ) { \ + m_ ## deft .reset(new classt); \ } \ - return *(m_ ## deft ## .get()); \ + return *(m_ ## deft .get()); \ }