1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1986-2009 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
19 ***********************************************************************/
25 * common preprocessor line sync handler
31 ppline(int line
, char* file
)
36 if (pp
.flags
& PP_lineignore
)
38 pp
.flags
&= ~PP_lineignore
;
39 if (!(pp
.flags
& PP_linetype
) || *pp
.lineid
)
42 file
= error_info
.file
;
45 type
[1] = PP_sync_ignore
;
47 else if (file
!= pp
.lastfile
)
51 type
[1] = ((pp
.flags
& PP_linetype
) && !*pp
.lineid
&& pp
.lastfile
) ? (line
<= 1 ? (file
== pp
.firstfile
? PP_sync
: PP_sync_push
) : PP_sync_pop
) : PP_sync
;
56 if (!(pp
.flags
& PP_linefile
))
60 if (!(pp
.flags
& PP_linetype
) || *pp
.lineid
|| type
[1] == PP_sync
)
65 if ((pp
.flags
& (PP_hosted
|PP_linehosted
)) == (PP_hosted
|PP_linehosted
))
68 type
[3] = PP_sync_hosted
;
75 * some front ends can't handle two line syncs in a row
78 if (pp
.pending
== pppendout() || pplastout() != '\n')
81 ppprintf("#%s %d \"%s\"%s\n", pp
.lineid
, line
, (pp
.flags
& PP_linebase
) && (s
= strrchr(file
, '/')) ? s
+ 1 : file
, type
);
83 ppprintf("#%s %d\n", pp
.lineid
, line
);
85 pp
.pending
= pppendout();