version 1.48, 2011/04/19 16:38:48 |
version 1.51, 2011/05/14 17:54:42 |
|
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <errno.h> |
|
#include <limits.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
Line 603 mandoc_eos(const char *p, size_t sz, int enclosed) |
|
Line 605 mandoc_eos(const char *p, size_t sz, int enclosed) |
|
/* |
/* |
* End-of-sentence recognition must include situations where |
* End-of-sentence recognition must include situations where |
* some symbols, such as `)', allow prior EOS punctuation to |
* some symbols, such as `)', allow prior EOS punctuation to |
* propogate outward. |
* propagate outward. |
*/ |
*/ |
|
|
found = 0; |
found = 0; |
Line 686 mandoc_getcontrol(const char *cp, int *ppos) |
|
Line 688 mandoc_getcontrol(const char *cp, int *ppos) |
|
*ppos = pos; |
*ppos = pos; |
return(1); |
return(1); |
} |
} |
|
|
|
/* |
|
* Convert a string to a long that may not be <0. |
|
* If the string is invalid, or is less than 0, return -1. |
|
*/ |
|
int |
|
mandoc_strntou(const char *p, size_t sz, int base) |
|
{ |
|
char buf[32]; |
|
char *ep; |
|
long v; |
|
|
|
if (sz > 31) |
|
return(-1); |
|
|
|
memcpy(buf, p, sz); |
|
buf[(int)sz] = '\0'; |
|
|
|
errno = 0; |
|
v = strtol(buf, &ep, base); |
|
|
|
if (buf[0] == '\0' || *ep != '\0') |
|
return(-1); |
|
|
|
if ((errno == ERANGE && |
|
(v == LONG_MAX || v == LONG_MIN)) || |
|
(v > INT_MAX || v < 0)) |
|
return(-1); |
|
|
|
return((int)v); |
|
} |
|
|