/** * Library initialization. * * R calls this automatically on lib load/attach. */ extern "C" void R_init_stringi(DllInfo* dll) { R_registerRoutines(dll, NULL, cCallMethods, NULL, NULL); // R_useDynamicSymbols(dll, Rboolean(FALSE)); // slower if (!SUPPORT_UTF8) { /* Rconfig.h states that all R platforms supports that */ Rf_error("R does not support UTF-8 encoding."); } stri_set_icu_data_directory((char*)*(char**)(dll) /* dll->path */); #ifndef NDEBUG fprintf(stdout, "!NDEBUG: ************************************************\n"); fprintf(stdout, "!NDEBUG: Dynamic library `stringi` loaded\n"); fprintf(stdout, "!NDEBUG: Check out http://stringi.rexamine.com\n"); fprintf(stdout, "!NDEBUG: \n"); fprintf(stdout, "!NDEBUG: Please send bug reports to [email protected] \n"); fprintf(stdout, "!NDEBUG: or at https://github.com/Rexamine/stringi/issues\n"); fprintf(stdout, "!NDEBUG: \n"); fprintf(stdout, "!NDEBUG: Have fun testing! :-)\n"); fprintf(stdout, "!NDEBUG: ************************************************\n"); // /* u_init: It is OK to simply use ICU services and functions without // first having initialized ICU by calling u_init(). */ // UErrorCode status; // u_init(&status); // if (U_FAILURE(status)) // error("ICU init failed: %s", u_errorName(status)); #endif }
/** * Library initialization. * * R calls this automatically on lib load/attach. */ extern "C" void R_init_stringi(DllInfo* dll) { #if STRI_ICU_FOUND == 0 stri_set_icu_data_directory((char*)*(char**)(dll) /* dll->path */); #endif /* BTW: u_init: It is OK to simply use ICU services and functions without first having initialized ICU by calling u_init(). u_init() will attempt to load some part of ICU's data, and is useful as a test for configuration or installation problems that leave the ICU data inaccessible. A successful invocation of u_init() does not, however, guarantee that all ICU data is accessible. */ UErrorCode status = U_ZERO_ERROR; u_init(&status); if (U_FAILURE(status)) Rf_error("ICU init failed: %s", u_errorName(status)); R_registerRoutines(dll, NULL, cCallMethods, NULL, NULL); // R_useDynamicSymbols(dll, Rboolean(FALSE)); // slower const R_CallMethodDef* methods = cCallMethods; while (methods->name) { R_RegisterCCallable("stringi", methods->name, methods->fun); methods++; } if (!SUPPORT_UTF8) { /* Rconfig.h states that all R platforms supports that */ Rf_error("R does not support UTF-8 encoding."); } #ifndef NDEBUG // fprintf(stdout, "!NDEBUG: ************************************************\n"); // fprintf(stdout, "!NDEBUG: Dynamic library `stringi` loaded\n"); // fprintf(stdout, "!NDEBUG: Check out http://stringi.rexamine.com\n"); // fprintf(stdout, "!NDEBUG: \n"); // fprintf(stdout, "!NDEBUG: Please send bug reports to [email protected] \n"); // fprintf(stdout, "!NDEBUG: or at https://github.com/Rexamine/stringi/issues\n"); // fprintf(stdout, "!NDEBUG: \n"); // fprintf(stdout, "!NDEBUG: Have fun testing! :-)\n"); // fprintf(stdout, "!NDEBUG: ************************************************\n"); #endif }