version 1.32.2.2, 2013/10/05 20:30:05 |
version 1.32.2.4, 2014/01/22 21:02:54 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2011, 2014 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
#if defined(__linux__) |
#if defined(__APPLE__) |
# include <endian.h> |
|
# include <db_185.h> |
|
#elif defined(__APPLE__) |
|
# include <libkern/OSByteOrder.h> |
# include <libkern/OSByteOrder.h> |
# include <db.h> |
#elif defined(__linux__) |
|
# include <endian.h> |
|
#elif defined(__sun) |
|
# include <sys/byteorder.h> |
#else |
#else |
# include <sys/endian.h> |
# include <sys/endian.h> |
|
#endif |
|
|
|
#if defined(__linux__) || defined(__sun) |
|
# include <db_185.h> |
|
#else |
# include <db.h> |
# include <db.h> |
#endif |
#endif |
|
|
Line 254 norm_string(const char *val, const struct mchars *mc, |
|
Line 259 norm_string(const char *val, const struct mchars *mc, |
|
const char *seq, *cpp; |
const char *seq, *cpp; |
int len, u, pos; |
int len, u, pos; |
enum mandoc_esc esc; |
enum mandoc_esc esc; |
static const char res[] = { '\\', '\t', |
static const char res[] = { '\\', '\t', ASCII_NBRSP, |
ASCII_NBRSP, ASCII_HYPH, '\0' }; |
ASCII_HYPH, ASCII_BREAK, '\0' }; |
|
|
/* Pre-allocate by the length of the input */ |
/* Pre-allocate by the length of the input */ |
|
|
Line 275 norm_string(const char *val, const struct mchars *mc, |
|
Line 280 norm_string(const char *val, const struct mchars *mc, |
|
val += (int)sz; |
val += (int)sz; |
} |
} |
|
|
if (ASCII_HYPH == *val) { |
switch (*val) { |
|
case (ASCII_HYPH): |
(*buf)[pos++] = '-'; |
(*buf)[pos++] = '-'; |
val++; |
val++; |
continue; |
continue; |
} else if ('\t' == *val || ASCII_NBRSP == *val) { |
case ('\t'): |
|
/* FALLTHROUGH */ |
|
case (ASCII_NBRSP): |
(*buf)[pos++] = ' '; |
(*buf)[pos++] = ' '; |
val++; |
val++; |
|
/* FALLTHROUGH */ |
|
case (ASCII_BREAK): |
continue; |
continue; |
} else if ('\\' != *val) |
default: |
|
break; |
|
} |
|
if ('\\' != *val) |
break; |
break; |
|
|
/* Read past the slash. */ |
/* Read past the slash. */ |