malcolmwallace / cpphs

The C pre-processor, implemented in Haskell.
2 stars 0 forks source link

Line splicing should be applied everywhere #21

Open gilgamec opened 5 years ago

gilgamec commented 5 years ago

According to the C99 spec (section 5.1.1.2, "Translation phases"), line splicing -- gluing together lines which end with a backslash -- should be performed for every line ending in a backslash. cpphs, however, only seems to do this for lines containing cpp commands, i.e. lines starting with a #:

% cat foo.c
#define X  123\
456

int x1 = X;

int x2 = 123\
456;
% cpp foo.c
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "foo.c"

int x1 = 123456;

int x2 = 123456;
% cpphs foo.c
#line 1 "foo.c"

int x1 = 123456;

int x2 = 123\
456;