version 1.9, 2009/07/04 09:01:55 |
version 1.13, 2009/11/02 06:22:46 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
|
#include <time.h> |
|
|
#include "libmdoc.h" |
#include "libmdoc.h" |
|
|
Line 30 struct mdoc_secname { |
|
Line 31 struct mdoc_secname { |
|
enum mdoc_sec sec; /* Corresponding section. */ |
enum mdoc_sec sec; /* Corresponding section. */ |
}; |
}; |
|
|
#define SECNAME_MAX (18) |
#define SECNAME_MAX (20) |
|
|
static const struct mdoc_secname secnames[SECNAME_MAX] = { |
static const struct mdoc_secname secnames[SECNAME_MAX] = { |
{ "NAME", SEC_NAME }, |
{ "NAME", SEC_NAME }, |
Line 38 static const struct mdoc_secname secnames[SECNAME_MAX] |
|
Line 39 static const struct mdoc_secname secnames[SECNAME_MAX] |
|
{ "SYNOPSIS", SEC_SYNOPSIS }, |
{ "SYNOPSIS", SEC_SYNOPSIS }, |
{ "DESCRIPTION", SEC_DESCRIPTION }, |
{ "DESCRIPTION", SEC_DESCRIPTION }, |
{ "IMPLEMENTATION NOTES", SEC_IMPLEMENTATION }, |
{ "IMPLEMENTATION NOTES", SEC_IMPLEMENTATION }, |
|
{ "EXIT STATUS", SEC_EXIT_STATUS }, |
{ "RETURN VALUES", SEC_RETURN_VALUES }, |
{ "RETURN VALUES", SEC_RETURN_VALUES }, |
{ "ENVIRONMENT", SEC_ENVIRONMENT }, |
{ "ENVIRONMENT", SEC_ENVIRONMENT }, |
{ "FILES", SEC_FILES }, |
{ "FILES", SEC_FILES }, |
Line 51 static const struct mdoc_secname secnames[SECNAME_MAX] |
|
Line 53 static const struct mdoc_secname secnames[SECNAME_MAX] |
|
{ "AUTHORS", SEC_AUTHORS }, |
{ "AUTHORS", SEC_AUTHORS }, |
{ "CAVEATS", SEC_CAVEATS }, |
{ "CAVEATS", SEC_CAVEATS }, |
{ "BUGS", SEC_BUGS }, |
{ "BUGS", SEC_BUGS }, |
|
{ "SECURITY CONSIDERATIONS", SEC_SECURITY } |
}; |
}; |
|
|
#ifdef __linux__ |
|
extern char *strptime(const char *, const char *, struct tm *); |
|
#endif |
|
|
|
|
|
int |
int |
mdoc_iscdelim(char p) |
mdoc_iscdelim(char p) |
{ |
{ |
Line 119 mdoc_atosec(const char *p) |
|
Line 118 mdoc_atosec(const char *p) |
|
return(secnames[i].sec); |
return(secnames[i].sec); |
|
|
return(SEC_CUSTOM); |
return(SEC_CUSTOM); |
} |
|
|
|
|
|
time_t |
|
mdoc_atotime(const char *p) |
|
{ |
|
struct tm tm; |
|
char *pp; |
|
|
|
bzero(&tm, sizeof(struct tm)); |
|
|
|
if (0 == strcmp(p, "$" "Mdocdate$")) |
|
return(time(NULL)); |
|
if ((pp = strptime(p, "$" "Mdocdate: %b %d %Y $", &tm)) && 0 == *pp) |
|
return(mktime(&tm)); |
|
/* XXX - this matches "June 1999", which is wrong. */ |
|
if ((pp = strptime(p, "%b %d %Y", &tm)) && 0 == *pp) |
|
return(mktime(&tm)); |
|
if ((pp = strptime(p, "%b %d, %Y", &tm)) && 0 == *pp) |
|
return(mktime(&tm)); |
|
|
|
return(0); |
|
} |
} |
|
|
|
|