1Fix compiler warnings for -Wundef
2Author: Henrik Fehlauer <rkflx@lab12.net>
3
4Index: synctex/synctex_parser.c
5===================================================================
6--- synctex.orig/synctex_parser.c
7+++ synctex/synctex_parser.c
8@@ -362,7 +362,7 @@ __synctex_scanner_register_handle_to(NOD
9 #       pragma mark Tree SETGET
10 #   endif
11
12-#if SYNCTEX_DEBUG > 1000
13+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG > 1000
14 #define SYNCTEX_PARAMETER_ASSERT(WHAT) \
15     do { \
16         if (!(WHAT)) { \
17@@ -459,11 +459,11 @@ DEFINE_SYNCTEX_TREE_GETSET(next_hbox)
18 DEFINE_SYNCTEX_TREE_GETSET(arg_sibling)
19 DEFINE_SYNCTEX_TREE_GETSET(target)
20
21-#if SYNCTEX_DEBUG>1000
22+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>1000
23 #   undef SYNCTEX_USE_NODE_COUNT
24 #   define SYNCTEX_USE_NODE_COUNT 1
25 #endif
26-#if SYNCTEX_USE_NODE_COUNT>0
27+#if defined SYNCTEX_USE_NODE_COUNT && SYNCTEX_USE_NODE_COUNT>0
28 #   define SYNCTEX_DECLARE_NODE_COUNT int node_count;
29 #   define SYNCTEX_INIT_NODE_COUNT \
30         do { node_count = 0; } while(synctex_NO)
31@@ -472,7 +472,7 @@ DEFINE_SYNCTEX_TREE_GETSET(target)
32 #   define SYNCTEX_INIT_NODE_COUNT
33 #endif
34
35-#if SYNCTEX_USE_NODE_COUNT>10
36+#if defined SYNCTEX_USE_NODE_COUNT && SYNCTEX_USE_NODE_COUNT>10
37 #   define SYNCTEX_DID_NEW(N)   _synctex_did_new(N)
38 #   define SYNCTEX_WILL_FREE(N) _synctex_will_free(N)
39 #else
40@@ -865,7 +865,7 @@ SYNCTEX_INLINE static void __synctex_sca
41     node->class->scanner->handle = NNN;
42 }
43 #endif
44-#if SYNCTEX_USE_NODE_COUNT>10
45+#if defined SYNCTEX_USE_NODE_COUNT && SYNCTEX_USE_NODE_COUNT>10
46 SYNCTEX_INLINE static void _synctex_did_new(synctex_node_p node) {
47     printf("NODE CREATED # %i, %s, %p\n",
48            (node->class->scanner->node_count)++,
49@@ -2516,7 +2516,7 @@ SYNCTEX_INLINE static synctex_nns_s _syn
50 }
51 static char * _synctex_node_abstract(synctex_node_p node);
52 SYNCTEX_INLINE static synctex_node_p synctex_tree_set_friend(synctex_node_p node,synctex_node_p new_friend) {
53-#if SYNCTEX_DEBUG
54+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG
55     synctex_node_p F = new_friend;
56     while (F) {
57         if (node == F) {
58@@ -2545,7 +2545,7 @@ SYNCTEX_INLINE static synctex_node_p __s
59         i = i%(node->class->scanner->number_of_lists);
60         old = synctex_tree_set_friend(node,(node->class->scanner->lists_of_friends)[i]);
61         (node->class->scanner->lists_of_friends)[i] = node;
62-#if SYNCTEX_DEBUG>500
63+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
64         printf("tl(%i)=>",i);
65         synctex_node_log(node);
66         if (synctex_node_parent_form(node)) {
67@@ -4186,7 +4186,7 @@ static synctex_ns_s __synctex_parse_new_
68     /*  Prepend this input node to the input linked list of the scanner */
69     __synctex_tree_set_sibling(input,scanner->input);/* input has no parent */
70     scanner->input = input;
71-#   if SYNCTEX_VERBOSE
72+#   ifdef SYNCTEX_VERBOSE
73     synctex_node_log(input);
74 #   endif
75     return (synctex_ns_s){input,_synctex_next_line(scanner)};/*  read the line termination character, if any */
76@@ -5083,10 +5083,10 @@ content_loop:
77      */
78     /* forms are everywhere */
79     ns = SYNCTEX_NS_NULL;
80-#if SYNCTEX_VERBOSE
81+#ifdef SYNCTEX_VERBOSE
82     synctex_scanner_set_display_switcher(scanner,-1);
83     printf("NEW CONTENT LOOP\n");
84-#if SYNCTEX_DEBUG>500
85+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
86     synctex_node_display(sheet);
87 #endif
88 #endif
89@@ -5106,7 +5106,7 @@ content_loop:
90                 }
91                 parent = ns.node;
92                 child = _synctex_tree_last(parent);
93-#   if SYNCTEX_VERBOSE
94+#   ifdef SYNCTEX_VERBOSE
95                 synctex_node_log(parent);
96 #   endif
97                 input.node = _synctex_input_register_line(input.node,parent);
98@@ -5124,7 +5124,7 @@ content_loop:
99                 }
100                 child = parent;
101                 parent = _synctex_tree_parent(child);
102-#   if SYNCTEX_VERBOSE
103+#   ifdef SYNCTEX_VERBOSE
104                 synctex_node_log(child);
105 #   endif
106                 if (_synctex_next_line(scanner)<SYNCTEX_STATUS_OK) {
107@@ -5166,7 +5166,7 @@ content_loop:
108                 } else {
109                     _synctex_error("Can't create box bdry record.");
110                 }
111-#   if SYNCTEX_VERBOSE
112+#   ifdef SYNCTEX_VERBOSE
113                 synctex_node_log(parent);
114 #   endif
115                 input.node = _synctex_input_register_line(input.node,parent);
116@@ -5238,7 +5238,7 @@ content_loop:
117                     child = parent;
118                     parent = _synctex_tree_parent(child);
119                     _synctex_make_hbox_contain_box(parent,_synctex_data_box_V(child));
120-#   if SYNCTEX_VERBOSE
121+#   ifdef SYNCTEX_VERBOSE
122                     synctex_node_log(child);
123 #   endif
124                 }
125@@ -5260,7 +5260,7 @@ content_loop:
126                     _synctex_node_set_child(parent,ns.node);
127                 }
128                 child = ns.node;
129-#   if SYNCTEX_VERBOSE
130+#   ifdef SYNCTEX_VERBOSE
131                 synctex_node_log(child);
132 #   endif
133                 input.node = _synctex_input_register_line(input.node,child);
134@@ -5282,7 +5282,7 @@ content_loop:
135                 }
136                 child = ns.node;
137                 _synctex_make_hbox_contain_box(parent,_synctex_data_box(child));
138-#   if SYNCTEX_VERBOSE
139+#   ifdef SYNCTEX_VERBOSE
140                 synctex_node_log(child);
141 #   endif
142                 input.node = _synctex_input_register_line(input.node,child);
143@@ -5305,7 +5305,7 @@ content_loop:
144                     __synctex_node_make_friend_tlc(child);
145                 }
146                 _synctex_make_hbox_contain_box(parent,_synctex_data_xob(child));
147-#   if SYNCTEX_VERBOSE
148+#   ifdef SYNCTEX_VERBOSE
149                 synctex_node_log(child);
150 #   endif
151                 input.node = _synctex_input_register_line(input.node,child);
152@@ -5327,7 +5327,7 @@ content_loop:
153                     __synctex_node_make_friend_tlc(child);
154                 }
155                 _synctex_make_hbox_contain_point(parent,_synctex_data_point(child));
156-#   if SYNCTEX_VERBOSE
157+#   ifdef SYNCTEX_VERBOSE
158                 synctex_node_log(child);
159 #   endif
160                 input.node = _synctex_input_register_line(input.node,child);
161@@ -5351,7 +5351,7 @@ content_loop:
162                 /* Rules are sometimes far too big
163 _synctex_make_hbox_contain_box(parent,_synctex_data_box(child));
164                  */
165-#   if SYNCTEX_VERBOSE
166+#   ifdef SYNCTEX_VERBOSE
167                 synctex_node_log(child);
168 #   endif
169                 input.node = _synctex_input_register_line(input.node,child);
170@@ -5373,7 +5373,7 @@ _synctex_make_hbox_contain_box(parent,_s
171                     __synctex_node_make_friend_tlc(child);
172                 }
173                 _synctex_make_hbox_contain_point(parent,_synctex_data_point(child));
174-#   if SYNCTEX_VERBOSE
175+#   ifdef SYNCTEX_VERBOSE
176                 synctex_node_log(child);
177 #   endif
178                 input.node = _synctex_input_register_line(input.node,child);
179@@ -5383,7 +5383,7 @@ _synctex_make_hbox_contain_box(parent,_s
180 #	ifdef SYNCTEX_NOTHING
181 #       pragma mark + SCAN FORM REF
182 #   endif
183-#if SYNCTEX_DEBUG>500
184+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
185             synctex_node_display(parent);
186             synctex_node_display(child);
187 #endif
188@@ -5406,7 +5406,7 @@ _synctex_make_hbox_contain_box(parent,_s
189                     }
190                     scanner->ref_in_sheet = child;
191                 }
192-#   if SYNCTEX_VERBOSE
193+#   ifdef SYNCTEX_VERBOSE
194                 synctex_node_log(child);
195 #   endif
196                 goto content_loop;
197@@ -5427,7 +5427,7 @@ _synctex_make_hbox_contain_box(parent,_s
198                     __synctex_node_make_friend_tlc(child);
199                 }
200                 _synctex_make_hbox_contain_point(parent,_synctex_data_point(child));
201-#   if SYNCTEX_VERBOSE
202+#   ifdef SYNCTEX_VERBOSE
203                 synctex_node_log(child);
204 #   endif
205                 input.node = _synctex_input_register_line(input.node,child);
206@@ -5536,7 +5536,7 @@ SYNCTEX_INLINE static synctex_ns_s __syn
207                 sibling->line_index = arg_sibling->line_index;
208             }
209 #endif
210-#if SYNCTEX_DEBUG>500
211+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
212             printf("!  Ref replacement:\n");
213             synctex_node_log(ref);
214             synctex_node_display(synctex_node_sibling(ref));
215@@ -5600,7 +5600,7 @@ SYNCTEX_INLINE static synctex_status_t _
216             }
217         }
218         do {
219-#if SYNCTEX_DEBUG>500
220+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
221             printf("POST PROCESSING %s\n",_synctex_node_abstract(proxy));
222             {
223                 int i,j = 0;
224@@ -5619,7 +5619,7 @@ SYNCTEX_INLINE static synctex_status_t _
225             }
226 #endif
227             f(proxy);
228-#if SYNCTEX_DEBUG>500
229+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
230             {
231                 int i,j = 0;
232                 for (i=0;i<proxy->class->scanner->number_of_lists;++i) {
233@@ -5638,7 +5638,7 @@ SYNCTEX_INLINE static synctex_status_t _
234 #endif
235             /*  Side effect: create the hierarchy on the fly */
236             proxy = synctex_node_next(proxy); /*  Change is here */
237-#if SYNCTEX_DEBUG>500
238+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
239             if (proxy) {
240                 int i,j = 0;
241                 for (i=0;i<proxy->class->scanner->number_of_lists;++i) {
242@@ -5670,7 +5670,7 @@ SYNCTEX_INLINE static synctex_status_t _
243 SYNCTEX_INLINE static synctex_status_t _synctex_post_process(synctex_scanner_p scanner) {
244     synctex_status_t status = SYNCTEX_STATUS_OK;
245     synctex_ns_s ns = {NULL,SYNCTEX_STATUS_NOT_OK};
246-#if SYNCTEX_DEBUG>500
247+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
248     printf("!  entering _synctex_post_process.\n");
249     synctex_node_display(scanner->sheet);
250     synctex_node_display(scanner->form);
251@@ -5681,7 +5681,7 @@ SYNCTEX_INLINE static synctex_status_t _
252     if (ns.status<status) {
253         status = ns.status;
254     }
255-#if SYNCTEX_DEBUG>500
256+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
257     printf("!  ref replaced in form _synctex_post_process.\n");
258     synctex_node_display(scanner->form);
259 #endif
260@@ -5703,7 +5703,7 @@ SYNCTEX_INLINE static synctex_status_t _
261         status = ns.status;
262     }
263     scanner->ref_in_sheet = NULL;
264-#if SYNCTEX_DEBUG>500
265+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
266     printf("!  ref replaced in sheet _synctex_post_process.\n");
267     synctex_node_display(scanner->sheet);
268 #endif
269@@ -5725,7 +5725,7 @@ SYNCTEX_INLINE static synctex_status_t _
270         }
271     }
272 #endif
273-#if SYNCTEX_DEBUG>10000
274+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>10000
275     {
276         int i;
277         for (i=0;i<scanner->number_of_lists;++i) {
278@@ -5746,7 +5746,7 @@ SYNCTEX_INLINE static synctex_status_t _
279     if (ns.status<status) {
280         status = ns.status;
281     }
282-#if SYNCTEX_DEBUG>500
283+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
284     printf("!  exiting _synctex_post_process.\n");
285     synctex_node_display(scanner->sheet);
286     synctex_node_display(scanner->form);
287@@ -5861,7 +5861,7 @@ int synctex_scanner_free(synctex_scanner
288         synctex_iterator_free(scanner->iterator);
289         free(scanner->output_fmt);
290         free(scanner->lists_of_friends);
291-#if SYNCTEX_USE_NODE_COUNT>0
292+#if defined SYNCTEX_USE_NODE_COUNT && SYNCTEX_USE_NODE_COUNT>0
293         node_count = scanner->node_count;
294 #endif
295         free(scanner);
296@@ -5919,7 +5919,7 @@ synctex_scanner_p synctex_scanner_parse(
297     if (status<SYNCTEX_STATUS_OK) {
298         _synctex_error("Bad postamble. Ignored\n");
299     }
300-#if SYNCTEX_DEBUG>500
301+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
302     synctex_scanner_set_display_switcher(scanner, 100);
303     synctex_node_display(scanner->sheet);
304     synctex_node_display(scanner->form);
305@@ -8048,7 +8048,7 @@ static synctex_nd_s __synctex_closest_de
306                SYNCTEX_LINEINDEX(node));
307 #endif
308         do {
309-#if SYNCTEX_DEBUG>500
310+#if defined SYNCTEX_DEBUG && SYNCTEX_DEBUG>500
311             synctex_node_display(child);
312 #endif
313             synctex_nd_s nd = SYNCTEX_ND_0;
314Index: synctex/synctex_parser_utils.c
315===================================================================
316--- synctex.orig/synctex_parser_utils.c
317+++ synctex/synctex_parser_utils.c
318@@ -129,7 +129,7 @@ int _synctex_log(int level, const char *
319 		OutputDebugStringA("\n");
320 		free(buff);
321 	}
322-#   elif SYNCTEX_USE_SYSLOG
323+#   elif defined SYNCTEX_USE_SYSLOG
324     char * buffer1 = NULL;
325     char * buffer2 = NULL;
326     openlog ("SyncTeX", LOG_CONS | LOG_PID | LOG_PERROR | LOG_NDELAY, LOG_LOCAL0);
327