mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Remove cmake build to simplify things.
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -17,6 +17,7 @@ dst | ||||
|  | ||||
| # Tools | ||||
| xxd | ||||
| xxd.exe | ||||
|  | ||||
| # VSCode | ||||
| .vs | ||||
|   | ||||
							
								
								
									
										144
									
								
								CMakeLists.txt
									
									
									
									
									
								
							
							
						
						
									
										144
									
								
								CMakeLists.txt
									
									
									
									
									
								
							| @@ -1,144 +0,0 @@ | ||||
| # Copyright (c) 2018 Calvin Rose | ||||
| #  | ||||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| # of this software and associated documentation files (the "Software"), to | ||||
| # deal in the Software without restriction, including without limitation the | ||||
| # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||||
| # sell copies of the Software, and to permit persons to whom the Software is | ||||
| # furnished to do so, subject to the following conditions: | ||||
| #  | ||||
| # The above copyright notice and this permission notice shall be included in | ||||
| # all copies or substantial portions of the Software. | ||||
| #  | ||||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||||
| # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||||
| # IN THE SOFTWARE. | ||||
|  | ||||
| cmake_minimum_required(VERSION 3.7) | ||||
| project(dst) | ||||
|  | ||||
| # Set Some Variables | ||||
| set(TARGET_NAME ${PROJECT_NAME}) | ||||
| set (CMAKE_C_STANDARD 99) | ||||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") | ||||
|  | ||||
| # Set configurations | ||||
| SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") | ||||
| SET(CMAKE_C_FLAGS_RELEASE "-O2") | ||||
| SET(CMAKE_C_FLAGS_DEBUG  "-O0 -g") | ||||
|  | ||||
| include_directories(src/include) | ||||
| include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||||
|  | ||||
| set(CORE_SOURCES | ||||
| src/core/abstract.c | ||||
| src/core/array.c | ||||
| src/core/asm.c | ||||
| src/core/buffer.c | ||||
| src/core/bytecode.c | ||||
| src/core/cfuns.c | ||||
| src/core/compile.c | ||||
| src/core/corelib.c | ||||
| src/core/emit.c | ||||
| src/core/fiber.c | ||||
| src/core/gc.c | ||||
| src/core/io.c | ||||
| src/core/marsh.c | ||||
| src/core/math.c | ||||
| src/core/os.c | ||||
| src/core/parse.c | ||||
| src/core/regalloc.c | ||||
| src/core/run.c | ||||
| src/core/specials.c | ||||
| src/core/string.c | ||||
| src/core/strtod.c | ||||
| src/core/struct.c | ||||
| src/core/symcache.c | ||||
| src/core/table.c | ||||
| src/core/tuple.c | ||||
| src/core/util.c | ||||
| src/core/value.c | ||||
| src/core/vector.c | ||||
| src/core/vm.c | ||||
| src/core/wrap.c | ||||
|  | ||||
| src/core/compile.h | ||||
| src/core/emit.h | ||||
| src/core/fiber.h | ||||
| src/core/gc.h | ||||
| src/core/regalloc.h | ||||
| src/core/state.h | ||||
| src/core/symcache.h | ||||
| src/core/util.h | ||||
|  | ||||
| generated/core.h | ||||
| ) | ||||
|  | ||||
| set(MAINCLIENT_SOURCES | ||||
| src/mainclient/main.c | ||||
| src/mainclient/line.c | ||||
| src/mainclient/line.h | ||||
|  | ||||
| generated/init.h | ||||
| ) | ||||
|  | ||||
| set(REPL_SOURCES | ||||
| ${CORE_SOURCES} | ||||
| ${MAINCLIENT_SOURCES} | ||||
| ) | ||||
|  | ||||
| # Set Public headers | ||||
| set(DST_PUBLIC_HEADERS | ||||
| src/include/dst/dst.h | ||||
| ) | ||||
|  | ||||
| # Build the executable | ||||
| add_executable(${TARGET_NAME} ${REPL_SOURCES}) | ||||
| if (APPLE) | ||||
|     # macOS flags here | ||||
| elseif (UNIX) | ||||
|     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic") | ||||
| 	target_link_libraries(${TARGET_NAME} m dl) | ||||
| endif (APPLE) | ||||
| set_target_properties(${TARGET_NAME} PROPERTIES PUBLIC_HEADER "${DST_PUBLIC_HEADERS}") | ||||
|  | ||||
| # Generate header containing standard library | ||||
| add_custom_command( | ||||
|     OUTPUT generated/core.h | ||||
|     COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gencore.cmake | ||||
|     DEPENDS src/core/core.dst | ||||
|     COMMENT "Generating stl bootstrap C header for embedding" | ||||
| ) | ||||
|  | ||||
| # Generate header containing main client script | ||||
| add_custom_command( | ||||
|     OUTPUT generated/init.h | ||||
|     COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/geninit.cmake | ||||
|     DEPENDS src/mainclient/init.dst | ||||
|     COMMENT "Generating mainclient init C header for embedding" | ||||
| ) | ||||
|  | ||||
| # Install | ||||
| install(TARGETS ${TARGET_NAME} | ||||
|         LIBRARY DESTINATION "lib" | ||||
|         RUNTIME DESTINATION "bin" | ||||
|         PUBLIC_HEADER DESTINATION "include/dst" | ||||
| ) | ||||
|  | ||||
| # Add some test scripts | ||||
| enable_testing() | ||||
| add_test(NAME suite0 COMMAND ${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/test/suite0.dst | ||||
|     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||||
| add_test(NAME suite1 COMMAND ${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/test/suite1.dst | ||||
|     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||||
|  | ||||
| # Add convenience script to run repl | ||||
| add_custom_target(run | ||||
|     COMMAND ${TARGET_NAME} | ||||
|     DEPENDS ${TARGET_NAME} | ||||
|     WORKING_DIRECTORY ${CMAKE_PROJECT_DIR} | ||||
| ) | ||||
							
								
								
									
										20
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								README.md
									
									
									
									
									
								
							| @@ -83,11 +83,13 @@ $ | ||||
|  | ||||
| ## Compiling and Running | ||||
|  | ||||
| Dst can be built with Make or CMake. | ||||
| Use Make if you are on a posix system and don't like CMake. | ||||
| Use CMake if you are on Windows or like CMake. | ||||
| Dst only uses Make and batch files to compile on Posix and windows | ||||
| respectively. To configure dst, edit the header file src/include/dst/dst.h | ||||
| before compilation. | ||||
|  | ||||
| ### Make | ||||
| ### Posix | ||||
|  | ||||
| On most platforms, use Make to build dst. To  | ||||
|  | ||||
| ```sh | ||||
| cd somewhere/my/projects/dst | ||||
| @@ -95,11 +97,13 @@ make | ||||
| make test | ||||
| ``` | ||||
|  | ||||
| ### CMake | ||||
| ### Windows | ||||
|  | ||||
| On a posix system using make as the target build system,  | ||||
| compiling and running is as follows (this is the same as | ||||
| most CMake based projects). | ||||
| 1. Install [Visual Studio](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=15#) | ||||
| or [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15#) | ||||
| 2. Run a Visual Studio Command Prompt (cl.exe and link.exe need to be on the PATH) and cd to the directory with dst. | ||||
| 3. Run `build` to compile dst. | ||||
| 4. Run `build test` to make sure everything is working. | ||||
|  | ||||
| ```sh | ||||
| cd somewhere/my/projects/dst | ||||
|   | ||||
							
								
								
									
										21
									
								
								appveyor.yml
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								appveyor.yml
									
									
									
									
									
								
							| @@ -19,28 +19,15 @@ matrix: | ||||
|  | ||||
| # skip unsupported combinations | ||||
| init: | ||||
| - set arch= | ||||
| - if "%arch%"=="Win64" ( set arch= Win64) | ||||
| - echo %arch% | ||||
| - echo %APPVEYOR_BUILD_WORKER_IMAGE% | ||||
| - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( set generator="Visual Studio 15 2017%arch%" ) | ||||
| - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" ( set generator="Visual Studio 14 2015%arch%" ) | ||||
| - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2013" ( set generator="Visual Studio 12 2013%arch%" ) | ||||
| - echo %generator% | ||||
| - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" | ||||
|  | ||||
| before_build: | ||||
| - cmd: |- | ||||
|     mkdir build | ||||
|     cd build | ||||
|     cmake --version | ||||
|     cmake .. -G %generator% | ||||
|     ls | ||||
|     build | ||||
| build: | ||||
|   project: c:\projects\dst\build\dst.sln | ||||
|   verbosity: minimal | ||||
|   parallel: true | ||||
| - cmd: |- | ||||
|     build test | ||||
| only_commits: | ||||
|   files: | ||||
|     - CMakeLists.txt | ||||
|     - appveyor.yml | ||||
|     - src/ | ||||
							
								
								
									
										97
									
								
								build.bat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								build.bat
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,97 @@ | ||||
| @rem Build dst on windows | ||||
| @rem | ||||
| @rem Open a "Windows SDK Command Shell" in the dst directory | ||||
| @rem and run this script | ||||
|  | ||||
| @echo off | ||||
|  | ||||
| @rem Ensure correct command prompt | ||||
| @if not defined INCLUDE goto :BADCMD | ||||
|  | ||||
| @rem Sub commands | ||||
| @if "%1"=="help" goto HELP | ||||
| @if "%1"=="clean" goto CLEAN | ||||
| @if "%1"=="test" goto TEST | ||||
|  | ||||
| @rem Set compile and link options here | ||||
| @setlocal | ||||
| @set DST_COMPILE=cl /nologo /Isrc\include /c /O2 /W3 /D_CRT_SECURE_NO_WARNINGS | ||||
| @set DST_LINK=link /nologo | ||||
|  | ||||
| @rem Build the xxd tool for generating sources | ||||
| @cl /nologo /c src/tools/xxd.c /Foxxd.o | ||||
| @if errorlevel 1 goto :BUILDFAIL | ||||
| @link /nologo /out:xxd.exe xxd.o | ||||
| @if errorlevel 1 goto :BUILDFAIL | ||||
|  | ||||
| @rem Generate the headers | ||||
| @xxd.exe src/core/core.dst src/include/generated/core.h dst_gen_core | ||||
| @if errorlevel 1 goto :BUILDFAIL | ||||
| @xxd.exe src/mainclient/init.dst src/include/generated/init.h dst_gen_init | ||||
| @if errorlevel 1 goto :BUILDFAIL | ||||
|  | ||||
| @rem Build the sources | ||||
| for %%f in (src/core/*.c) do ( | ||||
| 	@%DST_COMPILE% src/core/%%f | ||||
|     @if errorlevel 1 goto :BUILDFAIL | ||||
| ) | ||||
|  | ||||
| @rem Build the main client | ||||
| for %%f in (src/mainclient/*.c) do ( | ||||
| 	@%DST_COMPILE% src/mainclient/%%f | ||||
|     @if errorlevel 1 goto :BUILDFAIL | ||||
| ) | ||||
|  | ||||
| @rem Link everything to main client | ||||
| %DST_LINK% /out:dst.exe *.obj | ||||
| @if errorlevel 1 goto :BUILDFAIL | ||||
|  | ||||
| echo === Successfully built dst.exe for Windows === | ||||
| echo === Run 'build test' to run tests. == | ||||
| echo === Run 'build clean' to delete build artifacts. === | ||||
| exit /b 0 | ||||
|  | ||||
| @rem Not using correct command line | ||||
| :BADCMD | ||||
| @echo You must open a "Visual Studio .NET Command Prompt" to run this script | ||||
| exit /b 1 | ||||
|  | ||||
| @rem Show help | ||||
| :HELP | ||||
| @echo. | ||||
| @echo Usage: build_windows [subcommand=clean,help,test] | ||||
| @echo. | ||||
| @echo Script to build dst on windows. Must be run from the Visual Studio | ||||
| @echo command prompt. | ||||
| exit /b 0 | ||||
|  | ||||
| @rem Clean build artifacts  | ||||
| :CLEAN | ||||
| del *.obj | ||||
| del xxd.o | ||||
| del xxd.exe | ||||
| del dst.exe | ||||
| del src\include\generated\*.h | ||||
| exit /b 0 | ||||
|  | ||||
| @rem Run tests | ||||
| :TEST | ||||
| for %%f in (test/suite*.dst) do ( | ||||
| 	dst.exe test\%%f | ||||
| 	@if errorlevel 1 goto :TESTFAIL | ||||
| ) | ||||
| exit /b 0 | ||||
| :TESTFAIL | ||||
| @echo. | ||||
| @echo ******************************************************* | ||||
| @echo *** Tests FAILED -- Please check the error messages *** | ||||
| @echo ******************************************************* | ||||
| exit /b 1 | ||||
|  | ||||
| @rem Build failed | ||||
| :BUILDFAIL | ||||
| @echo. | ||||
| @echo ******************************************************* | ||||
| @echo *** Build FAILED -- Please check the error messages *** | ||||
| @echo ******************************************************* | ||||
| exit /b 1 | ||||
| @@ -1,83 +0,0 @@ | ||||
| # From https://gist.github.com/sivachandran/3a0de157dccef822a230 | ||||
|  | ||||
| include(CMakeParseArguments) | ||||
|  | ||||
| # Function to wrap a given string into multiple lines at the given column position. | ||||
| # Parameters: | ||||
| #   VARIABLE    - The name of the CMake variable holding the string. | ||||
| #   AT_COLUMN   - The column position at which string will be wrapped. | ||||
| function(WRAP_STRING) | ||||
|     set(oneValueArgs VARIABLE AT_COLUMN) | ||||
|     cmake_parse_arguments(WRAP_STRING "${options}" "${oneValueArgs}" "" ${ARGN}) | ||||
|  | ||||
|     string(LENGTH ${${WRAP_STRING_VARIABLE}} stringLength) | ||||
|     math(EXPR offset "0") | ||||
|  | ||||
|     while(stringLength GREATER 0) | ||||
|  | ||||
|         if(stringLength GREATER ${WRAP_STRING_AT_COLUMN}) | ||||
|             math(EXPR length "${WRAP_STRING_AT_COLUMN}") | ||||
|         else() | ||||
|             math(EXPR length "${stringLength}") | ||||
|         endif() | ||||
|  | ||||
|         string(SUBSTRING ${${WRAP_STRING_VARIABLE}} ${offset} ${length} line) | ||||
|         set(lines "${lines}\n${line}") | ||||
|  | ||||
|         math(EXPR stringLength "${stringLength} - ${length}") | ||||
|         math(EXPR offset "${offset} + ${length}") | ||||
|     endwhile() | ||||
|  | ||||
|     set(${WRAP_STRING_VARIABLE} "${lines}" PARENT_SCOPE) | ||||
| endfunction() | ||||
|  | ||||
| # Function to embed contents of a file as byte array in C/C++ header file(.h). The header file | ||||
| # will contain a byte array and integer variable holding the size of the array. | ||||
| # Parameters | ||||
| #   SOURCE_FILE     - The path of source file whose contents will be embedded in the header file. | ||||
| #   VARIABLE_NAME   - The name of the variable for the byte array. The string "_SIZE" will be append | ||||
| #                     to this name and will be used a variable name for size variable. | ||||
| #   HEADER_FILE     - The path of header file. | ||||
| #   APPEND          - If specified appends to the header file instead of overwriting it | ||||
| #   NULL_TERMINATE  - If specified a null byte(zero) will be append to the byte array. This will be | ||||
| #                     useful if the source file is a text file and we want to use the file contents | ||||
| #                     as string. But the size variable holds size of the byte array without this | ||||
| #                     null byte. | ||||
| # Usage: | ||||
| #   bin2h(SOURCE_FILE "Logo.png" HEADER_FILE "Logo.h" VARIABLE_NAME "LOGO_PNG") | ||||
| function(BIN2H) | ||||
|     set(options APPEND NULL_TERMINATE) | ||||
|     set(oneValueArgs SOURCE_FILE VARIABLE_NAME HEADER_FILE) | ||||
|     cmake_parse_arguments(BIN2H "${options}" "${oneValueArgs}" "" ${ARGN}) | ||||
|  | ||||
|     # reads source file contents as hex string | ||||
|     file(READ ${BIN2H_SOURCE_FILE} hexString HEX) | ||||
|     string(LENGTH ${hexString} hexStringLength) | ||||
|  | ||||
|     # appends null byte if asked | ||||
|     if(BIN2H_NULL_TERMINATE) | ||||
|         set(hexString "${hexString}00") | ||||
|     endif() | ||||
|  | ||||
|     # wraps the hex string into multiple lines at column 32(i.e. 16 bytes per line) | ||||
|     wrap_string(VARIABLE hexString AT_COLUMN 32) | ||||
|     math(EXPR arraySize "${hexStringLength} / 2") | ||||
|  | ||||
|     # adds '0x' prefix and comma suffix before and after every byte respectively | ||||
|     string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1, " arrayValues ${hexString}) | ||||
|     # removes trailing comma | ||||
|     string(REGEX REPLACE ", $" "" arrayValues ${arrayValues}) | ||||
|  | ||||
|     # converts the variable name into proper C identifier | ||||
|     string(MAKE_C_IDENTIFIER "${BIN2H_VARIABLE_NAME}" BIN2H_VARIABLE_NAME) | ||||
|  | ||||
|     # declares byte array | ||||
|     set(arrayDefinition "const unsigned char ${BIN2H_VARIABLE_NAME}[] = { ${arrayValues} };") | ||||
|  | ||||
|     set(declarations "${arrayDefinition}\n\n${arraySizeDefinition}\n\n") | ||||
|     if(BIN2H_APPEND) | ||||
|         file(APPEND ${BIN2H_HEADER_FILE} "${declarations}") | ||||
|     else() | ||||
|         file(WRITE ${BIN2H_HEADER_FILE} "${declarations}") | ||||
|     endif() | ||||
| endfunction() | ||||
| @@ -1,10 +0,0 @@ | ||||
| # Include bin2h cmake code | ||||
| set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") | ||||
|  | ||||
| include(bin2h) | ||||
|  | ||||
| bin2h ( | ||||
|     SOURCE_FILE ${CMAKE_CURRENT_LIST_DIR}/../src/core/core.dst | ||||
|     HEADER_FILE "generated/core.h" | ||||
|     VARIABLE_NAME dst_gen_core | ||||
| ) | ||||
| @@ -1,10 +0,0 @@ | ||||
| # Include bin2h cmake code | ||||
| set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") | ||||
|  | ||||
| include(bin2h) | ||||
|  | ||||
| bin2h ( | ||||
|     SOURCE_FILE ${CMAKE_CURRENT_LIST_DIR}/../src/mainclient/init.dst | ||||
|     HEADER_FILE "generated/init.h" | ||||
|     VARIABLE_NAME dst_gen_init | ||||
| ) | ||||
| @@ -95,7 +95,7 @@ static int dst_core_print(DstArgs args) { | ||||
|         } | ||||
|     } | ||||
|     putc('\n', stdout); | ||||
|     DST_RETURN_NIL(); | ||||
|     DST_RETURN_NIL(args); | ||||
| } | ||||
|  | ||||
| static int dst_core_describe(DstArgs args) { | ||||
|   | ||||
| @@ -74,7 +74,7 @@ static int os_execute(DstArgs args) { | ||||
|  | ||||
|     // Start the child process.  | ||||
|     if(!CreateProcess(NULL, | ||||
|                 sys_str, | ||||
|                 (LPSTR) sys_str, | ||||
|                 NULL, | ||||
|                 NULL, | ||||
|                 FALSE, | ||||
| @@ -93,7 +93,7 @@ static int os_execute(DstArgs args) { | ||||
|  | ||||
|     // Close process and thread handles. | ||||
|     WORD status; | ||||
|     GetExitCodeProcess(pi.hProcess, &status); | ||||
|     GetExitCodeProcess(pi.hProcess, (LPDWORD)&status); | ||||
|     CloseHandle(pi.hProcess); | ||||
|     CloseHandle(pi.hThread); | ||||
|     DST_RETURN_INTEGER(args, (int32_t)status); | ||||
|   | ||||
| @@ -338,9 +338,10 @@ void dst_description_b(DstBuffer *buffer, Dst x) { | ||||
|     case DST_ABSTRACT: | ||||
|         { | ||||
|             const char *n = dst_abstract_type(dst_unwrap_abstract(x))->name; | ||||
|             return string_description_b(buffer, | ||||
|                     n[0] == ':' ? n + 1 : n, | ||||
|                     dst_unwrap_abstract(x)); | ||||
|             string_description_b(buffer, | ||||
|                 n[0] == ':' ? n + 1 : n, | ||||
|                 dst_unwrap_abstract(x)); | ||||
| 			return; | ||||
|         } | ||||
|     case DST_CFUNCTION: | ||||
|         { | ||||
| @@ -492,7 +493,7 @@ const uint8_t *dst_formatc(const char *format, ...) { | ||||
|                         dst_buffer_push_cstring(bufp, va_arg(args, const char *)); | ||||
|                         break; | ||||
|                     case 'c': | ||||
|                         dst_buffer_push_u8(bufp, va_arg(args, long)); | ||||
|                         dst_buffer_push_u8(bufp, (uint8_t) va_arg(args, long)); | ||||
|                         break; | ||||
|                     case 'q': | ||||
|                     { | ||||
|   | ||||
| @@ -119,8 +119,8 @@ static double convert( | ||||
|     } | ||||
|  | ||||
|     return negative | ||||
|         ? -ldexp(mantissa, exponent2) | ||||
|         : ldexp(mantissa, exponent2); | ||||
|         ? -ldexp((double) mantissa, exponent2) | ||||
|         : ldexp((double) mantissa, exponent2); | ||||
| } | ||||
|  | ||||
| /* Result of scanning a number source string. Will be further processed | ||||
| @@ -207,7 +207,7 @@ static struct DstScanRes dst_scan_impl( | ||||
|         } else if (!gotradix && (*str == 'r' || *str == 'R'))  { | ||||
|             if (res.seenpoint) goto error; | ||||
|             if (res.mant < 2 || res.mant > 36) goto error; | ||||
|             res.base = res.mant; | ||||
|             res.base = (int) res.mant; | ||||
|             res.mant = 0; | ||||
|             seenadigit = 0; | ||||
|             gotradix = 1; | ||||
| @@ -278,7 +278,7 @@ int32_t dst_scan_integer( | ||||
|     if (res.error) goto error; | ||||
|     if (res.seenpoint) goto error; | ||||
|     if (res.ex < 0) goto error; | ||||
|     i64 = res.neg ? -res.mant : res.mant; | ||||
|     i64 = res.neg ? -(int64_t)res.mant : (int64_t)res.mant; | ||||
|     while (res.ex > 0) { | ||||
|         i64 *= res.base; | ||||
|         if (i64 > INT32_MAX || i64 < INT32_MIN) goto error; | ||||
| @@ -322,7 +322,7 @@ Dst dst_scan_number( | ||||
|     if (res.error) | ||||
|         return dst_wrap_nil(); | ||||
|     if (!res.foundexp && !res.seenpoint) { | ||||
|         int64_t i64 = res.neg ? -res.mant : res.mant; | ||||
|         int64_t i64 = res.neg ? -(int64_t)res.mant : (int64_t)res.mant; | ||||
|         if (i64 <= INT32_MAX && i64 >= INT32_MIN) { | ||||
|             return dst_wrap_integer((int32_t) i64); | ||||
|         } | ||||
|   | ||||
| @@ -49,7 +49,7 @@ void dst_symcache_init() { | ||||
|  | ||||
| /* Deinitialize the cache (free the cache memory) */ | ||||
| void dst_symcache_deinit() { | ||||
|     free(dst_vm_cache); | ||||
|     free((void *)dst_vm_cache); | ||||
|     dst_vm_cache = NULL; | ||||
|     dst_vm_cache_capacity = 0; | ||||
|     dst_vm_cache_count = 0; | ||||
| @@ -139,7 +139,7 @@ static void dst_cache_resize(uint32_t newCapacity) { | ||||
|         } | ||||
|     } | ||||
|     /* Free the old cache */ | ||||
|     free(oldCache); | ||||
|     free((void *)oldCache); | ||||
| } | ||||
|  | ||||
| /* Add an item to the cache */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose