Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions protobuf-c-text/generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include <protobuf-c/protobuf-c.h>
#include "protobuf-c-text.h"
#include "protobuf-c-util.h"
Expand Down Expand Up @@ -222,76 +223,76 @@ protobuf_c_text_to_string_internal(ReturnString *rs,
quantifier_offset = STRUCT_MEMBER(size_t, m, f[i].quantifier_offset);
/* Field exists and has data, dump it. */
switch (f[i].type) {
case PROTOBUF_C_TYPE_INT32:
case PROTOBUF_C_TYPE_UINT32:
case PROTOBUF_C_TYPE_FIXED32:
if (f[i].label == PROTOBUF_C_LABEL_REPEATED) {
for (j = 0; j < quantifier_offset; j++) {
rs_append(rs, level + strlen(f[i].name) + 20,
allocator,
"%*s%s: %u\n",
"%*s%s: %" PRIu32 "\n",
level, "", f[i].name,
STRUCT_MEMBER(uint32_t *, m, f[i].offset)[j]);
}
} else {
rs_append(rs, level + strlen(f[i].name) + 20,
allocator,
"%*s%s: %u\n",
"%*s%s: %" PRIu32 "\n",
level, "", f[i].name,
STRUCT_MEMBER(uint32_t, m, f[i].offset));
}
break;
case PROTOBUF_C_TYPE_INT32:
case PROTOBUF_C_TYPE_SINT32:
case PROTOBUF_C_TYPE_SFIXED32:
if (f[i].label == PROTOBUF_C_LABEL_REPEATED) {
for (j = 0; j < quantifier_offset; j++) {
rs_append(rs, level + strlen(f[i].name) + 20,
allocator,
"%*s%s: %d\n",
"%*s%s: %" PRId32 "\n",
level, "", f[i].name,
STRUCT_MEMBER(int32_t *, m, f[i].offset)[j]);
}
} else {
rs_append(rs, level + strlen(f[i].name) + 20,
allocator,
"%*s%s: %d\n",
"%*s%s: %" PRId32 "\n",
level, "", f[i].name,
STRUCT_MEMBER(int32_t, m, f[i].offset));
}
break;
case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64:
case PROTOBUF_C_TYPE_FIXED64:
if (f[i].label == PROTOBUF_C_LABEL_REPEATED) {
for (j = 0; j < quantifier_offset; j++) {
rs_append(rs, level + strlen(f[i].name) + 20,
allocator,
"%*s%s: %lu\n",
"%*s%s: %" PRIu64 "\n",
level, "", f[i].name,
STRUCT_MEMBER(uint64_t *, m, f[i].offset)[j]);
}
} else {
rs_append(rs, level + strlen(f[i].name) + 20,
allocator,
"%*s%s: %lu\n",
"%*s%s: %" PRIu64 "\n",
level, "", f[i].name,
STRUCT_MEMBER(uint64_t, m, f[i].offset));
}
break;
case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_SINT64:
case PROTOBUF_C_TYPE_SFIXED64:
if (f[i].label == PROTOBUF_C_LABEL_REPEATED) {
for (j = 0; j < quantifier_offset; j++) {
rs_append(rs, level + strlen(f[i].name) + 20,
allocator,
"%*s%s: %ld\n",
"%*s%s: %" PRId64 "\n",
level, "", f[i].name,
STRUCT_MEMBER(int64_t *, m, f[i].offset)[j]);
}
} else {
rs_append(rs, level + strlen(f[i].name) + 20,
allocator,
"%*s%s: %ld\n",
"%*s%s: %" PRId64 "\n",
level, "", f[i].name,
STRUCT_MEMBER(int64_t, m, f[i].offset));
}
Expand Down
4 changes: 2 additions & 2 deletions protobuf-c-text/parse.re
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,6 @@ state_value(State *state, Token *t)

case TOK_NUMBER:
switch (state->field->type) {
case PROTOBUF_C_TYPE_INT32:
case PROTOBUF_C_TYPE_UINT32:
case PROTOBUF_C_TYPE_FIXED32:
val = strtoul(t->number, &end, 10);
Expand Down Expand Up @@ -975,6 +974,7 @@ state_value(State *state, Token *t)
}
break;

case PROTOBUF_C_TYPE_INT32:
case PROTOBUF_C_TYPE_SINT32:
case PROTOBUF_C_TYPE_SFIXED32:
val = strtol(t->number, &end, 10);
Expand Down Expand Up @@ -1005,7 +1005,6 @@ state_value(State *state, Token *t)
}
break;

case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_UINT64:
case PROTOBUF_C_TYPE_FIXED64:
val = strtoull(t->number, &end, 10);
Expand Down Expand Up @@ -1036,6 +1035,7 @@ state_value(State *state, Token *t)
}
break;

case PROTOBUF_C_TYPE_INT64:
case PROTOBUF_C_TYPE_SINT64:
case PROTOBUF_C_TYPE_SFIXED64:
val = strtoll(t->number, &end, 10);
Expand Down