[ruby/prism] Add explicit check for PRISM_HAS_NO_FILESYSTEM
https://github.com/ruby/prism/commit/89c22f0e6c
This commit is contained in:
parent
1992bd31a5
commit
a65c205a1b
@ -118,6 +118,15 @@
|
|||||||
# endif
|
# endif
|
||||||
#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
|
* 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
|
* 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);
|
CloseHandle(file);
|
||||||
*string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = (size_t) file_size };
|
*string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = (size_t) file_size };
|
||||||
return true;
|
return true;
|
||||||
#else
|
#elif defined(PRISM_HAS_FILESYSTEM)
|
||||||
FILE *file = fopen(filepath, "rb");
|
FILE *file = fopen(filepath, "rb");
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
return false;
|
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 };
|
*string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = length };
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
(void) string;
|
||||||
|
(void) filepath;
|
||||||
|
perror("pm_string_file_init is not implemented for this platform");
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user