[ruby/prism] Add explicit check for PRISM_HAS_NO_FILESYSTEM

https://github.com/ruby/prism/commit/89c22f0e6c
This commit is contained in:
Yuta Saito 2024-07-20 02:59:39 +00:00 коммит произвёл git
Родитель 1992bd31a5
Коммит a65c205a1b
2 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -118,6 +118,15 @@
# endif
#endif
/**
* If PRISM_HAS_NO_FILESYSTEM is defined, then we want to exclude all filesystem
* related code from the library. All filesystem related code should be guarded
* by PRISM_HAS_FILESYSTEM.
*/
#ifndef PRISM_HAS_NO_FILESYSTEM
# define PRISM_HAS_FILESYSTEM
#endif
/**
* isinf on Windows is defined as accepting a float, but on POSIX systems it
* accepts a float, a double, or a long double. We want to mirror this behavior

Просмотреть файл

@ -202,7 +202,7 @@ pm_string_file_init(pm_string_t *string, const char *filepath) {
CloseHandle(file);
*string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = (size_t) file_size };
return true;
#else
#elif defined(PRISM_HAS_FILESYSTEM)
FILE *file = fopen(filepath, "rb");
if (file == NULL) {
return false;
@ -241,6 +241,11 @@ pm_string_file_init(pm_string_t *string, const char *filepath) {
*string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = length };
return true;
#else
(void) string;
(void) filepath;
perror("pm_string_file_init is not implemented for this platform");
return false;
#endif
}