summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-21 17:32:30 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-21 17:32:30 +0000
commit25005873740ccbca576d198a4036a8a1413905f8 (patch)
tree93f1f46bb258c6ea21c005fef2b7588a62d6a9c8
parent0375e765b1f7686f25a0159cfd409fbe33708f31 (diff)
downloadpx4-nuttx-25005873740ccbca576d198a4036a8a1413905f8.tar.gz
px4-nuttx-25005873740ccbca576d198a4036a8a1413905f8.tar.bz2
px4-nuttx-25005873740ccbca576d198a4036a8a1413905f8.zip
Add support for Fire STM32v3; sscanf fixes from Kate
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5168 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--apps/netutils/webserver/Kconfig4
-rw-r--r--nuttx/ChangeLog9
-rw-r--r--nuttx/Documentation/NuttX.html6
-rw-r--r--nuttx/configs/Kconfig8
-rw-r--r--nuttx/configs/README.txt3
-rw-r--r--nuttx/configs/fire-stm32v2/Kconfig22
-rw-r--r--nuttx/configs/fire-stm32v2/README.txt16
-rw-r--r--nuttx/configs/fire-stm32v2/nsh/defconfig17
-rw-r--r--nuttx/configs/fire-stm32v2/src/fire-internal.h18
-rw-r--r--nuttx/lib/stdio/lib_sscanf.c164
10 files changed, 205 insertions, 62 deletions
diff --git a/apps/netutils/webserver/Kconfig b/apps/netutils/webserver/Kconfig
index 78b0ff12c..edca8dfdd 100644
--- a/apps/netutils/webserver/Kconfig
+++ b/apps/netutils/webserver/Kconfig
@@ -6,6 +6,7 @@
config NETUTILS_WEBSERVER
bool "uIP web server"
default n
+ depends on NET_TCP
---help---
Enable support for the uIP web server. This tiny web server was
from uIP 1.0, but has undergone many changes. It is, however,
@@ -74,10 +75,11 @@ config NETUTILS_HTTPD_SERVERHEADER_DISABLE
config NETUTILS_HTTPD_TIMEOUT
int "Receive Timeout (sec)"
default 0
+ depends on NET_SOCKOPTS
---help---
Receive timeout setting (in seconds). A timeout value of zero
disables the timeout. An HTTP 408 error is generated if the timeout
- expires.
+ expires. This option depends on support for socket options (sockopts).
choice
prompt "File Transfer Method"
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 7ad830d89..42110fd79 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -3377,3 +3377,12 @@
commands used in the build (Contributed by Richard Cochran).
* drivers/net/enc28j60.c: The ENC28J60 Ethernet driver is
now functional.
+ * configs/fire-stm32v2: Add support or the fire-stm32v3 board as
+ well (untested because I do not have a v3 board).
+ * lib/stdio/lib_sscanf.c: Add %n psuedo-format (from Kate).
+ * lib/stdio/lib_sscanf.c: There is an issue of handling input
+ when (1) no fieldwidth is provided and (2) there is no space
+ seperating the input values. No solutions is in place for this
+ case now (either space or a fieldwidth must be provided). But
+ at least some of the bad logic that attempted to handle this
+ case has been removed (noted by Kate).
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index 6b120f4e2..b51b5e7b3 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -1753,7 +1753,7 @@
STM32F103VCT chip. Contributed by Laurent Latil.
</li>
<li>
- This M3 Wildfire development board (STM32F103VET6), version 2.
+ The M3 Wildfire development board (STM32F103VET6), version 2.
See <a href="http://firestm32.taobao.com">http://firestm32.taobao.com</a> (the current board is version 3).
</li>
</ol>
@@ -1787,7 +1787,9 @@
Support for the Wildfire board was included in version 6.22 of NuttX.
The board port is basically functional.
Not all features have been verified.
- The ENC28J60 network is not yet functional.
+ Support for FAT file system on an an SD card had been verified.
+ The ENC28J60 network is functional (but required lifting the chip select pin on the W25x16 part).
+ Customizations for the v3 version of the Wildfire board a selectable (but untested).
</li>
</ul>
<p>
diff --git a/nuttx/configs/Kconfig b/nuttx/configs/Kconfig
index 12cc41ea7..752a5b098 100644
--- a/nuttx/configs/Kconfig
+++ b/nuttx/configs/Kconfig
@@ -130,8 +130,8 @@ config ARCH_BOARD_EZ80F910200ZCO
development kit, eZ80F091 part, and the Zilog ZDS-II Windows command line
tools. The development environment is Cygwin under WinXP.
-config ARCH_BOARD_FIRE_STM32V2
- bool "M3 Wildfire STM32v2 board"
+config ARCH_BOARD_FIRE_STM32
+ bool "M3 Wildfire STM3 board (v2 or v3)"
depends on ARCH_CHIP_STM32F103VET6
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
@@ -607,7 +607,7 @@ config ARCH_BOARD
default "ekk-lm3s9b96" if ARCH_BOARD_EKK_LM3S9B96
default "ez80f0910200kitg" if ARCH_BOARD_EZ80F910200KITG
default "ez80f0910200zco" if ARCH_BOARD_EZ80F910200ZCO
- default "fire-stm32v2" if ARCH_BOARD_FIRE_STM32V2
+ default "fire-stm32v2" if ARCH_BOARD_FIRE_STM32
default "hymini-stm32v" if ARCH_BOARD_HYMINI_STM32V
default "kwikstik-k40" if ARCH_BOARD_KWIKSTIK_K40
default "lincoln60" if ARCH_BOARD_LINCOLN60
@@ -747,7 +747,7 @@ endif
if ARCH_BOARD_EZ80F910200ZCO
source "configs/ez80f910200zco/Kconfig"
endif
-if ARCH_BOARD_FIRE_STM32V2
+if ARCH_BOARD_FIRE_STM32
source "configs/fire-stm32v2/Kconfig"
endif
if ARCH_BOARD_HYMINI_STM32V
diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt
index b5ada6ee5..5bbec874f 100644
--- a/nuttx/configs/README.txt
+++ b/nuttx/configs/README.txt
@@ -1570,7 +1570,8 @@ configs/ez80f0910200zco
configs/fire-stm32v2
A configuration for the M3 Wildfire STM32 board. This board is based on the
- STM32F103VET6 chip. See http://firestm32.taobao.com
+ STM32F103VET6 chip. See http://firestm32.taobao.com . Version 2 and 3 of
+ the boards are supported but only version 2 has been tested.
configs/hymini-stm32v
A configuration for the HY-Mini STM32v board. This board is based on the
diff --git a/nuttx/configs/fire-stm32v2/Kconfig b/nuttx/configs/fire-stm32v2/Kconfig
index 3f4b857da..4249a3dbd 100644
--- a/nuttx/configs/fire-stm32v2/Kconfig
+++ b/nuttx/configs/fire-stm32v2/Kconfig
@@ -4,3 +4,25 @@
#
comment "M3 Wildfire Configuration"
+
+if ARCH_BOARD_FIRE_STM32
+
+choice
+ prompt "Select Wildfire STM32 version"
+ default ARCH_BOARD_FIRE_STM32V2
+ ---help---
+ This port has logic differences to support either the Version 2 or
+ Version 3 of the Wildfire board.
+
+config ARCH_BOARD_FIRE_STM32V2
+ bool "Wildfire STM32v2"
+ ---help---
+ Selects the M3 Wildfire version 2.
+
+config ARCH_BOARD_FIRE_STM32V3
+ bool "Wildfire STM32v3"
+ ---help---
+ Selects the M3 Wildfire version 3.
+
+endchoice
+endif
diff --git a/nuttx/configs/fire-stm32v2/README.txt b/nuttx/configs/fire-stm32v2/README.txt
index d9a4d14ca..6382a7363 100644
--- a/nuttx/configs/fire-stm32v2/README.txt
+++ b/nuttx/configs/fire-stm32v2/README.txt
@@ -4,6 +4,10 @@ README
This README discusses issues unique to NuttX configurations for the M3
Wildfire development board (STM32F103VET6). See http://firestm32.taobao.com
+This configuration should support both the version 2 and version 3 of the
+Wildfire board (using NuttX configuration options). However, only version 2
+has been verified.
+
Contents
========
@@ -27,8 +31,10 @@ PIN NAME SIGNAL NOTES
1 PE2 PE2-C-RCLK Camera (P9)
2 PE3 PE3-USB-M USB2.0
-3 PE4 PE4-BEEP LS1 Bell
-4 PE5 (no name) 10Mbps ENC28J60 Interrupt
+3 PE4 PE4-BEEP LS1 Bell (v2)
+ PE4 10Mbps ENC28J60 Interrupt (v3)
+4 PE5 (no name) 10Mbps ENC28J60 Interrupt (v2)
+ PE5 KEY1, Low when closed (pulled high if open) (v3)
5 PE6
6 VBAT BT1 Battery (BT1)
7 PC13 Header 7X2
@@ -64,7 +70,8 @@ PIN NAME SIGNAL NOTES
32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
33 PC4 PC4-LED2 LED2, Active low (pulled high)
34 PC5 PC5-LED3 LED3, Active low (pulled high)
-35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open)
+35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open) (v2)
+ PB0 Header P5 (v3)
36 PB1 PB1-KEY2 KEY2, Low when closed (pulled high if open)
37 PB2 BOOT1/DGND
38 PE7 PE7-FSMC_D4 2.4" TFT + Touchscreen
@@ -525,7 +532,8 @@ M3 Wildfire-specific Configuration Options
CONFIG_ARCH_BOARD_name - For use in C code
- CONFIG_ARCH_BOARD_FIRE_STM32V2=y
+ CONFIG_ARCH_BOARD_FIRE_STM32V2=y (Version 2)
+ CONFIG_ARCH_BOARD_FIRE_STM32V3=y (Version 3)
CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
of delay loops
diff --git a/nuttx/configs/fire-stm32v2/nsh/defconfig b/nuttx/configs/fire-stm32v2/nsh/defconfig
index fd5187801..0802af3c9 100644
--- a/nuttx/configs/fire-stm32v2/nsh/defconfig
+++ b/nuttx/configs/fire-stm32v2/nsh/defconfig
@@ -150,6 +150,7 @@ CONFIG_STM32_USART2=y
CONFIG_STM32_USB=y
# CONFIG_STM32_WWDG is not set
CONFIG_STM32_SPI=y
+CONFIG_STM32_I2C=y
#
# Alternate Pin Mapping
@@ -172,6 +173,15 @@ CONFIG_STM32_JTAG_FULL_ENABLE=y
# CONFIG_STM32_SPI_DMA is not set
#
+# I2C Configuration
+#
+# CONFIG_STM32_I2C_DYNTIMEO is not set
+CONFIG_STM32_I2CTIMEOSEC=0
+CONFIG_STM32_I2CTIMEOMS=500
+CONFIG_STM32_I2CTIMEOTICKS=500
+# CONFIG_STM32_I2C_DUTY16_9 is not set
+
+#
# SDIO Configuration
#
CONFIG_SDIO_DMA=y
@@ -215,7 +225,7 @@ CONFIG_BOOT_RUNFROMFLASH=y
#
# Board Selection
#
-CONFIG_ARCH_BOARD_FIRE_STM32V2=y
+CONFIG_ARCH_BOARD_FIRE_STM32=y
# CONFIG_ARCH_BOARD_CUSTOM is not set
CONFIG_ARCH_BOARD="fire-stm32v2"
@@ -238,6 +248,8 @@ CONFIG_NSH_MMCSDSPIPORTNO=0
#
# M3 Wildfire Configuration
#
+CONFIG_ARCH_BOARD_FIRE_STM32V2=y
+# CONFIG_ARCH_BOARD_FIRE_STM32V3 is not set
#
# RTOS Features
@@ -316,6 +328,8 @@ CONFIG_I2C_TRANSFER=y
# CONFIG_I2C_WRITEREAD is not set
CONFIG_I2C_POLLED=y
# CONFIG_I2C_TRACE is not set
+CONFIG_ARCH_HAVE_I2CRESET=y
+# CONFIG_I2C_RESET is not set
CONFIG_SPI=y
# CONFIG_SPI_OWNBUS is not set
CONFIG_SPI_EXCHANGE=y
@@ -348,6 +362,7 @@ CONFIG_ENC28J60_SPIMODE=0
CONFIG_ENC28J60_FREQUENCY=20000000
# CONFIG_ENC28J60_STATS is not set
# CONFIG_ENC28J60_HALFDUPPLEX is not set
+# CONFIG_ENC28J60_DUMPPACKET is not set
# CONFIG_NET_E1000 is not set
# CONFIG_NET_SLIP is not set
# CONFIG_NET_VNET is not set
diff --git a/nuttx/configs/fire-stm32v2/src/fire-internal.h b/nuttx/configs/fire-stm32v2/src/fire-internal.h
index e9f7a8508..7ab78a08f 100644
--- a/nuttx/configs/fire-stm32v2/src/fire-internal.h
+++ b/nuttx/configs/fire-stm32v2/src/fire-internal.h
@@ -166,7 +166,8 @@
* PIN NAME SIGNAL NOTES
* --- ------ -------------- -------------------------------------------------------------------
*
- * 35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open)
+ * 35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open) (v2)
+ * 35 PE5 PB0 KEY1, Low when closed (pulled high if open) (v3)
* 36 PB1 PB1-KEY2 KEY2, Low when closed (pulled high if open)
*/
@@ -174,8 +175,13 @@
#define MAX_IRQBUTTON BUTTON_KEY2
#define NUM_IRQBUTTONS (MAX_IRQBUTTON - MIN_IRQBUTTON + 1)
-#define GPIO_BTN_KEY1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+#ifdef CONFIG_ARCH_BOARD_FIRE_STM32V3
+# define GPIO_BTN_KEY1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_EXTI|GPIO_PORTE|GPIO_PIN5)
+#else
+# define GPIO_BTN_KEY1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
GPIO_EXTI|GPIO_PORTB|GPIO_PIN0)
+#endif
#define GPIO_BTN_KEY2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
GPIO_EXTI|GPIO_PORTB|GPIO_PIN1)
@@ -207,7 +213,8 @@
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
* 98 PE1 PE1-FSMC_NBL1 2.4" TFT + Touchscreen, 10Mbit EN28J60 Reset
- * 4 PE5 (no name) 10Mbps ENC28J60 Interrupt
+ * 4 PE5 (no name) 10Mbps ENC28J60 Interrupt (v2)
+ * 4 PE4 PE4 10Mbps ENC28J60 Interrupt (v3)
*/
#if defined(CONFIG_STM32_FSMC) && defined(CONFIG_ENC28J60)
@@ -224,9 +231,14 @@
GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
# define GPIO_ENC28J60_RESET (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN1)
+#ifdef CONFIG_ARCH_BOARD_FIRE_STM32V3
+# define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_EXTI|GPIO_PORTE|GPIO_PIN4)
+#else /* CONFIG_ARCH_BOARD_FIRE_STM32V2 */
# define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
GPIO_EXTI|GPIO_PORTE|GPIO_PIN5)
#endif
+#endif
/* MP3
*
diff --git a/nuttx/lib/stdio/lib_sscanf.c b/nuttx/lib/stdio/lib_sscanf.c
index 01c96c21d..11b5f387e 100644
--- a/nuttx/lib/stdio/lib_sscanf.c
+++ b/nuttx/lib/stdio/lib_sscanf.c
@@ -1,7 +1,7 @@
/****************************************************************************
* lib/stdio/lib_sscanf.c
*
- * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -63,7 +63,7 @@
* Global Function Prototypes
****************************************************************************/
-int vsscanf(char *buf, const char *s, va_list ap);
+int vsscanf(char *buf, const char *fmt, va_list ap);
/**************************************************************************
* Global Constant Data
@@ -109,67 +109,81 @@ int sscanf(FAR const char *buf, FAR const char *fmt, ...)
* ANSI standard vsscanf implementation.
*
****************************************************************************/
-int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
+
+int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
{
+ FAR char *bufstart;
+ FAR char *tv;
+ FAR const char *tc;
int count;
int noassign;
int width;
int base = 10;
int lflag;
- FAR char *tv;
- FAR const char *tc;
char tmp[MAXLN];
- lvdbg("vsscanf: buf=\"%s\" fmt=\"%s\"\n", buf, s);
+ lvdbg("vsscanf: buf=\"%s\" fmt=\"%s\"\n", buf, fmt);
+
+ /* Remember the start of the input buffer. We will need this for %n
+ * calculations.
+ */
- count = noassign = width = lflag = 0;
- while (*s && *buf)
+ bufstart = buf;
+
+ /* Parse the format, extracting values from the input buffer as needed */
+
+ count = 0;
+ noassign = 0;
+ width = 0;
+ lflag = 0;
+
+ while (*fmt && *buf)
{
/* Skip over white space */
- while (isspace(*s))
+ while (isspace(*fmt))
{
- s++;
+ fmt++;
}
/* Check for a conversion specifier */
- if (*s == '%')
+ if (*fmt == '%')
{
lvdbg("vsscanf: Specifier found\n");
/* Check for qualifiers on the conversion specifier */
- s++;
- for (; *s; s++)
+ fmt++;
+ for (; *fmt; fmt++)
{
- lvdbg("vsscanf: Processing %c\n", *s);
+ lvdbg("vsscanf: Processing %c\n", *fmt);
- if (strchr("dibouxcsefg%", *s))
+ if (strchr("dibouxcsefgn%", *fmt))
{
break;
}
- if (*s == '*')
+ if (*fmt == '*')
{
noassign = 1;
}
- else if (*s == 'l' || *s == 'L')
+ else if (*fmt == 'l' || *fmt == 'L')
{
lflag = 1;
}
- else if (*s >= '1' && *s <= '9')
+ else if (*fmt >= '1' && *fmt <= '9')
{
- for (tc = s; isdigit(*s); s++);
- strncpy(tmp, tc, s - tc);
- tmp[s - tc] = '\0';
+ for (tc = fmt; isdigit(*fmt); fmt++);
+ strncpy(tmp, tc, fmt - tc);
+ tmp[fmt - tc] = '\0';
width = atoi(tmp);
- s--;
+ fmt--;
}
}
/* Process %s: String conversion */
- if (*s == 's')
+ if (*fmt == 's')
{
lvdbg("vsscanf: Performing string conversion\n");
@@ -178,9 +192,26 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
buf++;
}
+ /* Was a fieldwidth specified? */
+
if (!width)
{
- width = strcspn(buf, spaces);
+ /* No... is there a space after the format? */
+
+#if 0 /* Needs more thought */
+ if (isspace(*(s + 1)) || *(s + 1) == 0)
+#endif
+ {
+ /* Use the input up until the first white space is
+ * encountered. NOTE: This means that values on the
+ * input line must be separated by whitespace or they
+ * will get combined! This is a bug. We have no good
+ * way of determining the width of the data if there
+ * is no field with and no space separating the input.
+ */
+
+ width = strcspn(buf, spaces);
+ }
}
if (!noassign)
@@ -189,17 +220,22 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
strncpy(tv, buf, width);
tv[width] = '\0';
}
+
buf += width;
}
/* Process %c: Character conversion */
- else if (*s == 'c')
+ else if (*fmt == 'c')
{
lvdbg("vsscanf: Performing character conversion\n");
+ /* Was a fieldwidth specified? */
+
if (!width)
{
+ /* No, then width is this one single character */
+
width = 1;
}
@@ -209,12 +245,13 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
strncpy(tv, buf, width);
tv[width] = '\0';
}
+
buf += width;
}
/* Process %d, %o, %b, %x, %u: Various integer conversions */
- else if (strchr("dobxu", *s))
+ else if (strchr("dobxu", *fmt))
{
lvdbg("vsscanf: Performing integer conversion\n");
@@ -229,37 +266,47 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
* conversion specification.
*/
- if (*s == 'd' || *s == 'u')
+ if (*fmt == 'd' || *fmt == 'u')
{
base = 10;
}
- else if (*s == 'x')
+ else if (*fmt == 'x')
{
base = 16;
}
- else if (*s == 'o')
+ else if (*fmt == 'o')
{
base = 8;
}
- else if (*s == 'b')
+ else if (*fmt == 'b')
{
base = 2;
}
- /* Copy the integer string into a temporary working buffer. */
+ /* Was a fieldwidth specified? */
if (!width)
{
+ /* No... is there a space after the format? */
+
+#if 0 /* Needs more thought */
if (isspace(*(s + 1)) || *(s + 1) == 0)
+#endif
{
+ /* Use the input up until the first white space is
+ * encountered. NOTE: This means that values on the
+ * input line must be separated by whitespace or they
+ * will get combined! This is a bug. We have no good
+ * way of determining the width of the data if there
+ * is no field with and no space separating the input.
+ */
+
width = strcspn(buf, spaces);
}
- else
- {
- width = strchr(buf, *(s + 1)) - buf;
- }
}
+ /* Copy the numeric string into a temporary working buffer. */
+
strncpy(tmp, buf, width);
tmp[width] = '\0';
@@ -284,7 +331,7 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
/* Process %f: Floating point conversion */
- else if (*s == 'f')
+ else if (*fmt == 'f')
{
#ifndef CONFIG_LIBC_FLOATINGPOINT
/* No floating point conversions */
@@ -303,20 +350,30 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
buf++;
}
- /* Copy the real string into a temporary working buffer. */
+ /* Was a fieldwidth specified? */
if (!width)
{
+ /* No... is there a space after the format? */
+
+#if 0 /* Needs more thought */
if (isspace(*(s + 1)) || *(s + 1) == 0)
+#endif
{
- width = strcspn(buf, spaces);
- }
- else
- {
- width = strchr(buf, *(s + 1)) - buf;
+ /* Use the input up until the first white space is
+ * encountered. NOTE: This means that values on the
+ * input line must be separated by whitespace or they
+ * will get combined! This is a bug. We have no good
+ * way of determining the width of the data if there
+ * is no field with and no space separating the input.
+ */
+
+ width = strcspn(buf, spaces);
}
}
+ /* Copy the real string into a temporary working buffer. */
+
strncpy(tmp, buf, width);
tmp[width] = '\0';
buf += width;
@@ -356,13 +413,28 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
#endif
}
- if (!noassign)
+ /* Process %n: Character count */
+
+ else if (*fmt == 'n')
+ {
+ lvdbg("vsscanf: Performing character count\n");
+
+ if (!noassign)
+ {
+ int *pint = va_arg(ap, int*);
+ *pint = (int)(buf - bufstart) - 1;
+ }
+ }
+
+ /* Note %n does not count as a conversion */
+
+ if (!noassign && *fmt != 'n')
{
count++;
}
width = noassign = lflag = 0;
- s++;
+ fmt++;
}
/* Its is not a conversion specifier */
@@ -374,13 +446,13 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
buf++;
}
- if (*s != *buf)
+ if (*fmt != *buf)
{
break;
}
else
{
- s++;
+ fmt++;
buf++;
}
}