# Indent pre-processor directives
--indent-preproc-block
--indent-preproc-define
---indent-preproc-cond
+#--indent-preproc-cond
# Line endings
m->next->start > m->start &&
m->next->start < m->start + m->len) {
// This match is "lefter" than next
- #ifndef __clang_analyzer__
+#ifndef __clang_analyzer__
match_excise(m->next);
- #endif
+#endif
}
while (m->next &&
m->prev->start >= m->start) {
// We are "lefter" than previous
n = m->prev;
- #ifndef __clang_analyzer__
+#ifndef __clang_analyzer__
match_excise(n);
- #endif
+#endif
}
m = m->next;
// Extended ASCII
- #ifdef USE_EXTENDED_ASCII
+#ifdef USE_EXTENDED_ASCII
// Punctuation ranges
for (int i = 132; i < 138; ++i) {
}
}
- #endif
+#endif
// Print output as 16 x 16 table
#ifdef TEST
void Test_critic(CuTest* tc) {
- #ifdef kUseObjectPool
+#ifdef kUseObjectPool
token_pool_init();
- #endif
+#endif
DString * test = d_string_new("{--foo bar--}");
mmd_critic_markup_reject(test);
mmd_critic_markup_reject(test);
CuAssertStrEquals(tc, "", test->str);
- #ifdef kUseObjectPool
+#ifdef kUseObjectPool
// Decrement counter and clean up token pool
token_pool_drain();
token_pool_free();
- #endif
+#endif
}
#endif
va_list ap2;
va_copy(ap2, ap);
- #if (defined(_WIN32) || defined(__WIN32__))
+#if (defined(_WIN32) || defined(__WIN32__))
char *tmp = NULL;
int size = vsnprintf(tmp, 0, fmt, ap2);
- #else
+#else
char tmp[1];
int size = vsnprintf(tmp, 1, fmt, ap2);
- #endif
+#endif
if (size <= 0) {
return size;
FILE * file;
- #if defined(__WIN32)
+#if defined(__WIN32)
int wchars_num = MultiByteToWideChar(CP_UTF8, 0, fname, -1, NULL, 0);
wchar_t wstr[wchars_num];
MultiByteToWideChar(CP_UTF8, 0, fname, -1, wstr, wchars_num);
if ((file = _wfopen(wstr, L"rb")) == NULL) {
- #else
+#else
if ((file = fopen(fname, "r")) == NULL ) {
- #endif
+#endif
return NULL;
}
/// Windows can use either `\` or `/` as a separator -- thanks to t-beckmann on github
/// for suggesting a fix for this.
bool is_separator(char c) {
- #if defined(__WIN32)
+#if defined(__WIN32)
return c == '\\' || c == '/';
- #else
+#else
return c == '/';
- #endif
+#endif
}
void Test_is_separator(CuTest* tc) {
char * test = "a/\\";
- #if defined(__WIN32)
+#if defined(__WIN32)
CuAssertIntEquals(tc, false, is_separator(test[0]));
CuAssertIntEquals(tc, true, is_separator(test[1]));
CuAssertIntEquals(tc, true, is_separator(test[2]));
- #else
+#else
CuAssertIntEquals(tc, false, is_separator(test[0]));
CuAssertIntEquals(tc, true, is_separator(test[1]));
CuAssertIntEquals(tc, false, is_separator(test[2]));
- #endif
+#endif
}
#endif
/// Ensure that path ends in separator
void add_trailing_sep(DString * path) {
- #if defined(__WIN32)
+#if defined(__WIN32)
char sep = '\\';
- #else
+#else
char sep = '/';
- #endif
+#endif
// Ensure that folder ends in separator
if ((path->currentStringLength == 0) || (!is_separator(path->str[path->currentStringLength - 1]))) {
char * path = path_from_dir_base(dir, base);
- #if defined(__WIN32)
+#if defined(__WIN32)
CuAssertStrEquals(tc, "/foo\\bar", path);
- #else
+#else
CuAssertStrEquals(tc, "/foo/bar", path);
- #endif
+#endif
free(path);
strcpy(base, "/bar");
void split_path_file(char ** dir, char ** file, const char * path) {
const char * slash = path, * next;
- #if defined(__WIN32)
+#if defined(__WIN32)
const char sep[] = "\\/"; // Windows allows either variant
- #else
+#else
const char sep[] = "/";
- #endif
+#endif
while ((next = strpbrk(slash + 1, sep))) {
slash = next;
path = "\\foo\\bar.txt";
split_path_file(&dir, &file, path);
- #if defined(__WIN32)
+#if defined(__WIN32)
CuAssertStrEquals(tc, "\\foo\\", dir);
CuAssertStrEquals(tc, "bar.txt", file);
- #else
+#else
CuAssertStrEquals(tc, "", dir);
CuAssertStrEquals(tc, "\\foo\\bar.txt", file);
- #endif
+#endif
}
#endif
// Convert argument to absolute path
char * absolute_path_for_argument(const char * arg) {
char * result = NULL;
- #ifdef PATH_MAX
+#ifdef PATH_MAX
// If PATH_MAX defined, use it
char absolute[PATH_MAX + 1];
realpath(arg, absolute);
result = my_strdup(absolute);
- #else
+#else
// If undefined, then we *should* be able to use a NULL pointer to allocate
result = realpath(arg, NULL);
- #endif
+#endif
return result;
}
** the following structure */
struct yyParser {
yyStackEntry *yytos; /* Pointer to top element of the stack */
- #ifdef YYTRACKMAXSTACKDEPTH
+#ifdef YYTRACKMAXSTACKDEPTH
int yyhwm; /* High-water mark of the stack */
- #endif
- #ifndef YYNOERRORRECOVERY
+#endif
+#ifndef YYNOERRORRECOVERY
int yyerrcnt; /* Shifts left before out of the error */
- #endif
+#endif
ITMZARG_SDECL /* A place to hold %extra_argument */
- #if YYSTACKDEPTH<=0
+#if YYSTACKDEPTH<=0
int yystksz; /* Current side of the stack */
yyStackEntry *yystack; /* The parser's stack */
yyStackEntry yystk0; /* First stack entry */
- #else
+#else
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
- #endif
+#endif
};
typedef struct yyParser yyParser;
if ( pNew ) {
p->yystack = pNew;
p->yytos = &p->yystack[idx];
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sStack grows from %d to %d entries.\n",
yyTracePrompt, p->yystksz, newSize);
}
- #endif
+#endif
p->yystksz = newSize;
}
pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
if ( pParser ) {
- #ifdef YYTRACKMAXSTACKDEPTH
+#ifdef YYTRACKMAXSTACKDEPTH
pParser->yyhwm = 0;
- #endif
- #if YYSTACKDEPTH<=0
+#endif
+#if YYSTACKDEPTH<=0
pParser->yytos = NULL;
pParser->yystack = NULL;
pParser->yystksz = 0;
pParser->yystksz = 1;
}
- #endif
- #ifndef YYNOERRORRECOVERY
+#endif
+#ifndef YYNOERRORRECOVERY
pParser->yyerrcnt = -1;
- #endif
+#endif
pParser->yytos = pParser->yystack;
pParser->yystack[0].stateno = 0;
pParser->yystack[0].major = 0;
assert( pParser->yytos != 0 );
assert( pParser->yytos > pParser->yystack );
yytos = pParser->yytos--;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sPopping %s\n",
yyTokenName[yytos->major]);
}
- #endif
+#endif
yy_destructor(pParser, yytos->major, &yytos->minor);
}
void (*freeProc)(void*) /* Function used to reclaim memory */
) {
yyParser *pParser = (yyParser*)p;
- #ifndef YYPARSEFREENEVERNULL
+#ifndef YYPARSEFREENEVERNULL
if ( pParser == 0 ) {
return;
}
- #endif
+#endif
while ( pParser->yytos > pParser->yystack ) {
yy_pop_parser_stack(pParser);
}
- #if YYSTACKDEPTH<=0
+#if YYSTACKDEPTH<=0
if ( pParser->yystack != &pParser->yystk0 ) {
free(pParser->yystack);
}
- #endif
+#endif
(*freeProc)((void*)pParser);
}
i += iLookAhead;
if ( i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead ) {
- #ifdef YYFALLBACK
+#ifdef YYFALLBACK
YYCODETYPE iFallback; /* Fallback token */
if ( iLookAhead < sizeof(yyFallback) / sizeof(yyFallback[0])
&& (iFallback = yyFallback[iLookAhead]) != 0 ) {
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
}
- #endif
+#endif
assert( yyFallback[iFallback] == 0 ); /* Fallback loop must terminate */
iLookAhead = iFallback;
continue;
}
- #endif
- #ifdef YYWILDCARD
+#endif
+#ifdef YYWILDCARD
{
int j = i - iLookAhead + YYWILDCARD;
if (
- #if YY_SHIFT_MIN+YYWILDCARD<0
+#if YY_SHIFT_MIN+YYWILDCARD<0
j >= 0 &&
- #endif
- #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
+#endif
+#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
j < YY_ACTTAB_COUNT &&
- #endif
+#endif
yy_lookahead[j] == YYWILDCARD && iLookAhead > 0
) {
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
yyTokenName[YYWILDCARD]);
}
- #endif /* NDEBUG */
+#endif /* NDEBUG */
return yy_action[j];
}
}
- #endif /* YYWILDCARD */
+#endif /* YYWILDCARD */
return yy_default[stateno];
} else {
return yy_action[i];
YYCODETYPE iLookAhead /* The look-ahead token */
) {
int i;
- #ifdef YYERRORSYMBOL
+#ifdef YYERRORSYMBOL
if ( stateno > YY_REDUCE_COUNT ) {
return yy_default[stateno];
}
- #else
+#else
assert( stateno <= YY_REDUCE_COUNT );
- #endif
+#endif
i = yy_reduce_ofst[stateno];
assert( i != YY_REDUCE_USE_DFLT );
assert( iLookAhead != YYNOCODE );
i += iLookAhead;
- #ifdef YYERRORSYMBOL
+#ifdef YYERRORSYMBOL
if ( i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead ) {
return yy_default[stateno];
}
- #else
+#else
assert( i >= 0 && i < YY_ACTTAB_COUNT );
assert( yy_lookahead[i] == iLookAhead );
- #endif
+#endif
return yy_action[i];
}
static void yyStackOverflow(yyParser *yypParser) {
ITMZARG_FETCH;
yypParser->yytos--;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sStack Overflow!\n", yyTracePrompt);
}
- #endif
+#endif
while ( yypParser->yytos > yypParser->yystack ) {
yy_pop_parser_stack(yypParser);
) {
yyStackEntry *yytos;
yypParser->yytos++;
- #ifdef YYTRACKMAXSTACKDEPTH
+#ifdef YYTRACKMAXSTACKDEPTH
if ( (int)(yypParser->yytos - yypParser->yystack) > yypParser->yyhwm ) {
yypParser->yyhwm++;
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
}
- #endif
- #if YYSTACKDEPTH>0
+#endif
+#if YYSTACKDEPTH>0
if ( yypParser->yytos >= &yypParser->yystack[YYSTACKDEPTH] ) {
yyStackOverflow(yypParser);
return;
}
- #else
+#else
if ( yypParser->yytos >= &yypParser->yystack[yypParser->yystksz] ) {
if ( yyGrowStack(yypParser) ) {
}
}
- #endif
+#endif
if ( yyNewState > YY_MAX_SHIFT ) {
yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
int yysize; /* Amount to pop the stack */
ITMZARG_FETCH;
yymsp = yypParser->yytos;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE && yyruleno < (int)(sizeof(yyRuleName) / sizeof(yyRuleName[0])) ) {
yysize = yyRuleInfo[yyruleno].nrhs;
yyRuleName[yyruleno], yymsp[-yysize].stateno);
}
- #endif /* NDEBUG */
+#endif /* NDEBUG */
/* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */
if ( yyRuleInfo[yyruleno].nrhs == 0 ) {
- #ifdef YYTRACKMAXSTACKDEPTH
+#ifdef YYTRACKMAXSTACKDEPTH
if ( (int)(yypParser->yytos - yypParser->yystack) > yypParser->yyhwm ) {
yypParser->yyhwm++;
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
}
- #endif
- #if YYSTACKDEPTH>0
+#endif
+#if YYSTACKDEPTH>0
if ( yypParser->yytos >= &yypParser->yystack[YYSTACKDEPTH - 1] ) {
yyStackOverflow(yypParser);
return;
}
- #else
+#else
if ( yypParser->yytos >= &yypParser->yystack[yypParser->yystksz - 1] ) {
if ( yyGrowStack(yypParser) ) {
yymsp = yypParser->yytos;
}
- #endif
+#endif
}
switch ( yyruleno ) {
yyParser *yypParser /* The parser */
) {
ITMZARG_FETCH;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sFail!\n", yyTracePrompt);
}
- #endif
+#endif
while ( yypParser->yytos > yypParser->yystack ) {
yy_pop_parser_stack(yypParser);
/************ Begin %syntax_error code ****************************************/
fprintf(stderr, "Parser syntax error.\n");
- #ifndef NDEBUG
+#ifndef NDEBUG
fprintf(stderr, "Parser syntax error.\n");
int n = sizeof(yyTokenName) / sizeof(yyTokenName[0]);
}
}
- #endif
+#endif
/************ End %syntax_error code ******************************************/
ITMZARG_STORE; /* Suppress warning about unused %extra_argument variable */
}
yyParser *yypParser /* The parser */
) {
ITMZARG_FETCH;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sAccept!\n", yyTracePrompt);
}
- #endif
- #ifndef YYNOERRORRECOVERY
+#endif
+#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
- #endif
+#endif
assert( yypParser->yytos == yypParser->yystack );
/* Here code is inserted which will be executed whenever the
** parser accepts */
) {
YYMINORTYPE yyminorunion;
unsigned int yyact; /* The parser action. */
- #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
+#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
int yyendofinput; /* True if we are at the end of input */
- #endif
- #ifdef YYERRORSYMBOL
+#endif
+#ifdef YYERRORSYMBOL
int yyerrorhit = 0; /* True if yymajor has invoked an error */
- #endif
+#endif
yyParser *yypParser; /* The parser */
yypParser = (yyParser*)yyp;
assert( yypParser->yytos != 0 );
- #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
+#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
yyendofinput = (yymajor == 0);
- #endif
+#endif
ITMZARG_STORE;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sInput '%s'\n", yyTracePrompt, yyTokenName[yymajor]);
}
- #endif
+#endif
do {
yyact = yy_find_shift_action(yypParser, (YYCODETYPE)yymajor);
if ( yyact <= YY_MAX_SHIFTREDUCE ) {
yy_shift(yypParser, yyact, yymajor, yyminor);
- #ifndef YYNOERRORRECOVERY
+#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt--;
- #endif
+#endif
yymajor = YYNOCODE;
} else if ( yyact <= YY_MAX_REDUCE ) {
yy_reduce(yypParser, yyact - YY_MIN_REDUCE);
} else {
assert( yyact == YY_ERROR_ACTION );
yyminorunion.yy0 = yyminor;
- #ifdef YYERRORSYMBOL
+#ifdef YYERRORSYMBOL
int yymx;
- #endif
- #ifndef NDEBUG
+#endif
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt);
}
- #endif
- #ifdef YYERRORSYMBOL
+#endif
+#ifdef YYERRORSYMBOL
/* A syntax error has occurred.
** The response to an error depends upon whether or not the
yymx = yypParser->yytos->major;
if ( yymx == YYERRORSYMBOL || yyerrorhit ) {
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sDiscard input token %s\n",
yyTracePrompt, yyTokenName[yymajor]);
}
- #endif
+#endif
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
yymajor = YYNOCODE;
} else {
if ( yypParser->yytos < yypParser->yystack || yymajor == 0 ) {
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
yy_parse_failed(yypParser);
- #ifndef YYNOERRORRECOVERY
+#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
- #endif
+#endif
yymajor = YYNOCODE;
} else if ( yymx != YYERRORSYMBOL ) {
yy_shift(yypParser, yyact, YYERRORSYMBOL, yyminor);
yypParser->yyerrcnt = 3;
yyerrorhit = 1;
- #elif defined(YYNOERRORRECOVERY)
+#elif defined(YYNOERRORRECOVERY)
/* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
** do any kind of error recovery. Instead, simply invoke the syntax
** error routine and continue going as if nothing had happened.
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
yymajor = YYNOCODE;
- #else /* YYERRORSYMBOL is not defined */
+#else /* YYERRORSYMBOL is not defined */
/* This is what we do if the grammar does not define ERROR:
**
if ( yyendofinput ) {
yy_parse_failed(yypParser);
- #ifndef YYNOERRORRECOVERY
+#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
- #endif
+#endif
}
yymajor = YYNOCODE;
- #endif
+#endif
}
} while ( yymajor != YYNOCODE && yypParser->yytos > yypParser->yystack );
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
yyStackEntry *i;
fprintf(yyTraceFILE, "]\n");
}
- #endif
+#endif
return;
}
token * walker = chain->next; // Walk the existing tree
token * remainder; // Hold unparsed tail of chain
- #ifndef NDEBUG
+#ifndef NDEBUG
ITMZTrace(stderr, "parser >>");
- #endif
+#endif
// Remove existing token tree
e->root = NULL;
}
// Signal finish to parser
- #ifndef NDEBUG
+#ifndef NDEBUG
fprintf(stderr, "\nFinish parse\n");
- #endif
+#endif
ITMZ(pParser, 0, NULL, e);
if (e->root) {
token * walker = chain->child; // Walk the existing tree
token * remainder; // Hold unparsed tail of chain
- #ifndef NDEBUG
+#ifndef NDEBUG
ParseTrace(stderr, "parser >>");
- #endif
+#endif
// Remove existing token tree
e->root = NULL;
remainder->prev = NULL;
}
- #ifndef NDEBUG
+#ifndef NDEBUG
fprintf(stderr, "\nNew line\n");
- #endif
+#endif
Parse(pParser, walker->type, walker, e);
}
// Signal finish to parser
- #ifndef NDEBUG
+#ifndef NDEBUG
fprintf(stderr, "\nFinish parse\n");
- #endif
+#endif
Parse(pParser, 0, NULL, e);
// Disconnect of (now empty) root
return;
}
- #ifndef NDEBUG
+#ifndef NDEBUG
fprintf(stderr, "Strip line tokens from %d (%lu:%lu) (child %d)\n", block->type, block->start, block->len, block->child->type);
token_tree_describe(block, e->dstr->str);
- #endif
+#endif
token * l = block->child;
pair_emphasis_tokens(doc);
- #ifndef NDEBUG
+#ifndef NDEBUG
token_tree_describe(doc, e->dstr->str);
- #endif
+#endif
}
// Return original extensions
** the following structure */
struct yyParser {
yyStackEntry *yytos; /* Pointer to top element of the stack */
- #ifdef YYTRACKMAXSTACKDEPTH
+#ifdef YYTRACKMAXSTACKDEPTH
int yyhwm; /* High-water mark of the stack */
- #endif
- #ifndef YYNOERRORRECOVERY
+#endif
+#ifndef YYNOERRORRECOVERY
int yyerrcnt; /* Shifts left before out of the error */
- #endif
+#endif
OPMLARG_SDECL /* A place to hold %extra_argument */
- #if YYSTACKDEPTH<=0
+#if YYSTACKDEPTH<=0
int yystksz; /* Current side of the stack */
yyStackEntry *yystack; /* The parser's stack */
yyStackEntry yystk0; /* First stack entry */
- #else
+#else
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
- #endif
+#endif
};
typedef struct yyParser yyParser;
if ( pNew ) {
p->yystack = pNew;
p->yytos = &p->yystack[idx];
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sStack grows from %d to %d entries.\n",
yyTracePrompt, p->yystksz, newSize);
}
- #endif
+#endif
p->yystksz = newSize;
}
pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
if ( pParser ) {
- #ifdef YYTRACKMAXSTACKDEPTH
+#ifdef YYTRACKMAXSTACKDEPTH
pParser->yyhwm = 0;
- #endif
- #if YYSTACKDEPTH<=0
+#endif
+#if YYSTACKDEPTH<=0
pParser->yytos = NULL;
pParser->yystack = NULL;
pParser->yystksz = 0;
pParser->yystksz = 1;
}
- #endif
- #ifndef YYNOERRORRECOVERY
+#endif
+#ifndef YYNOERRORRECOVERY
pParser->yyerrcnt = -1;
- #endif
+#endif
pParser->yytos = pParser->yystack;
pParser->yystack[0].stateno = 0;
pParser->yystack[0].major = 0;
assert( pParser->yytos != 0 );
assert( pParser->yytos > pParser->yystack );
yytos = pParser->yytos--;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sPopping %s\n",
yyTokenName[yytos->major]);
}
- #endif
+#endif
yy_destructor(pParser, yytos->major, &yytos->minor);
}
void (*freeProc)(void*) /* Function used to reclaim memory */
) {
yyParser *pParser = (yyParser*)p;
- #ifndef YYPARSEFREENEVERNULL
+#ifndef YYPARSEFREENEVERNULL
if ( pParser == 0 ) {
return;
}
- #endif
+#endif
while ( pParser->yytos > pParser->yystack ) {
yy_pop_parser_stack(pParser);
}
- #if YYSTACKDEPTH<=0
+#if YYSTACKDEPTH<=0
if ( pParser->yystack != &pParser->yystk0 ) {
free(pParser->yystack);
}
- #endif
+#endif
(*freeProc)((void*)pParser);
}
i += iLookAhead;
if ( i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead ) {
- #ifdef YYFALLBACK
+#ifdef YYFALLBACK
YYCODETYPE iFallback; /* Fallback token */
if ( iLookAhead < sizeof(yyFallback) / sizeof(yyFallback[0])
&& (iFallback = yyFallback[iLookAhead]) != 0 ) {
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
}
- #endif
+#endif
assert( yyFallback[iFallback] == 0 ); /* Fallback loop must terminate */
iLookAhead = iFallback;
continue;
}
- #endif
- #ifdef YYWILDCARD
+#endif
+#ifdef YYWILDCARD
{
int j = i - iLookAhead + YYWILDCARD;
if (
- #if YY_SHIFT_MIN+YYWILDCARD<0
+#if YY_SHIFT_MIN+YYWILDCARD<0
j >= 0 &&
- #endif
- #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
+#endif
+#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
j < YY_ACTTAB_COUNT &&
- #endif
+#endif
yy_lookahead[j] == YYWILDCARD && iLookAhead > 0
) {
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
yyTokenName[YYWILDCARD]);
}
- #endif /* NDEBUG */
+#endif /* NDEBUG */
return yy_action[j];
}
}
- #endif /* YYWILDCARD */
+#endif /* YYWILDCARD */
return yy_default[stateno];
} else {
return yy_action[i];
YYCODETYPE iLookAhead /* The look-ahead token */
) {
int i;
- #ifdef YYERRORSYMBOL
+#ifdef YYERRORSYMBOL
if ( stateno > YY_REDUCE_COUNT ) {
return yy_default[stateno];
}
- #else
+#else
assert( stateno <= YY_REDUCE_COUNT );
- #endif
+#endif
i = yy_reduce_ofst[stateno];
assert( i != YY_REDUCE_USE_DFLT );
assert( iLookAhead != YYNOCODE );
i += iLookAhead;
- #ifdef YYERRORSYMBOL
+#ifdef YYERRORSYMBOL
if ( i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead ) {
return yy_default[stateno];
}
- #else
+#else
assert( i >= 0 && i < YY_ACTTAB_COUNT );
assert( yy_lookahead[i] == iLookAhead );
- #endif
+#endif
return yy_action[i];
}
static void yyStackOverflow(yyParser *yypParser) {
OPMLARG_FETCH;
yypParser->yytos--;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sStack Overflow!\n", yyTracePrompt);
}
- #endif
+#endif
while ( yypParser->yytos > yypParser->yystack ) {
yy_pop_parser_stack(yypParser);
) {
yyStackEntry *yytos;
yypParser->yytos++;
- #ifdef YYTRACKMAXSTACKDEPTH
+#ifdef YYTRACKMAXSTACKDEPTH
if ( (int)(yypParser->yytos - yypParser->yystack) > yypParser->yyhwm ) {
yypParser->yyhwm++;
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
}
- #endif
- #if YYSTACKDEPTH>0
+#endif
+#if YYSTACKDEPTH>0
if ( yypParser->yytos >= &yypParser->yystack[YYSTACKDEPTH] ) {
yyStackOverflow(yypParser);
return;
}
- #else
+#else
if ( yypParser->yytos >= &yypParser->yystack[yypParser->yystksz] ) {
if ( yyGrowStack(yypParser) ) {
}
}
- #endif
+#endif
if ( yyNewState > YY_MAX_SHIFT ) {
yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
int yysize; /* Amount to pop the stack */
OPMLARG_FETCH;
yymsp = yypParser->yytos;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE && yyruleno < (int)(sizeof(yyRuleName) / sizeof(yyRuleName[0])) ) {
yysize = yyRuleInfo[yyruleno].nrhs;
yyRuleName[yyruleno], yymsp[-yysize].stateno);
}
- #endif /* NDEBUG */
+#endif /* NDEBUG */
/* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */
if ( yyRuleInfo[yyruleno].nrhs == 0 ) {
- #ifdef YYTRACKMAXSTACKDEPTH
+#ifdef YYTRACKMAXSTACKDEPTH
if ( (int)(yypParser->yytos - yypParser->yystack) > yypParser->yyhwm ) {
yypParser->yyhwm++;
assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
}
- #endif
- #if YYSTACKDEPTH>0
+#endif
+#if YYSTACKDEPTH>0
if ( yypParser->yytos >= &yypParser->yystack[YYSTACKDEPTH - 1] ) {
yyStackOverflow(yypParser);
return;
}
- #else
+#else
if ( yypParser->yytos >= &yypParser->yystack[yypParser->yystksz - 1] ) {
if ( yyGrowStack(yypParser) ) {
yymsp = yypParser->yytos;
}
- #endif
+#endif
}
switch ( yyruleno ) {
yyParser *yypParser /* The parser */
) {
OPMLARG_FETCH;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sFail!\n", yyTracePrompt);
}
- #endif
+#endif
while ( yypParser->yytos > yypParser->yystack ) {
yy_pop_parser_stack(yypParser);
/************ Begin %syntax_error code ****************************************/
fprintf(stderr, "Parser syntax error.\n");
- #ifndef NDEBUG
+#ifndef NDEBUG
fprintf(stderr, "Parser syntax error.\n");
int n = sizeof(yyTokenName) / sizeof(yyTokenName[0]);
}
}
- #endif
+#endif
/************ End %syntax_error code ******************************************/
OPMLARG_STORE; /* Suppress warning about unused %extra_argument variable */
}
yyParser *yypParser /* The parser */
) {
OPMLARG_FETCH;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sAccept!\n", yyTracePrompt);
}
- #endif
- #ifndef YYNOERRORRECOVERY
+#endif
+#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
- #endif
+#endif
assert( yypParser->yytos == yypParser->yystack );
/* Here code is inserted which will be executed whenever the
** parser accepts */
) {
YYMINORTYPE yyminorunion;
unsigned int yyact; /* The parser action. */
- #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
+#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
int yyendofinput; /* True if we are at the end of input */
- #endif
- #ifdef YYERRORSYMBOL
+#endif
+#ifdef YYERRORSYMBOL
int yyerrorhit = 0; /* True if yymajor has invoked an error */
- #endif
+#endif
yyParser *yypParser; /* The parser */
yypParser = (yyParser*)yyp;
assert( yypParser->yytos != 0 );
- #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
+#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
yyendofinput = (yymajor == 0);
- #endif
+#endif
OPMLARG_STORE;
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sInput '%s'\n", yyTracePrompt, yyTokenName[yymajor]);
}
- #endif
+#endif
do {
yyact = yy_find_shift_action(yypParser, (YYCODETYPE)yymajor);
if ( yyact <= YY_MAX_SHIFTREDUCE ) {
yy_shift(yypParser, yyact, yymajor, yyminor);
- #ifndef YYNOERRORRECOVERY
+#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt--;
- #endif
+#endif
yymajor = YYNOCODE;
} else if ( yyact <= YY_MAX_REDUCE ) {
yy_reduce(yypParser, yyact - YY_MIN_REDUCE);
} else {
assert( yyact == YY_ERROR_ACTION );
yyminorunion.yy0 = yyminor;
- #ifdef YYERRORSYMBOL
+#ifdef YYERRORSYMBOL
int yymx;
- #endif
- #ifndef NDEBUG
+#endif
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt);
}
- #endif
- #ifdef YYERRORSYMBOL
+#endif
+#ifdef YYERRORSYMBOL
/* A syntax error has occurred.
** The response to an error depends upon whether or not the
yymx = yypParser->yytos->major;
if ( yymx == YYERRORSYMBOL || yyerrorhit ) {
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
fprintf(yyTraceFILE, "%sDiscard input token %s\n",
yyTracePrompt, yyTokenName[yymajor]);
}
- #endif
+#endif
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
yymajor = YYNOCODE;
} else {
if ( yypParser->yytos < yypParser->yystack || yymajor == 0 ) {
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
yy_parse_failed(yypParser);
- #ifndef YYNOERRORRECOVERY
+#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
- #endif
+#endif
yymajor = YYNOCODE;
} else if ( yymx != YYERRORSYMBOL ) {
yy_shift(yypParser, yyact, YYERRORSYMBOL, yyminor);
yypParser->yyerrcnt = 3;
yyerrorhit = 1;
- #elif defined(YYNOERRORRECOVERY)
+#elif defined(YYNOERRORRECOVERY)
/* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
** do any kind of error recovery. Instead, simply invoke the syntax
** error routine and continue going as if nothing had happened.
yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
yymajor = YYNOCODE;
- #else /* YYERRORSYMBOL is not defined */
+#else /* YYERRORSYMBOL is not defined */
/* This is what we do if the grammar does not define ERROR:
**
if ( yyendofinput ) {
yy_parse_failed(yypParser);
- #ifndef YYNOERRORRECOVERY
+#ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt = -1;
- #endif
+#endif
}
yymajor = YYNOCODE;
- #endif
+#endif
}
} while ( yymajor != YYNOCODE && yypParser->yytos > yypParser->yystack );
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( yyTraceFILE ) {
yyStackEntry *i;
fprintf(yyTraceFILE, "]\n");
}
- #endif
+#endif
return;
}
token * walker = chain->next; // Walk the existing tree
token * remainder; // Hold unparsed tail of chain
- #ifndef NDEBUG
+#ifndef NDEBUG
OPMLTrace(stderr, "parser >>");
- #endif
+#endif
// Remove existing token tree
e->root = NULL;
}
// Signal finish to parser
- #ifndef NDEBUG
+#ifndef NDEBUG
fprintf(stderr, "\nFinish parse\n");
- #endif
+#endif
OPML(pParser, 0, NULL, e);
if (e->root) {
token * token_new(unsigned short type, size_t start, size_t len) {
- #ifdef kUseObjectPool
+#ifdef kUseObjectPool
token * t = pool_allocate_object(token_pool);
- #else
+#else
token * t = malloc(sizeof(token));
- #endif
+#endif
if (t) {
t->type = type;
/// Duplicate an existing token
token * token_copy(token * original) {
- #ifdef kUseObjectPool
+#ifdef kUseObjectPool
token * t = pool_allocate_object(token_pool);
- #else
+#else
token * t = malloc(sizeof(token));
- #endif
+#endif
if (t) {
* t = * original;
/// Free token
void token_free(token * t) {
- #ifdef kUseObjectPool
+#ifdef kUseObjectPool
return;
- #else
+#else
if (t == NULL) {
return;
token_tree_free(t->child);
free(t);
- #endif
+#endif
}
/// Free token chain
void token_tree_free(token * t) {
- #ifdef kUseObjectPool
+#ifdef kUseObjectPool
return;
- #else
+#else
token * n;
while (t != NULL) {
t = n;
}
- #endif
+#endif
}
opener_count[peek->type]--;
}
- #ifndef NDEBUG
+#ifndef NDEBUG
fprintf(stderr, "stack now sized %lu\n", s->size);
- #endif
+#endif
// Prune matched section
if (e->should_prune[pair_type]) {
break;
}
- #ifndef NDEBUG
+#ifndef NDEBUG
else {
fprintf(stderr, "token type %d failed to match stack element\n", walker->type);
}
- #endif
+#endif
i--;
}
}
if (walker->can_open && e->can_open_pair[walker->type] && walker->unmatched) {
stack_push(s, walker);
opener_count[walker->type]++;
- #ifndef NDEBUG
+#ifndef NDEBUG
fprintf(stderr, "push token type %d to stack (%lu elements)\n", walker->type, s->size);
- #endif
+#endif
}
walker = walker->next;
}
- #ifndef NDEBUG
+#ifndef NDEBUG
fprintf(stderr, "token stack has %lu elements (of %lu)\n", s->size, s->capacity);
- #endif
+#endif
// Remove unused tokens from stack and return to parent
s->size = start_counter;
a->next = attr_new(key, value);
a = a->next;
} else {
- #ifndef __clang_analyzer__
+#ifndef __clang_analyzer__
a = attr_new(key, value);
attributes = a;
- #endif
+#endif
}
free(value); // We stored a modified copy
void footnote_free(footnote * f) {
if (f) {
if (f->free_para) {
- #ifdef kUseObjectPool
+#ifdef kUseObjectPool
// Nothing to do here
- #else
+#else
free(f->content);
- #endif
+#endif
}
free(f->clean_text);
char * output_filename;
// Increment counter and prepare token pool
- #ifdef kUseObjectPool
+#ifdef kUseObjectPool
token_pool_init();
- #endif
+#endif
// Seed random numbers
custom_seed_rand();
}
// Increment counter and prepare token pool
- #ifdef kUseObjectPool
+#ifdef kUseObjectPool
token_pool_init();
- #endif
+#endif
if (a_meta->count > 0) {
// List metadata keys
// Perform transclusion(s)
// Convert to absolute path for first file to enable proper path resolution
- #ifdef PATH_MAX
+#ifdef PATH_MAX
// If PATH_MAX defined, use it
char absolute[PATH_MAX + 1];
realpath(a_file->filename[0], absolute);
folder = dirname((char *) a_file->filename[0]);
mmd_transclude_source(buffer, folder, absolute, format, NULL, NULL);
- #else
+#else
// If undefined, then we *should* be able to use a NULL pointer to allocate
char * absolute = realpath(a_file->filename[0], NULL);
folder = dirname((char *) a_file->filename[0]);
mmd_transclude_source(buffer, folder, absolute, format, NULL, NULL);
free(absolute);
- #endif
+#endif
// Don't free folder -- owned by dirname
}
// Decrement counter and clean up token pool
token_pool_drain();
- #ifdef kUseObjectPool
+#ifdef kUseObjectPool
token_pool_free();
- #endif
+#endif
exit2: