Print this page
Address Robert's feedback
*** 10,32 ****
*/
/*
* Copyright 2017 Jason King.
*/
!
#include <errno.h>
#include <string.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/isa_defs.h>
#include <sys/debug.h>
#include "sysdemangle.h"
#include "sysdemangle_int.h"
! #include "cpp.h"
#define ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))
#define CPP_QUAL_CONST (1U)
#define CPP_QUAL_VOLATILE (2U)
#define CPP_QUAL_RESTRICT (4U)
--- 10,35 ----
*/
/*
* Copyright 2017 Jason King.
*/
! #include <ctype.h>
#include <errno.h>
+ #include <locale.h>
#include <string.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/isa_defs.h>
#include <sys/debug.h>
#include "sysdemangle.h"
#include "sysdemangle_int.h"
! #include "cxx.h"
+ #ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))
+ #endif
#define CPP_QUAL_CONST (1U)
#define CPP_QUAL_VOLATILE (2U)
#define CPP_QUAL_RESTRICT (4U)
*** 41,50 ****
--- 44,54 ----
unsigned cpp_depth;
boolean_t cpp_parsed_ctor_dtor_cv;
boolean_t cpp_tag_templates;
boolean_t cpp_fix_forward_references;
boolean_t cpp_try_to_parse_template_args;
+ locale_t cpp_loc;
} cpp_db_t;
#define CK(x) \
do { \
if (!(x)) \
*** 53,64 ****
#define TOP_L(db) (&(name_top(&(db)->cpp_name)->strp_l))
#define RLEN(f, l) ((size_t)((l) - (f)))
#define NAMT(db, n) (nlen(db) - n)
- static inline boolean_t is_digit(int);
- static inline boolean_t is_upper(int);
static inline boolean_t is_xdigit(int);
static boolean_t nempty(cpp_db_t *);
static size_t nlen(cpp_db_t *);
static void nadd_l(cpp_db_t *, const char *, size_t);
--- 57,66 ----
*** 74,84 ****
static void tsub(cpp_db_t *, size_t);
static void tpush(cpp_db_t *);
static void tpop(cpp_db_t *);
static void tsave(cpp_db_t *, size_t);
! static void db_init(cpp_db_t *, sysdem_ops_t *);
static void db_fini(cpp_db_t *);
static void dump(cpp_db_t *, FILE *);
static void demangle(const char *, const char *, cpp_db_t *);
--- 76,86 ----
static void tsub(cpp_db_t *, size_t);
static void tpush(cpp_db_t *);
static void tpop(cpp_db_t *);
static void tsave(cpp_db_t *, size_t);
! static boolean_t db_init(cpp_db_t *, sysdem_ops_t *);
static void db_fini(cpp_db_t *);
static void dump(cpp_db_t *, FILE *);
static void demangle(const char *, const char *, cpp_db_t *);
*** 89,108 ****
static const char *parse_dot_suffix(const char *, const char *, cpp_db_t *);
static const char *parse_block_invoke(const char *, const char *, cpp_db_t *);
static const char *parse_special_name(const char *, const char *, cpp_db_t *);
static const char *parse_name(const char *, const char *, boolean_t *,
cpp_db_t *);
! static const char *parse_call_offset(const char *, const char *);
! static const char *parse_number(const char *, const char *);
static const char *parse_nested_name(const char *, const char *, boolean_t *,
cpp_db_t *);
static const char *parse_local_name(const char *, const char *, boolean_t *,
cpp_db_t *);
static const char *parse_unscoped_name(const char *, const char *, cpp_db_t *);
static const char *parse_template_args(const char *, const char *, cpp_db_t *);
static const char *parse_substitution(const char *, const char *, cpp_db_t *);
! static const char *parse_discriminator(const char *, const char *);
static const char *parse_cv_qualifiers(const char *, const char *, unsigned *);
static const char *parse_template_param(const char *, const char *, cpp_db_t *);
static const char *parse_decltype(const char *, const char *, cpp_db_t *);
static const char *parse_template_args(const char *, const char *, cpp_db_t *);
static const char *parse_unqualified_name(const char *, const char *,
--- 91,110 ----
static const char *parse_dot_suffix(const char *, const char *, cpp_db_t *);
static const char *parse_block_invoke(const char *, const char *, cpp_db_t *);
static const char *parse_special_name(const char *, const char *, cpp_db_t *);
static const char *parse_name(const char *, const char *, boolean_t *,
cpp_db_t *);
! static const char *parse_call_offset(const char *, const char *, locale_t);
! static const char *parse_number(const char *, const char *, locale_t);
static const char *parse_nested_name(const char *, const char *, boolean_t *,
cpp_db_t *);
static const char *parse_local_name(const char *, const char *, boolean_t *,
cpp_db_t *);
static const char *parse_unscoped_name(const char *, const char *, cpp_db_t *);
static const char *parse_template_args(const char *, const char *, cpp_db_t *);
static const char *parse_substitution(const char *, const char *, cpp_db_t *);
! static const char *parse_discriminator(const char *, const char *, locale_t);
static const char *parse_cv_qualifiers(const char *, const char *, unsigned *);
static const char *parse_template_param(const char *, const char *, cpp_db_t *);
static const char *parse_decltype(const char *, const char *, cpp_db_t *);
static const char *parse_template_args(const char *, const char *, cpp_db_t *);
static const char *parse_unqualified_name(const char *, const char *,
*** 164,175 ****
{
char *result = NULL;
cpp_db_t db;
size_t srclen = strlen(src);
! db_init(&db, ops);
!
if (setjmp(db.cpp_jmp) != 0)
goto done;
errno = 0;
demangle(src, src + srclen, &db);
--- 166,177 ----
{
char *result = NULL;
cpp_db_t db;
size_t srclen = strlen(src);
! if (!db_init(&db, ops))
! goto done;
if (setjmp(db.cpp_jmp) != 0)
goto done;
errno = 0;
demangle(src, src + srclen, &db);
*** 269,279 ****
}
static const char *
parse_dot_suffix(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (first == last || first[0] != '.')
return (first);
if (nempty(db))
--- 271,281 ----
}
static const char *
parse_dot_suffix(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (first == last || first[0] != '.')
return (first);
if (nempty(db))
*** 291,301 ****
* _block_invoke_<digit>+
*/
static const char *
parse_block_invoke(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 13)
return (first);
const char test[] = "_block_invoke";
--- 293,303 ----
* _block_invoke_<digit>+
*/
static const char *
parse_block_invoke(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 13)
return (first);
const char test[] = "_block_invoke";
*** 308,323 ****
if (t == last)
goto done;
if (t[0] == '_') {
/* need at least one digit */
! if (t + 1 == last || !is_digit(t[1]))
return (first);
t += 2;
}
! while (t < last && is_digit(t[0]))
t++;
done:
if (nempty(db))
return (first);
--- 310,325 ----
if (t == last)
goto done;
if (t[0] == '_') {
/* need at least one digit */
! if (t + 1 == last || !isdigit_l(t[1], db->cpp_loc))
return (first);
t += 2;
}
! while (t < last && isdigit_l(t[0], db->cpp_loc))
t++;
done:
if (nempty(db))
return (first);
*** 332,342 ****
* ::= <special name>
*/
static const char *
parse_encoding(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (first == last)
return (first);
const char *t = NULL;
--- 334,344 ----
* ::= <special name>
*/
static const char *
parse_encoding(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (first == last)
return (first);
const char *t = NULL;
*** 405,415 ****
* a bit of a hack, but a template substitution can apparently be
* an empty string at the end of an argument list, so avoid
* <...., >
*/
if (NAMT(db, n) > 1 && str_pair_len(name_top(&db->cpp_name)) == 0)
! (void) name_pop(&db->cpp_name, NULL);
njoin(db, NAMT(db, n), ", ");
nfmt(db, "({0})", NULL);
str_t *s = TOP_L(db);
--- 407,417 ----
* a bit of a hack, but a template substitution can apparently be
* an empty string at the end of an argument list, so avoid
* <...., >
*/
if (NAMT(db, n) > 1 && str_pair_len(name_top(&db->cpp_name)) == 0)
! name_pop(&db->cpp_name, NULL);
njoin(db, NAMT(db, n), ", ");
nfmt(db, "({0})", NULL);
str_t *s = TOP_L(db);
*** 463,473 ****
* extension ::= GR <object name> # reference temporary for object
*/
static const char *
parse_special_name(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
const char *t = first;
const char *t1 = NULL;
size_t n = nlen(db);
--- 465,475 ----
* extension ::= GR <object name> # reference temporary for object
*/
static const char *
parse_special_name(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
const char *t = first;
const char *t1 = NULL;
size_t n = nlen(db);
*** 493,506 ****
nadd_l(db, "typeinfo name for", 0);
t = parse_type(first + 2, last, db);
break;
case 'c':
nadd_l(db, "covariant return thunk to", 0);
! t1 = parse_call_offset(first + 2, last);
if (t1 == t)
return (first);
! t = parse_call_offset(t1, last);
if (t == t1)
return (first);
t1 = parse_encoding(t, last, db);
if (t1 == t)
return (first);
--- 495,508 ----
nadd_l(db, "typeinfo name for", 0);
t = parse_type(first + 2, last, db);
break;
case 'c':
nadd_l(db, "covariant return thunk to", 0);
! t1 = parse_call_offset(first + 2, last, db->cpp_loc);
if (t1 == t)
return (first);
! t = parse_call_offset(t1, last, db->cpp_loc);
if (t == t1)
return (first);
t1 = parse_encoding(t, last, db);
if (t1 == t)
return (first);
*** 507,517 ****
break;
case 'C':
t = parse_type(first + 2, last, db);
if (t == first + 2)
return (first);
! t1 = parse_number(t, last);
if (*t1 != '_')
return (first);
t = parse_type(t1 + 1, last, db);
if (t == t1 + 1 || nlen(db) < 2)
return (first);
--- 509,519 ----
break;
case 'C':
t = parse_type(first + 2, last, db);
if (t == first + 2)
return (first);
! t1 = parse_number(t, last, db->cpp_loc);
if (*t1 != '_')
return (first);
t = parse_type(t1 + 1, last, db);
if (t == t1 + 1 || nlen(db) < 2)
return (first);
*** 531,541 ****
nadd_l(db, "virtual thunk to", 0);
} else {
nadd_l(db, "non-virtual thunk to", 0);
}
! t = parse_call_offset(first + 1, last);
if (t == first + 1)
return (first);
t1 = parse_encoding(t, last, db);
if (t == t1)
return (first);
--- 533,543 ----
nadd_l(db, "virtual thunk to", 0);
} else {
nadd_l(db, "non-virtual thunk to", 0);
}
! t = parse_call_offset(first + 1, last, db->cpp_loc);
if (t == first + 1)
return (first);
t1 = parse_encoding(t, last, db);
if (t == t1)
return (first);
*** 578,590 ****
*
* <v-offset> ::= <offset number> _ <virtual offset number>
* # virtual base override, with vcall offset
*/
static const char *
! parse_call_offset(const char *first, const char *last)
{
! ASSERT3P(first, <=, last);
const char *t = NULL;
const char *t1 = NULL;
if (first == last)
--- 580,592 ----
*
* <v-offset> ::= <offset number> _ <virtual offset number>
* # virtual base override, with vcall offset
*/
static const char *
! parse_call_offset(const char *first, const char *last, locale_t loc)
{
! VERIFY3P(first, <=, last);
const char *t = NULL;
const char *t1 = NULL;
if (first == last)
*** 591,611 ****
return (first);
if (first[0] != 'h' && first[0] != 'v')
return (first);
! t = parse_number(first + 1, last);
if (t == first + 1 || t == last || t[0] != '_')
return (first);
/* skip _ */
t++;
if (first[0] == 'h')
return (t);
! t1 = parse_number(t, last);
if (t == t1 || t1 == last || t1[0] != '_')
return (first);
/* skip _ */
t1++;
--- 593,613 ----
return (first);
if (first[0] != 'h' && first[0] != 'v')
return (first);
! t = parse_number(first + 1, last, loc);
if (t == first + 1 || t == last || t[0] != '_')
return (first);
/* skip _ */
t++;
if (first[0] == 'h')
return (t);
! t1 = parse_number(t, last, loc);
if (t == t1 || t1 == last || t1[0] != '_')
return (first);
/* skip _ */
t1++;
*** 624,634 ****
*/
static const char *
parse_name(const char *first, const char *last,
boolean_t *ends_with_template_args, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
const char *t = first;
const char *t1 = NULL;
if (last - first < 2)
--- 626,636 ----
*/
static const char *
parse_name(const char *first, const char *last,
boolean_t *ends_with_template_args, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
const char *t = first;
const char *t1 = NULL;
if (last - first < 2)
*** 687,697 ****
/* END CSTYLED */
const char *
parse_local_name(const char *first, const char *last,
boolean_t *ends_with_template_args, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
const char *t = NULL;
const char *t1 = NULL;
const char *t2 = NULL;
--- 689,699 ----
/* END CSTYLED */
const char *
parse_local_name(const char *first, const char *last,
boolean_t *ends_with_template_args, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
const char *t = NULL;
const char *t1 = NULL;
const char *t2 = NULL;
*** 700,721 ****
t = parse_encoding(first + 1, last, db);
if (t == first + 1 || t == last || t[0] != 'E')
return (first);
! ASSERT(!nempty(db));
/* skip E */
t++;
if (t[0] == 's') {
nfmt(db, "{0:L}::string literal", "{0:R}");
! return (parse_discriminator(t, last));
}
if (t[0] == 'd') {
! t1 = parse_number(t + 1, last);
if (t1[0] != '_')
return (first);
t1++;
} else {
t1 = t;
--- 702,723 ----
t = parse_encoding(first + 1, last, db);
if (t == first + 1 || t == last || t[0] != 'E')
return (first);
! VERIFY(!nempty(db));
/* skip E */
t++;
if (t[0] == 's') {
nfmt(db, "{0:L}::string literal", "{0:R}");
! return (parse_discriminator(t, last, db->cpp_loc));
}
if (t[0] == 'd') {
! t1 = parse_number(t + 1, last, db->cpp_loc);
if (t1[0] != '_')
return (first);
t1++;
} else {
t1 = t;
*** 727,737 ****
nfmt(db, "{1:L}::{0}", "{1:R}");
/* parsed, but ignored */
if (t[0] != 'd')
! t2 = parse_discriminator(t2, last);
return (t2);
}
/* BEGIN CSTYLED */
--- 729,739 ----
nfmt(db, "{1:L}::{0}", "{1:R}");
/* parsed, but ignored */
if (t[0] != 'd')
! t2 = parse_discriminator(t2, last, db->cpp_loc);
return (t2);
}
/* BEGIN CSTYLED */
*** 755,765 ****
/* END CSTYLED */
static const char *
parse_nested_name(const char *first, const char *last,
boolean_t *ends_with_template_args, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (first == last || first[0] != 'N')
return (first);
unsigned cv = 0;
--- 757,767 ----
/* END CSTYLED */
static const char *
parse_nested_name(const char *first, const char *last,
boolean_t *ends_with_template_args, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (first == last || first[0] != 'N')
return (first);
unsigned cv = 0;
*** 808,818 ****
return (first);
if (!more) {
nfmt(db, "{0}", NULL);
} else {
! ASSERT3U(nlen(db), >, 1);
nfmt(db, "{1:L}::{0}", "{1:R}");
save_top(db, 1);
}
more = B_TRUE;
--- 810,820 ----
return (first);
if (!more) {
nfmt(db, "{0}", NULL);
} else {
! VERIFY3U(nlen(db), >, 1);
nfmt(db, "{1:L}::{0}", "{1:R}");
save_top(db, 1);
}
more = B_TRUE;
*** 826,836 ****
return (first);
if (!more) {
nfmt(db, "{0}", NULL);
} else {
! ASSERT3U(nlen(db), >, 1);
nfmt(db, "{1:L}::{0}", "{1:R}");
}
save_top(db, 1);
more = B_TRUE;
--- 828,838 ----
return (first);
if (!more) {
nfmt(db, "{0}", NULL);
} else {
! VERIFY3U(nlen(db), >, 1);
nfmt(db, "{1:L}::{0}", "{1:R}");
}
save_top(db, 1);
more = B_TRUE;
*** 846,856 ****
return (first);
if (!more) {
nfmt(db, "{0}", NULL);
} else {
! ASSERT3U(nlen(db), >, 1);
nfmt(db, "{1:L}::{0}", "{1:R}");
}
save_top(db, 1);
more = B_TRUE;
--- 848,858 ----
return (first);
if (!more) {
nfmt(db, "{0}", NULL);
} else {
! VERIFY3U(nlen(db), >, 1);
nfmt(db, "{1:L}::{0}", "{1:R}");
}
save_top(db, 1);
more = B_TRUE;
*** 868,878 ****
t1 = parse_template_args(t, last, db);
if (t1 == t || t1 == last)
return (first);
! ASSERT3U(nlen(db), >, 1);
nfmt(db, "{1:L}{0}", "{1:R}");
save_top(db, 1);
t = t1;
component_ends_with_template_args = B_TRUE;
continue;
--- 870,880 ----
t1 = parse_template_args(t, last, db);
if (t1 == t || t1 == last)
return (first);
! VERIFY3U(nlen(db), >, 1);
nfmt(db, "{1:L}{0}", "{1:R}");
save_top(db, 1);
t = t1;
component_ends_with_template_args = B_TRUE;
continue;
*** 892,902 ****
return (first);
if (!more) {
nfmt(db, "{0}", NULL);
} else {
! ASSERT3U(nlen(db), >, 1);
nfmt(db, "{1:L}::{0}", "{1:R}");
}
save_top(db, 1);
more = B_TRUE;
--- 894,904 ----
return (first);
if (!more) {
nfmt(db, "{0}", NULL);
} else {
! VERIFY3U(nlen(db), >, 1);
nfmt(db, "{1:L}::{0}", "{1:R}");
}
save_top(db, 1);
more = B_TRUE;
*** 929,939 ****
* ::= LZ <encoding> E # extension
*/
static const char *
parse_template_arg(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
const char *t = NULL;
const char *t1 = NULL;
if (first == last)
--- 931,941 ----
* ::= LZ <encoding> E # extension
*/
static const char *
parse_template_arg(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
const char *t = NULL;
const char *t1 = NULL;
if (first == last)
*** 1129,1139 ****
#undef PN
static const char *
parse_expression(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
for (size_t i = 0; i < ARRAY_SIZE(expr_tbl); i++) {
--- 1131,1141 ----
#undef PN
static const char *
parse_expression(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
for (size_t i = 0; i < ARRAY_SIZE(expr_tbl); i++) {
*** 1173,1183 ****
static const char *
parse_binary_expr(const char *first, const char *last, const char *op,
cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
size_t n = nlen(db);
--- 1175,1185 ----
static const char *
parse_binary_expr(const char *first, const char *last, const char *op,
cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
size_t n = nlen(db);
*** 1193,1203 ****
return (first);
if (NAMT(db, n) != 3)
return (first);
! ASSERT3U(nlen(db), >, 2);
nfmt(db, "({2}) {1} ({0})", NULL);
if (strcmp(op, ">") == 0)
nfmt(db, "({0})", NULL);
--- 1195,1205 ----
return (first);
if (NAMT(db, n) != 3)
return (first);
! VERIFY3U(nlen(db), >, 2);
nfmt(db, "({2}) {1} ({0})", NULL);
if (strcmp(op, ">") == 0)
nfmt(db, "({0})", NULL);
*** 1206,1216 ****
static const char *
parse_prefix_expr(const char *first, const char *last, const char *op,
cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
nadd_l(db, op, 0);
--- 1208,1218 ----
static const char *
parse_prefix_expr(const char *first, const char *last, const char *op,
cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
nadd_l(db, op, 0);
*** 1218,1237 ****
const char *t = parse_expression(first + 2, last, db);
if (t == first + 2) {
return (first);
}
! ASSERT3U(nlen(db), >, 1);
nfmt(db, "{1}({0})", NULL);
return (t);
}
static const char *
parse_gs(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
const char *t = NULL;
if (last - first < 4)
return (first);
--- 1220,1239 ----
const char *t = parse_expression(first + 2, last, db);
if (t == first + 2) {
return (first);
}
! VERIFY3U(nlen(db), >, 1);
nfmt(db, "{1}({0})", NULL);
return (t);
}
static const char *
parse_gs(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
const char *t = NULL;
if (last - first < 4)
return (first);
*** 1244,1254 ****
return (first);
if (t == first + 2)
return (first);
! ASSERT3U(nlen(db), >, 0);
nfmt(db, "::{0}", NULL);
return (t);
}
--- 1246,1256 ----
return (first);
if (t == first + 2)
return (first);
! VERIFY3U(nlen(db), >, 0);
nfmt(db, "::{0}", NULL);
return (t);
}
*** 1260,1287 ****
* <initializer> ::= pi <expression>* E # parenthesized initialization
*/
static const char *
parse_new_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
/* note [gs] is already handled by parse_gs() */
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 'n');
! ASSERT(first[1] == 'a' || first[1] == 'w');
const char *t1 = first + 2;
const char *t2 = NULL;
size_t n = nlen(db);
nadd_l(db, (first[1] == 'w') ? "new" : "new[]", 0);
while (t1 != last && t1[0] != '_') {
t2 = parse_expression(t1, last, db);
! ASSERT3P(t2, !=, NULL);
if (t2 == t1)
return (first);
t1 = t2;
}
if (t1 == last)
--- 1262,1289 ----
* <initializer> ::= pi <expression>* E # parenthesized initialization
*/
static const char *
parse_new_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
/* note [gs] is already handled by parse_gs() */
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 'n');
! VERIFY(first[1] == 'a' || first[1] == 'w');
const char *t1 = first + 2;
const char *t2 = NULL;
size_t n = nlen(db);
nadd_l(db, (first[1] == 'w') ? "new" : "new[]", 0);
while (t1 != last && t1[0] != '_') {
t2 = parse_expression(t1, last, db);
! VERIFY3P(t2, !=, NULL);
if (t2 == t1)
return (first);
t1 = t2;
}
if (t1 == last)
*** 1327,1343 ****
}
static const char *
parse_del_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 'd');
! ASSERT(first[1] == 'l' || first[1] == 'a');
size_t n = nlen(db);
const char *t = parse_expression(first + 2, last, db);
if (t == first + 2 || NAMT(db, n) != 1)
return (first);
--- 1329,1345 ----
}
static const char *
parse_del_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 'd');
! VERIFY(first[1] == 'l' || first[1] == 'a');
size_t n = nlen(db);
const char *t = parse_expression(first + 2, last, db);
if (t == first + 2 || NAMT(db, n) != 1)
return (first);
*** 1347,1359 ****
}
static const char *
parse_idx_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
! ASSERT3U(first[0], ==, 'i');
! ASSERT3U(first[1], ==, 'x');
size_t n = nlen(db);
const char *t1 = parse_expression(first + 2, last, db);
if (t1 == first + 2)
return (first);
--- 1349,1361 ----
}
static const char *
parse_idx_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
! VERIFY3U(first[0], ==, 'i');
! VERIFY3U(first[1], ==, 'x');
size_t n = nlen(db);
const char *t1 = parse_expression(first + 2, last, db);
if (t1 == first + 2)
return (first);
*** 1368,1378 ****
static const char *
parse_ppmm_expr(const char *first, const char *last, const char *fmt,
cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
const char *t = NULL;
--- 1370,1380 ----
static const char *
parse_ppmm_expr(const char *first, const char *last, const char *fmt,
cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
const char *t = NULL;
*** 1394,1425 ****
}
static const char *
parse_mm_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
! ASSERT3U(first[0], ==, 'm');
! ASSERT3U(first[1], ==, 'm');
return (parse_ppmm_expr(first, last, "({0})--", db));
}
static const char *
parse_pp_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
! ASSERT3U(first[0], ==, 'p');
! ASSERT3U(first[0], ==, 'p');
return (parse_ppmm_expr(first, last, "({0})++", db));
}
static const char *
parse_trinary_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
const char *t1, *t2, *t3;
size_t n = nlen(db);
if (last - first < 2)
--- 1396,1427 ----
}
static const char *
parse_mm_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
! VERIFY3U(first[0], ==, 'm');
! VERIFY3U(first[1], ==, 'm');
return (parse_ppmm_expr(first, last, "({0})--", db));
}
static const char *
parse_pp_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
! VERIFY3U(first[0], ==, 'p');
! VERIFY3U(first[0], ==, 'p');
return (parse_ppmm_expr(first, last, "({0})++", db));
}
static const char *
parse_trinary_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
const char *t1, *t2, *t3;
size_t n = nlen(db);
if (last - first < 2)
*** 1443,1453 ****
}
static const char *
parse_noexcept_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
size_t n = nlen(db);
--- 1445,1455 ----
}
static const char *
parse_noexcept_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
size_t n = nlen(db);
*** 1466,1476 ****
* sc <type> <expression> # static_cast<type> (expression)
*/
static const char *
parse_cast_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
const char *fmt = NULL;
--- 1468,1478 ----
* sc <type> <expression> # static_cast<type> (expression)
*/
static const char *
parse_cast_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
const char *fmt = NULL;
*** 1489,1519 ****
break;
default:
return (first);
}
! ASSERT3U(first[1], ==, 'c');
const char *t1 = parse_type(first + 2, last, db);
if (t1 == first + 2)
return (first);
const char *t2 = parse_expression(t1, last, db);
if (t2 == t1)
return (first);
! ASSERT3U(nlen(db), >, 1);
nfmt(db, fmt, NULL);
return (t2);
}
/* pt <expression> <expression> # expr->name */
static const char *
parse_arrow_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 4)
return (first);
size_t n = nlen(db);
--- 1491,1521 ----
break;
default:
return (first);
}
! VERIFY3U(first[1], ==, 'c');
const char *t1 = parse_type(first + 2, last, db);
if (t1 == first + 2)
return (first);
const char *t2 = parse_expression(t1, last, db);
if (t2 == t1)
return (first);
! VERIFY3U(nlen(db), >, 1);
nfmt(db, fmt, NULL);
return (t2);
}
/* pt <expression> <expression> # expr->name */
static const char *
parse_arrow_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 4)
return (first);
size_t n = nlen(db);
*** 1574,1584 ****
*/
/* END CSTYLED */
static const char *
parse_type(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (first == last)
return (first);
switch (first[0]) {
--- 1576,1586 ----
*/
/* END CSTYLED */
static const char *
parse_type(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (first == last)
return (first);
switch (first[0]) {
*** 1741,1754 ****
if (t != name->str_s + 9) {
nfmt(db, "{1}<{0}>", NULL);
str_pair_t save = {0};
! (void) name_pop(&db->cpp_name, &save);
/* get rid of 'objcproto' */
! (void) name_pop(&db->cpp_name, NULL);
CK(name_add_str(&db->cpp_name, &save.strp_l,
&save.strp_r));
} else {
nfmt(db, "{1} {0}", NULL);
}
--- 1743,1756 ----
if (t != name->str_s + 9) {
nfmt(db, "{1}<{0}>", NULL);
str_pair_t save = {0};
! name_pop(&db->cpp_name, &save);
/* get rid of 'objcproto' */
! name_pop(&db->cpp_name, NULL);
CK(name_add_str(&db->cpp_name, &save.strp_l,
&save.strp_r));
} else {
nfmt(db, "{1} {0}", NULL);
}
*** 1839,1849 ****
}
static const char *
parse_qual_type(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
const char *t = NULL;
const char *t1 = NULL;
unsigned cv = 0;
--- 1841,1851 ----
}
static const char *
parse_qual_type(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
const char *t = NULL;
const char *t1 = NULL;
unsigned cv = 0;
*** 1914,1924 ****
* az <expression> # alignof (a expression)
*/
static const char *
parse_alignof(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
const char *(*fn)(const char *, const char *, cpp_db_t *);
--- 1916,1926 ----
* az <expression> # alignof (a expression)
*/
static const char *
parse_alignof(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
const char *(*fn)(const char *, const char *, cpp_db_t *);
*** 1939,1954 ****
* sz <expr> # sizeof (a expression)
*/
static const char *
parse_sizeof(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
! ASSERT3U(first[0], ==, 's');
const char *t = NULL;
size_t n = nlen(db);
switch (first[1]) {
--- 1941,1956 ----
* sz <expr> # sizeof (a expression)
*/
static const char *
parse_sizeof(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
! VERIFY3U(first[0], ==, 's');
const char *t = NULL;
size_t n = nlen(db);
switch (first[1]) {
*** 1977,2007 ****
*/
/* END CSTYLED */
static const char *
parse_function_param(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3 || first[0] != 'f')
return (first);
const char *t1 = first + 2;
const char *t2 = NULL;
unsigned cv = 0;
if (first[1] == 'L') {
! t2 = parse_number(t1, last);
if (t2 == last || t2[0] != 'p')
return (first);
t1 = t2;
}
if (first[1] != 'p')
return (first);
t1 = parse_cv_qualifiers(t1, last, &cv);
! t2 = parse_number(t1, last);
if (t2 == last || t2[0] != '_')
return (first);
if (t2 - t1 > 0)
nadd_l(db, t1, (size_t)(t2 - t1));
--- 1979,2009 ----
*/
/* END CSTYLED */
static const char *
parse_function_param(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3 || first[0] != 'f')
return (first);
const char *t1 = first + 2;
const char *t2 = NULL;
unsigned cv = 0;
if (first[1] == 'L') {
! t2 = parse_number(t1, last, db->cpp_loc);
if (t2 == last || t2[0] != 'p')
return (first);
t1 = t2;
}
if (first[1] != 'p')
return (first);
t1 = parse_cv_qualifiers(t1, last, &cv);
! t2 = parse_number(t1, last, db->cpp_loc);
if (t2 == last || t2[0] != '_')
return (first);
if (t2 - t1 > 0)
nadd_l(db, t1, (size_t)(t2 - t1));
*** 2017,2033 ****
* sZ <function-param> # size of a function parameter pack
*/
static const char *
parse_sizeof_param_pack_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 's');
! ASSERT3U(first[1], ==, 'Z');
if (first[2] != 'T' && first[2] != 'f')
return (first);
const char *t = NULL;
--- 2019,2035 ----
* sZ <function-param> # size of a function parameter pack
*/
static const char *
parse_sizeof_param_pack_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 's');
! VERIFY3U(first[1], ==, 'Z');
if (first[2] != 'T' && first[2] != 'f')
return (first);
const char *t = NULL;
*** 2051,2067 ****
* ti <type> # typeid (type)
*/
static const char *
parse_typeid_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 't');
! ASSERT(first[1] == 'e' || first[1] == 'i');
const char *t = NULL;
size_t n = nlen(db);
if (first[1] == 'e')
--- 2053,2069 ----
* ti <type> # typeid (type)
*/
static const char *
parse_typeid_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 't');
! VERIFY(first[1] == 'e' || first[1] == 'i');
const char *t = NULL;
size_t n = nlen(db);
if (first[1] == 'e')
*** 2081,2097 ****
* tw <expression> # throw expression
*/
static const char *
parse_throw_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 't');
! ASSERT(first[1] == 'w' || first[1] == 'r');
if (first[1] == 'r') {
nadd_l(db, "throw", 0);
return (first + 2);
}
--- 2083,2099 ----
* tw <expression> # throw expression
*/
static const char *
parse_throw_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 't');
! VERIFY(first[1] == 'w' || first[1] == 'r');
if (first[1] == 'r') {
nadd_l(db, "throw", 0);
return (first + 2);
}
*** 2107,2123 ****
/* ds <expression> <expression> # expr.*expr */
static const char *
parse_dot_star_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 'd');
! ASSERT3U(first[1], ==, 's');
size_t n = nlen(db);
const char *t = parse_expression(first + 2, last, db);
if (t == first + 2)
return (first);
--- 2109,2125 ----
/* ds <expression> <expression> # expr.*expr */
static const char *
parse_dot_star_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 'd');
! VERIFY3U(first[1], ==, 's');
size_t n = nlen(db);
const char *t = parse_expression(first + 2, last, db);
if (t == first + 2)
return (first);
*** 2132,2148 ****
/* dt <expression> <unresolved-name> # expr.name */
static const char *
parse_dot_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 'd');
! ASSERT3U(first[1], ==, 't');
const char *t = parse_expression(first + 2, last, db);
if (t == first + 2)
return (first);
--- 2134,2150 ----
/* dt <expression> <unresolved-name> # expr.name */
static const char *
parse_dot_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 'd');
! VERIFY3U(first[1], ==, 't');
const char *t = parse_expression(first + 2, last, db);
if (t == first + 2)
return (first);
*** 2156,2172 ****
/* cl <expression>+ E # call */
static const char *
parse_call_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 4)
return (first);
! ASSERT3U(first[0], ==, 'c');
! ASSERT3U(first[1], ==, 'l');
const char *t = first + 2;
const char *t1 = NULL;
size_t n = nlen(db);
--- 2158,2174 ----
/* cl <expression>+ E # call */
static const char *
parse_call_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 4)
return (first);
! VERIFY3U(first[0], ==, 'c');
! VERIFY3U(first[1], ==, 'l');
const char *t = first + 2;
const char *t1 = NULL;
size_t n = nlen(db);
*** 2182,2192 ****
return (first);
njoin(db, amt - 1, ", ");
nfmt(db, "{1}({0})", NULL);
! ASSERT3U(t[0], ==, 'E');
return (t + 1);
}
/* BEGIN CSTYLED */
/*
--- 2184,2194 ----
return (first);
njoin(db, amt - 1, ", ");
nfmt(db, "{1}({0})", NULL);
! VERIFY3U(t[0], ==, 'E');
return (t + 1);
}
/* BEGIN CSTYLED */
/*
*** 2195,2211 ****
*/
/* END CSTYLED */
static const char *
parse_conv_expr(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 'c');
! ASSERT3U(first[1], ==, 'v');
const char *t = NULL;
const char *t1 = NULL;
size_t n = nlen(db);
--- 2197,2213 ----
*/
/* END CSTYLED */
static const char *
parse_conv_expr(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 'c');
! VERIFY3U(first[1], ==, 'v');
const char *t = NULL;
const char *t1 = NULL;
size_t n = nlen(db);
*** 2252,2262 ****
/* <simple-id> ::= <source-name> [ <template-args> ] */
static const char *
parse_simple_id(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
const char *t = parse_source_name(first, last, db);
if (t == first)
return (t);
--- 2254,2264 ----
/* <simple-id> ::= <source-name> [ <template-args> ] */
static const char *
parse_simple_id(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
const char *t = parse_source_name(first, last, db);
if (t == first)
return (t);
*** 2274,2284 ****
* ::= <substitution>
*/
static const char *
parse_unresolved_type(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (first == last)
return (first);
const char *t = first;
--- 2276,2286 ----
* ::= <substitution>
*/
static const char *
parse_unresolved_type(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (first == last)
return (first);
const char *t = first;
*** 2287,2297 ****
switch (first[0]) {
case 'T':
t = parse_template_param(first, last, db);
if (t == first || NAMT(db, n) != 1) {
for (size_t i = 0; i < NAMT(db, n); i++)
! (void) name_pop(&db->cpp_name, NULL);
return (first);
}
save_top(db, 1);
return (t);
--- 2289,2299 ----
switch (first[0]) {
case 'T':
t = parse_template_param(first, last, db);
if (t == first || NAMT(db, n) != 1) {
for (size_t i = 0; i < NAMT(db, n); i++)
! name_pop(&db->cpp_name, NULL);
return (first);
}
save_top(db, 1);
return (t);
*** 2324,2340 ****
/* sp <expression> # pack expansion */
static const char *
parse_pack_expansion(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 's');
! ASSERT3U(first[1], ==, 'p');
const char *t = parse_expression(first + 2, last, db);
if (t == first +2)
return (first);
--- 2326,2342 ----
/* sp <expression> # pack expansion */
static const char *
parse_pack_expansion(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 's');
! VERIFY3U(first[1], ==, 'p');
const char *t = parse_expression(first + 2, last, db);
if (t == first +2)
return (first);
*** 2347,2357 ****
* extension ::= StL<unqualified-name>
*/
static const char *
parse_unscoped_name(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
const char *t = first;
--- 2349,2359 ----
* extension ::= StL<unqualified-name>
*/
static const char *
parse_unscoped_name(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
const char *t = first;
*** 2383,2393 ****
* ::= <unnamed-type-name>
*/
const char *
parse_unqualified_name(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (first == last)
return (first);
switch (*first) {
--- 2385,2395 ----
* ::= <unnamed-type-name>
*/
const char *
parse_unqualified_name(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (first == last)
return (first);
switch (*first) {
*** 2422,2432 ****
* # Parameter types or "v" if the lambda has no parameters
*/
static const char *
parse_unnamed_type_name(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2 || first[0] != 'U')
return (first);
if (first[1] != 't' && first[1] != 'l')
--- 2424,2434 ----
* # Parameter types or "v" if the lambda has no parameters
*/
static const char *
parse_unnamed_type_name(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2 || first[0] != 'U')
return (first);
if (first[1] != 't' && first[1] != 'l')
*** 2434,2444 ****
const char *t1 = first + 2;
const char *t2 = NULL;
if (first[1] == 't') {
! while (t1 != last && t1[0] != '_' && is_digit(t1[0]))
t1++;
if (t1[0] != '_')
return (first);
--- 2436,2447 ----
const char *t1 = first + 2;
const char *t2 = NULL;
if (first[1] == 't') {
! while (t1 != last && t1[0] != '_' &&
! isdigit_l(t1[0], db->cpp_loc))
t1++;
if (t1[0] != '_')
return (first);
*** 2477,2487 ****
/* E */
t1++;
t2 = t1;
while (t2 != last && t2[0] != '_') {
! if (!is_digit(*t2++))
return (first);
}
if (t2[0] != '_')
return (first);
--- 2480,2490 ----
/* E */
t1++;
t2 = t1;
while (t2 != last && t2[0] != '_') {
! if (!isdigit_l(*t2++, db->cpp_loc))
return (first);
}
if (t2[0] != '_')
return (first);
*** 2570,2580 ****
}
}
}
out:
! ASSERT3P(end, >=, start);
if (end - start < 2) {
nadd_l(db, "", 0);
return;
}
--- 2573,2583 ----
}
}
}
out:
! VERIFY3P(end, >=, start);
if (end - start < 2) {
nadd_l(db, "", 0);
return;
}
*** 2584,2594 ****
start++;
break;
}
}
! ASSERT3P(end, >=, start);
nadd_l(db, start, (size_t)(end - start));
}
/*
--- 2587,2597 ----
start++;
break;
}
}
! VERIFY3P(end, >=, start);
nadd_l(db, start, (size_t)(end - start));
}
/*
*** 2602,2612 ****
* extension ::= D5 # ?
*/
static const char *
parse_ctor_dtor_name(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2 || nempty(db) || str_length(TOP_L(db)) == 0)
return (first);
switch (first[0]) {
--- 2605,2615 ----
* extension ::= D5 # ?
*/
static const char *
parse_ctor_dtor_name(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2 || nempty(db) || str_length(TOP_L(db)) == 0)
return (first);
switch (first[0]) {
*** 2645,2657 ****
static const char *
parse_integer_literal(const char *first, const char *last, const char *fmt,
cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
! const char *t = parse_number(first, last);
const char *start = first;
if (t == first || t == last || t[0] != 'E')
return (first);
--- 2648,2660 ----
static const char *
parse_integer_literal(const char *first, const char *last, const char *fmt,
cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
! const char *t = parse_number(first, last, db->cpp_loc);
const char *start = first;
if (t == first || t == last || t[0] != 'E')
return (first);
*** 2678,2689 ****
};
static const char *
parse_floating_literal(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
! ASSERT(first[0] == 'f' || first[0] == 'd' || first[0] == 'e');
const struct float_data_s *fd = NULL;
for (size_t i = 0; i < ARRAY_SIZE(float_info); i++) {
if (float_info[i].type != first[0])
--- 2681,2692 ----
};
static const char *
parse_floating_literal(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
! VERIFY(first[0] == 'f' || first[0] == 'd' || first[0] == 'e');
const struct float_data_s *fd = NULL;
for (size_t i = 0; i < ARRAY_SIZE(float_info); i++) {
if (float_info[i].type != first[0])
*** 2730,2753 ****
#if defined(_BIG_ENDIAN)
for (t = first + 1; t != last; t++, e++) {
if (!is_xdigit(t[0]))
return (first);
! unsigned d1 = is_digit(t[0]) ? t[0] - '0' : t[0] - 'a' + 10;
t++;
! unsigned d0 = is_digit(t[0]) ? t[0] - '0' : t[0] - 'a' + 10;
*e = (d1 << 4) + d0;
}
#elif defined(_LITTLE_ENDIAN)
for (t = last - 1; t > first; t--, e++) {
if (!is_xdigit(t[0]))
return (first);
! unsigned d0 = is_digit(t[0]) ? t[0] - '0' : t[0] - 'a' + 10;
t--;
! unsigned d1 = is_digit(t[0]) ? t[0] - '0' : t[0] - 'a' + 10;
*e = (d1 << 4) + d0;
}
t = last;
#else
--- 2733,2756 ----
#if defined(_BIG_ENDIAN)
for (t = first + 1; t != last; t++, e++) {
if (!is_xdigit(t[0]))
return (first);
! unsigned d1 = isdigit_l(t[0], db->cpp_loc) ? t[0] - '0' : t[0] - 'a' + 10;
t++;
! unsigned d0 = isdigit_l(t[0], db->cpp_loc) ? t[0] - '0' : t[0] - 'a' + 10;
*e = (d1 << 4) + d0;
}
#elif defined(_LITTLE_ENDIAN)
for (t = last - 1; t > first; t--, e++) {
if (!is_xdigit(t[0]))
return (first);
! unsigned d0 = isdigit_l(t[0], db->cpp_loc) ? t[0] - '0' : t[0] - 'a' + 10;
t--;
! unsigned d1 = isdigit_l(t[0], db->cpp_loc) ? t[0] - '0' : t[0] - 'a' + 10;
*e = (d1 << 4) + d0;
}
t = last;
#else
*** 2824,2834 ****
};
static const char *
parse_expr_primary(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 4 || first[0] != 'L')
return (first);
const char *t = NULL;
--- 2827,2837 ----
};
static const char *
parse_expr_primary(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 4 || first[0] != 'L')
return (first);
const char *t = NULL;
*** 2888,2898 ****
if (t[0] == 'E')
return (t + 1);
const char *n;
! for (n = t; n != last && is_digit(n[0]); n++)
;
if (n == last || nempty(db) || n[0] != 'E')
return (first);
if (n == t)
return (t);
--- 2891,2901 ----
if (t[0] == 'E')
return (t + 1);
const char *n;
! for (n = t; n != last && isdigit_l(n[0], db->cpp_loc); n++)
;
if (n == last || nempty(db) || n[0] != 'E')
return (first);
if (n == t)
return (t);
*** 3011,3021 ****
};
static const char *
parse_operator_name(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
for (size_t i = 0; i < ARRAY_SIZE(op_tbl); i++) {
--- 3014,3024 ----
};
static const char *
parse_operator_name(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
for (size_t i = 0; i < ARRAY_SIZE(op_tbl); i++) {
*** 3036,3046 ****
nfmt(db, "operator\"\" {0}", NULL);
return (t);
}
if (first[0] == 'v') {
! if (!is_digit(first[1]))
return (first);
t = parse_source_name(first + 2, last, db);
if (t == first + 2)
return (first);
--- 3039,3049 ----
nfmt(db, "operator\"\" {0}", NULL);
return (t);
}
if (first[0] == 'v') {
! if (!isdigit_l(first[1], db->cpp_loc))
return (first);
t = parse_source_name(first + 2, last, db);
if (t == first + 2)
return (first);
*** 3109,3119 ****
};
static const char *
parse_builtin_type(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (first == last)
return (first);
size_t i;
--- 3112,3122 ----
};
static const char *
parse_builtin_type(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (first == last)
return (first);
size_t i;
*** 3145,3167 ****
return (first);
}
static const char *
! parse_base36(const char *first, const char *last, size_t *val)
{
! ASSERT3P(first, <=, last);
const char *t;
for (t = first, *val = 0; t != last; t++) {
! if (!is_digit(t[0]) && !is_upper(t[0]))
return (t);
*val *= 36;
! if (is_digit(t[0]))
*val += t[0] - '0';
else
*val += t[0] - 'A' + 10;
}
return (t);
--- 3148,3170 ----
return (first);
}
static const char *
! parse_base36(const char *first, const char *last, size_t *val, locale_t loc)
{
! VERIFY3P(first, <=, last);
const char *t;
for (t = first, *val = 0; t != last; t++) {
! if (!isdigit_l(t[0], loc) && !isupper_l(t[0], loc))
return (t);
*val *= 36;
! if (isdigit_l(t[0], loc))
*val += t[0] - '0';
else
*val += t[0] - 'A' + 10;
}
return (t);
*** 3177,3187 ****
};
static const char *
parse_substitution(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (first == last || last - first < 2)
return (first);
if (first[0] != 'S')
--- 3180,3190 ----
};
static const char *
parse_substitution(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (first == last || last - first < 2)
return (first);
if (first[0] != 'S')
*** 3196,3206 ****
const char *t = first + 1;
size_t n = 0;
if (t[0] != '_') {
! t = parse_base36(first + 1, last, &n);
if (t == first + 1 || t[0] != '_')
return (first);
/*
* S_ == substitution 0,
--- 3199,3209 ----
const char *t = first + 1;
size_t n = 0;
if (t[0] != '_') {
! t = parse_base36(first + 1, last, &n, db->cpp_loc);
if (t == first + 1 || t[0] != '_')
return (first);
/*
* S_ == substitution 0,
*** 3214,3240 ****
return (first);
sub(db, n);
/* skip _ */
! ASSERT3U(t[0], ==, '_');
return (t + 1);
}
static const char *
parse_source_name(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (first == last)
return (first);
const char *t = NULL;
size_t n = 0;
! for (t = first; t != last && is_digit(t[0]); t++) {
/* make sure we don't overflow */
size_t nn = n * 10;
if (nn < n)
return (first);
--- 3217,3243 ----
return (first);
sub(db, n);
/* skip _ */
! VERIFY3U(t[0], ==, '_');
return (t + 1);
}
static const char *
parse_source_name(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (first == last)
return (first);
const char *t = NULL;
size_t n = 0;
! for (t = first; t != last && isdigit_l(t[0], db->cpp_loc); t++) {
/* make sure we don't overflow */
size_t nn = n * 10;
if (nn < n)
return (first);
*** 3266,3288 ****
* ::= p # AltiVec vector pixel
*/
static const char *
parse_vector_type(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 'D');
! ASSERT3U(first[1], ==, 'v');
const char *t = first + 2;
const char *t1 = NULL;
! if (is_digit(first[2]) && first[2] != '0') {
! t1 = parse_number(t, last);
if (t1 == last || t1 + 1 == last || t1[0] != '_')
return (first);
nadd_l(db, t, (size_t)(t1 - t));
--- 3269,3291 ----
* ::= p # AltiVec vector pixel
*/
static const char *
parse_vector_type(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 'D');
! VERIFY3U(first[1], ==, 'v');
const char *t = first + 2;
const char *t1 = NULL;
! if (isdigit_l(first[2], db->cpp_loc) && first[2] != '0') {
! t1 = parse_number(t, last, db->cpp_loc);
if (t1 == last || t1 + 1 == last || t1[0] != '_')
return (first);
nadd_l(db, t, (size_t)(t1 - t));
*** 3327,3342 ****
*/
/* END CSTYLED */
static const char *
parse_decltype(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 4)
return (first);
! ASSERT3U(first[0], ==, 'D');
if (first[1] != 't' && first[1] != 'T')
return (first);
size_t n = nlen(db);
--- 3330,3345 ----
*/
/* END CSTYLED */
static const char *
parse_decltype(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 4)
return (first);
! VERIFY3U(first[0], ==, 'D');
if (first[1] != 't' && first[1] != 'T')
return (first);
size_t n = nlen(db);
*** 3355,3377 ****
* ::= A [<dimension expression>] _ <element type>
*/
static const char *
parse_array_type(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
! ASSERT3U(first[0], ==, 'A');
if (last - first < 3)
return (first);
const char *t = first + 1;
const char *t1 = NULL;
size_t n = nlen(db);
if (t[0] != '_') {
! if (is_digit(t[0]) && t[0] != '0') {
! t1 = parse_number(t, last);
if (t1 == last)
return (first);
nadd_l(db, t, (size_t)(t1 - t));
} else {
--- 3358,3380 ----
* ::= A [<dimension expression>] _ <element type>
*/
static const char *
parse_array_type(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
! VERIFY3U(first[0], ==, 'A');
if (last - first < 3)
return (first);
const char *t = first + 1;
const char *t1 = NULL;
size_t n = nlen(db);
if (t[0] != '_') {
! if (isdigit_l(t[0], db->cpp_loc) && t[0] != '0') {
! t1 = parse_number(t, last, db->cpp_loc);
if (t1 == last)
return (first);
nadd_l(db, t, (size_t)(t1 - t));
} else {
*** 3386,3396 ****
t = t1;
} else {
nadd_l(db, "", 0);
}
! ASSERT3U(t[0], ==, '_');
t1 = parse_type(t + 1, last, db);
if (t1 == t + 1 || NAMT(db, n) != 2)
return (first);
--- 3389,3399 ----
t = t1;
} else {
nadd_l(db, "", 0);
}
! VERIFY3U(t[0], ==, '_');
t1 = parse_type(t + 1, last, db);
if (t1 == t + 1 || NAMT(db, n) != 2)
return (first);
*** 3408,3423 ****
/* <pointer-to-member-type> ::= M <class type> <member type> */
static const char *
parse_pointer_to_member_type(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 3)
return (first);
! ASSERT3U(first[0], ==, 'M');
const char *t1 = first + 1;
const char *t2 = NULL;
size_t n = nlen(db);
--- 3411,3426 ----
/* <pointer-to-member-type> ::= M <class type> <member type> */
static const char *
parse_pointer_to_member_type(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 3)
return (first);
! VERIFY3U(first[0], ==, 'M');
const char *t1 = first + 1;
const char *t2 = NULL;
size_t n = nlen(db);
*** 3457,3467 ****
*/
/* END CSTYLED */
static const char *
parse_unresolved_name(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
const char *t = first;
--- 3460,3470 ----
*/
/* END CSTYLED */
static const char *
parse_unresolved_name(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
const char *t = first;
*** 3505,3515 ****
nfmt(db, "{1:L}{0}", "{1:R}");
t = t2;
}
! ASSERT3U(NAMT(db, n), ==, 1);
while (t[0] != 'E') {
size_t nn = nlen(db);
t2 = parse_unresolved_qualifier_level(t, last, db);
if (t == t2 || t == last || NAMT(db, nn) != 1)
--- 3508,3518 ----
nfmt(db, "{1:L}{0}", "{1:R}");
t = t2;
}
! VERIFY3U(NAMT(db, n), ==, 1);
while (t[0] != 'E') {
size_t nn = nlen(db);
t2 = parse_unresolved_qualifier_level(t, last, db);
if (t == t2 || t == last || NAMT(db, nn) != 1)
*** 3577,3587 ****
/* <unresolved-qualifier-level> ::= <simple-id> */
static const char *
parse_unresolved_qualifier_level(const char *first, const char *last,
cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
return (parse_simple_id(first, last, db));
}
/* BEGIN CSTYLED */
/*
--- 3580,3590 ----
/* <unresolved-qualifier-level> ::= <simple-id> */
static const char *
parse_unresolved_qualifier_level(const char *first, const char *last,
cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
return (parse_simple_id(first, last, db));
}
/* BEGIN CSTYLED */
/*
*** 3595,3605 ****
*/
/* END CSTYLED */
static const char *
parse_base_unresolved_name(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
const char *t = NULL;
--- 3598,3608 ----
*/
/* END CSTYLED */
static const char *
parse_base_unresolved_name(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
const char *t = NULL;
*** 3644,3654 ****
* ::= <simple-id> # e.g., ~A<2*N>
*/
static const char *
parse_destructor_name(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (first == last)
return (first);
const char *t = parse_unresolved_type(first, last, db);
--- 3647,3657 ----
* ::= <simple-id> # e.g., ~A<2*N>
*/
static const char *
parse_destructor_name(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (first == last)
return (first);
const char *t = parse_unresolved_type(first, last, db);
*** 3670,3685 ****
* <function-type> ::= F [Y] <bare-function-type> [<ref-qualifier>] E
*/
static const char *
parse_function_type(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2)
return (first);
! ASSERT3U(first[0], ==, 'F');
const char *t = first + 1;
/* extern "C" */
if (t[0] == 'Y')
--- 3673,3688 ----
* <function-type> ::= F [Y] <bare-function-type> [<ref-qualifier>] E
*/
static const char *
parse_function_type(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2)
return (first);
! VERIFY3U(first[0], ==, 'F');
const char *t = first + 1;
/* extern "C" */
if (t[0] == 'Y')
*** 3746,3765 ****
* ::= T <parameter-2 non-negative number> _
*/
static const char *
parse_template_param(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2 || first[0] != 'T')
return (first);
const char *t = first + 1;
size_t idx = 0;
while (t != last && t[0] != '_') {
! if (!is_digit(t[0]))
return (first);
idx *= 10;
idx += t[0] - '0';
t++;
--- 3749,3768 ----
* ::= T <parameter-2 non-negative number> _
*/
static const char *
parse_template_param(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2 || first[0] != 'T')
return (first);
const char *t = first + 1;
size_t idx = 0;
while (t != last && t[0] != '_') {
! if (!isdigit_l(t[0], db->cpp_loc))
return (first);
idx *= 10;
idx += t[0] - '0';
t++;
*** 3766,3776 ****
}
if (t == last)
return (first);
! ASSERT3U(t[0], ==, '_');
/*
* T_ -> idx 0
* T0 -> idx 1
* T1 -> idx 2
--- 3769,3779 ----
}
if (t == last)
return (first);
! VERIFY3U(t[0], ==, '_');
/*
* T_ -> idx 0
* T0 -> idx 1
* T1 -> idx 2
*** 3800,3810 ****
* extension, the abi says <template-arg>+
*/
static const char *
parse_template_args(const char *first, const char *last, cpp_db_t *db)
{
! ASSERT3P(first, <=, last);
if (last - first < 2 || first[0] != 'I')
return (first);
if (db->cpp_tag_templates)
--- 3803,3813 ----
* extension, the abi says <template-arg>+
*/
static const char *
parse_template_args(const char *first, const char *last, cpp_db_t *db)
{
! VERIFY3P(first, <=, last);
if (last - first < 2 || first[0] != 'I')
return (first);
if (db->cpp_tag_templates)
*** 3836,3850 ****
* ugly, but if the last thing pushed was an empty string,
* get rid of it so we dont get "<..., >"
*/
if (NAMT(db, n) > 1 &&
str_pair_len(name_top(&db->cpp_name)) == 0)
! (void) name_pop(&db->cpp_name, NULL);
njoin(db, NAMT(db, n), ", ");
! ASSERT3U(nlen(db), >, 0);
/* make sure we don't bitshift ourselves into oblivion */
str_t *top = TOP_L(db);
if (str_length(top) > 0 &&
top->str_s[top->str_len - 1] == '>')
--- 3839,3853 ----
* ugly, but if the last thing pushed was an empty string,
* get rid of it so we dont get "<..., >"
*/
if (NAMT(db, n) > 1 &&
str_pair_len(name_top(&db->cpp_name)) == 0)
! name_pop(&db->cpp_name, NULL);
njoin(db, NAMT(db, n), ", ");
! VERIFY3U(nlen(db), >, 0);
/* make sure we don't bitshift ourselves into oblivion */
str_t *top = TOP_L(db);
if (str_length(top) > 0 &&
top->str_s[top->str_len - 1] == '>')
*** 3860,3880 ****
* <discriminator> := _ <non-negative number> # when number < 10
* := __ <non-negative number> _ # when number >= 10
* extension := decimal-digit+ # at the end of string
*/
static const char *
! parse_discriminator(const char *first, const char *last)
{
! ASSERT3P(first, <=, last);
const char *t = NULL;
if (first == last)
return (first);
! if (is_digit(first[0])) {
! for (t = first; t != last && is_digit(t[0]); t++)
;
/* not at the end of the string */
if (t != last)
return (first);
--- 3863,3883 ----
* <discriminator> := _ <non-negative number> # when number < 10
* := __ <non-negative number> _ # when number >= 10
* extension := decimal-digit+ # at the end of string
*/
static const char *
! parse_discriminator(const char *first, const char *last, locale_t loc)
{
! VERIFY3P(first, <=, last);
const char *t = NULL;
if (first == last)
return (first);
! if (isdigit_l(first[0], loc)) {
! for (t = first; t != last && isdigit_l(t[0], loc); t++)
;
/* not at the end of the string */
if (t != last)
return (first);
*** 3883,3899 ****
} else if (first[0] != '_' || first + 1 == last) {
return (first);
}
t = first + 1;
! if (is_digit(t[0]))
return (t + 1);
if (t[0] != '_' || t + 1 == last)
return (first);
! for (t++; t != last && is_digit(t[0]); t++)
;
if (t == last || t[0] != '_')
return (first);
return (t);
--- 3886,3902 ----
} else if (first[0] != '_' || first + 1 == last) {
return (first);
}
t = first + 1;
! if (isdigit_l(t[0], loc))
return (t + 1);
if (t[0] != '_' || t + 1 == last)
return (first);
! for (t++; t != last && isdigit_l(t[0], loc); t++)
;
if (t == last || t[0] != '_')
return (first);
return (t);
*** 3901,3911 ****
/* <CV-qualifiers> ::= [r] [V] [K] */
const char *
parse_cv_qualifiers(const char *first, const char *last, unsigned *cv)
{
! ASSERT3P(first, <=, last);
if (first == last)
return (first);
*cv = 0;
--- 3904,3914 ----
/* <CV-qualifiers> ::= [r] [V] [K] */
const char *
parse_cv_qualifiers(const char *first, const char *last, unsigned *cv)
{
! VERIFY3P(first, <=, last);
if (first == last)
return (first);
*cv = 0;
*** 3927,3977 ****
/*
* <number> ::= [n] <non-negative decimal integer>
*/
static const char *
! parse_number(const char *first, const char *last)
{
! ASSERT3P(first, <=, last);
const char *t = first;
! if (first == last || (first[0] != 'n' && !is_digit(first[0])))
return (first);
if (t[0] == 'n')
t++;
if (t[0] == '0')
return (t + 1);
! while (is_digit(t[0]))
t++;
return (t);
}
/*
! * we only ever use ASCII versions of these
*/
static inline boolean_t
- is_digit(int c)
- {
- if (c < '0' || c > '9')
- return (B_FALSE);
- return (B_TRUE);
- }
-
- static inline boolean_t
- is_upper(int c)
- {
- if (c < 'A' || c > 'Z')
- return (B_FALSE);
- return (B_TRUE);
- }
-
- static inline boolean_t
is_xdigit(int c)
{
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'))
return (B_TRUE);
return (B_FALSE);
--- 3930,3966 ----
/*
* <number> ::= [n] <non-negative decimal integer>
*/
static const char *
! parse_number(const char *first, const char *last, locale_t loc)
{
! VERIFY3P(first, <=, last);
const char *t = first;
! if (first == last || (first[0] != 'n' && !isdigit_l(first[0], loc)))
return (first);
if (t[0] == 'n')
t++;
if (t[0] == '0')
return (t + 1);
! while (isdigit_l(t[0], loc))
t++;
return (t);
}
/*
! * Like isxdigit(3C), except we can only accept lower case letters as
! * that's only what is allowed when [de]mangling floating point constants into
! * their hex representation.
*/
static inline boolean_t
is_xdigit(int c)
{
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'))
return (B_TRUE);
return (B_FALSE);
*** 4055,4065 ****
tsave(cpp_db_t *db, size_t amt)
{
CK(templ_save(&db->cpp_name, amt, &db->cpp_templ));
}
! static void
db_init(cpp_db_t *db, sysdem_ops_t *ops)
{
(void) memset(db, 0, sizeof (*db));
db->cpp_ops = ops;
name_init(&db->cpp_name, ops);
--- 4044,4054 ----
tsave(cpp_db_t *db, size_t amt)
{
CK(templ_save(&db->cpp_name, amt, &db->cpp_templ));
}
! static boolean_t
db_init(cpp_db_t *db, sysdem_ops_t *ops)
{
(void) memset(db, 0, sizeof (*db));
db->cpp_ops = ops;
name_init(&db->cpp_name, ops);
*** 4066,4083 ****
--- 4055,4075 ----
sub_init(&db->cpp_subs, ops);
templ_init(&db->cpp_templ, ops);
db->cpp_tag_templates = B_TRUE;
db->cpp_try_to_parse_template_args = B_TRUE;
tpush(db);
+ db->cpp_loc = newlocale(LC_CTYPE_MASK, "C", 0);
+ return ((db->cpp_loc != NULL) ? B_TRUE : B_FALSE);
}
static void
db_fini(cpp_db_t *db)
{
name_fini(&db->cpp_name);
sub_fini(&db->cpp_subs);
templ_fini(&db->cpp_templ);
+ freelocale(db->cpp_loc);
(void) memset(db, 0, sizeof (*db));
}
static void
print_sp(const str_pair_t *sp, FILE *out)
*** 4105,4115 ****
}
(void) fputc('\n', out);
}
!
static char *
base36(char *buf, size_t val)
{
char tmp[16] = { 0 };
char *p = tmp;
--- 4097,4107 ----
}
(void) fputc('\n', out);
}
! /* Print a base-36 number (for substitutions) */
static char *
base36(char *buf, size_t val)
{
char tmp[16] = { 0 };
char *p = tmp;