Commit e037f518624cdd4c694b2b696ae314382b03ac0b

Ran Benita 2012-07-21T14:53:49

action: use new log functions Signed-off-by: Ran Benita <ran234@gmail.com>

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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
diff --git a/src/utils.h b/src/utils.h
index 7d4e612..5e4000a 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -37,7 +37,6 @@
 #define UNCONSTIFY(const_ptr)  ((void *) (uintptr_t) (const_ptr))
 
 #define uDupString(s)          ((s) ? strdup(s) : NULL)
-#define uStringText(s)         ((s) == NULL ? "<NullString>" : (s))
 #define uStrCasePrefix(s1, s2) (strncasecmp((s1), (s2), strlen(s1)) == 0)
 
 /* Compiler Attributes */
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index badd05a..d648384 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -166,46 +166,54 @@ fieldText(unsigned field)
 /***====================================================================***/
 
 static inline bool
-ReportMismatch(unsigned action, unsigned field, const char *type)
+ReportMismatch(struct xkb_keymap *keymap, unsigned action, unsigned field,
+               const char *type)
 {
-    ERROR("Value of %s field must be of type %s\n", fieldText(field), type);
-    ACTION("Action %s definition ignored\n", XkbcActionTypeText(action));
+    log_err(keymap->ctx,
+            "Value of %s field must be of type %s; "
+            "Action %s definition ignored\n",
+            fieldText(field), type, XkbcActionTypeText(action));
     return false;
 }
 
 static inline bool
-ReportIllegal(unsigned action, unsigned field)
+ReportIllegal(struct xkb_keymap *keymap, unsigned action, unsigned field)
 {
-    ERROR("Field %s is not defined for an action of type %s\n",
-          fieldText(field), XkbcActionTypeText(action));
-    ACTION("Action definition ignored\n");
+    log_err(keymap->ctx,
+            "Field %s is not defined for an action of type %s; "
+            "Action definition ignored\n",
+            fieldText(field), XkbcActionTypeText(action));
     return false;
 }
 
 static inline bool
-ReportActionNotArray(unsigned action, unsigned field)
+ReportActionNotArray(struct xkb_keymap *keymap, unsigned action,
+                     unsigned field)
 {
-    ERROR("The %s field in the %s action is not an array\n",
-          fieldText(field), XkbcActionTypeText(action));
-    ACTION("Action definition ignored\n");
+    log_err(keymap->ctx,
+            "The %s field in the %s action is not an array; "
+            "Action definition ignored\n",
+            fieldText(field), XkbcActionTypeText(action));
     return false;
 }
 
 static inline bool
-ReportNotFound(unsigned action, unsigned field, const char *what,
-               const char *bad)
+ReportNotFound(struct xkb_keymap *keymap, unsigned action, unsigned field,
+               const char *what, const char *bad)
 {
-    ERROR("%s named %s not found\n", what, bad);
-    ACTION("Ignoring the %s field of an %s action\n", fieldText(field),
-           XkbcActionTypeText(action));
+    log_err(keymap->ctx,
+            "%s named %s not found; "
+            "Ignoring the %s field of an %s action\n",
+            what, bad, fieldText(field), XkbcActionTypeText(action));
     return false;
 }
 
 static bool
 HandleNoAction(struct xkb_keymap *keymap, struct xkb_any_action *action,
                unsigned field, ExprDef *array_ndx, ExprDef *value)
+
 {
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
@@ -222,7 +230,7 @@ CheckLatchLockFlags(struct xkb_keymap *keymap, unsigned action,
     else
         return false;           /* WSGO! */
     if (!ExprResolveBoolean(keymap->ctx, value, &result))
-        return ReportMismatch(action, field, "boolean");
+        return ReportMismatch(keymap, action, field, "boolean");
     if (result.uval)
         *flags_inout |= tmp;
     else
@@ -248,7 +256,7 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
         }
     }
     if (!ExprResolveVModMask(value, &rtrn, keymap))
-        return ReportMismatch(action, F_Modifiers, "modifier mask");
+        return ReportMismatch(keymap, action, F_Modifiers, "modifier mask");
     *mods_rtrn = rtrn.uval;
     *flags_inout &= ~XkbSA_UseModMapMods;
     return true;
