Merge remote-tracking branch 'origin/next' into Horus
# Conflicts: # companion/src/CMakeLists.txt # companion/src/firmwares/opentx/opentxinterface.cpp # companion/src/firmwares/opentx/simulator/CMakeLists.txt # companion/src/firmwares/opentx/stamp-opentx.h.in # radio/src/Makefile # radio/src/cli.cpp # radio/src/gui/Taranis/helpers.cpp # radio/src/gui/Taranis/lcd.cpp # radio/src/gui/Taranis/menu_model_setup.cpp # radio/src/gui/Taranis/view_main.cpp # radio/src/lua_api.cpp # radio/src/main_avr.cpp # radio/src/myeeprom.h # radio/src/opentx.cpp # radio/src/pulses/pxx_arm.cpp # radio/src/storage/eeprom_conversions.cpp # radio/src/targets/Horus/adc_driver.cpp # radio/src/targets/Horus/board_horus.cpp # radio/src/targets/Horus/board_horus.h # radio/src/targets/Horus/diskio.cpp # radio/src/targets/Horus/hal.h # radio/src/targets/Horus/haptic_driver.cpp # radio/src/targets/Horus/i2c_driver.cpp # radio/src/targets/Horus/keys_driver.cpp # radio/src/targets/Horus/lcd_driver.cpp # radio/src/targets/Horus/led_driver.cpp # radio/src/targets/Horus/pulses_driver.cpp # radio/src/targets/Horus/pwr_driver.c # radio/src/targets/Horus/sdio_sd.c # radio/src/targets/Horus/sdio_sd.h # radio/src/targets/Horus/serial2_driver.cpp # radio/src/targets/Horus/telemetry_driver.cpp # radio/src/targets/Horus/usb_conf.h # radio/src/targets/Horus/usbd_desc.c # radio/src/targets/Horus/usbd_storage_msd.cpp
This commit is contained in:
Vendored
+5
-1
@@ -238,7 +238,11 @@ TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the fil
|
||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
|
||||
#define f_error(fp) ((fp)->err)
|
||||
#define f_tell(fp) ((fp)->fptr)
|
||||
#define f_size(fp) ((fp)->fsize)
|
||||
#if !defined(SIMU)
|
||||
#define f_size(fp) ((fp)->fsize)
|
||||
#else
|
||||
UINT f_size(FIL* fil);
|
||||
#endif
|
||||
|
||||
#ifndef EOF
|
||||
#define EOF (-1)
|
||||
|
||||
+11
-13
@@ -19,6 +19,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define liolib_c
|
||||
|
||||
@@ -183,14 +184,10 @@ static LStream *newprefile (lua_State *L) {
|
||||
|
||||
#if !defined(USE_FATFS)
|
||||
static int aux_close (lua_State *L) {
|
||||
#if !defined(USE_FATFS)
|
||||
LStream *p = tolstream(L);
|
||||
lua_CFunction cf = p->closef;
|
||||
p->closef = NULL; /* mark stream as closed */
|
||||
return (*cf)(L); /* close it */
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -249,14 +246,14 @@ static int io_open (lua_State *L) {
|
||||
const char *md = luaL_optstring(L, 2, "r");
|
||||
LStream *p = newfile(L);
|
||||
#if defined(USE_FATFS)
|
||||
BYTE mode;
|
||||
if (strchr(md, 'w') || strchr(md, 'a'))
|
||||
mode = FA_WRITE;
|
||||
else
|
||||
mode = FA_READ;
|
||||
BYTE mode = FA_READ;
|
||||
if (*md == 'w')
|
||||
mode = FA_WRITE | FA_CREATE_ALWAYS; // always create file and truncate it
|
||||
else if (*md == 'a')
|
||||
mode = FA_WRITE | FA_OPEN_ALWAYS; // always open file (create it if necessary)
|
||||
FRESULT result = f_open(&p->f, filename, mode);
|
||||
if (result == FR_OK && strchr(md, 'a'))
|
||||
result = f_lseek(&p->f, f_size(&p->f));
|
||||
if (result == FR_OK && *md == 'a')
|
||||
result = f_lseek(&p->f, f_size(&p->f)); // seek to the end of the file
|
||||
return result == FR_OK ? 1 : 0;
|
||||
#else
|
||||
const char *mode = md; /* to traverse/check mode */
|
||||
@@ -559,8 +556,9 @@ static int g_write (lua_State *L, FILE *f, int arg) {
|
||||
for (; nargs--; arg++) {
|
||||
if (lua_type(L, arg) == LUA_TNUMBER) {
|
||||
/* optimization: could be done exactly as for strings */
|
||||
status = status &&
|
||||
f_printf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
|
||||
char s[LUAI_MAXNUMBER2STR];
|
||||
sprintf(s, LUA_NUMBER_FMT, lua_tonumber(L, arg));
|
||||
status = status && f_puts(s, f) > 0;
|
||||
}
|
||||
else {
|
||||
size_t l;
|
||||
|
||||
Reference in New Issue
Block a user