about summary refs log tree commit diff stats
path: root/main.c
blob: 27e2627fd1d15a9dfa48ba7425b68ed90b6bf8db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weigh
/*
 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
 * See LICENSE file for license details.
 */

#include "dwm.h"

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <X11/cursorfont.h>
#include <X11/Xatom.h>
#include <X11/Xproto.h>


/* static */

static Bool otherwm;
static int (*xerrorxlib)(Display *, XErrorEvent *);

static void
cleanup()
{
	while(sel) {
		resize(sel, True);
		unmanage(sel);
	}
	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
}

static void
scan()
{
	unsigned int i, num;
	Window *wins;
	XWindowAttributes wa;
	Window d1, d2;

	if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
		for(i = 0; i < num; i++) {
			if(!XGetWindowAttributes(dpy, wins[i], &wa))
				continue;
			if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
				continue;
			if(wa.map_state == IsViewable)
				manage(wins[i], &wa);
		}
	}
	if(wins)
		XFree(wins);
}

static int
win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
{
	Atom real;
	int format;
	unsigned long res, extra;
	int status;

	status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format,
			&res, &extra, prop);

	if(status != Success || *prop == 0) {
		return 0;
	}
	if(res == 0) {
		free((void *) *prop);
	}
	return res;
}

/*
 * Startup Error handler to check if another window manager
 * is already running.
 */
static int
xerrorstart(Display *dsply, XErrorEvent *ee)
{
	otherwm = True;
	return -1;
}

/* extern */

char stext[1024];
int tsel = Tdev; /* default tag */
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
Atom wmatom[WMLast], netatom[NetLast];
Bool running = True;
Bool issel = True;
Client *clients = NULL;
Client *sel = NULL;
Cursor cursor[CurLast];
Display *dpy;
DC dc = {0};
Window root, barwin;

int
getproto(Window w)
{
	unsigned char *protocols;
	long res;
	int protos = 0;
	int i;

	res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L, &protocols);
	if(res <= 0) {
		return protos;
	}
	for(i = 0; i < res; i++) {
		if(protocols[i] == wmatom[WMDelete])
			protos |= WM_PROTOCOL_DELWIN;
	}
	free((char *) protocols);
	return protos;
}

void
sendevent(Window w, Atom a, long value)
{
	XEvent e;

	e.type = ClientMessage;
	e.xclient.window = w;
	e.xclient.message_type = a;
	e.xclient.format = 32;
	e.xclient.data.l[0] = value;
	e.xclient.data.l[1] = CurrentTime;
	XSendEvent(dpy, w, False, NoEventMask, &e);
	XSync(dpy, False);
}

void
quit(Arg *arg)
{
	running = False;
}

/*
 * There's no way to check accesses to destroyed windows, thus those cases are
 * ignored (especially on UnmapNotify's).  Other types of errors call Xlibs
 * default error handler, which calls exit().
 */
int
xerror(Display *dpy, XErrorEvent *ee)
{
	if(ee->error_code == BadWindow
			|| (ee->request_code == X_SetInputFocus
				&& ee->error_code == BadMatch)
			|| (ee->request_code == X_PolyText8
				&& ee->error_code == BadDrawable)
			|| (ee->request_code == X_PolyFillRectangle
				&& ee->error_code == BadDrawable)
			|| (ee->request_code == X_PolySegment
				&& ee->error_code == BadDrawable)
			|| (ee->request_code == X_ConfigureWindow
				&& ee->error_code == BadMatch)
			|| (ee->request_code == X_GrabKey
				&& ee->error_code == BadAccess))
		return 0;
	fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
			ee->request_code, ee->error_code);
	return xerrorxlib(dpy, ee); /* may call exit() */
}

int
main(int argc, char *argv[])
{
	int i, n;
	fd_set rd;
	XSetWindowAttributes wa;
	unsigned int mask;
	Bool readstdin = True;
	Window w;
	XEvent ev;

	for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
		switch (argv[i][1]) {
		case 'v':
			fprintf(stdout, "%s",
					"dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n");
			exit(0);
			break;
		default:
			eprint("usage: dwm [-v]\n");
			break;
		}
	}

	dpy = XOpenDisplay(0);
	if(!dpy)
		eprint("dwm: cannot connect X server\n");

	screen = DefaultScreen(dpy);
	root = RootWindow(dpy, screen);

	/* check if another WM is already running */
	otherwm = False;
	XSetErrorHandler(xerrorstart);
	/* this causes an error if some other WM is running */
	XSelectInput(dpy, root, SubstructureRedirectMask);
	XSync(dpy, False);

	if(otherwm)
		eprint("dwm: another window manager is already running\n");

	XSetErrorHandler(NULL);
	xerrorxlib = XSetErrorHandler(xerror);

	/* init atoms */
	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
	netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
	XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
			PropModeReplace, (unsigned char *) netatom, NetLast);

	/* init cursors */
	cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);

	grabkeys();

	/* style */
	dc.bg = getcolor(BGCOLOR);
	dc.fg = getcolor(FGCOLOR);
	dc.border = getcolor(BORDERCOLOR);
	setfont(FONT);

	sx = sy = 0;
	sw = DisplayWidth(dpy, screen);
	sh = DisplayHeight(dpy, screen);
	mw = (sw * MASTERW) / 100;

	wa.override_redirect = 1;
	wa.background_pixmap = ParentRelative;
	wa.event_mask = ButtonPressMask | ExposureMask;

	bx = by = 0;
	bw = sw;
	dc.h = bh = dc.font.height + 4;
	barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
			CopyFromParent, DefaultVisual(dpy, screen),
			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
	XDefineCursor(dpy, barwin, cursor[CurNormal]);
	XMapRaised(dpy, barwin);

	dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
	dc.gc = XCreateGC(dpy, root, 0, 0);
	drawstatus();

	issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);

	wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
					| LeaveWindowMask;
	wa.cursor = cursor[CurNormal];

	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);

	strcpy(stext, "dwm-"VERSION);
	scan();

	/* main event loop, reads status text from stdin as well */