@@ -268,7 +276,7 @@ HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
         case F_ClearLocks:
         case F_LatchToLock:
         case F_Modifiers:
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         }
     }
     switch (field) {
@@ -291,7 +299,7 @@ HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
         }
         return false;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
@@ -303,7 +311,7 @@ HandleLockMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
 
     act = (struct xkb_mod_action *) action;
     if ((array_ndx != NULL) && (field == F_Modifiers))
-        return ReportActionNotArray(action->type, field);
+        return ReportActionNotArray(keymap, action->type, field);
     switch (field) {
     case F_Modifiers:
         t1 = act->flags;
@@ -315,7 +323,7 @@ HandleLockMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
         }
         return false;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
@@ -336,7 +344,8 @@ CheckGroupField(struct xkb_keymap *keymap, unsigned action,
     }
 
     if (!ExprResolveGroup(keymap->ctx, spec, &rtrn))
-        return ReportMismatch(action, F_Group, "integer (range 1..8)");
+        return ReportMismatch(keymap, action, F_Group,
+                              "integer (range 1..8)");
     if (value->op == OpNegate)
         *grp_rtrn = -rtrn.ival;
     else if (value->op == OpUnaryPlus)
@@ -361,7 +370,7 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
         case F_ClearLocks:
         case F_LatchToLock:
         case F_Group:
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         }
     }
     switch (field) {
@@ -383,7 +392,7 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
         }
         return false;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
@@ -396,7 +405,7 @@ HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
 
     act = (struct xkb_group_action *) action;
     if ((array_ndx != NULL) && (field == F_Group))
-        return ReportActionNotArray(action->type, field);
+        return ReportActionNotArray(keymap, action->type, field);
     if (field == F_Group) {
         t1 = act->flags;
         if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
@@ -406,7 +415,7 @@ HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
         }
         return false;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
@@ -419,7 +428,7 @@ HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action,
 
     act = (struct xkb_pointer_action *) action;
     if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
-        return ReportActionNotArray(action->type, field);
+        return ReportActionNotArray(keymap, action->type, field);
 
     if ((field == F_X) || (field == F_Y)) {
         if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
@@ -427,7 +436,7 @@ HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action,
         else
             absolute = true;
         if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
-            return ReportMismatch(action->type, field, "integer");
+            return ReportMismatch(keymap, action->type, field, "integer");
         if (field == F_X) {
             if (absolute)
                 act->flags |= XkbSA_MoveAbsoluteX;
@@ -442,13 +451,13 @@ HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action,
     }
     else if (field == F_Accel) {
         if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
-            return ReportMismatch(action->type, field, "boolean");
+            return ReportMismatch(keymap, action->type, field, "boolean");
         if (rtrn.uval)
             act->flags &= ~XkbSA_NoAcceleration;
         else
             act->flags |= XkbSA_NoAcceleration;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static const LookupEntry lockWhich[] = {
@@ -469,13 +478,14 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
     act = (struct xkb_pointer_button_action *) action;
     if (field == F_Button) {
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveButton(keymap->ctx, value, &rtrn))
-            return ReportMismatch(action->type, field,
+            return ReportMismatch(keymap, action->type, field,
                                   "integer (range 1..5)");
         if ((rtrn.ival < 0) || (rtrn.ival > 5)) {
-            ERROR("Button must specify default or be in the range 1..5\n");
-            ACTION("Illegal button value %d ignored\n", rtrn.ival);
+            log_err(keymap->ctx,
+                    "Button must specify default or be in the range 1..5; "
+                    "Illegal button value %d ignored\n", rtrn.ival);
             return false;
         }
         act->button = rtrn.ival;
@@ -483,27 +493,29 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
     }
     else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect)) {
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
-            return ReportMismatch(action->type, field, "lock or unlock");
+            return ReportMismatch(keymap, action->type, field,
+                                  "lock or unlock");
         act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
         act->flags |= rtrn.ival;
         return true;
     }
     else if (field == F_Count) {
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveButton(keymap->ctx, value, &rtrn))
-            return ReportMismatch(action->type, field, "integer");
+            return ReportMismatch(keymap, action->type, field, "integer");
         if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
-            ERROR("The count field must have a value in the range 0..255\n");
-            ACTION("Illegal count %d ignored\n", rtrn.ival);
+            log_err(keymap->ctx,
+                    "The count field must have a value in the range 0..255; "
+                    "Illegal count %d ignored\n", rtrn.ival);
             return false;
         }
         act->count = rtrn.ival;
         return true;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static const LookupEntry ptrDflts[] = {
@@ -523,16 +535,17 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
     act = (struct xkb_pointer_default_action *) action;
     if (field == F_Affect) {
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveEnum(keymap->ctx, value, &rtrn, ptrDflts))
-            return ReportMismatch(action->type, field, "pointer component");
+            return ReportMismatch(keymap, action->type, field,
+                                  "pointer component");
         act->affect = rtrn.uval;
         return true;
     }
     else if ((field == F_Button) || (field == F_Value)) {
         ExprDef *btn;
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
             act->flags &= ~XkbSA_DfltBtnAbsolute;
             btn = value->value.child;
@@ -543,16 +556,18 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
         }
 
         if (!ExprResolveButton(keymap->ctx, btn, &rtrn))
