# Indent pre-processor directives
--indent-preproc-block
--indent-preproc-define
-#--indent-preproc-cond
+# --indent-preproc-cond
# Line endings
# Pointers/References
+--align-pointer=middle
--align-reference=name
+# Line endings
+--lineend=linux
+
+
# Excludes
--exclude="Sources/libMultiMarkdown/scanners.c"
--exclude="Sources/libMultiMarkdown/parser.c"
#ifdef TEST
-void Test_trie_insert(CuTest* tc) {
+void Test_trie_insert(CuTest * tc) {
trie * a = trie_new(0);
CuAssertIntEquals(tc, kTrieStartingSize, a->capacity);
#ifdef TEST
-void Test_trie_search(CuTest* tc) {
+void Test_trie_search(CuTest * tc) {
trie * a = trie_new(0);
trie_insert(a, "foo", 42);
#ifdef TEST
-void Test_trie_prepare(CuTest* tc) {
+void Test_trie_prepare(CuTest * tc) {
trie * a = trie_new(0);
trie_insert(a, "a", 1);
#ifdef TEST
-void Test_aho_trie_search(CuTest* tc) {
+void Test_aho_trie_search(CuTest * tc) {
trie * a = trie_new(0);
trie_insert(a, "foo", 42);
size_t size; // How many nodes are in use?
size_t capacity; // How many nodes can we hold
- trie_node * node; // Pointer to stack of nodes
+ trie_node * node; // Pointer to stack of nodes
};
typedef struct trie trie;
size_t start; // Starting offset for this match
size_t len; // Length for this match
unsigned short match_type; // Match type
- struct match * next; // Pointer to next match in list
- struct match * prev; // Pointer to previous match in list
+ struct match * next; // Pointer to next match in list
+ struct match * prev; // Pointer to previous match in list
};
typedef struct match match;
}
#ifdef TEST
-void Test_char_is_windows_line_ending(CuTest* tc) {
+void Test_char_is_windows_line_ending(CuTest * tc) {
char * test = "\r\n\n";
CuAssertIntEquals(tc, 1, char_is_windows_line_ending(&test[0]));
#define USE_EXTENDED_ASCII_disabled 1
-int main( int argc, char** argv ) {
+int main( int argc, char ** argv ) {
unsigned char table[256] = {0};
// Define punctuation
#ifdef TEST
-void Test_critic(CuTest* tc) {
+void Test_critic(CuTest * tc) {
#ifdef kUseObjectPool
token_pool_init();
#endif
// Some operating systems do not supply vasprintf() -- standardize on this
// replacement from:
// https://github.com/esp8266/Arduino/issues/1954
-int vasprintf(char** strp, const char* fmt, va_list ap) {
+int vasprintf(char ** strp, const char * fmt, va_list ap) {
va_list ap2;
va_copy(ap2, ap);
#if (defined(_WIN32) || defined(__WIN32__))
- char *tmp = NULL;
+ char * tmp = NULL;
int size = vsnprintf(tmp, 0, fmt, ap2);
#else
char tmp[1];
va_end(ap2);
size += 1;
- *strp = (char*)malloc(size * sizeof(char));
+ *strp = (char *)malloc(size * sizeof(char));
return vsnprintf(*strp, size, fmt, ap);
}
/// Create a new dynamic string
-DString* d_string_new(const char * startingString) {
- DString* newString = malloc(sizeof(DString));
+DString * d_string_new(const char * startingString) {
+ DString * newString = malloc(sizeof(DString));
if (!newString) {
return NULL;
#ifdef TEST
-void Test_d_string_new(CuTest* tc) {
+void Test_d_string_new(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
/// Free dynamic string
-char* d_string_free(DString * ripString, bool freeCharacterData) {
+char * d_string_free(DString * ripString, bool freeCharacterData) {
if (ripString == NULL) {
return NULL;
}
- char* returnedString = ripString->str;
+ char * returnedString = ripString->str;
if (freeCharacterData) {
if (ripString->str != NULL) {
}
}
- char *temp;
+ char * temp;
temp = realloc(baseString->str, newBufferSize);
if (temp == NULL) {
#ifdef TEST
-void Test_ensureStringBufferCanHold(CuTest* tc) {
+void Test_ensureStringBufferCanHold(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
#ifdef TEST
-void Test_d_string_append(CuTest* tc) {
+void Test_d_string_append(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
#ifdef TEST
-void Test_d_string_append_c(CuTest* tc) {
+void Test_d_string_append_c(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
size_t newSizeNeeded = baseString->currentStringLength + bytes;
ensureStringBufferCanHold(baseString, newSizeNeeded);
- memcpy((void*)baseString->str + baseString->currentStringLength, appendedChars, bytes);
+ memcpy((void *)baseString->str + baseString->currentStringLength, appendedChars, bytes);
baseString->currentStringLength = newSizeNeeded;
baseString->str[newSizeNeeded] = '\0';
#ifdef TEST
-void Test_d_string_append_c_array(CuTest* tc) {
+void Test_d_string_append_c_array(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
va_list args;
va_start(args, format);
- char* formattedString = NULL;
+ char * formattedString = NULL;
vasprintf(&formattedString, format, args);
if (formattedString != NULL) {
#ifdef TEST
-void Test_d_string_append_printf(CuTest* tc) {
+void Test_d_string_append_printf(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
#ifdef TEST
-void Test_d_string_prepend(CuTest* tc) {
+void Test_d_string_prepend(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
#ifdef TEST
-void Test_d_string_insert(CuTest* tc) {
+void Test_d_string_insert(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
#ifdef TEST
-void Test_d_string_insert_c(CuTest* tc) {
+void Test_d_string_insert_c(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
#ifdef TEST
-void Test_d_string_insert_c_array(CuTest* tc) {
+void Test_d_string_insert_c_array(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
va_list args;
va_start(args, format);
- char* formattedString = NULL;
+ char * formattedString = NULL;
vasprintf(&formattedString, format, args);
if (formattedString != NULL) {
#ifdef TEST
-void Test_d_string_insert_printf(CuTest* tc) {
+void Test_d_string_insert_printf(CuTest * tc) {
char * test = "foo";
DString * result = d_string_new(test);
#ifdef TEST
-void Test_d_string_erase(CuTest* tc) {
+void Test_d_string_erase(CuTest * tc) {
char * test = "foobar";
DString * result = d_string_new(test);
#ifdef TEST
-void Test_d_string_copy_substring(CuTest* tc) {
+void Test_d_string_copy_substring(CuTest * tc) {
char * test = "foobar";
DString * result = d_string_new(test);
#ifdef TEST
-void Test_d_string_replace_text_in_range(CuTest* tc) {
+void Test_d_string_replace_text_in_range(CuTest * tc) {
char * test = "foobarfoobarfoo";
long delta = 0;
#ifdef TEST
-void Test_is_separator(CuTest* tc) {
+void Test_is_separator(CuTest * tc) {
char * test = "a/\\";
#if defined(__WIN32)
#ifdef TEST
-void Test_path_from_dir_base(CuTest* tc) {
+void Test_path_from_dir_base(CuTest * tc) {
char dir[10] = "/foo";
char base[10] = "bar";
#ifdef TEST
-void Test_split_path_file(CuTest* tc) {
+void Test_split_path_file(CuTest * tc) {
char * dir, * file;
char * path = "/foo/bar.txt";
// Let compiler know where to find GetFullPathName()
#include <windows.h>
-char *realpath(const char *path, char *resolved_path) {
+char * realpath(const char * path, char * resolved_path) {
DWORD retval = 0;
DWORD dwBufSize = 0; // Just in case MAX_PATH differs from PATH_MAX
- TCHAR *buffer = NULL;
+ TCHAR * buffer = NULL;
if (resolved_path == NULL) {
// realpath allocates appropiate bytes if resolved_path is null. This is to mimic realpath behavior
dwBufSize = PATH_MAX; // Use windows PATH_MAX constant, because we are in Windows context now.
- buffer = (char*)malloc(dwBufSize);
+ buffer = (char *)malloc(dwBufSize);
if (buffer == NULL) {
return NULL; // some really weird is going on...
#if (defined(_WIN32) || defined(__WIN32__))
// Windows does not know realpath(), so we need a "windows port"
- char *realpath(const char *path, char *resolved_path);
+ char * realpath(const char * path, char * resolved_path);
#endif
#endif
}
-static char * strip_dimension_units(char *original) {
- char *result;
+static char * strip_dimension_units(char * original) {
+ char * result;
int i;
result = my_strdup(original);
/// Create MMD Engine using an existing DString (A new copy is *not* made)
mmd_engine * mmd_engine_create_with_dstring(
- DString * d,
+ DString * d,
unsigned long extensions
);
/// Convert OPML to text without modifying original engine source
-DString * mmd_engine_convert_opml_to_text(mmd_engine * e);
+DString * mmd_engine_convert_opml_to_text(mmd_engine * e);
/// Convert ITMZ to text without modifying original engine source
-DString * mmd_engine_convert_itmz_to_text(mmd_engine * e);
+DString * mmd_engine_convert_itmz_to_text(mmd_engine * e);
/// Convert MMD text to specified format using DString as a container for block of data
size_t start; //!< Starting offset in the source string
size_t len; //!< Length of the token in the source string
- struct token * next; //!< Pointer to next token in the chain
- struct token * prev; //!< Pointer to previous marker in the chain
- struct token * child; //!< Pointer to child chain
+ struct token * next; //!< Pointer to next token in the chain
+ struct token * prev; //!< Pointer to previous marker in the chain
+ struct token * child; //!< Pointer to child chain
- struct token * tail; //!< Pointer to last token in the chain
+ struct token * tail; //!< Pointer to last token in the chain
- struct token * mate; //!< Pointer to other token in matched pair
+ struct token * mate; //!< Pointer to other token in matched pair
};
typedef struct token token;
/* The state of the parser is completely contained in an instance of
** the following structure */
struct yyParser {
- yyStackEntry *yytos; /* Pointer to top element of the stack */
+ yyStackEntry * yytos; /* Pointer to top element of the stack */
#ifdef YYTRACKMAXSTACKDEPTH
int yyhwm; /* High-water mark of the stack */
#endif
ITMZARG_SDECL /* A place to hold %extra_argument */
#if YYSTACKDEPTH<=0
int yystksz; /* Current side of the stack */
- yyStackEntry *yystack; /* The parser's stack */
+ yyStackEntry * yystack; /* The parser's stack */
yyStackEntry yystk0; /* First stack entry */
#else
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
#ifndef NDEBUG
#include <stdio.h>
- static FILE *yyTraceFILE = 0;
- static char *yyTracePrompt = 0;
+ static FILE * yyTraceFILE = 0;
+ static char * yyTracePrompt = 0;
#endif /* NDEBUG */
#ifndef NDEBUG
** Outputs:
** None.
*/
-void ITMZTrace(FILE *TraceFILE, char *zTracePrompt) {
+void ITMZTrace(FILE * TraceFILE, char * zTracePrompt) {
yyTraceFILE = TraceFILE;
yyTracePrompt = zTracePrompt;
#ifndef NDEBUG
/* For tracing shifts, the names of all terminals and nonterminals
** are required. The following table supplies these names */
-static const char *const yyTokenName[] = {
+static const char * const yyTokenName[] = {
"$", "ITMZ_ITHOUGHTS_OPEN", "ITMZ_ITHOUGHTS_CLOSE", "ITMZ_TOPICS_OPEN",
"ITMZ_TOPICS_CLOSE", "ITMZ_TOPIC_OPEN", "ITMZ_TOPIC_CLOSE", "ITMZ_TOPIC_PREAMBLE",
"ITMZ_TOPIC_METADATA", "ITMZ_TOPIC_SELF_CLOSE", "ITMZ_RELATIONSHIPS_OPEN", "ITMZ_RELATIONSHIPS_CLOSE",
#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
-static const char *const yyRuleName[] = {
+static const char * const yyRuleName[] = {
/* 0 */ "doc ::= doc_ithoughts",
/* 1 */ "doc_ithoughts ::= ITMZ_ITHOUGHTS_OPEN itmz_topics_section itmz_relationships ITMZ_ITHOUGHTS_CLOSE",
/* 2 */ "doc_ithoughts ::= ITMZ_ITHOUGHTS_OPEN itmz_relationships ITMZ_ITHOUGHTS_CLOSE",
** Try to increase the size of the parser stack. Return the number
** of errors. Return 0 on success.
*/
-static int yyGrowStack(yyParser *p) {
+static int yyGrowStack(yyParser * p) {
int newSize;
int idx;
- yyStackEntry *pNew;
+ yyStackEntry * pNew;
newSize = p->yystksz * 2 + 100;
idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
** A pointer to a parser. This pointer is used in subsequent calls
** to ITMZ and ITMZFree.
*/
-void *ITMZAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)) {
- yyParser *pParser;
- pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
+void * ITMZAlloc(void * (*mallocProc)(YYMALLOCARGTYPE)) {
+ yyParser * pParser;
+ pParser = (yyParser *)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
if ( pParser ) {
#ifdef YYTRACKMAXSTACKDEPTH
** directives of the input grammar.
*/
static void yy_destructor(
- yyParser *yypParser, /* The parser */
+ yyParser * yypParser, /* The parser */
YYCODETYPE yymajor, /* Type code for object to destroy */
- YYMINORTYPE *yypminor /* The object to be destroyed */
+ YYMINORTYPE * yypminor /* The object to be destroyed */
) {
ITMZARG_FETCH;
** If there is a destructor routine associated with the token which
** is popped from the stack, then call it.
*/
-static void yy_pop_parser_stack(yyParser *pParser) {
- yyStackEntry *yytos;
+static void yy_pop_parser_stack(yyParser * pParser) {
+ yyStackEntry * yytos;
assert( pParser->yytos != 0 );
assert( pParser->yytos > pParser->yystack );
yytos = pParser->yytos--;
** assumed that the input pointer is never NULL.
*/
void ITMZFree(
- void *p, /* The parser to be deleted */
- void (*freeProc)(void*) /* Function used to reclaim memory */
+ void * p, /* The parser to be deleted */
+ void (*freeProc)(void *) /* Function used to reclaim memory */
) {
- yyParser *pParser = (yyParser*)p;
+ yyParser * pParser = (yyParser *)p;
#ifndef YYPARSEFREENEVERNULL
if ( pParser == 0 ) {
}
#endif
- (*freeProc)((void*)pParser);
+ (*freeProc)((void *)pParser);
}
/*
** Return the peak depth of the stack for a parser.
*/
#ifdef YYTRACKMAXSTACKDEPTH
-int ITMZStackPeak(void *p) {
- yyParser *pParser = (yyParser*)p;
+int ITMZStackPeak(void * p) {
+ yyParser * pParser = (yyParser *)p;
return pParser->yyhwm;
}
#endif
** look-ahead token iLookAhead.
*/
static unsigned int yy_find_shift_action(
- yyParser *pParser, /* The parser */
+ yyParser * pParser, /* The parser */
YYCODETYPE iLookAhead /* The look-ahead token */
) {
int i;
/*
** The following routine is called if the stack overflows.
*/
-static void yyStackOverflow(yyParser *yypParser) {
+static void yyStackOverflow(yyParser * yypParser) {
ITMZARG_FETCH;
yypParser->yytos--;
#ifndef NDEBUG
** Print tracing information for a SHIFT action
*/
#ifndef NDEBUG
-static void yyTraceShift(yyParser *yypParser, int yyNewState) {
+static void yyTraceShift(yyParser * yypParser, int yyNewState) {
if ( yyTraceFILE ) {
if ( yyNewState < YYNSTATE ) {
fprintf(yyTraceFILE, "%sShift '%s', go to state %d\n",
** Perform a shift action.
*/
static void yy_shift(
- yyParser *yypParser, /* The parser to be shifted */
+ yyParser * yypParser, /* The parser to be shifted */
int yyNewState, /* The new state to shift in */
int yyMajor, /* The major token to shift in */
ITMZTOKENTYPE yyMinor /* The minor token to shift in */
) {
- yyStackEntry *yytos;
+ yyStackEntry * yytos;
yypParser->yytos++;
#ifdef YYTRACKMAXSTACKDEPTH
{ 16, 0 },
};
-static void yy_accept(yyParser*); /* Forward Declaration */
+static void yy_accept(yyParser *); /* Forward Declaration */
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
- yyParser *yypParser, /* The parser */
+ yyParser * yypParser, /* The parser */
unsigned int yyruleno /* Number of the rule by which to reduce */
) {
int yygoto; /* The next state */
int yyact; /* The next action */
- yyStackEntry *yymsp; /* The top of the parser's stack */
+ yyStackEntry * yymsp; /* The top of the parser's stack */
int yysize; /* Amount to pop the stack */
ITMZARG_FETCH;
yymsp = yypParser->yytos;
*/
#ifndef YYNOERRORRECOVERY
static void yy_parse_failed(
- yyParser *yypParser /* The parser */
+ yyParser * yypParser /* The parser */
) {
ITMZARG_FETCH;
#ifndef NDEBUG
** The following code executes when a syntax error first occurs.
*/
static void yy_syntax_error(
- yyParser *yypParser, /* The parser */
+ yyParser * yypParser, /* The parser */
int yymajor, /* The major type of the error token */
ITMZTOKENTYPE yyminor /* The minor type of the error token */
) {
** The following is executed when the parser accepts
*/
static void yy_accept(
- yyParser *yypParser /* The parser */
+ yyParser * yypParser /* The parser */
) {
ITMZARG_FETCH;
#ifndef NDEBUG
** None.
*/
void ITMZ(
- void *yyp, /* The parser */
+ void * yyp, /* The parser */
int yymajor, /* The major token code number */
ITMZTOKENTYPE yyminor /* The value for the token */
ITMZARG_PDECL /* Optional %extra_argument parameter */
#ifdef YYERRORSYMBOL
int yyerrorhit = 0; /* True if yymajor has invoked an error */
#endif
- yyParser *yypParser; /* The parser */
+ yyParser * yypParser; /* The parser */
- yypParser = (yyParser*)yyp;
+ yypParser = (yyParser *)yyp;
assert( yypParser->yytos != 0 );
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
yyendofinput = (yymajor == 0);
#ifndef NDEBUG
if ( yyTraceFILE ) {
- yyStackEntry *i;
+ yyStackEntry * i;
char cDiv = '[';
fprintf(yyTraceFILE, "%sReturn. Stack=", yyTracePrompt);
void * ITMZAlloc(void *);
void ITMZ(void *, int, void *, void *);
void ITMZFree(void *, void *);
-void ITMZTrace(FILE *stream, char *zPrefix);
+void ITMZTrace(FILE * stream, char * zPrefix);
#define print(x) d_string_append(out, x)
void parse_itmz_token_chain(mmd_engine * e, token * chain) {
- void* pParser = ITMZAlloc (malloc); // Create a parser (for lemon)
+ void * pParser = ITMZAlloc (malloc); // Create a parser (for lemon)
token * walker = chain->next; // Walk the existing tree
token * remainder; // Hold unparsed tail of chain
}
-static char * correct_dimension_units(char *original) {
- char *result;
+static char * correct_dimension_units(char * original) {
+ char * result;
int i;
result = my_strdup(original);
void * ParseAlloc(void *);
void Parse(void *, int, void *, void *);
void ParseFree(void *, void *);
-void ParseTrace(FILE *stream, char *zPrefix);
+void ParseTrace(FILE * stream, char * zPrefix);
void mmd_pair_tokens_in_block(token * block, token_pair_engine * e, stack * s);
e->recurse_depth++;
- void* pParser = ParseAlloc (malloc); // Create a parser (for lemon)
+ void * pParser = ParseAlloc (malloc); // Create a parser (for lemon)
token * walker = chain->child; // Walk the existing tree
token * remainder; // Hold unparsed tail of chain
/// Convert OPML to text without modifying original engine source
-DString * mmd_engine_convert_opml_to_text(mmd_engine * e) {
+DString * mmd_engine_convert_opml_to_text(mmd_engine * e) {
DString * original = d_string_new("");
d_string_append_c_array(original, e->dstr->str, e->dstr->currentStringLength);
/// Convert ITMZ to text without modifying original engine source
-DString * mmd_engine_convert_itmz_to_text(mmd_engine * e) {
+DString * mmd_engine_convert_itmz_to_text(mmd_engine * e) {
DString * original = d_string_new("");
d_string_append_c_array(original, e->dstr->str, e->dstr->currentStringLength);
struct mmd_engine {
- DString * dstr;
- token * root;
+ DString * dstr;
+ token * root;
unsigned long extensions;
unsigned short recurse_depth;
bool allow_meta;
- token_pair_engine * pairings1;
- token_pair_engine * pairings2;
- token_pair_engine * pairings3;
- token_pair_engine * pairings4;
-
- stack * abbreviation_stack;
- stack * citation_stack;
- stack * definition_stack;
- stack * footnote_stack;
- stack * glossary_stack;
- stack * header_stack;
- stack * link_stack;
- stack * metadata_stack;
- stack * table_stack;
+ token_pair_engine * pairings1;
+ token_pair_engine * pairings2;
+ token_pair_engine * pairings3;
+ token_pair_engine * pairings4;
+
+ stack * abbreviation_stack;
+ stack * citation_stack;
+ stack * definition_stack;
+ stack * footnote_stack;
+ stack * glossary_stack;
+ stack * header_stack;
+ stack * link_stack;
+ stack * metadata_stack;
+ stack * table_stack;
short language;
short quotes_lang;
- struct asset * asset_hash;
+ struct asset * asset_hash;
int random_seed_base_labels;
};
struct asset {
- char * url;
- char * asset_path;
+ char * url;
+ char * asset_path;
UT_hash_handle hh;
};
/// Structure for an object allocator pool
struct pool {
- stack * allocated; //!< Stack of pointers to slabs that have been allocated
- void * next; //!< Pointer to next available memory for allocation
- void * last; //!< Pointer to end of available memory
+ stack * allocated; //!< Stack of pointers to slabs that have been allocated
+ void * next; //!< Pointer to next available memory for allocation
+ void * last; //!< Pointer to end of available memory
short object_size; //!< Size of individual objects to be allocated
char _PADDING[6]; //!< pad struct for alignment
}
-static char * correct_dimension_units(char *original) {
- char *result;
+static char * correct_dimension_units(char * original) {
+ char * result;
int i;
result = my_strdup(original);
/* The state of the parser is completely contained in an instance of
** the following structure */
struct yyParser {
- yyStackEntry *yytos; /* Pointer to top element of the stack */
+ yyStackEntry * yytos; /* Pointer to top element of the stack */
#ifdef YYTRACKMAXSTACKDEPTH
int yyhwm; /* High-water mark of the stack */
#endif
OPMLARG_SDECL /* A place to hold %extra_argument */
#if YYSTACKDEPTH<=0
int yystksz; /* Current side of the stack */
- yyStackEntry *yystack; /* The parser's stack */
+ yyStackEntry * yystack; /* The parser's stack */
yyStackEntry yystk0; /* First stack entry */
#else
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
#ifndef NDEBUG
#include <stdio.h>
- static FILE *yyTraceFILE = 0;
- static char *yyTracePrompt = 0;
+ static FILE * yyTraceFILE = 0;
+ static char * yyTracePrompt = 0;
#endif /* NDEBUG */
#ifndef NDEBUG
** Outputs:
** None.
*/
-void OPMLTrace(FILE *TraceFILE, char *zTracePrompt) {
+void OPMLTrace(FILE * TraceFILE, char * zTracePrompt) {
yyTraceFILE = TraceFILE;
yyTracePrompt = zTracePrompt;
#ifndef NDEBUG
/* For tracing shifts, the names of all terminals and nonterminals
** are required. The following table supplies these names */
-static const char *const yyTokenName[] = {
+static const char * const yyTokenName[] = {
"$", "OPML_XML", "OPML_WSNL", "OPML_OPML_OPEN",
"OPML_OPML_CLOSE", "OPML_HEAD_OPEN", "OPML_HEAD_CLOSE", "OPML_TITLE_OPEN",
"OPML_TITLE_CLOSE", "OPML_BODY_OPEN", "OPML_BODY_CLOSE", "OPML_OUTLINE_OPEN",
#ifndef NDEBUG
/* For tracing reduce actions, the names of all rules are required.
*/
-static const char *const yyRuleName[] = {
+static const char * const yyRuleName[] = {
/* 0 */ "doc ::= doc_xml",
/* 1 */ "doc_xml ::= OPML_XML doc_opml",
/* 2 */ "doc_xml ::= doc_opml",
** Try to increase the size of the parser stack. Return the number
** of errors. Return 0 on success.
*/
-static int yyGrowStack(yyParser *p) {
+static int yyGrowStack(yyParser * p) {
int newSize;
int idx;
- yyStackEntry *pNew;
+ yyStackEntry * pNew;
newSize = p->yystksz * 2 + 100;
idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
** A pointer to a parser. This pointer is used in subsequent calls
** to OPML and OPMLFree.
*/
-void *OPMLAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)) {
- yyParser *pParser;
- pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
+void * OPMLAlloc(void * (*mallocProc)(YYMALLOCARGTYPE)) {
+ yyParser * pParser;
+ pParser = (yyParser *)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
if ( pParser ) {
#ifdef YYTRACKMAXSTACKDEPTH
** directives of the input grammar.
*/
static void yy_destructor(
- yyParser *yypParser, /* The parser */
+ yyParser * yypParser, /* The parser */
YYCODETYPE yymajor, /* Type code for object to destroy */
- YYMINORTYPE *yypminor /* The object to be destroyed */
+ YYMINORTYPE * yypminor /* The object to be destroyed */
) {
OPMLARG_FETCH;
** If there is a destructor routine associated with the token which
** is popped from the stack, then call it.
*/
-static void yy_pop_parser_stack(yyParser *pParser) {
- yyStackEntry *yytos;
+static void yy_pop_parser_stack(yyParser * pParser) {
+ yyStackEntry * yytos;
assert( pParser->yytos != 0 );
assert( pParser->yytos > pParser->yystack );
yytos = pParser->yytos--;
** assumed that the input pointer is never NULL.
*/
void OPMLFree(
- void *p, /* The parser to be deleted */
- void (*freeProc)(void*) /* Function used to reclaim memory */
+ void * p, /* The parser to be deleted */
+ void (*freeProc)(void *) /* Function used to reclaim memory */
) {
- yyParser *pParser = (yyParser*)p;
+ yyParser * pParser = (yyParser *)p;
#ifndef YYPARSEFREENEVERNULL
if ( pParser == 0 ) {
}
#endif
- (*freeProc)((void*)pParser);
+ (*freeProc)((void *)pParser);
}
/*
** Return the peak depth of the stack for a parser.
*/
#ifdef YYTRACKMAXSTACKDEPTH
-int OPMLStackPeak(void *p) {
- yyParser *pParser = (yyParser*)p;
+int OPMLStackPeak(void * p) {
+ yyParser * pParser = (yyParser *)p;
return pParser->yyhwm;
}
#endif
** look-ahead token iLookAhead.
*/
static unsigned int yy_find_shift_action(
- yyParser *pParser, /* The parser */
+ yyParser * pParser, /* The parser */
YYCODETYPE iLookAhead /* The look-ahead token */
) {
int i;
/*
** The following routine is called if the stack overflows.
*/
-static void yyStackOverflow(yyParser *yypParser) {
+static void yyStackOverflow(yyParser * yypParser) {
OPMLARG_FETCH;
yypParser->yytos--;
#ifndef NDEBUG
** Print tracing information for a SHIFT action
*/
#ifndef NDEBUG
-static void yyTraceShift(yyParser *yypParser, int yyNewState) {
+static void yyTraceShift(yyParser * yypParser, int yyNewState) {
if ( yyTraceFILE ) {
if ( yyNewState < YYNSTATE ) {
fprintf(yyTraceFILE, "%sShift '%s', go to state %d\n",
** Perform a shift action.
*/
static void yy_shift(
- yyParser *yypParser, /* The parser to be shifted */
+ yyParser * yypParser, /* The parser to be shifted */
int yyNewState, /* The new state to shift in */
int yyMajor, /* The major token to shift in */
OPMLTOKENTYPE yyMinor /* The minor token to shift in */
) {
- yyStackEntry *yytos;
+ yyStackEntry * yytos;
yypParser->yytos++;
#ifdef YYTRACKMAXSTACKDEPTH
{ 24, 1 },
};
-static void yy_accept(yyParser*); /* Forward Declaration */
+static void yy_accept(yyParser *); /* Forward Declaration */
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
- yyParser *yypParser, /* The parser */
+ yyParser * yypParser, /* The parser */
unsigned int yyruleno /* Number of the rule by which to reduce */
) {
int yygoto; /* The next state */
int yyact; /* The next action */
- yyStackEntry *yymsp; /* The top of the parser's stack */
+ yyStackEntry * yymsp; /* The top of the parser's stack */
int yysize; /* Amount to pop the stack */
OPMLARG_FETCH;
yymsp = yypParser->yytos;
*/
#ifndef YYNOERRORRECOVERY
static void yy_parse_failed(
- yyParser *yypParser /* The parser */
+ yyParser * yypParser /* The parser */
) {
OPMLARG_FETCH;
#ifndef NDEBUG
** The following code executes when a syntax error first occurs.
*/
static void yy_syntax_error(
- yyParser *yypParser, /* The parser */
+ yyParser * yypParser, /* The parser */
int yymajor, /* The major type of the error token */
OPMLTOKENTYPE yyminor /* The minor type of the error token */
) {
** The following is executed when the parser accepts
*/
static void yy_accept(
- yyParser *yypParser /* The parser */
+ yyParser * yypParser /* The parser */
) {
OPMLARG_FETCH;
#ifndef NDEBUG
** None.
*/
void OPML(
- void *yyp, /* The parser */
+ void * yyp, /* The parser */
int yymajor, /* The major token code number */
OPMLTOKENTYPE yyminor /* The value for the token */
OPMLARG_PDECL /* Optional %extra_argument parameter */
#ifdef YYERRORSYMBOL
int yyerrorhit = 0; /* True if yymajor has invoked an error */
#endif
- yyParser *yypParser; /* The parser */
+ yyParser * yypParser; /* The parser */
- yypParser = (yyParser*)yyp;
+ yypParser = (yyParser *)yyp;
assert( yypParser->yytos != 0 );
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
yyendofinput = (yymajor == 0);
#ifndef NDEBUG
if ( yyTraceFILE ) {
- yyStackEntry *i;
+ yyStackEntry * i;
char cDiv = '[';
fprintf(yyTraceFILE, "%sReturn. Stack=", yyTracePrompt);
void * OPMLAlloc(void *);
void OPML(void *, int, void *, void *);
void OPMLFree(void *, void *);
-void OPMLTrace(FILE *stream, char *zPrefix);
+void OPMLTrace(FILE * stream, char * zPrefix);
#define print(x) d_string_append(out, x)
void parse_opml_token_chain(mmd_engine * e, token * chain) {
- void* pParser = OPMLAlloc (malloc); // Create a parser (for lemon)
+ void * pParser = OPMLAlloc (malloc); // Create a parser (for lemon)
token * walker = chain->next; // Walk the existing tree
token * remainder; // Hold unparsed tail of chain
void ran_array(long aa[], int n)
#else
void ran_array(aa, n) /* put n new random numbers in aa */
- long *aa; /* destination */
+ long * aa; /* destination */
int n; /* array length (must be at least KK) */
#endif
{
#define QUALITY 1009 /* recommended quality level for high-res use */
long ran_arr_buf[QUALITY];
long ran_arr_dummy = -1, ran_arr_started = -1;
-long *ran_arr_ptr = &ran_arr_dummy; /* the next random number, or -1 */
+long * ran_arr_ptr = &ran_arr_dummy; /* the next random number, or -1 */
#define TT 70 /* guaranteed separation between streams */
#define is_odd(x) ((x)&1) /* units bit of x */
struct stack {
size_t size; //!< Number of objects currently in stack
size_t capacity; //!< Total current capacity for stack
- void ** element; //!< Array of pointers to objects in stack
+ void ** element; //!< Array of pointers to objects in stack
};
typedef struct stack stack;
#define kMaxTableColumns 48 //!< Maximum number of table columns for specifying alignment
typedef struct {
- struct link * link_hash;
- struct meta * meta_hash;
+ struct link * link_hash;
+ struct meta * meta_hash;
unsigned long extensions;
short output_format;
short skip_token;
short footnote_para_counter;
- stack * used_footnotes;
- stack * inline_footnotes_to_free;
+ stack * used_footnotes;
+ stack * inline_footnotes_to_free;
struct fn_holder * footnote_hash;
short footnote_being_printed;
int random_seed_base_labels;
int label_counter;
- stack * used_citations;
- stack * inline_citations_to_free;
+ stack * used_citations;
+ stack * inline_citations_to_free;
struct fn_holder * citation_hash;
short citation_being_printed;
- char * bibtex_file;
+ char * bibtex_file;
- stack * used_glossaries;
- stack * inline_glossaries_to_free;
+ stack * used_glossaries;
+ stack * inline_glossaries_to_free;
struct fn_holder * glossary_hash;
short glossary_being_printed;
- stack * used_abbreviations;
- stack * inline_abbreviations_to_free;
+ stack * used_abbreviations;
+ stack * inline_abbreviations_to_free;
struct fn_holder * abbreviation_hash;
short language;
short base_header_level;
- stack * header_stack;
+ stack * header_stack;
- stack * outline_stack;
+ stack * outline_stack;
short opml_item_closed;
short recurse_depth;
short odf_para_type;
- struct asset * asset_hash;
+ struct asset * asset_hash;
short store_assets;
short remember_assets;
} scratch_pad;
struct attr {
- char * key;
- char * value;
- struct attr * next;
+ char * key;
+ char * value;
+ struct attr * next;
};
typedef struct attr attr;
struct link {
- token * label;
- char * label_text;
- char * clean_text;
- char * url;
- char * title;
- attr * attributes;
+ token * label;
+ char * label_text;
+ char * clean_text;
+ char * url;
+ char * title;
+ attr * attributes;
short flags;
UT_hash_handle hh;
};
typedef struct link link;
struct footnote {
- token * label;
- char * label_text;
- char * clean_text;
- token * content;
+ token * label;
+ char * label_text;
+ char * clean_text;
+ token * content;
size_t count;
bool free_para;
typedef struct footnote footnote;
struct fn_holder {
- footnote * note;
+ footnote * note;
UT_hash_handle hh;
};
typedef struct fn_holder fn_holder;
struct meta {
- char * key;
- char * value;
+ char * key;
+ char * value;
size_t start;
UT_hash_handle hh;
};
typedef struct meta meta;
struct abbr {
- char * abbr;
+ char * abbr;
size_t abbr_len;
- char * expansion;
+ char * expansion;
size_t expansion_len;
UT_hash_handle hh;
};
#define kBUFFERSIZE 4096 // How many bytes to read at a time
// argtable structs
-struct arg_lit *a_help, *a_version, *a_compatibility, *a_nolabels, *a_batch,
+struct arg_lit * a_help, *a_version, *a_compatibility, *a_nolabels, *a_batch,
*a_accept, *a_reject, *a_full, *a_snippet, *a_random, *a_unique, *a_meta,
*a_notransclude, *a_nosmart, *a_opml, *a_itmz;
-struct arg_str *a_format, *a_lang, *a_extract;
-struct arg_file *a_file, *a_o;
-struct arg_end *a_end;
-struct arg_rem *a_rem1, *a_rem2, *a_rem3, *a_rem4, *a_rem5, *a_rem6;
+struct arg_str * a_format, *a_lang, *a_extract;
+struct arg_file * a_file, *a_o;
+struct arg_end * a_end;
+struct arg_rem * a_rem1, *a_rem2, *a_rem3, *a_rem4, *a_rem5, *a_rem6;
/// strdup() not available on all platforms
}
-int main(int argc, char** argv) {
+int main(int argc, char ** argv) {
int exitcode = EXIT_SUCCESS;
char * binname = "multimarkdown";
short format = FORMAT_HTML;
short language = LC_EN;
// Initialize argtable structs
- void *argtable[] = {
+ void * argtable[] = {
a_help = arg_lit0(NULL, "help", "display this help and exit"),
a_version = arg_lit0(NULL, "version", "display version info and exit"),