8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libpp / common / ppline.c
blob5bd0014bde002270b81bceae39a2dccff1c0bfc3
1 /***********************************************************************
2 * *
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 *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * *
19 ***********************************************************************/
20 #pragma prototyped
22 * Glenn Fowler
23 * AT&T Research
25 * common preprocessor line sync handler
28 #include "pplib.h"
30 void
31 ppline(int line, char* file)
33 char* s;
34 static char type[5];
36 if (pp.flags & PP_lineignore)
38 pp.flags &= ~PP_lineignore;
39 if (!(pp.flags & PP_linetype) || *pp.lineid)
41 ppline(1, file);
42 file = error_info.file;
44 else
45 type[1] = PP_sync_ignore;
47 else if (file != pp.lastfile)
49 if (!pp.firstfile)
50 pp.firstfile = file;
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;
52 pp.lastfile = file;
54 else
56 if (!(pp.flags & PP_linefile))
57 file = 0;
58 type[1] = PP_sync;
60 if (!(pp.flags & PP_linetype) || *pp.lineid || type[1] == PP_sync)
61 type[0] = 0;
62 else
64 type[0] = ' ';
65 if ((pp.flags & (PP_hosted|PP_linehosted)) == (PP_hosted|PP_linehosted))
67 type[2] = ' ';
68 type[3] = PP_sync_hosted;
70 else
71 type[2] = 0;
75 * some front ends can't handle two line syncs in a row
78 if (pp.pending == pppendout() || pplastout() != '\n')
79 ppputchar('\n');
80 if (file)
81 ppprintf("#%s %d \"%s\"%s\n", pp.lineid, line, (pp.flags & PP_linebase) && (s = strrchr(file, '/')) ? s + 1 : file, type);
82 else
83 ppprintf("#%s %d\n", pp.lineid, line);
84 if (!pp.macref)
85 pp.pending = pppendout();