Mainloop:
	while(running) {
		FD_ZERO(&rd);
		if(readstdin)
			FD_SET(STDIN_FILENO, &rd);
		FD_SET(ConnectionNumber(dpy), &rd);

		i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0);
		if(i == -1 && errno == EINTR)
			continue;
		if(i < 0)
			eprint("select failed\n");
		else if(i > 0) {
			if(FD_ISSET(ConnectionNumber(dpy), &rd)) {
				while(XPending(dpy)) {
					XNextEvent(dpy, &ev);
					if(handler[ev.type])
						(handler[ev.type])(&ev); /* call handler */
				}
			}
			if(readstdin && FD_ISSET(STDIN_FILENO, &rd)) {
				i = n = 0;
				for(;;) {
					if((i = getchar()) == EOF) {
						/* broken pipe/end of producer */
						readstdin = False;
						strcpy(stext, "broken pipe");
						goto Mainloop;
					}
					if(i == '\n' || n >= sizeof(stext) - 1)
						break;
					stext[n++] = i;
				}
				stext[n] = 0;
				drawstatus();
			}
		}
	}

	cleanup();
	XCloseDisplay(dpy);

	return 0;
}
/span> in &gt;&gt; std::noskipws<span class="Delimiter">;</span> <span class="Identifier">return</span> parse_property_list<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">:(scenario type_error1)</span> <span class="Special">% Hide_errors = true;</span> type foo <span class="traceContains">+error: incomplete 'type' statement 'type foo'</span> <span class="Delimiter">:(scenario type_error2)</span> <span class="Special">% Hide_errors = true;</span> type foo = <span class="traceContains">+error: incomplete 'type' statement 'type foo ='</span> <span class="Delimiter">:(scenario type_error3)</span> <span class="Special">% Hide_errors = true;</span> type foo bar baz <span class="traceContains">+error: 'type' statements must be of the form 'type &lt;new type name&gt; = &lt;type expression&gt;' but got 'type foo bar'</span> <span class="Delimiter">:(scenario type_conflict_error)</span> <span class="Special">% Hide_errors = true;</span> type foo = bar type foo = baz <span class="traceContains">+error: 'type' conflict: 'foo' defined as both 'bar' and 'baz'</span> <span class="Delimiter">:(scenario type_abbreviation_for_compound)</span> type foo = address:number def main [ <span class="Normal">a</span>:foo<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+transform: product type after expanding abbreviations: (&quot;address&quot; &quot;number&quot;)</span> <span class="Comment">//: cleaning up type abbreviations between tests and before exiting</span> <span class="Delimiter">:(before &quot;End save_snapshots&quot;)</span> Type_abbreviations_snapshot = Type_abbreviations<span class="Delimiter">;</span> <span class="Delimiter">:(before &quot;End restore_snapshots&quot;)</span> restore_type_abbreviations<span class="Delimiter">();</span> <span class="Delimiter">:(before &quot;End One-time Setup&quot;)</span> atexit<span class="Delimiter">(</span>clear_type_abbreviations<span class="Delimiter">);</span> <span class="Delimiter">:(code)</span> <span class="Normal">void</span> restore_type_abbreviations<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Normal">for</span> <span class="Delimiter">(</span>map&lt;string<span class="Delimiter">,</span> type_tree*&gt;::iterator p = Type_abbreviations<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Type_abbreviations<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Type_abbreviations_snapshot<span class="Delimiter">,</span> p<span class="Delimiter">-&gt;</span>first<span class="Delimiter">))</span> <span class="Normal">delete</span> p<span class="Delimiter">-&gt;</span>second<span class="Delimiter">;</span> <span class="Delimiter">}</span> Type_abbreviations<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> Type_abbreviations = Type_abbreviations_snapshot<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">void</span> clear_type_abbreviations<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Normal">for</span> <span class="Delimiter">(</span>map&lt;string<span class="Delimiter">,</span> type_tree*&gt;::iterator p = Type_abbreviations<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Type_abbreviations<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Normal">delete</span> p<span class="Delimiter">-&gt;</span>second<span class="Delimiter">;</span> Type_abbreviations<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="SalientComment">//:: A few default abbreviations.</span> <span class="Delimiter">:(before &quot;End Mu Types Initialization&quot;)</span> put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">&quot;&amp;&quot;</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">&quot;address&quot;</span><span class="Delimiter">));</span> put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">&quot;@&quot;</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">&quot;array&quot;</span><span class="Delimiter">));</span> put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">&quot;num&quot;</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">&quot;number&quot;</span><span class="Delimiter">));</span> put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">&quot;bool&quot;</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">&quot;boolean&quot;</span><span class="Delimiter">));</span> put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">&quot;char&quot;</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">&quot;character&quot;</span><span class="Delimiter">));</span> <span class="Delimiter">:(scenario use_type_abbreviations_when_declaring_type_abbreviations)</span> type foo = &amp;:num def main [ <span class="Normal">a</span>:foo<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+transform: product type after expanding abbreviations: (&quot;address&quot; &quot;number&quot;)</span> <span class="SalientComment">//:: Expand type aliases before running.</span> <span class="Comment">//: We'll do this in a transform so that we don't need to define abbreviations</span> <span class="Comment">//: before we use them.</span> <span class="Delimiter">:(scenario abbreviations_for_address_and_array)</span> def main [ f <span class="Constant">1</span>:&amp;:number <span class="Comment"># abbreviation for 'address:number'</span> f <span class="Constant">2</span>:@:number <span class="Comment"># abbreviation for 'array:number'</span> f <span class="Constant">3</span>:&amp;:@:number <span class="Comment"># combining '&amp;' and '@'</span> f <span class="Constant">4</span>:&amp;:&amp;:@:&amp;:@:number <span class="Comment"># ..any number of times</span> f <span class="Delimiter">{</span><span class="Constant">5</span>: <span class="Delimiter">(</span>array <span class="Delimiter">(</span>&amp; number<span class="Delimiter">)</span> <span class="Constant">3</span><span class="Delimiter">)}</span> <span class="Comment"># support for dilated reagents and more complex parse trees</span> ] def f [ ] <span class="traceContains">+transform: --- expand type abbreviations in recipe 'main'</span> <span class="traceContains">+transform: ingredient type after expanding abbreviations: (&quot;address&quot; &quot;number&quot;)</span> <span class="traceContains">+transform: ingredient type after expanding abbreviations: (&quot;array&quot; &quot;number&quot;)</span> <span class="traceContains">+transform: ingredient type after expanding abbreviations: (&quot;address&quot; &quot;array&quot; &quot;number&quot;)</span> <span class="traceContains">+transform: ingredient type after expanding abbreviations: (&quot;address&quot; &quot;address&quot; &quot;array&quot; &quot;address&quot; &quot;array&quot; &quot;number&quot;)</span> <span class="traceContains">+transform: ingredient type after expanding abbreviations: (&quot;array&quot; (&quot;address&quot; &quot;number&quot;) &quot;3&quot;)</span> <span class="Delimiter">:(before &quot;Transform.push_back(update_instruction_operations)&quot;)</span> Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>expand_type_abbreviations<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> <span class="Comment">// Begin Type Modifying Transforms</span> <span class="Comment">// End Type Modifying Transforms</span> <span class="Delimiter">:(code)</span> <span class="Normal">void</span> expand_type_abbreviations<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> recipe&amp; caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">&quot;transform&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;--- expand type abbreviations in recipe '&quot;</span> &lt;&lt; caller<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot;'&quot;</span> &lt;&lt; end<span class="Delimiter">();</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction&amp; inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">&quot;transform&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;instruction '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>original_string &lt;&lt; end<span class="Delimiter">();</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> expand_type_abbreviations<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">&quot;transform&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;ingredient type after expanding abbreviations: &quot;</span> &lt;&lt; names_to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> &lt;&lt; end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> expand_type_abbreviations<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">&quot;transform&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;product type after expanding abbreviations: &quot;</span> &lt;&lt; names_to_string<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>type<span class="Delimiter">)</span> &lt;&lt; end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Comment">// End Expand Type Abbreviations(caller)</span> <span class="Delimiter">}</span> <span class="Normal">void</span> expand_type_abbreviations<span class="Delimiter">(</span>type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">-&gt;</span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> expand_type_abbreviations<span class="Delimiter">(</span>type<span class="Delimiter">-&gt;</span>left<span class="Delimiter">);</span> expand_type_abbreviations<span class="Delimiter">(</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> type<span class="Delimiter">-&gt;</span>name<span class="Delimiter">))</span> *type = type_tree<span class="Delimiter">(</span>*get<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> type<span class="Delimiter">-&gt;</span>name<span class="Delimiter">));</span> <span class="Delimiter">}</span> </pre> </body> </html> <!-- vim: set foldmethod=manual : -->