Skip to content

Commit cd3fb1d

Browse files
committed
Updated some formatter with PRIu64 macro
1 parent 711b970 commit cd3fb1d

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/parser.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,18 @@ static ssize_t tokenize_select(Lexer *l, Token *tokens, size_t capacity)
174174
} else if (strncmp(token.p, "AT", token.length) == 0) {
175175
tokens[i].type = TOKEN_AT;
176176
token = lexer_next(l);
177-
if (sscanf(token.p, "%lli", &(int64_t){0}) == 1)
177+
if (sscanf(token.p, "%" PRId64, &(int64_t){0}) == 1)
178178
strncpy(tokens[i].value, token.p, token.length);
179179
} else if (strncmp(token.p, "RANGE", token.length) == 0) {
180180
tokens[i].type = TOKEN_RANGE;
181181
token = lexer_next(l);
182-
if (sscanf(token.p, "%lli", &(int64_t){0}) == 1)
182+
if (sscanf(token.p, "%" PRId64, &(int64_t){0}) == 1)
183183
strncpy(tokens[i].value, token.p, token.length);
184184
// TOOD error here, missing the start timestamp
185185
} else if (strncmp(token.p, "TO", token.length) == 0) {
186186
tokens[i].type = TOKEN_TO;
187187
token = lexer_next(l);
188-
if (sscanf(token.p, "%lli", &(int64_t){0}) == 1)
188+
if (sscanf(token.p, "%" PRId64, &(int64_t){0}) == 1)
189189
strncpy(tokens[i].value, token.p, token.length);
190190
// TOOD error here, missing the start timestamp
191191
} else if (strncmp(token.p, "WHERE", token.length) == 0) {
@@ -199,7 +199,7 @@ static ssize_t tokenize_select(Lexer *l, Token *tokens, size_t capacity)
199199
} else if (strncmp(token.p, "BY", token.length) == 0) {
200200
tokens[i].type = TOKEN_BY;
201201
token = lexer_next(l);
202-
if (sscanf(token.p, "%llu", &(uint64_t){0}) == 1)
202+
if (sscanf(token.p, "%" PRIu64, &(uint64_t){0}) == 1)
203203
strncpy(tokens[i].value, token.p, token.length);
204204
// TOOD error here, missing the start timestamp
205205
} else {
@@ -217,7 +217,7 @@ static ssize_t tokenize_select(Lexer *l, Token *tokens, size_t capacity)
217217
tokens[i].type = TOKEN_OPERATOR_NE;
218218
}
219219
token = lexer_next(l);
220-
if (sscanf(token.p, "%llu", &(uint64_t){0}) == 1)
220+
if (sscanf(token.p, "%" PRIu64, &(uint64_t){0}) == 1)
221221
strncpy(tokens[i].value, token.p, token.length);
222222
}
223223
}
@@ -428,7 +428,7 @@ static void print_insert(const Statement_Insert *insert)
428428
printf("INSERT\n\t%s\nINTO\n\t%s\n", insert->ts_name, insert->db_name);
429429
printf("VALUES\n\t");
430430
for (size_t i = 0; i < insert->record_len; ++i) {
431-
printf("(%llu, %.2f) ", insert->records[i].timestamp,
431+
printf("(%" PRId64 ", %.2f) ", insert->records[i].timestamp,
432432
insert->records[i].value);
433433
}
434434
printf("\n");
@@ -438,16 +438,17 @@ static void print_select(const Statement_Select *select)
438438
{
439439
printf("SELECT\n\t%s\nFROM\n\t%s\n", select->ts_name, select->db_name);
440440
if (select->mask & SM_SINGLE)
441-
printf("AT\n\t%lli\n", select->start_time);
441+
printf("AT\n\t%" PRId64 "\n", select->start_time);
442442
else if (select->mask & SM_RANGE)
443-
printf("RANGE\n\t%lli TO %lli\n", select->start_time, select->end_time);
443+
printf("RANGE\n\t%" PRId64 " TO %" PRId64 "\n", select->start_time,
444+
select->end_time);
444445
if (select->mask & SM_WHERE)
445446
printf("WHERE\n\t%s %i %.2lf\n", select->where.key,
446447
select->where.operator, select->where.value);
447448
if (select->mask & SM_AGGREGATE)
448449
printf("AGGREAGATE\n\t%i\n", select->af);
449450
if (select->mask & SM_BY)
450-
printf("BY\n\t%llu\n", select->interval);
451+
printf("BY\n\t%" PRIu64 "\n", select->interval);
451452
}
452453

453454
void print_statement(const Statement *statement)

src/protocol.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "protocol.h"
2+
#include <inttypes.h>
23
#include <stdio.h>
34
#include <string.h>
45

@@ -81,7 +82,7 @@ ssize_t encode_response(const Response *r, uint8_t *dst)
8182
while (j < r->array_response.length) {
8283
// Timestamp
8384
dst[i++] = ':';
84-
n = snprintf((char *)dst + i, 21, "%llu",
85+
n = snprintf((char *)dst + i, 21, "%" PRIu64,
8586
r->array_response.records[j].timestamp);
8687
i += n;
8788
dst[i++] = '\r';

src/roach_cli.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "client.h"
22
#include "protocol.h"
33
#include <errno.h>
4+
#include <inttypes.h>
45
#include <stdlib.h>
56
#include <string.h>
67
#include <time.h>
@@ -44,7 +45,8 @@ static void print_response(const Response *rs)
4445
printf("%s\n", rs->string_response.message);
4546
} else {
4647
for (size_t i = 0; i < rs->array_response.length; ++i)
47-
printf("%llu %.6f\n", rs->array_response.records[i].timestamp,
48+
printf("%" PRIu64 " %.6f\n",
49+
rs->array_response.records[i].timestamp,
4850
rs->array_response.records[i].value);
4951
}
5052
}

0 commit comments

Comments
 (0)