求解答下面c代码片段中为什么语句: if(non_alphanum(*(++ch)))
中使用*(++ch)不行,必须使用*(ch+1)?
补充环境信息:Linux 4.4.0-64-generic #85-Ubuntu
#define is_alphanum(c) (((c)>='A' && (c) <= 'Z') || ((c) >= 'a' && \
(c) <= 'z') || ((c) >= '0' && (c) <= '9'))
#define non_alphanum(c) !is_alphanum((c))
int is_word_delimiter(char * ch)
{
/*
* Use a static variable to remember whether previous
* character is a delimiter, if true, then the
* following '\'' is also a delimiter
* e.g. "hello 'world'":both '\'' is delimiter
* "don't": '\'' is not a delimiter
*
* Initialize the variable to 1 to indicate "'hello'" cases
*/
static int pre_char_is_delimiter = 1;
if(*ch == '\''){
/*
* NOTE: can't use *(++ch), dont know why
* but is truely has the side effect of
* changing the ch pointer itself.
* Gdb shows that ++ch cause ch pointer to
* shift 3 characters, WTK.
*/
if(non_alphanum(*(++ch))){
pre_char_is_delimiter = 1;
return 1;
}else if(pre_char_is_delimiter){
pre_char_is_delimiter = 1;
return 1;
}else{
pre_char_is_delimiter = 0;
return 0;
}
}
if(is_alphanum(*ch)){
pre_char_is_delimiter = 0;
return 0;
} else{
pre_char_is_delimiter = 1;
return 1;
}
}