Skip to content

Commit 7080c15

Browse files
committed
fixes #255
1 parent 892c4be commit 7080c15

File tree

8 files changed

+443
-400
lines changed

8 files changed

+443
-400
lines changed

src/file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
enum {A = 18446744073709551615ULL*2};
1+
#define foo(b) a #b
2+
foo(1)

src/lib.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8036,7 +8036,7 @@ static struct token_list replace_macro_arguments(struct preprocessor_ctx* ctx, s
80368036
antes copia flags dele
80378037
*/
80388038

8039-
const enum token_flags flags = input_list->head->flags;
8039+
const enum token_flags flags = r.tail->flags;
80408040
token_list_pop_front(input_list);
80418041

80428042
//deleta tambem # do fim
@@ -11014,6 +11014,7 @@ int test_predefined_macros()
1101411014
}
1101511015
if (strcmp(result, output) != 0)
1101611016
{
11017+
1101711018
}
1101811019

1101911020

@@ -11034,7 +11035,26 @@ int test_utf8()
1103411035
return 0;
1103511036
}
1103611037

11038+
int bug_test()
11039+
{
11040+
const char* input =
11041+
"#define M(b) a #b \n"
11042+
"M(1)\n";
1103711043

11044+
const char* output =
11045+
"a \"1\""
11046+
;
11047+
11048+
11049+
struct tokenizer_ctx tctx = { 0 };
11050+
struct token_list list = tokenizer(&tctx, input, "source", 0, TK_FLAG_NONE);
11051+
11052+
11053+
11054+
assert(test_preprocessor_in_out(input, output) == 0);
11055+
11056+
return 0;
11057+
}
1103811058
int test_line_continuation()
1103911059
{
1104011060

@@ -25558,7 +25578,7 @@ void defer_start_visit_declaration(struct defer_visit_ctx* ctx, struct declarati
2555825578

2555925579
//#pragma once
2556025580

25561-
#define CAKE_VERSION "0.10.19"
25581+
#define CAKE_VERSION "0.10.20"
2556225582

2556325583

2556425584

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int main(int argc, char** argv)
8686
#ifdef TEST
8787
test_main();
8888
printf("--------------------------------------\n");
89-
printf("Embedded tests in #ifdef TEST groups\n");
89+
printf("Tests embedded within #ifdef TEST blocks.\n");
9090
printf("%d tests failed, %d tests passed\n", g_unit_test_error_count, g_unit_test_success_count);
9191
printf("--------------------------------------\n");
9292
if (g_unit_test_error_count > 0)

src/tokenizer.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4734,7 +4734,7 @@ static struct token_list replace_macro_arguments(struct preprocessor_ctx* ctx, s
47344734
antes copia flags dele
47354735
*/
47364736

4737-
const enum token_flags flags = input_list->head->flags;
4737+
const enum token_flags flags = r.tail->flags;
47384738
token_list_pop_front(input_list);
47394739

47404740
//deleta tambem # do fim
@@ -7671,6 +7671,7 @@ int test_predefined_macros()
76717671
}
76727672
if (strcmp(result, output) != 0)
76737673
{
7674+
76747675
}
76757676

76767677

@@ -7691,7 +7692,26 @@ int test_utf8()
76917692
return 0;
76927693
}
76937694

7695+
int bug_test()
7696+
{
7697+
const char* input =
7698+
"#define M(b) a #b \n"
7699+
"M(1)\n";
7700+
7701+
const char* output =
7702+
"a \"1\""
7703+
;
7704+
76947705

7706+
struct tokenizer_ctx tctx = { 0 };
7707+
struct token_list list = tokenizer(&tctx, input, "source", 0, TK_FLAG_NONE);
7708+
7709+
7710+
7711+
assert(test_preprocessor_in_out(input, output) == 0);
7712+
7713+
return 0;
7714+
}
76957715
int test_line_continuation()
76967716
{
76977717

src/unit_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ int test_stringfy(void);
6969
int test_tokens(void);
7070
int test_predefined_macros(void);
7171
int test_utf8(void);
72+
int bug_test(void);
7273
int test_line_continuation(void);
7374
int stringify_test(void);
7475

@@ -136,6 +137,7 @@ g_unit_test_success_count = 0;
136137
test_tokens();
137138
test_predefined_macros();
138139
test_utf8();
140+
bug_test();
139141
test_line_continuation();
140142
stringify_test();
141143
test_get_warning_name();

src/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#pragma once
77

8-
#define CAKE_VERSION "0.10.19"
8+
#define CAKE_VERSION "0.10.20"
99

1010

1111

src/web/cake.js

Lines changed: 393 additions & 393 deletions
Large diffs are not rendered by default.

vc/cprimev3.vcxproj.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
4-
<LocalDebuggerCommandArguments>file.c</LocalDebuggerCommandArguments>
4+
<LocalDebuggerCommandArguments>file.c -E</LocalDebuggerCommandArguments>
55
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
66
<LocalDebuggerWorkingDirectory>$(ProjectDir)../src/</LocalDebuggerWorkingDirectory>
77
</PropertyGroup>

0 commit comments

Comments
 (0)