Also handle hyphen replacement if it was used as plain input and no

backslash sequence was used at all in the line.
This commit is contained in:
joerg 2012-02-15 23:36:10 +00:00
parent 79cdc1651d
commit c701d37453
1 changed files with 17 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: makemandb.c,v 1.3 2012/02/15 23:35:00 joerg Exp $ */ /* $NetBSD: makemandb.c,v 1.4 2012/02/15 23:36:10 joerg Exp $ */
/* /*
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com> * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@ -17,7 +17,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__RCSID("$NetBSD: makemandb.c,v 1.3 2012/02/15 23:35:00 joerg Exp $"); __RCSID("$NetBSD: makemandb.c,v 1.4 2012/02/15 23:36:10 joerg Exp $");
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
@ -1846,6 +1846,14 @@ free_secbuffs(mandb_rec *rec)
free(rec->errors.data); free(rec->errors.data);
} }
static void
replace_hyph(char *str)
{
char *iter = str;
while ((iter = strchr(iter, ASCII_HYPH)) != NULL)
*iter = '-';
}
static char * static char *
parse_escape(const char *str) parse_escape(const char *str)
{ {
@ -1857,8 +1865,11 @@ parse_escape(const char *str)
last_backslash = str; last_backslash = str;
backslash = strchr(str, '\\'); backslash = strchr(str, '\\');
if (backslash == NULL) if (backslash == NULL) {
return estrdup(str); result = estrdup(str);
replace_hyph(result);
return result;
}
result = emalloc(strlen(str) + 1); result = emalloc(strlen(str) + 1);
iter = result; iter = result;
@ -1882,9 +1893,8 @@ parse_escape(const char *str)
} while (backslash != NULL); } while (backslash != NULL);
if (last_backslash != NULL) if (last_backslash != NULL)
strcpy(iter, last_backslash); strcpy(iter, last_backslash);
iter = result;
while ((iter = strchr(iter, ASCII_HYPH)) != NULL) replace_hyph(result);
*iter = '-';
return result; return result;
} }