From 1f1fa3776c03b51f845d9d9f54cbc3c980f6ead6 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Thu, 21 Jul 2011 23:30:39 +0000 Subject: Complete eqn.7 parsing. Features all productions from the original 1975 CACM paper in an LR(1) parse (1 -> eqn_rewind()). Right now the code is a little jungly, but will clear up as I consolidate parse components. The AST structure will also be cleaned up, as right now it's pretty ad hoc (this won't change the parse itself). I added the mandoc_strndup() function will here. --- mandoc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'mandoc.c') diff --git a/mandoc.c b/mandoc.c index 891b9511..299b64f9 100644 --- a/mandoc.c +++ b/mandoc.c @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.54 2011/07/21 15:21:13 kristaps Exp $ */ +/* $Id: mandoc.c,v 1.55 2011/07/21 23:30:39 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2011 Ingo Schwarze @@ -432,6 +432,16 @@ mandoc_realloc(void *ptr, size_t size) return(ptr); } +char * +mandoc_strndup(const char *ptr, size_t sz) +{ + char *p; + + p = mandoc_malloc(sz + 1); + memcpy(p, ptr, sz); + p[(int)sz] = '\0'; + return(p); +} char * mandoc_strdup(const char *ptr) -- cgit v1.2.3