-            return ReportMismatch(action->type, field,
+            return ReportMismatch(keymap, action->type, field,
                                   "integer (range 1..5)");
         if ((rtrn.ival < 0) || (rtrn.ival > 5)) {
-            ERROR("New default button value must be in the range 1..5\n");
-            ACTION("Illegal default button value %d ignored\n", rtrn.ival);
+            log_err(keymap->ctx,
+                    "New default button value must be in the range 1..5; "
+                    "Illegal default button value %d ignored\n", rtrn.ival);
             return false;
         }
         if (rtrn.ival == 0) {
-            ERROR("Cannot set default pointer button to \"default\"\n");
-            ACTION("Illegal default button setting ignored\n");
+            log_err(keymap->ctx,
+                    "Cannot set default pointer button to \"default\"; "
+                    "Illegal default button setting ignored\n");
             return false;
         }
         if (value->op == OpNegate)
@@ -561,7 +576,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
             act->value = rtrn.ival;
         return true;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static const LookupEntry isoNames[] = {
@@ -591,7 +606,7 @@ HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
     switch (field) {
     case F_Modifiers:
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         flags = act->flags;
         if (CheckModifierField(keymap, action->type, value, &flags, &mods)) {
             act->flags = flags & (~XkbSA_ISODfltIsGroup);
@@ -603,7 +618,7 @@ HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
 
     case F_Group:
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         flags = act->flags;
         if (CheckGroupField(keymap, action->type, value, &flags, &group)) {
             act->flags = flags | XkbSA_ISODfltIsGroup;
@@ -614,13 +629,14 @@ HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
 
     case F_Affect:
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveMask(keymap->ctx, value, &rtrn, isoNames))
-            return ReportMismatch(action->type, field, "keyboard component");
+            return ReportMismatch(keymap, action->type, field,
+                                  "keyboard component");
         act->affect = (~rtrn.uval) & XkbSA_ISOAffectMask;
         return true;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
@@ -634,7 +650,7 @@ HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action,
     if (field == F_Screen) {
         ExprDef *scrn;
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
             act->flags &= ~XkbSA_SwitchAbsolute;
             scrn = value->value.child;
@@ -645,10 +661,12 @@ HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action,
         }
 
         if (!ExprResolveInteger(keymap->ctx, scrn, &rtrn))
-            return ReportMismatch(action->type, field, "integer (0..255)");
+            return ReportMismatch(keymap, action->type, field,
+                                  "integer (0..255)");
         if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
-            ERROR("Screen index must be in the range 1..255\n");
-            ACTION("Illegal screen value %d ignored\n", rtrn.ival);
+            log_err(keymap->ctx,
+                    "Screen index must be in the range 1..255; "
+                    "Illegal screen value %d ignored\n", rtrn.ival);
             return false;
         }
         if (value->op == OpNegate)
@@ -659,16 +677,16 @@ HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action,
     }
     else if (field == F_Same) {
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
-            return ReportMismatch(action->type, field, "boolean");
+            return ReportMismatch(keymap, action->type, field, "boolean");
         if (rtrn.uval)
             act->flags &= ~XkbSA_SwitchApplication;
         else
             act->flags |= XkbSA_SwitchApplication;
         return true;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 const LookupEntry ctrlNames[] = {
@@ -704,13 +722,14 @@ HandleSetLockControls(struct xkb_keymap *keymap,
     act = (struct xkb_controls_action *) action;
     if (field == F_Controls) {
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
-            return ReportMismatch(action->type, field, "controls mask");
+            return ReportMismatch(keymap, action->type, field,
+                                  "controls mask");
         act->ctrls = rtrn.uval;
         return true;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static const LookupEntry evNames[] = {
@@ -734,9 +753,10 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
     switch (field) {
     case F_Report:
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveMask(keymap->ctx, value, &rtrn, evNames))
-            return ReportMismatch(action->type, field, "key event mask");
+            return ReportMismatch(keymap, action->type, field,
+                                  "key event mask");
         act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
         act->flags =
             rtrn.uval & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
@@ -744,9 +764,9 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
 
     case F_GenKeyEvent:
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
-            return ReportMismatch(action->type, field, "boolean");
+            return ReportMismatch(keymap, action->type, field, "boolean");
         if (rtrn.uval)
             act->flags |= XkbSA_MessageGenKeyEvent;
         else
@@ -756,12 +776,13 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
     case F_Data:
         if (array_ndx == NULL) {
             if (!ExprResolveString(keymap->ctx, value, &rtrn))
-                return ReportMismatch(action->type, field, "string");
+                return ReportMismatch(keymap, action->type, field, "string");
             else {
                 int len = strlen(rtrn.str);
                 if ((len < 1) || (len > 6)) {
-                    WARN("An action message can hold only 6 bytes\n");
-                    ACTION("Extra %d bytes ignored\n", len - 6);
+                    log_warn(keymap->ctx,
+                             "An action message can hold only 6 bytes; "
+                             "Extra %d bytes ignored\n", len - 6);
                 }
                 strncpy((char *) act->message, rtrn.str, 6);
             }
@@ -770,28 +791,31 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
         else {
             unsigned ndx;
             if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) {
-                ERROR("Array subscript must be integer\n");
-                ACTION("Illegal subscript ignored\n");
+                log_err(keymap->ctx,
+                        "Array subscript must be integer; "
+                        "Illegal subscript ignored\n");
                 return false;
             }
             ndx = rtrn.uval;
             if (ndx > 5) {
-                ERROR("An action message is at most 6 bytes long\n");
-                ACTION("Attempt to use data[%d] ignored\n", ndx);
+                log_err(keymap->ctx,
+                        "An action message is at most 6 bytes long; "
+                        "Attempt to use data[%d] ignored\n", ndx);
                 return false;
             }
             if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
-                return ReportMismatch(action->type, field, "integer");
+                return ReportMismatch(keymap, action->type, field, "integer");
             if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
-                ERROR("Message data must be in the range 0..255\n");
-                ACTION("Illegal datum %d ignored\n", rtrn.ival);
+                log_err(keymap->ctx,
+                        "Message data must be in the range 0..255; "
+                        "Illegal datum %d ignored\n", rtrn.ival);
                 return false;
             }
             act->message[ndx] = rtrn.uval;
         }
         return true;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
@@ -805,18 +829,18 @@ HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action,
     unsigned long tmp;
 
     if (array_ndx != NULL)
-        return ReportActionNotArray(action->type, field);
+        return ReportActionNotArray(keymap, action->type, field);
 
     act = (struct xkb_redirect_key_action *) action;
     switch (field) {
     case F_Keycode:
         if (!ExprResolveKeyName(keymap->ctx, value, &rtrn))
-            return ReportMismatch(action->type, field, "key name");
+            return ReportMismatch(keymap, action->type, field, "key name");
 
         tmp = KeyNameToLong(rtrn.name);
         key = FindNamedKey(keymap, tmp, true, CreateKeyNames(keymap), 0);
         if (!key)
-            return ReportNotFound(action->type, field, "Key",
+            return ReportNotFound(keymap, action->type, field, "Key",
                                   XkbcKeyNameText(rtrn.name));
         act->new_kc = XkbKeyGetKeycode(keymap, key);
         return true;
@@ -841,7 +865,7 @@ HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action,
         }
         return true;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
@@ -854,13 +878,14 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
     act = (struct xkb_device_button_action *) action;
     if (field == F_Button) {
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
-            return ReportMismatch(action->type, field,
+            return ReportMismatch(keymap, action->type, field,
                                   "integer (range 1..255)");
         if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
-            ERROR("Button must specify default or be in the range 1..255\n");
-            ACTION("Illegal button value %d ignored\n", rtrn.ival);
+            log_err(keymap->ctx,
+                    "Button must specify default or be in the range 1..255; "
+                    "Illegal button value %d ignored\n", rtrn.ival);
             return false;
         }
         act->button = rtrn.ival;
@@ -868,21 +893,23 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
     }
     else if ((action->type == XkbSA_LockDeviceBtn) && (field == F_Affect)) {
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
-            return ReportMismatch(action->type, field, "lock or unlock");
+            return ReportMismatch(keymap, action->type, field,
+                                  "lock or unlock");
         act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
         act->flags |= rtrn.ival;
         return true;
     }
     else if (field == F_Count) {
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveButton(keymap->ctx, value, &rtrn))
-            return ReportMismatch(action->type, field, "integer");
+            return ReportMismatch(keymap, action->type, field, "integer");
         if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
-            ERROR("The count field must have a value in the range 0..255\n");
-            ACTION("Illegal count %d ignored\n", rtrn.ival);
+            log_err(keymap->ctx,
+                    "The count field must have a value in the range 0..255; "
+                    "Illegal count %d ignored\n", rtrn.ival);
             return false;
         }
         act->count = rtrn.ival;
@@ -890,19 +917,20 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
     }
     else if (field == F_Device) {
         if (array_ndx != NULL)
-            return ReportActionNotArray(action->type, field);
+            return ReportActionNotArray(keymap, action->type, field);
         if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
-            return ReportMismatch(action->type, field,
+            return ReportMismatch(keymap, action->type, field,
                                   "integer (range 1..255)");
         if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
-            ERROR("Device must specify default or be in the range 1..255\n");
-            ACTION("Illegal device value %d ignored\n", rtrn.ival);
+            log_err(keymap->ctx,
+                    "Device must specify default or be in the range 1..255; "
+                    "Illegal device value %d ignored\n", rtrn.ival);
             return false;
         }
         act->device = rtrn.ival;
         return true;
     }
-    return ReportIllegal(action->type, field);
+    return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
@@ -928,10 +956,11 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
     switch (field) {
     case F_Type:
         if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
-            return ReportMismatch(PrivateAction, field, "integer");
+            return ReportMismatch(keymap, PrivateAction, field, "integer");
         if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
-            ERROR("Private action type must be in the range 0..255\n");
-            ACTION("Illegal type %d ignored\n", rtrn.ival);
+            log_err(keymap->ctx,
+                    "Private action type must be in the range 0..255; "
+                    "Illegal type %d ignored\n", rtrn.ival);
             return false;
         }
         action->type = rtrn.uval;
@@ -940,12 +969,13 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
     case F_Data:
         if (array_ndx == NULL) {
             if (!ExprResolveString(keymap->ctx, value, &rtrn))
-                return ReportMismatch(action->type, field, "string");
+                return ReportMismatch(keymap, action->type, field, "string");
             else {
                 int len = strlen(rtrn.str);
                 if ((len < 1) || (len > 7)) {
-                    WARN("A private action has 7 data bytes\n");
-                    ACTION("Extra %d bytes ignored\n", len - 6);
+                    log_warn(keymap->ctx,
+                             "A private action has 7 data bytes; "
+                             "Extra %d bytes ignored\n", len - 6);
                     return false;
                 }
                 strncpy((char *) action->data, rtrn.str, sizeof action->data);
@@ -956,28 +986,31 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
         else {
             unsigned ndx;
             if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) {
-                ERROR("Array subscript must be integer\n");
-                ACTION("Illegal subscript ignored\n");
+                log_err(keymap->ctx,
+                        "Array subscript must be integer; "
+                        "Illegal subscript ignored\n");
                 return false;
             }
             ndx = rtrn.uval;
             if (ndx >= sizeof action->data) {
-                ERROR("The data for a private action is 18 bytes long\n");
-                ACTION("Attempt to use data[%d] ignored\n", ndx);
+                log_err(keymap->ctx,
+                        "The data for a private action is 18 bytes long; "
+                        "Attempt to use data[%d] ignored\n", ndx);
                 return false;
             }
             if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
-                return ReportMismatch(action->type, field, "integer");
+                return ReportMismatch(keymap, action->type, field, "integer");
             if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
-                ERROR("All data for a private action must be 0..255\n");
-                ACTION("Illegal datum %d ignored\n", rtrn.ival);
+                log_err(keymap->ctx,
+                        "All data for a private action must be 0..255; "
+                        "Illegal datum %d ignored\n", rtrn.ival);
                 return false;
             }
             action->data[ndx] = rtrn.uval;
             return true;
         }
     }
-    return ReportIllegal(PrivateAction, field);
+    return ReportIllegal(keymap, PrivateAction, field);
 }
 
 typedef bool (*actionHandler)(struct xkb_keymap *keymap,
@@ -1040,17 +1073,17 @@ HandleActionDef(ExprDef * def,
         ActionsInit(keymap->ctx);
 
     if (def->op != ExprActionDecl) {
-        ERROR("Expected an action definition, found %s\n",
-              exprOpText(def->op));
+        log_err(keymap->ctx, "Expected an action definition, found %s\n",
+                exprOpText(def->op));
         return false;
     }
     str = xkb_atom_text(keymap->ctx, def->value.action.name);
     if (!str) {
-        WSGO("Missing name in action definition!!\n");
+        log_wsgo(keymap->ctx, "Missing name in action definition!!\n");
         return false;
     }
     if (!stringToAction(str, &tmp)) {
-        ERROR("Unknown action %s\n", str);
+        log_err(keymap->ctx, "Unknown action %s\n", str);
         return false;
     }
     action->type = hndlrType = tmp;
@@ -1096,15 +1129,16 @@ HandleActionDef(ExprDef * def,
             return false;       /* internal error -- already reported */
 
         if (elemRtrn.str != NULL) {
-            ERROR("Cannot change defaults in an action definition\n");
-            ACTION("Ignoring attempt to change %s.%s\n", elemRtrn.str,
-                   fieldRtrn.str);
+            log_err(keymap->ctx,
+                    "Cannot change defaults in an action definition; "
+                    "Ignoring attempt to change %s.%s\n",
+                    elemRtrn.str, fieldRtrn.str);
             free(elemRtrn.str);
             free(fieldRtrn.str);
             return false;
         }
         if (!stringToField(fieldRtrn.str, &fieldNdx)) {
-            ERROR("Unknown field name %s\n", uStringText(fieldRtrn.str));
+            log_err(keymap->ctx, "Unknown field name %s\n", fieldRtrn.str);
             free(elemRtrn.str);
             free(fieldRtrn.str);
             return false;
@@ -1121,10 +1155,8 @@ HandleActionDef(ExprDef * def,
 /***====================================================================***/
 
 int
-SetActionField(struct xkb_keymap *keymap,
-               char *elem,
-               char *field,
-               ExprDef * array_ndx, ExprDef * value, ActionInfo ** info_rtrn)
+SetActionField(struct xkb_keymap *keymap, char *elem, char *field,
+               ExprDef *array_ndx, ExprDef *value, ActionInfo **info_rtrn)
 {
     ActionInfo *new, *old;
 
@@ -1133,7 +1165,7 @@ SetActionField(struct xkb_keymap *keymap,
 
     new = malloc(sizeof(*new));
     if (!new) {
-        WSGO("Couldn't allocate space for action default\n");
+        log_wsgo(keymap->ctx, "Couldn't allocate space for action default\n");
         return false;
     }
 
@@ -1145,14 +1177,15 @@ SetActionField(struct xkb_keymap *keymap,
             return false;
         }
         if (new->action == XkbSA_NoAction) {
-            ERROR("\"%s\" is not a valid field in a NoAction action\n",
-                  field);
+            log_err(keymap->ctx,
+                    "\"%s\" is not a valid field in a NoAction action\n",
+                    field);
             free(new);
             return false;
         }
     }
     if (!stringToField(field, &new->field)) {
-        ERROR("\"%s\" is not a legal field name\n", field);
+        log_err(keymap->ctx, "\"%s\" is not a legal field name\n", field);
         free(new);
         return false;
     }