From f0046239049623a3d7e442ee672ae6bb28674e76 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Wed, 7 Jan 2009 15:57:14 +0000 Subject: Added line numbering. --- macro.c | 12 ++++++------ mdoc.c | 7 ++++--- private.h | 11 ++++++----- prologue.c | 6 +++--- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/macro.c b/macro.c index c419874f..027a4b88 100644 --- a/macro.c +++ b/macro.c @@ -314,7 +314,7 @@ macro_close_explicit(MACRO_PROT_ARGS) return(0); flushed = 1; } - if ( ! mdoc_macro(mdoc, c, lastarg, pos, buf)) + if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf)) return(0); break; } @@ -405,7 +405,7 @@ macro_text(MACRO_PROT_ARGS) return(0); } mdoc_argv_free(argc, argv); - if ( ! mdoc_macro(mdoc, c, lastarg, pos, buf)) + if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf)) return(0); if (ppos > 1) return(1); @@ -504,7 +504,7 @@ macro_scoped(MACRO_PROT_ARGS) continue; } - if ( ! mdoc_macro(mdoc, c, lastarg, pos, buf)) + if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf)) return(0); break; } @@ -565,7 +565,7 @@ macro_scoped_line(MACRO_PROT_ARGS) continue; } - if ( ! mdoc_macro(mdoc, c, lastarg, pos, buf)) + if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf)) return(0); break; } @@ -645,7 +645,7 @@ macro_constant_scoped(MACRO_PROT_ARGS) mdoc_body_alloc(mdoc, ppos, tok); mdoc->next = MDOC_NEXT_CHILD; } - if ( ! mdoc_macro(mdoc, c, lastarg, pos, buf)) + if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf)) return(0); break; } @@ -751,7 +751,7 @@ macro_constant_delimited(MACRO_PROT_ARGS) if ( ! flushed && ! rewind_elem(mdoc, ppos, tok)) return(0); flushed = 1; - if ( ! mdoc_macro(mdoc, c, lastarg, pos, buf)) + if ( ! mdoc_macro(mdoc, c, line, lastarg, pos, buf)) return(0); break; } diff --git a/mdoc.c b/mdoc.c index 02a967c5..1ac6d6f3 100644 --- a/mdoc.c +++ b/mdoc.c @@ -312,7 +312,7 @@ mdoc_parseln(struct mdoc *mdoc, int line, char *buf) while (buf[i] && isspace(buf[i])) i++; - if ( ! mdoc_macro(mdoc, c, 1, &i, buf)) { + if ( ! mdoc_macro(mdoc, c, line, 1, &i, buf)) { mdoc->flags |= MDOC_HALT; return(0); } @@ -358,7 +358,8 @@ mdoc_warn(struct mdoc *mdoc, int tok, int pos, enum mdoc_warn type) int -mdoc_macro(struct mdoc *mdoc, int tok, int ppos, int *pos, char *buf) +mdoc_macro(struct mdoc *mdoc, int tok, + int line, int ppos, int *pos, char *buf) { if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) && @@ -375,7 +376,7 @@ mdoc_macro(struct mdoc *mdoc, int tok, int ppos, int *pos, char *buf) return(0); } - return((*mdoc_macros[tok].fp)(mdoc, tok, ppos, pos, buf)); + return((*mdoc_macros[tok].fp)(mdoc, tok, line, ppos, pos, buf)); } diff --git a/private.h b/private.h index 2eaa0d7b..81c3e3ab 100644 --- a/private.h +++ b/private.h @@ -40,8 +40,12 @@ struct mdoc { enum mdoc_sec sec_last; }; + +#define MACRO_PROT_ARGS struct mdoc *mdoc, int tok, int line, \ + int ppos, int *pos, char *buf + struct mdoc_macro { - int (*fp)(struct mdoc *, int, int, int *, char *); + int (*fp)(MACRO_PROT_ARGS); int flags; #define MDOC_CALLABLE (1 << 0) #define MDOC_PARSED (1 << 1) @@ -53,15 +57,12 @@ struct mdoc_macro { extern const struct mdoc_macro *const mdoc_macros; -#define MACRO_PROT_ARGS struct mdoc *mdoc, int tok, \ - int ppos, int *pos, char *buf - __BEGIN_DECLS int mdoc_err(struct mdoc *, int, int, enum mdoc_err); int mdoc_warn(struct mdoc *, int, int, enum mdoc_warn); void mdoc_msg(struct mdoc *, int, const char *, ...); -int mdoc_macro(struct mdoc *, int, int, int *, char *); +int mdoc_macro(MACRO_PROT_ARGS); int mdoc_find(const struct mdoc *, const char *); void mdoc_word_alloc(struct mdoc *, int, const char *); void mdoc_elem_alloc(struct mdoc *, int, int, diff --git a/prologue.c b/prologue.c index f3d9b109..fe03d11e 100644 --- a/prologue.c +++ b/prologue.c @@ -203,11 +203,11 @@ macro_prologue(MACRO_PROT_ARGS) switch (tok) { case (MDOC_Dt): - return(prologue_dt(mdoc, tok, ppos, pos, buf)); + return(prologue_dt(mdoc, tok, line, ppos, pos, buf)); case (MDOC_Dd): - return(prologue_dd(mdoc, tok, ppos, pos, buf)); + return(prologue_dd(mdoc, tok, line, ppos, pos, buf)); case (MDOC_Os): - return(prologue_os(mdoc, tok, ppos, pos, buf)); + return(prologue_os(mdoc, tok, line, ppos, pos, buf)); default: break; } -- cgit