本文整理汇总了C++中skip_atoi函数的典型用法代码示例。如果您正苦于以下问题:C++ skip_atoi函数的具体用法?C++ skip_atoi怎么用?C++ skip_atoi使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skip_atoi函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vtxprintf
int vtxprintf(void (*tx_byte)(unsigned char byte, void *data),
const char *fmt, va_list args, void *data)
{
int len;
unsigned long long num;
int i, base;
const char *s;
int flags; /* flags to number() */
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'H', 'l', or 'L' for integer fields */
int count;
for (count = 0; *fmt ; ++fmt) {
if (*fmt != '%') {
call_tx(*fmt), count++;
continue;
}
/* process flags */
flags = 0;
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
/* get field width */
field_width = -1;
if (is_digit(*fmt)) {
field_width = skip_atoi(&fmt);
} else if (*fmt == '*') {
++fmt;
/* it's the next argument */
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
/* get the precision */
precision = -1;
if (*fmt == '.') {
++fmt;
if (is_digit(*fmt)) {
precision = skip_atoi(&fmt);
} else if (*fmt == '*') {
++fmt;
/* it's the next argument */
precision = va_arg(args, int);
}
示例2: vsprintf
int vsprintf(char* buf, const char* fmt, va_list args)
{
int len;
long num;
int i;
int base;
char* str;
const char* s;
int flags; /* flags to number() */
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'q' for integer fields */
for (str = buf; *fmt; ++fmt) {
if (*fmt != '%') {
*str++ = *fmt;
continue;
}
/* process flags */
flags = 0;
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
/* get field width */
field_width = -1;
if (is_digit(*fmt)) {
field_width = skip_atoi(&fmt);
} else if (*fmt == '*') {
++fmt;
/* it's the next argument */
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
/* get the precision */
precision = -1;
if (*fmt == '.') {
++fmt;
if (is_digit(*fmt)) {
precision = skip_atoi(&fmt);
} else if (*fmt == '*') {
++fmt;
/* it's the next argument */
precision = va_arg(args, int);
}
示例3: vsprintf
static int vsprintf(char *buff, const char *format, va_list args)
{
int len;
int i;
char *str;
char *s;
int *ip;
int flags; // flags to number()
int field_width; // width of output field
int precision; // min. # of digits for integers; max number of chars for from string
for (str = buff ; *format ; ++format) {
if (*format != '%') {
*str++ = *format;
continue;
}
flags = 0;
repeat:
++format; // this also skips first '%'
switch (*format) {
case '-': flags |= LEFT;
goto repeat;
case '+': flags |= PLUS;
goto repeat;
case ' ': flags |= SPACE;
goto repeat;
case '#': flags |= SPECIAL;
goto repeat;
case '0': flags |= ZEROPAD;
goto repeat;
}
// get field width
field_width = -1;
if (is_digit(*format)) {
field_width = skip_atoi(&format);
} else if (*format == '*') {
// it's the next argument
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
// get the precision
precision = -1;
if (*format == '.') {
++format;
if (is_digit(*format)) {
precision = skip_atoi(&format);
} else if (*format == '*') {
// it's the next argument
precision = va_arg(args, int);
}
示例4: vsnprintf
/*
** This vsnprintf() emulation does not implement the conversions:
** %e, %E, %g, %G, %wc, %ws
** The %f implementation is limited.
*/
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
int len;
unsigned long num;
int i, base;
char *str;
const char *s;
int flags;
int dotflag;
int field_width;
int precision;
int qualifier;
size--;
for(str = buf; *fmt && size; ++fmt) {
if(*fmt != '%') {
*str++ = *fmt;
size--;
continue;
}
flags = 0;
dotflag = 0;
repeat:
++fmt;
switch(*fmt) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
field_width = -1;
if(isdigit(*fmt))
field_width = skip_atoi(&fmt);
else if(*fmt == '*') {
++fmt;
field_width = va_arg(args,int);
if(field_width < 0) {
field_width = - field_width;
flags |= LEFT;
}
}
precision = -1;
if(*fmt == '.') {
dotflag++;
++fmt;
if(isdigit(*fmt))
precision = skip_atoi(&fmt);
else if(*fmt == '*') {
++fmt;
precision = va_arg(args,int);
}
示例5: vsprintf
int vsprintf(char *buf, const char *fmt, va_list args) {
int len;
unsigned long num;
int i, base;
char *str;
char *s;
int flags; // Flags to number()
int field_width; // Width of output field
int precision; // Min. # of digits for integers; max number of chars for from string
int qualifier; // 'l', or 'L' for integer fields
for (str = buf; *fmt; fmt++) {
if (*fmt != '%') {
*str++ = *fmt;
continue;
}
// Process flags
flags = 0;
repeat:
fmt++; // This also skips first '%'
switch (*fmt) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
// Get field width
field_width = -1;
if (is_digit(*fmt)) {
field_width = skip_atoi(&fmt);
}
else if (*fmt == '*') {
fmt++;
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
// Get the precision
precision = -1;
if (*fmt == '.') {
++fmt;
if (is_digit(*fmt)) {
precision = skip_atoi(&fmt);
}
else if (*fmt == '*') {
++fmt;
precision = va_arg(args, int);
}
示例6: vsprintf
static int vsprintf(char *buff, const char *format, va_list args)
{
int len;
int i;
char *str;
char *s;
int *ip;
int flags;
int field_width;
int precision;
for (str = buff; *format; ++format) {
if (*format != '%') {
*str ++ = *format;
continue;
}
flags = 0;
repeat:
++format;
switch (*format) {
case '-': flags |= LEFT;
goto repeat;
case '+': flags |= PLUS;
goto repeat;
case ' ': flags |= SPACE;
goto repeat;
case '#': flags |= SPECIAL;
goto repeat;
case '0': flags |= ZEROPAD;
goto repeat;
}
// get field width
field_width = -1;
if (is_digit(*format)) {
field_width = skip_atoi(&format);
} else if (*format == '*') {
// it's the next arguments
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
// get the precision
precision = -1;
if (*format == '.') {
++ format;
if (is_digit(*format)) {
precision = skip_atoi(&format);
} else if (*format == '*') {
// it's the next arguments
precision = va_arg(args, int);
}
示例7: sprintf
int sprintf(char *buf, const char *fmt, va_list args)
{
char *str; // for keeping track of output location in buf
int flags; // for keeping track of formatting flags
int field_width;// width of output field
int precision; // min number of digits for integers; for strings,
// max number of chars
int qualifier; // 'h', 'l' or 'L' for integers
char *s; // if there's a string argument, this is it
int len; // this is its length
int i; // index variable
int *ip; // ptr for 'n' format
for (str = buf; *fmt; ++fmt) { // loop til end of format string
if (*fmt != '%') { // detect speshul placeholders
*str++ = *fmt; // twas a regular char so stick it in
continue;
}
flags = 0;
repeat: // an elegant use of goto if I've ever seen one
++fmt; // look at next char, or skip first '%'
switch(*fmt) { // look at it!
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
// flags done, now field width
field_width = -1;
if (is_digit(*fmt)) {
field_width = skip_atoi(&fmt);
} else if (*fmt == '*') { // width in next arg
field_width = va_arg(args, int);
if (field_width < 0) {
// negative width means left-align
field_width = -field_width;
flags |= LEFT;
}
}
// width done, get precision
precision = -1;
if (*fmt == '.') { // precision coming up
++fmt;
if (is_digit(*fmt)) {
precision = skip_atoi(&fmt);
} else if (*fmt == '*') {
// precision is next argument
precision = va_arg(args, int);
}
示例8: vsprintf
static int vsprintf(char *buf, const char *fmt, va_list args)
{
int len;
unsigned long num;
int i, base;
char * str;
const char *s;
int flags; /* flags to number() */
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
for (str = buf; *fmt; ++fmt) {
if (*fmt != '%') {
*str++ = *fmt;
continue;
}
flags = 0;
repeat:
++fmt;
switch (*fmt) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE;goto repeat;
case '#': flags |= SPECIAL;goto repeat;
case '0': flags |= ZEROPAD;goto repeat;
}
field_width = -1;
if (is_digit(*fmt))
field_width = skip_atoi(&fmt);
else if (*fmt == '*') {
++ fmt;
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
precision = -1;
if (*fmt == '.') {
++fmt;
if (is_digit(*fmt))
precision = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
precision = va_arg(args, int);
}
示例9: parse_printf_fmt
/**
* parse_printf_fmt() - Parse printf/printk conversion spec.
* fmt points to the '%' in a printk conversion specification. Advance
* fmt past any flags, width and/or precision specifiers, and qualifiers
* such as 'l' and 'L'. Return a pointer to the conversion character.
* Stores the qualifier character (or -1, if there is none) at *pqualifier.
* *wp is set to flags indicating whether the width and/or precision are '*'.
* For example, given
* %*.2lx
* *pqualifier is set to 'l', *wp is set to 0x1, and a pointer to the 'x'
* is returned.
*
* Note: This function is derived from vsnprintf() (see * lib/vsprintf.c),
* and should be kept in sync with that function.
*
* @fmt - points to '%' in conversion spec
* @pqualifier - *pqualifier is set to conversion spec's qualifier, or -1.
* @wp - Bits in *wp are set if the width or/and precision are '*'.
*/
const char *
parse_printf_fmt(const char *fmt, int *pqualifier, int *wp)
{
int qualifier = -1;
*wp = 0;
/* process flags */
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt) {
case '-':
case '+':
case ' ':
case '#':
case '0':
goto repeat;
}
/* get field width */
if (isdigit(*fmt))
skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
/* it's the next argument */
*wp |= 0x1;
}
/* get the precision */
if (*fmt == '.') {
++fmt;
if (isdigit(*fmt))
skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
/* it's the next argument */
*wp |= 0x2;
}
}
/* get the conversion qualifier */
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt =='Z') {
qualifier = *fmt;
++fmt;
if (qualifier == 'l' && *fmt == 'l') {
qualifier = 'L';
++fmt;
}
}
*pqualifier = qualifier;
return fmt;
}
示例10: do_gpio
static int do_gpio(int argc, const char* argv[])
{
char *tmp = argv[2];
int gpio = skip_atoi(&tmp);
if (strcmp(argv[1], "in") == 0) {
GPIO_DIS_OUTPUT(gpio);
console_printf("GP%d==%d\n", gpio, GPIO_INPUT_GET(gpio));
} else if (strcmp(argv[1], "out") == 0) {
if (argc < 4)
return;
tmp = argv[3];
int v = skip_atoi(&tmp);
GPIO_OUTPUT_SET(gpio, v);
}
}
示例11: do_listen
static int do_listen(int argc, const char* argv[])
{
int port = skip_atoi(&argv[1]);
console_printf("Listening (TCP) on port %d\n", port);
esp_conn.type = ESPCONN_TCP;
esp_conn.state = ESPCONN_NONE;
esp_conn.proto.tcp = &esptcp;
esp_conn.proto.tcp->local_port = port;
espconn_regist_connectcb(&esp_conn, webserver_listen);
espconn_accept(&esp_conn);
linebuffer = os_malloc(LINEBUFFER_SIZE);
lineptr = 0;
console_lock(1);
}
示例12: bvsnprintf
/**
* bvsnprintf - BIRD's vsnprintf()
* @buf: destination buffer
* @size: size of the buffer
* @fmt: format string
* @args: a list of arguments to be formatted
*
* This functions acts like ordinary sprintf() except that it checks
* available space to avoid buffer overflows and it allows some more
* format specifiers: |%I| for formatting of IP addresses (any non-zero
* width is automatically replaced by standard IP address width which
* depends on whether we use IPv4 or IPv6; |%#I| gives hexadecimal format),
* |%R| for Router / Network ID (u32 value printed as IPv4 address)
* and |%m| resp. |%M| for error messages (uses strerror() to translate @errno code to
* message text). On the other hand, it doesn't support floating
* point numbers.
*
* Result: number of characters of the output string or -1 if
* the buffer space was insufficient.
*/
int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
{
int len;
unsigned long num;
int i, base;
u32 x;
char *str, *start;
const char *s;
char ipbuf[STD_ADDRESS_P_LENGTH+1];
struct iface *iface;
int flags; /* flags to number() */
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
for (start=str=buf ; *fmt ; ++fmt, size-=(str-start), start=str) {
if (*fmt != '%') {
if (!size)
return -1;
*str++ = *fmt;
continue;
}
/* process flags */
flags = 0;
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
/* get field width */
field_width = -1;
if (is_digit(*fmt))
field_width = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
/* it's the next argument */
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
/* get the precision */
precision = -1;
if (*fmt == '.') {
++fmt;
if (is_digit(*fmt))
precision = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
/* it's the next argument */
precision = va_arg(args, int);
}
示例13: vsnprintf
int
vsnprintf(char *buffer, size_t bufferSize, const char *format, va_list args)
{
uint64 num;
int base;
int flags; /* flags to number() */
int fieldWidth; /* width of output field */
int precision;
/* min. # of digits for integers; max number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
Buffer outBuffer(buffer, bufferSize);
for (; format[0]; format++) {
if (format[0] != '%') {
outBuffer.PutCharacter(format[0]);
continue;
}
/* process flags */
flags = 0;
repeat:
format++;
/* this also skips first '%' */
switch (format[0]) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
case '%':
outBuffer.PutCharacter(format[0]);
continue;
}
/* get field width */
fieldWidth = -1;
if (isdigit(*format))
fieldWidth = skip_atoi(&format);
else if (format[0] == '*') {
format++;
/* it's the next argument */
fieldWidth = va_arg(args, int);
if (fieldWidth < 0) {
fieldWidth = -fieldWidth;
flags |= LEFT;
}
}
/* get the precision */
precision = -1;
if (format[0] == '.') {
format++;
if (isdigit(*format))
precision = skip_atoi(&format);
else if (format[0] == '*') {
format++;
/* it's the next argument */
precision = va_arg(args, int);
}
示例14: rt_vsnprintf
rt_int32_t rt_vsnprintf(char *buf,
rt_size_t size,
const char *fmt,
va_list args)
{
#ifdef RT_PRINTF_LONGLONG
unsigned long long num;
#else
rt_uint32_t num;
#endif
int i, len;
char *str, *end, c;
const char *s;
rt_uint8_t base; /* the base of number */
rt_uint8_t flags; /* flags to print number */
rt_uint8_t qualifier; /* 'h', 'l', or 'L' for integer fields */
rt_int32_t field_width; /* width of output field */
#ifdef RT_PRINTF_PRECISION
int precision; /* min. # of digits for integers and max for a string */
#endif
str = buf;
end = buf + size - 1;
/* Make sure end is always >= buf */
if (end < buf)
{
end = ((char *)-1);
size = end - buf;
}
for (; *fmt ; ++fmt)
{
if (*fmt != '%')
{
if (str <= end)
*str = *fmt;
++ str;
continue;
}
/* process flags */
flags = 0;
while (1)
{
/* skips the first '%' also */
++ fmt;
if (*fmt == '-') flags |= LEFT;
else if (*fmt == '+') flags |= PLUS;
else if (*fmt == ' ') flags |= SPACE;
else if (*fmt == '#') flags |= SPECIAL;
else if (*fmt == '0') flags |= ZEROPAD;
else break;
}
/* get field width */
field_width = -1;
if (isdigit(*fmt)) field_width = skip_atoi(&fmt);
else if (*fmt == '*')
{
++ fmt;
/* it's the next argument */
field_width = va_arg(args, int);
if (field_width < 0)
{
field_width = -field_width;
flags |= LEFT;
}
}
#ifdef RT_PRINTF_PRECISION
/* get the precision */
precision = -1;
if (*fmt == '.')
{
++ fmt;
if (isdigit(*fmt)) precision = skip_atoi(&fmt);
else if (*fmt == '*')
{
++ fmt;
/* it's the next argument */
precision = va_arg(args, int);
}
示例15: vsprintf
// 下面函数是送格式化输出到字符串中。
// 为了能在内核中使用格式化的输出,Linus 在内核实现了该C 标准函数。
// 其中参数fmt 是格式字符串;args 是个数变化的值;buf 是输出字符串缓冲区。
// 请参见本代码列表后的有关格式转换字符的介绍。
int
vsprintf (char *buf, const char *fmt, va_list args)
{
int len;
int i;
char *str; // 用于存放转换过程中的字符串。
char *s;
int *ip;
int flags; /* flags to number() */
/* number()函数使用的标志 */
int field_width; /* width of output field */
/* 输出字段宽度*/
int precision; /* min. # of digits for integers; max
number of chars for from string */
/* min. 整数数字个数;max. 字符串中字符个数 */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
/* 'h', 'l',或'L'用于整数字段 */
// 首先将字符指针指向buf,然后扫描格式字符串,对各个格式转换指示进行相应的处理。
for (str = buf; *fmt; ++fmt)
{
// 格式转换指示字符串均以'%'开始,这里从fmt 格式字符串中扫描'%',寻找格式转换字符串的开始。
// 不是格式指示的一般字符均被依次存入str。
if (*fmt != '%')
{
*str++ = *fmt;
continue;
}
// 下面取得格式指示字符串中的标志域,并将标志常量放入flags 变量中。
/* process flags */
flags = 0;
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt)
{
case '-':
flags |= LEFT;
goto repeat; // 左靠齐调整。
case '+':
flags |= PLUS;
goto repeat; // 放加号。
case ' ':
flags |= SPACE;
goto repeat; // 放空格。
case '#':
flags |= SPECIAL;
goto repeat; // 是特殊转换。
case '0':
flags |= ZEROPAD;
goto repeat; // 要填零(即'0')。
}
// 取当前参数字段宽度域值,放入field_width 变量中。如果宽度域中是数值则直接取其为宽度值。
// 如果宽度域中是字符'*',表示下一个参数指定宽度。因此调用va_arg 取宽度值。若此时宽度值
// 小于0,则该负数表示其带有标志域'-'标志(左靠齐),因此还需在标志变量中添入该标志,并
// 将字段宽度值取为其绝对值。
/* get field width */
field_width = -1;
if (is_digit (*fmt))
field_width = skip_atoi (&fmt);
else if (*fmt == '*')
{
/* it's the next argument */
field_width = va_arg (args, int);
if (field_width < 0)
{
field_width = -field_width;
flags |= LEFT;
}
}
// 下面这段代码,取格式转换串的精度域,并放入precision 变量中。精度域开始的标志是'.'。
// 其处理过程与上面宽度域的类似。如果精度域中是数值则直接取其为精度值。如果精度域中是
// 字符'*',表示下一个参数指定精度。因此调用va_arg 取精度值。若此时宽度值小于0,则
// 将字段精度值取为其绝对值。
/* get the precision */
precision = -1;
if (*fmt == '.')
{
++fmt;
if (is_digit (*fmt))
precision = skip_atoi (&fmt);
else if (*fmt == '*')
{
/* it's the next argument */
precision = va_arg (args, int);
}