Gau*_*v K 108 c gcc-extensions
指的js0n.c
代码语法如下:
static void *gostruct[] =
{
[0 ... 255] = &&l_bad,
['\t'] = &&l_loop, [' '] = &&l_loop, ['\r'] = &&l_loop, ['\n'] = &&l_loop,
['"'] = &&l_qup,
[':'] = &&l_loop, [','] = &&l_loop,
['['] = &&l_up, [']'] = &&l_down, // tracking [] and {} individually would allow fuller validation but is really messy
['{'] = &&l_up, ['}'] = &&l_down,
['-'] = &&l_bare, [48 ... 57] = &&l_bare, // 0-9
[65 ... 90] = &&l_bare, // A-Z
[97 ... 122] = &&l_bare // a-z
};
........
.......
l_bad:
*vlen = cur - json; // where error'd
return 0;
........
........
Run Code Online (Sandbox Code Playgroud)
谁能解释一下这里做了什么?语法[0 ... 255]和
&&l_bad做什么在这里?
use*_*267 108
... 是GCC提供的扩展
https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html#Designated-Inits
要将一系列元素初始化为相同的值,请写入
[first ... last] = value.这是一个GNU扩展.例如,Run Code Online (Sandbox Code Playgroud)int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };
&& 是另一个扩展
https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html#Labels-as-Values
您可以使用一元运算符获取当前函数(或包含函数)中定义的标签的地址
&&.值有类型void *.此值是常量,可以在该类型的常量有效的任何位置使用.例如:Run Code Online (Sandbox Code Playgroud)void *ptr; /* ... */ ptr = &&foo;