Showing the changes to src/core/chuck_parse.cpp (1 of 3 files). Show all
Unified · Split
| @@ -94,6 +94,23 @@ FILE *win32_tmpfile() · 93 unmodified lines | ||
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | |
| 97 | +//----------------------------------------------------------------------------- | |
| 98 | +// name: android_tmpfile() | |
| 99 | +// desc: replacement for broken tmpfile() on Android | |
| 100 | +//----------------------------------------------------------------------------- | |
| 101 | +#ifdef __ANDROID__ | |
| 102 | + | |
| 103 | +#include "chuck_android.h" | |
| 104 | + | |
| 105 | +FILE *android_tmpfile() | |
| 106 | +{ | |
| 107 | + return ChuckAndroid::getTemporaryFile(); | |
| 108 | +} | |
| 109 | + | |
| 110 | +#endif | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 97 | 114 | //----------------------------------------------------------------------------- |
| 98 | 115 | // name: chuck_parse() |
| 99 | 116 | // desc: ... |
| @@ -118,9 +135,13 @@ t_CKBOOL chuck_parse( c_constr fname, FILE * fd, c_constr code ) · 18 unmodified lines | ||
| 118 | 135 | // generate temp file |
| 119 | 136 | #ifdef __PLATFORM_WIN32__ |
| 120 | 137 | fd = win32_tmpfile(); |
| 138 | +#elif defined (__ANDROID__) | |
| 139 | + fd = android_tmpfile(); | |
| 121 | 140 | #else |
| 122 | 141 | fd = tmpfile(); |
| 123 | 142 | #endif |
| 143 | + // on some systems, tmpfile() can return NULL | |
| 144 | + if( !fd ) { EM_error2( 0, "unable to create temp file" ); return FALSE; } | |
| 124 | 145 | // flag it to close |
| 125 | 146 | clo = TRUE; |
| 126 | 147 | // write |