From 6a81c8460007e1d52bf6aab06460b9ce75c1ae4b Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 23 Mar 2014 11:25:25 +0000 Subject: The files mandoc.c and mandoc.h contained both specialised low-level functions used for multiple languages (mdoc, man, roff), for example mandoc_escape(), mandoc_getarg(), mandoc_eos(), and generic auxiliary functions. Split the auxiliaries out into their own file and header. While here, do some #include cleanup. --- mandoc.c | 71 ++-------------------------------------------------------------- 1 file changed, 2 insertions(+), 69 deletions(-) (limited to 'mandoc.c') diff --git a/mandoc.c b/mandoc.c index b3928ae4..2df01659 100644 --- a/mandoc.c +++ b/mandoc.c @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.75 2013/12/31 23:23:10 schwarze Exp $ */ +/* $Id: mandoc.c,v 1.76 2014/03/23 11:25:26 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013 Ingo Schwarze @@ -31,6 +31,7 @@ #include #include "mandoc.h" +#include "mandoc_aux.h" #include "libmandoc.h" #define DATESIZE 32 @@ -353,74 +354,6 @@ mandoc_escape(const char **end, const char **start, int *sz) return(gly); } -void * -mandoc_calloc(size_t num, size_t size) -{ - void *ptr; - - ptr = calloc(num, size); - if (NULL == ptr) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } - - return(ptr); -} - - -void * -mandoc_malloc(size_t size) -{ - void *ptr; - - ptr = malloc(size); - if (NULL == ptr) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } - - return(ptr); -} - - -void * -mandoc_realloc(void *ptr, size_t size) -{ - - ptr = realloc(ptr, size); - if (NULL == ptr) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } - - 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) -{ - char *p; - - p = strdup(ptr); - if (NULL == p) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } - - return(p); -} - /* * Parse a quoted or unquoted roff-style request or macro argument. * Return a pointer to the parsed argument, which is either the original -- cgit v1.2.3-56-ge451