- 论坛徽章:
- 0
|
最近在看libass相关字幕,发现if (0) 中的语句也被执行,不知为什么?(在ass.c中), 我在vs2008下测试是不可以的。 谁能给解释一下
if (0) { // cool 
#define NEXT(str,token) \
token = next_token(&str); \
if (!token) break;
#define ANYVAL(name,func) \
} else if (strcasecmp(tname, #name) == 0) { \
target->name = func(token); \
mp_msg(MSGT_ASS, MSGL_DBG2, "%s = %s\n", #name, token);
#define STRVAL(name) \
} else if (strcasecmp(tname, #name) == 0) { \
if (target->name != NULL) free(target->name); \
target->name = strdup(token); \
mp_msg(MSGT_ASS, MSGL_DBG2, "%s = %s\n", #name, token);
#define COLORVAL(name) ANYVAL(name,string2color)
#define INTVAL(name) ANYVAL(name,atoi)
#define FPVAL(name) ANYVAL(name,atof)
#define TIMEVAL(name) ANYVAL(name,string2timecode)
#define STYLEVAL(name) \
} else if (strcasecmp(tname, #name) == 0) { \
target->name = lookup_style(track, token); \
mp_msg(MSGT_ASS, MSGL_DBG2, "%s = %s\n", #name, token);
#define ALIAS(alias,name) \
if (strcasecmp(tname, #alias) == 0) {tname = #name;}
/**
* \brief Parse the tail of Dialogue line
* \param track track
* \param event parsed data goes here
* \param str string to parse, zero-terminated
* \param n_ignored number of format options to skip at the beginning
*/
static int process_event_tail(ass_track_t* track, ass_event_t* event, char* str, int n_ignored)
{
char* token;
char* tname;
char* p = str;
int i;
ass_event_t* target = event;
char* format = strdup(track->event_format);
char* q = format; // format scanning pointer
if (track->n_styles == 0) {
// add "Default" style to the end
// will be used if track does not contain a default style (or even does not contain styles at all)
int sid = ass_alloc_style(track);
track->styles[sid].Name = strdup("Default" ;
track->styles[sid].FontName = strdup("Arial" ;
}
for (i = 0; i < n_ignored; ++i) {
NEXT(q, tname);
}
while (1) {
NEXT(q, tname);
if (strcasecmp(tname, "Text" == 0) {
char* last;
event->Text = strdup(p);
if (*event->Text != 0) {
last = event->Text + strlen(event->Text) - 1;
if (last >= event->Text && *last == '\r')
*last = 0;
}
mp_msg(MSGT_ASS, MSGL_DBG2, "Text = %s\n", event->Text);
event->Duration -= event->Start;
free(format);
return 0; // "Text" is always the last
}
NEXT(p, token);
ALIAS(End,Duration) // temporarily store end timecode in event->Duration
if (0) { // cool 
INTVAL(Layer)
STYLEVAL(Style)
STRVAL(Name)
STRVAL(Effect)
INTVAL(MarginL)
INTVAL(MarginR)
INTVAL(MarginV)
TIMEVAL(Start)
TIMEVAL(Duration)
}
}
free(format);
return 1;
} |
|