E
Ellixis
I have been looking at "sh" source code and have found this strange
thing:
/**** syntax.c ****/
#define ndx(ch) (ch + 1 - CHAR_MIN)
#define set(ch, val) [ndx(ch)] = val,
#define set_range(s, e, val) [ndx(s) ... ndx(e)] = val,
/* character classification table */
const char is_type[257] = { 0,
set_range('0', '9', ISDIGIT)
set_range('a', 'z', ISLOWER)
set_range('A', 'Z', ISUPPER)
set('_', ISUNDER)
set('#', ISSPECL)
set('?', ISSPECL)
set('$', ISSPECL)
set('!', ISSPECL)
set('-', ISSPECL)
set('*', ISSPECL)
set('@', ISSPECL)
};
/**** !syntax.c ****/
/**** gcc -E syntax.c ****/
const char is_type[257] = { 0,
[( '0' + 1 - (-0x7f-1) ) ... ( '9' + 1 - (-0x7f-1) ) ] =
01 ,
[( 'a' + 1 - (-0x7f-1) ) ... ( 'z' + 1 - (-0x7f-1) ) ] =
04 ,
[( 'A' + 1 - (-0x7f-1) ) ... ( 'Z' + 1 - (-0x7f-1) ) ] =
02 ,
[( '_' + 1 - (-0x7f-1) ) ] = 010 ,
[( '#' + 1 - (-0x7f-1) ) ] = 020 ,
[( '?' + 1 - (-0x7f-1) ) ] = 020 ,
[( '$' + 1 - (-0x7f-1) ) ] = 020 ,
[( '!' + 1 - (-0x7f-1) ) ] = 020 ,
[( '-' + 1 - (-0x7f-1) ) ] = 020 ,
[( '*' + 1 - (-0x7f-1) ) ] = 020 ,
[( '@' + 1 - (-0x7f-1) ) ] = 020 ,
};
/**** !gcc -E syntax.c ****/
It compiles without error message or warning. Does somebody have an
explanation of this portion of source code ?
thing:
/**** syntax.c ****/
#define ndx(ch) (ch + 1 - CHAR_MIN)
#define set(ch, val) [ndx(ch)] = val,
#define set_range(s, e, val) [ndx(s) ... ndx(e)] = val,
/* character classification table */
const char is_type[257] = { 0,
set_range('0', '9', ISDIGIT)
set_range('a', 'z', ISLOWER)
set_range('A', 'Z', ISUPPER)
set('_', ISUNDER)
set('#', ISSPECL)
set('?', ISSPECL)
set('$', ISSPECL)
set('!', ISSPECL)
set('-', ISSPECL)
set('*', ISSPECL)
set('@', ISSPECL)
};
/**** !syntax.c ****/
/**** gcc -E syntax.c ****/
const char is_type[257] = { 0,
[( '0' + 1 - (-0x7f-1) ) ... ( '9' + 1 - (-0x7f-1) ) ] =
01 ,
[( 'a' + 1 - (-0x7f-1) ) ... ( 'z' + 1 - (-0x7f-1) ) ] =
04 ,
[( 'A' + 1 - (-0x7f-1) ) ... ( 'Z' + 1 - (-0x7f-1) ) ] =
02 ,
[( '_' + 1 - (-0x7f-1) ) ] = 010 ,
[( '#' + 1 - (-0x7f-1) ) ] = 020 ,
[( '?' + 1 - (-0x7f-1) ) ] = 020 ,
[( '$' + 1 - (-0x7f-1) ) ] = 020 ,
[( '!' + 1 - (-0x7f-1) ) ] = 020 ,
[( '-' + 1 - (-0x7f-1) ) ] = 020 ,
[( '*' + 1 - (-0x7f-1) ) ] = 020 ,
[( '@' + 1 - (-0x7f-1) ) ] = 020 ,
};
/**** !gcc -E syntax.c ****/
It compiles without error message or warning. Does somebody have an
explanation of this portion of source code ?