From 4f049544ec827a9f1f16a913d7241f29179fdde7 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 13 May 2020 20:29:23 +0200 Subject: [PATCH] fix char related code --- src/animated-mesh-md2.cpp | 2 +- src/driver-types.cpp | 2 +- src/file-archive.cpp | 2 +- src/file-system.cpp | 4 ++-- src/gui-environment.cpp | 2 +- src/gui-skin.cpp | 4 ++-- src/material-flags.cpp | 2 +- src/material-types.cpp | 2 +- src/material.cpp | 12 ++++++------ src/primitive-types.cpp | 2 +- src/scene-manager.cpp | 2 +- src/vertex3d.cpp | 2 +- src/video-driver.cpp | 4 ++-- src/wchar.cpp | 12 +++--------- 14 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/animated-mesh-md2.cpp b/src/animated-mesh-md2.cpp index 11e680f..141a634 100644 --- a/src/animated-mesh-md2.cpp +++ b/src/animated-mesh-md2.cpp @@ -28,7 +28,7 @@ using namespace irr; scene::EMD2_ANIMATION_TYPE scm_to_md2_animation_type (SCM md2_animation_type) { - char* flag = scm_to_utf8_stringn (scm_symbol_to_string (md2_animation_type), NULL); + char* flag = scm_to_utf8_string (scm_symbol_to_string (md2_animation_type)); if (!strcmp (flag, "stand")) { return scene::EMAT_STAND; diff --git a/src/driver-types.cpp b/src/driver-types.cpp index d18ecfa..3486251 100644 --- a/src/driver-types.cpp +++ b/src/driver-types.cpp @@ -28,7 +28,7 @@ using namespace irr; video::E_DRIVER_TYPE scm_to_driver_type (SCM driver_type) { - char* driverType = scm_to_utf8_stringn (scm_symbol_to_string (driver_type), NULL); + char* driverType = scm_to_utf8_string (scm_symbol_to_string (driver_type)); if (!strcmp (driverType, "null")) { return video::EDT_NULL; diff --git a/src/file-archive.cpp b/src/file-archive.cpp index 1527520..ffaac42 100644 --- a/src/file-archive.cpp +++ b/src/file-archive.cpp @@ -28,7 +28,7 @@ using namespace irr; io::E_FILE_ARCHIVE_TYPE scm_to_file_archive_type (SCM file_archive_type) { - char* type = scm_to_utf8_stringn (scm_symbol_to_string (file_archive_type), NULL); + char* type = scm_to_utf8_string (scm_symbol_to_string (file_archive_type)); if (!strcmp (type, "zip")) { return io::EFAT_ZIP; diff --git a/src/file-system.cpp b/src/file-system.cpp index fe9b062..afb9f0b 100644 --- a/src/file-system.cpp +++ b/src/file-system.cpp @@ -46,11 +46,11 @@ IFileSystem_addFileArchive (SCM file_system, return scm_from_bool (((io::IFileSystem*)scm_to_irr_pointer (file_system))-> - addFileArchive (scm_to_utf8_stringn (filename, NULL), + addFileArchive (scm_to_utf8_string (filename), scm_to_bool (ignore_case), scm_to_bool (ignore_paths), scm_to_file_archive_type (archive_type), - scm_to_utf8_stringn (password, NULL), + scm_to_utf8_string (password), retArchiveReference)); } diff --git a/src/gui-environment.cpp b/src/gui-environment.cpp index 1ee3e5d..ae2e087 100644 --- a/src/gui-environment.cpp +++ b/src/gui-environment.cpp @@ -186,7 +186,7 @@ IGUIEnvironment_getFont (SCM gui_environment, { gui::IGUIFont* font = ((gui::IGUIEnvironment*)scm_to_irr_pointer (gui_environment))-> - getFont (scm_to_utf8_stringn (filename, NULL)); + getFont (scm_to_utf8_string (filename)); return scm_from_pointer ((void*)font, NULL); } diff --git a/src/gui-skin.cpp b/src/gui-skin.cpp index fae5c3d..6e4f66e 100644 --- a/src/gui-skin.cpp +++ b/src/gui-skin.cpp @@ -80,7 +80,7 @@ init_gui_skin (void) gui::EGUI_DEFAULT_COLOR scm_to_default_color (SCM default_color) { - char* color = scm_to_utf8_stringn (scm_symbol_to_string (default_color), NULL); + char* color = scm_to_utf8_string (scm_symbol_to_string (default_color)); if (!strcmp (color, "3d-dark-shadow")) { return gui::EGDC_3D_DARK_SHADOW; @@ -191,7 +191,7 @@ scm_to_default_color (SCM default_color) gui::EGUI_DEFAULT_FONT scm_to_default_font (SCM default_font) { - char* font = scm_to_utf8_stringn (scm_symbol_to_string (default_font), NULL); + char* font = scm_to_utf8_string (scm_symbol_to_string (default_font)); if (!strcmp (font, "default")) { return gui::EGDF_DEFAULT; diff --git a/src/material-flags.cpp b/src/material-flags.cpp index 0b28f00..5b0c93a 100644 --- a/src/material-flags.cpp +++ b/src/material-flags.cpp @@ -27,7 +27,7 @@ using namespace irr; video::E_MATERIAL_FLAG scm_to_material_flag (SCM material_flag) { - char* flag = scm_to_utf8_stringn (scm_symbol_to_string (material_flag), NULL); + char* flag = scm_to_utf8_string (scm_symbol_to_string (material_flag)); if (!strcmp (flag, "wireframe")) { return video::EMF_WIREFRAME; diff --git a/src/material-types.cpp b/src/material-types.cpp index 19511f8..5faad73 100644 --- a/src/material-types.cpp +++ b/src/material-types.cpp @@ -28,7 +28,7 @@ using namespace irr; video::E_MATERIAL_TYPE scm_to_material_type (SCM material_type) { - char* type = scm_to_utf8_stringn (scm_symbol_to_string (material_type), NULL); + char* type = scm_to_utf8_string (scm_symbol_to_string (material_type)); if (!strcmp (type, "solid")) { return video::EMT_SOLID; diff --git a/src/material.cpp b/src/material.cpp index 72467ac..7c2eb0e 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -128,7 +128,7 @@ init_material (void) video::E_ANTI_ALIASING_MODE scm_to_anti_aliasing_mode (SCM anti_aliasing_mode) { - char* mode = scm_to_utf8_stringn (scm_symbol_to_string (anti_aliasing_mode), NULL); + char* mode = scm_to_utf8_string (scm_symbol_to_string (anti_aliasing_mode)); if (!strcmp (mode, "off")) { return video::EAAM_OFF; @@ -167,7 +167,7 @@ scm_to_anti_aliasing_mode (SCM anti_aliasing_mode) video::E_BLEND_OPERATION scm_to_blend_operation (SCM blend_operation) { - char* operation = scm_to_utf8_stringn (scm_symbol_to_string (blend_operation), NULL); + char* operation = scm_to_utf8_string (scm_symbol_to_string (blend_operation)); if (!strcmp (operation, "none")) { return video::EBO_NONE; @@ -218,7 +218,7 @@ scm_to_blend_operation (SCM blend_operation) video::E_COLOR_MATERIAL scm_to_color_material (SCM color_material) { - char* material = scm_to_utf8_stringn (scm_symbol_to_string (color_material), NULL); + char* material = scm_to_utf8_string (scm_symbol_to_string (color_material)); if (!strcmp (material, "none")) { return video::ECM_NONE; @@ -253,7 +253,7 @@ scm_to_color_material (SCM color_material) video::E_COLOR_PLANE scm_to_color_plane (SCM color_plane) { - char* plane = scm_to_utf8_stringn (scm_symbol_to_string (color_plane), NULL); + char* plane = scm_to_utf8_string (scm_symbol_to_string (color_plane)); if (!strcmp (plane, "none")) { return video::ECP_NONE; @@ -292,7 +292,7 @@ scm_to_color_plane (SCM color_plane) video::E_COMPARISON_FUNC scm_to_comparison_func (SCM comparison_func) { - char* func = scm_to_utf8_stringn (scm_symbol_to_string (comparison_func), NULL); + char* func = scm_to_utf8_string (scm_symbol_to_string (comparison_func)); if (!strcmp (func, "never")) { return video::ECFN_NEVER; @@ -335,7 +335,7 @@ scm_to_comparison_func (SCM comparison_func) video::E_POLYGON_OFFSET scm_to_polygon_offset (SCM polygon_offset) { - char* offset = scm_to_utf8_stringn (scm_symbol_to_string (polygon_offset), NULL); + char* offset = scm_to_utf8_string (scm_symbol_to_string (polygon_offset)); if (!strcmp (offset, "back")) { return video::EPO_BACK; diff --git a/src/primitive-types.cpp b/src/primitive-types.cpp index 9704803..7f4db7f 100644 --- a/src/primitive-types.cpp +++ b/src/primitive-types.cpp @@ -28,7 +28,7 @@ using namespace irr; scene::E_PRIMITIVE_TYPE scm_to_primitive_type (SCM primitive_type) { - char* type = scm_to_utf8_stringn (scm_symbol_to_string (primitive_type), NULL); + char* type = scm_to_utf8_string (scm_symbol_to_string (primitive_type)); if (!strcmp (type, "points")) { return scene::EPT_POINTS; diff --git a/src/scene-manager.cpp b/src/scene-manager.cpp index f120955..815b83a 100644 --- a/src/scene-manager.cpp +++ b/src/scene-manager.cpp @@ -323,7 +323,7 @@ ISceneManager_getMesh (SCM scene_manager, SCM filename) { scene::ISceneManager* smgr = (scene::ISceneManager*) scm_to_irr_pointer (scene_manager); - scene::IAnimatedMesh* mesh = smgr->getMesh(scm_to_utf8_stringn (filename, NULL)); + scene::IAnimatedMesh* mesh = smgr->getMesh(scm_to_utf8_string (filename)); return scm_from_pointer ((void*) mesh, NULL); } diff --git a/src/vertex3d.cpp b/src/vertex3d.cpp index 9b7a1e8..2bc305c 100644 --- a/src/vertex3d.cpp +++ b/src/vertex3d.cpp @@ -60,7 +60,7 @@ init_vertex3d (void) video::E_VERTEX_TYPE scm_to_vertex_type (SCM vertex_type) { - char* type = scm_to_utf8_stringn (scm_symbol_to_string (vertex_type), NULL); + char* type = scm_to_utf8_string (scm_symbol_to_string (vertex_type)); if (!strcmp (type, "standard")) { return video::EVT_STANDARD; diff --git a/src/video-driver.cpp b/src/video-driver.cpp index b52b24f..45e8358 100644 --- a/src/video-driver.cpp +++ b/src/video-driver.cpp @@ -119,7 +119,7 @@ IVideoDriver_getTexture (SCM video_driver, SCM filename) { video::IVideoDriver* driver = (video::IVideoDriver*) scm_to_irr_pointer (video_driver); - video::ITexture* texture = driver->getTexture (scm_to_utf8_stringn (filename, NULL)); + video::ITexture* texture = driver->getTexture (scm_to_utf8_string (filename)); return scm_from_pointer ((void*) texture, NULL); } @@ -160,7 +160,7 @@ init_video_driver (void) video::E_TRANSFORMATION_STATE scm_to_transformation_state (SCM transformation_state) { - char* state = scm_to_utf8_stringn (scm_symbol_to_string (transformation_state), NULL); + char* state = scm_to_utf8_string (scm_symbol_to_string (transformation_state)); if (!strcmp (state, "view")) { return video::ETS_VIEW; diff --git a/src/wchar.cpp b/src/wchar.cpp index a41a003..e9c98ed 100644 --- a/src/wchar.cpp +++ b/src/wchar.cpp @@ -24,19 +24,13 @@ #include "wchar.h" SCM -scm_from_wide_char_string (const wchar_t* wtext) +scm_from_wide_char_string (const wchar_t* text) { - size_t nbytes = wcslen (wtext) + 1; - char* ctext = (char*)malloc (nbytes); - wcstombs (ctext, wtext, nbytes); - return scm_from_utf8_string (ctext); + return scm_from_utf32_string ((const scm_t_wchar*) text); } const wchar_t* scm_to_wide_char_string (SCM text) { - char* ctext = scm_to_utf8_stringn (text, NULL); - wchar_t* wtext = (wchar_t*)malloc ((strlen (ctext) + 1) * sizeof (wchar_t)); - mbstowcs (wtext, ctext, strlen (ctext) + 1); - return wtext; + return (const wchar_t*) scm_to_utf32_string (text); } -- 2.39.5