pull/13171/head
Joshua Haberman 6 years ago
parent 45d61f4299
commit d0c8bb84f4
  1. 9
      upb/def.c
  2. 2
      upb/msg.h

@ -916,7 +916,7 @@ const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym) {
* this code is used to directly build defs from Ruby (for example) we do need
* to validate important constraints like uniqueness of names and numbers. */
#define CHK(x) if (!(x)) { __builtin_trap(); return false; }
#define CHK(x) if (!(x)) { return false; }
#define CHK_OOM(x) if (!(x)) { upb_upberr_setoom(ctx->status); return false; }
typedef struct {
@ -1105,6 +1105,7 @@ static bool parse_default(const symtab_addctx *ctx, const char *str, size_t len,
case UPB_TYPE_BYTES:
/* XXX: need to interpret the C-escaped value. */
f->defaultval.str = newstr(ctx->alloc, str, len);
break;
case UPB_TYPE_MESSAGE:
/* Should not have a default value. */
return false;
@ -1449,8 +1450,10 @@ static bool resolve_fielddef(const symtab_addctx *ctx, const char *prefix,
}
if (!parse_default(ctx, defaultval.data, defaultval.size, f)) {
upb_status_seterrf(ctx->status, "couldn't parse default for field (%s)",
f->full_name);
upb_status_seterrf(ctx->status,
"couldn't parse default '" UPB_STRINGVIEW_FORMAT
"' for field (%s)",
UPB_STRINGVIEW_ARGS(defaultval), f->full_name);
return false;
}
}

@ -99,7 +99,7 @@ UPB_INLINE bool upb_stringview_eql(upb_stringview a, upb_stringview b) {
}
#define UPB_STRINGVIEW_FORMAT "%.*s"
#define UPB_STRINGVIEW_ARGS(view) view.size, view.data
#define UPB_STRINGVIEW_ARGS(view) (int)(view).size, (view).data
#define UPB_STRINGVIEW_INIT(ptr, len) {ptr, len}

Loading…
Cancel
Save