]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/locale/keymap-util.c
headers: remove unneeded includes from util.h
[thirdparty/systemd.git] / src / locale / keymap-util.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include <errno.h>
4 #include <stdio_ext.h>
5 #include <string.h>
6 #include <sys/stat.h>
7 #include <sys/types.h>
8 #include <unistd.h>
9
10 #include "bus-util.h"
11 #include "env-file-label.h"
12 #include "env-file.h"
13 #include "env-util.h"
14 #include "fd-util.h"
15 #include "fileio-label.h"
16 #include "fileio.h"
17 #include "kbd-util.h"
18 #include "keymap-util.h"
19 #include "locale-util.h"
20 #include "macro.h"
21 #include "mkdir.h"
22 #include "nulstr-util.h"
23 #include "string-util.h"
24 #include "strv.h"
25 #include "tmpfile-util.h"
26
27 static bool startswith_comma(const char *s, const char *prefix) {
28 s = startswith(s, prefix);
29 if (!s)
30 return false;
31
32 return IN_SET(*s, ',', '\0');
33 }
34
35 static const char* strnulldash(const char *s) {
36 return isempty(s) || streq(s, "-") ? NULL : s;
37 }
38
39 static const char* systemd_kbd_model_map(void) {
40 const char* s;
41
42 s = getenv("SYSTEMD_KBD_MODEL_MAP");
43 if (s)
44 return s;
45
46 return SYSTEMD_KBD_MODEL_MAP;
47 }
48
49 static const char* systemd_language_fallback_map(void) {
50 const char* s;
51
52 s = getenv("SYSTEMD_LANGUAGE_FALLBACK_MAP");
53 if (s)
54 return s;
55
56 return SYSTEMD_LANGUAGE_FALLBACK_MAP;
57 }
58
59 static void context_free_x11(Context *c) {
60 c->x11_layout = mfree(c->x11_layout);
61 c->x11_options = mfree(c->x11_options);
62 c->x11_model = mfree(c->x11_model);
63 c->x11_variant = mfree(c->x11_variant);
64 }
65
66 static void context_free_vconsole(Context *c) {
67 c->vc_keymap = mfree(c->vc_keymap);
68 c->vc_keymap_toggle = mfree(c->vc_keymap_toggle);
69 }
70
71 static void context_free_locale(Context *c) {
72 int p;
73
74 for (p = 0; p < _VARIABLE_LC_MAX; p++)
75 c->locale[p] = mfree(c->locale[p]);
76 }
77
78 void context_clear(Context *c) {
79 context_free_locale(c);
80 context_free_x11(c);
81 context_free_vconsole(c);
82
83 sd_bus_message_unref(c->locale_cache);
84 sd_bus_message_unref(c->x11_cache);
85 sd_bus_message_unref(c->vc_cache);
86
87 bus_verify_polkit_async_registry_free(c->polkit_registry);
88 };
89
90 void locale_simplify(char *locale[_VARIABLE_LC_MAX]) {
91 int p;
92
93 for (p = VARIABLE_LANG+1; p < _VARIABLE_LC_MAX; p++)
94 if (isempty(locale[p]) || streq_ptr(locale[VARIABLE_LANG], locale[p]))
95 locale[p] = mfree(locale[p]);
96 }
97
98 int locale_read_data(Context *c, sd_bus_message *m) {
99 struct stat st;
100 int r;
101
102 /* Do not try to re-read the file within single bus operation. */
103 if (m) {
104 if (m == c->locale_cache)
105 return 0;
106
107 sd_bus_message_unref(c->locale_cache);
108 c->locale_cache = sd_bus_message_ref(m);
109 }
110
111 r = stat("/etc/locale.conf", &st);
112 if (r < 0 && errno != ENOENT)
113 return -errno;
114
115 if (r >= 0) {
116 usec_t t;
117
118 /* If mtime is not changed, then we do not need to re-read the file. */
119 t = timespec_load(&st.st_mtim);
120 if (c->locale_mtime != USEC_INFINITY && t == c->locale_mtime)
121 return 0;
122
123 c->locale_mtime = t;
124 context_free_locale(c);
125
126 r = parse_env_file(NULL, "/etc/locale.conf",
127 "LANG", &c->locale[VARIABLE_LANG],
128 "LANGUAGE", &c->locale[VARIABLE_LANGUAGE],
129 "LC_CTYPE", &c->locale[VARIABLE_LC_CTYPE],
130 "LC_NUMERIC", &c->locale[VARIABLE_LC_NUMERIC],
131 "LC_TIME", &c->locale[VARIABLE_LC_TIME],
132 "LC_COLLATE", &c->locale[VARIABLE_LC_COLLATE],
133 "LC_MONETARY", &c->locale[VARIABLE_LC_MONETARY],
134 "LC_MESSAGES", &c->locale[VARIABLE_LC_MESSAGES],
135 "LC_PAPER", &c->locale[VARIABLE_LC_PAPER],
136 "LC_NAME", &c->locale[VARIABLE_LC_NAME],
137 "LC_ADDRESS", &c->locale[VARIABLE_LC_ADDRESS],
138 "LC_TELEPHONE", &c->locale[VARIABLE_LC_TELEPHONE],
139 "LC_MEASUREMENT", &c->locale[VARIABLE_LC_MEASUREMENT],
140 "LC_IDENTIFICATION", &c->locale[VARIABLE_LC_IDENTIFICATION]);
141 if (r < 0)
142 return r;
143 } else {
144 int p;
145
146 c->locale_mtime = USEC_INFINITY;
147 context_free_locale(c);
148
149 /* Fill in what we got passed from systemd. */
150 for (p = 0; p < _VARIABLE_LC_MAX; p++) {
151 const char *name;
152
153 name = locale_variable_to_string(p);
154 assert(name);
155
156 r = free_and_strdup(&c->locale[p], empty_to_null(getenv(name)));
157 if (r < 0)
158 return r;
159 }
160 }
161
162 locale_simplify(c->locale);
163 return 0;
164 }
165
166 int vconsole_read_data(Context *c, sd_bus_message *m) {
167 struct stat st;
168 usec_t t;
169 int r;
170
171 /* Do not try to re-read the file within single bus operation. */
172 if (m) {
173 if (m == c->vc_cache)
174 return 0;
175
176 sd_bus_message_unref(c->vc_cache);
177 c->vc_cache = sd_bus_message_ref(m);
178 }
179
180 if (stat("/etc/vconsole.conf", &st) < 0) {
181 if (errno != ENOENT)
182 return -errno;
183
184 c->vc_mtime = USEC_INFINITY;
185 context_free_vconsole(c);
186 return 0;
187 }
188
189 /* If mtime is not changed, then we do not need to re-read */
190 t = timespec_load(&st.st_mtim);
191 if (c->vc_mtime != USEC_INFINITY && t == c->vc_mtime)
192 return 0;
193
194 c->vc_mtime = t;
195 context_free_vconsole(c);
196
197 r = parse_env_file(NULL, "/etc/vconsole.conf",
198 "KEYMAP", &c->vc_keymap,
199 "KEYMAP_TOGGLE", &c->vc_keymap_toggle);
200 if (r < 0)
201 return r;
202
203 return 0;
204 }
205
206 int x11_read_data(Context *c, sd_bus_message *m) {
207 _cleanup_fclose_ FILE *f = NULL;
208 bool in_section = false;
209 struct stat st;
210 usec_t t;
211 int r;
212
213 /* Do not try to re-read the file within single bus operation. */
214 if (m) {
215 if (m == c->x11_cache)
216 return 0;
217
218 sd_bus_message_unref(c->x11_cache);
219 c->x11_cache = sd_bus_message_ref(m);
220 }
221
222 if (stat("/etc/X11/xorg.conf.d/00-keyboard.conf", &st) < 0) {
223 if (errno != ENOENT)
224 return -errno;
225
226 c->x11_mtime = USEC_INFINITY;
227 context_free_x11(c);
228 return 0;
229 }
230
231 /* If mtime is not changed, then we do not need to re-read */
232 t = timespec_load(&st.st_mtim);
233 if (c->x11_mtime != USEC_INFINITY && t == c->x11_mtime)
234 return 0;
235
236 c->x11_mtime = t;
237 context_free_x11(c);
238
239 f = fopen("/etc/X11/xorg.conf.d/00-keyboard.conf", "re");
240 if (!f)
241 return -errno;
242
243 for (;;) {
244 _cleanup_free_ char *line = NULL;
245 char *l;
246
247 r = read_line(f, LONG_LINE_MAX, &line);
248 if (r < 0)
249 return r;
250 if (r == 0)
251 break;
252
253 l = strstrip(line);
254 if (IN_SET(l[0], 0, '#'))
255 continue;
256
257 if (in_section && first_word(l, "Option")) {
258 _cleanup_strv_free_ char **a = NULL;
259
260 r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_QUOTES);
261 if (r < 0)
262 return r;
263
264 if (strv_length(a) == 3) {
265 char **p = NULL;
266
267 if (streq(a[1], "XkbLayout"))
268 p = &c->x11_layout;
269 else if (streq(a[1], "XkbModel"))
270 p = &c->x11_model;
271 else if (streq(a[1], "XkbVariant"))
272 p = &c->x11_variant;
273 else if (streq(a[1], "XkbOptions"))
274 p = &c->x11_options;
275
276 if (p) {
277 free_and_replace(*p, a[2]);
278 }
279 }
280
281 } else if (!in_section && first_word(l, "Section")) {
282 _cleanup_strv_free_ char **a = NULL;
283
284 r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_QUOTES);
285 if (r < 0)
286 return -ENOMEM;
287
288 if (strv_length(a) == 2 && streq(a[1], "InputClass"))
289 in_section = true;
290
291 } else if (in_section && first_word(l, "EndSection"))
292 in_section = false;
293 }
294
295 return 0;
296 }
297
298 int locale_write_data(Context *c, char ***settings) {
299 _cleanup_strv_free_ char **l = NULL;
300 struct stat st;
301 int r, p;
302
303 /* Set values will be returned as strv in *settings on success. */
304
305 for (p = 0; p < _VARIABLE_LC_MAX; p++) {
306 _cleanup_free_ char *t = NULL;
307 char **u;
308 const char *name;
309
310 name = locale_variable_to_string(p);
311 assert(name);
312
313 if (isempty(c->locale[p]))
314 continue;
315
316 if (asprintf(&t, "%s=%s", name, c->locale[p]) < 0)
317 return -ENOMEM;
318
319 u = strv_env_set(l, t);
320 if (!u)
321 return -ENOMEM;
322
323 strv_free_and_replace(l, u);
324 }
325
326 if (strv_isempty(l)) {
327 if (unlink("/etc/locale.conf") < 0)
328 return errno == ENOENT ? 0 : -errno;
329
330 c->locale_mtime = USEC_INFINITY;
331 return 0;
332 }
333
334 r = write_env_file_label("/etc/locale.conf", l);
335 if (r < 0)
336 return r;
337
338 *settings = TAKE_PTR(l);
339
340 if (stat("/etc/locale.conf", &st) >= 0)
341 c->locale_mtime = timespec_load(&st.st_mtim);
342
343 return 0;
344 }
345
346 int vconsole_write_data(Context *c) {
347 _cleanup_strv_free_ char **l = NULL;
348 struct stat st;
349 int r;
350
351 r = load_env_file(NULL, "/etc/vconsole.conf", &l);
352 if (r < 0 && r != -ENOENT)
353 return r;
354
355 if (isempty(c->vc_keymap))
356 l = strv_env_unset(l, "KEYMAP");
357 else {
358 _cleanup_free_ char *s = NULL;
359 char **u;
360
361 s = strappend("KEYMAP=", c->vc_keymap);
362 if (!s)
363 return -ENOMEM;
364
365 u = strv_env_set(l, s);
366 if (!u)
367 return -ENOMEM;
368
369 strv_free_and_replace(l, u);
370 }
371
372 if (isempty(c->vc_keymap_toggle))
373 l = strv_env_unset(l, "KEYMAP_TOGGLE");
374 else {
375 _cleanup_free_ char *s = NULL;
376 char **u;
377
378 s = strappend("KEYMAP_TOGGLE=", c->vc_keymap_toggle);
379 if (!s)
380 return -ENOMEM;
381
382 u = strv_env_set(l, s);
383 if (!u)
384 return -ENOMEM;
385
386 strv_free_and_replace(l, u);
387 }
388
389 if (strv_isempty(l)) {
390 if (unlink("/etc/vconsole.conf") < 0)
391 return errno == ENOENT ? 0 : -errno;
392
393 c->vc_mtime = USEC_INFINITY;
394 return 0;
395 }
396
397 r = write_env_file_label("/etc/vconsole.conf", l);
398 if (r < 0)
399 return r;
400
401 if (stat("/etc/vconsole.conf", &st) >= 0)
402 c->vc_mtime = timespec_load(&st.st_mtim);
403
404 return 0;
405 }
406
407 int x11_write_data(Context *c) {
408 _cleanup_fclose_ FILE *f = NULL;
409 _cleanup_free_ char *temp_path = NULL;
410 struct stat st;
411 int r;
412
413 if (isempty(c->x11_layout) &&
414 isempty(c->x11_model) &&
415 isempty(c->x11_variant) &&
416 isempty(c->x11_options)) {
417
418 if (unlink("/etc/X11/xorg.conf.d/00-keyboard.conf") < 0)
419 return errno == ENOENT ? 0 : -errno;
420
421 c->vc_mtime = USEC_INFINITY;
422 return 0;
423 }
424
425 mkdir_p_label("/etc/X11/xorg.conf.d", 0755);
426
427 r = fopen_temporary("/etc/X11/xorg.conf.d/00-keyboard.conf", &f, &temp_path);
428 if (r < 0)
429 return r;
430
431 (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
432 (void) fchmod(fileno(f), 0644);
433
434 fputs("# Written by systemd-localed(8), read by systemd-localed and Xorg. It's\n"
435 "# probably wise not to edit this file manually. Use localectl(1) to\n"
436 "# instruct systemd-localed to update it.\n"
437 "Section \"InputClass\"\n"
438 " Identifier \"system-keyboard\"\n"
439 " MatchIsKeyboard \"on\"\n", f);
440
441 if (!isempty(c->x11_layout))
442 fprintf(f, " Option \"XkbLayout\" \"%s\"\n", c->x11_layout);
443
444 if (!isempty(c->x11_model))
445 fprintf(f, " Option \"XkbModel\" \"%s\"\n", c->x11_model);
446
447 if (!isempty(c->x11_variant))
448 fprintf(f, " Option \"XkbVariant\" \"%s\"\n", c->x11_variant);
449
450 if (!isempty(c->x11_options))
451 fprintf(f, " Option \"XkbOptions\" \"%s\"\n", c->x11_options);
452
453 fputs("EndSection\n", f);
454
455 r = fflush_sync_and_check(f);
456 if (r < 0)
457 goto fail;
458
459 if (rename(temp_path, "/etc/X11/xorg.conf.d/00-keyboard.conf") < 0) {
460 r = -errno;
461 goto fail;
462 }
463
464 if (stat("/etc/X11/xorg.conf.d/00-keyboard.conf", &st) >= 0)
465 c->x11_mtime = timespec_load(&st.st_mtim);
466
467 return 0;
468
469 fail:
470 if (temp_path)
471 (void) unlink(temp_path);
472
473 return r;
474 }
475
476 static int read_next_mapping(const char* filename,
477 unsigned min_fields, unsigned max_fields,
478 FILE *f, unsigned *n, char ***a) {
479 assert(f);
480 assert(n);
481 assert(a);
482
483 for (;;) {
484 _cleanup_free_ char *line = NULL;
485 size_t length;
486 char *l, **b;
487 int r;
488
489 r = read_line(f, LONG_LINE_MAX, &line);
490 if (r < 0)
491 return r;
492 if (r == 0)
493 break;
494
495 (*n)++;
496
497 l = strstrip(line);
498 if (IN_SET(l[0], 0, '#'))
499 continue;
500
501 r = strv_split_extract(&b, l, WHITESPACE, EXTRACT_QUOTES);
502 if (r < 0)
503 return r;
504
505 length = strv_length(b);
506 if (length < min_fields || length > max_fields) {
507 log_error("Invalid line %s:%u, ignoring.", filename, *n);
508 strv_free(b);
509 continue;
510
511 }
512
513 *a = b;
514 return 1;
515 }
516
517 return 0;
518 }
519
520 int vconsole_convert_to_x11(Context *c) {
521 const char *map;
522 int modified = -1;
523
524 map = systemd_kbd_model_map();
525
526 if (isempty(c->vc_keymap)) {
527 modified =
528 !isempty(c->x11_layout) ||
529 !isempty(c->x11_model) ||
530 !isempty(c->x11_variant) ||
531 !isempty(c->x11_options);
532
533 context_free_x11(c);
534 } else {
535 _cleanup_fclose_ FILE *f = NULL;
536 unsigned n = 0;
537
538 f = fopen(map, "re");
539 if (!f)
540 return -errno;
541
542 for (;;) {
543 _cleanup_strv_free_ char **a = NULL;
544 int r;
545
546 r = read_next_mapping(map, 5, UINT_MAX, f, &n, &a);
547 if (r < 0)
548 return r;
549 if (r == 0)
550 break;
551
552 if (!streq(c->vc_keymap, a[0]))
553 continue;
554
555 if (!streq_ptr(c->x11_layout, strnulldash(a[1])) ||
556 !streq_ptr(c->x11_model, strnulldash(a[2])) ||
557 !streq_ptr(c->x11_variant, strnulldash(a[3])) ||
558 !streq_ptr(c->x11_options, strnulldash(a[4]))) {
559
560 if (free_and_strdup(&c->x11_layout, strnulldash(a[1])) < 0 ||
561 free_and_strdup(&c->x11_model, strnulldash(a[2])) < 0 ||
562 free_and_strdup(&c->x11_variant, strnulldash(a[3])) < 0 ||
563 free_and_strdup(&c->x11_options, strnulldash(a[4])) < 0)
564 return -ENOMEM;
565
566 modified = true;
567 }
568
569 break;
570 }
571 }
572
573 if (modified > 0)
574 log_info("Changing X11 keyboard layout to '%s' model '%s' variant '%s' options '%s'",
575 strempty(c->x11_layout),
576 strempty(c->x11_model),
577 strempty(c->x11_variant),
578 strempty(c->x11_options));
579 else if (modified < 0)
580 log_notice("X11 keyboard layout was not modified: no conversion found for \"%s\".",
581 c->vc_keymap);
582 else
583 log_debug("X11 keyboard layout did not need to be modified.");
584
585 return modified > 0;
586 }
587
588 int find_converted_keymap(const char *x11_layout, const char *x11_variant, char **new_keymap) {
589 const char *dir;
590 _cleanup_free_ char *n;
591
592 if (x11_variant)
593 n = strjoin(x11_layout, "-", x11_variant);
594 else
595 n = strdup(x11_layout);
596 if (!n)
597 return -ENOMEM;
598
599 NULSTR_FOREACH(dir, KBD_KEYMAP_DIRS) {
600 _cleanup_free_ char *p = NULL, *pz = NULL;
601 bool uncompressed;
602
603 p = strjoin(dir, "xkb/", n, ".map");
604 pz = strjoin(dir, "xkb/", n, ".map.gz");
605 if (!p || !pz)
606 return -ENOMEM;
607
608 uncompressed = access(p, F_OK) == 0;
609 if (uncompressed || access(pz, F_OK) == 0) {
610 log_debug("Found converted keymap %s at %s",
611 n, uncompressed ? p : pz);
612
613 *new_keymap = TAKE_PTR(n);
614 return 1;
615 }
616 }
617
618 return 0;
619 }
620
621 int find_legacy_keymap(Context *c, char **ret) {
622 const char *map;
623 _cleanup_fclose_ FILE *f = NULL;
624 _cleanup_free_ char *new_keymap = NULL;
625 unsigned n = 0;
626 unsigned best_matching = 0;
627 int r;
628
629 assert(!isempty(c->x11_layout));
630
631 map = systemd_kbd_model_map();
632
633 f = fopen(map, "re");
634 if (!f)
635 return -errno;
636
637 for (;;) {
638 _cleanup_strv_free_ char **a = NULL;
639 unsigned matching = 0;
640
641 r = read_next_mapping(map, 5, UINT_MAX, f, &n, &a);
642 if (r < 0)
643 return r;
644 if (r == 0)
645 break;
646
647 /* Determine how well matching this entry is */
648 if (streq(c->x11_layout, a[1]))
649 /* If we got an exact match, this is best */
650 matching = 10;
651 else {
652 /* We have multiple X layouts, look for an
653 * entry that matches our key with everything
654 * but the first layout stripped off. */
655 if (startswith_comma(c->x11_layout, a[1]))
656 matching = 5;
657 else {
658 char *x;
659
660 /* If that didn't work, strip off the
661 * other layouts from the entry, too */
662 x = strndupa(a[1], strcspn(a[1], ","));
663 if (startswith_comma(c->x11_layout, x))
664 matching = 1;
665 }
666 }
667
668 if (matching > 0) {
669 if (isempty(c->x11_model) || streq_ptr(c->x11_model, a[2])) {
670 matching++;
671
672 if (streq_ptr(c->x11_variant, a[3])) {
673 matching++;
674
675 if (streq_ptr(c->x11_options, a[4]))
676 matching++;
677 }
678 }
679 }
680
681 /* The best matching entry so far, then let's save that */
682 if (matching >= MAX(best_matching, 1u)) {
683 log_debug("Found legacy keymap %s with score %u",
684 a[0], matching);
685
686 if (matching > best_matching) {
687 best_matching = matching;
688
689 r = free_and_strdup(&new_keymap, a[0]);
690 if (r < 0)
691 return r;
692 }
693 }
694 }
695
696 if (best_matching < 10 && c->x11_layout) {
697 /* The best match is only the first part of the X11
698 * keymap. Check if we have a converted map which
699 * matches just the first layout.
700 */
701 char *l, *v = NULL, *converted;
702
703 l = strndupa(c->x11_layout, strcspn(c->x11_layout, ","));
704 if (c->x11_variant)
705 v = strndupa(c->x11_variant, strcspn(c->x11_variant, ","));
706 r = find_converted_keymap(l, v, &converted);
707 if (r < 0)
708 return r;
709 if (r > 0)
710 free_and_replace(new_keymap, converted);
711 }
712
713 *ret = TAKE_PTR(new_keymap);
714 return (bool) *ret;
715 }
716
717 int find_language_fallback(const char *lang, char **language) {
718 const char *map;
719 _cleanup_fclose_ FILE *f = NULL;
720 unsigned n = 0;
721
722 assert(lang);
723 assert(language);
724
725 map = systemd_language_fallback_map();
726
727 f = fopen(map, "re");
728 if (!f)
729 return -errno;
730
731 for (;;) {
732 _cleanup_strv_free_ char **a = NULL;
733 int r;
734
735 r = read_next_mapping(map, 2, 2, f, &n, &a);
736 if (r <= 0)
737 return r;
738
739 if (streq(lang, a[0])) {
740 assert(strv_length(a) == 2);
741 *language = TAKE_PTR(a[1]);
742 return 1;
743 }
744 }
745
746 assert_not_reached("should not be here");
747 }
748
749 int x11_convert_to_vconsole(Context *c) {
750 bool modified = false;
751
752 if (isempty(c->x11_layout)) {
753 modified =
754 !isempty(c->vc_keymap) ||
755 !isempty(c->vc_keymap_toggle);
756
757 context_free_vconsole(c);
758 } else {
759 _cleanup_free_ char *new_keymap = NULL;
760 int r;
761
762 r = find_converted_keymap(c->x11_layout, c->x11_variant, &new_keymap);
763 if (r < 0)
764 return r;
765 else if (r == 0) {
766 r = find_legacy_keymap(c, &new_keymap);
767 if (r < 0)
768 return r;
769 }
770 if (r == 0)
771 /* We search for layout-variant match first, but then we also look
772 * for anything which matches just the layout. So it's accurate to say
773 * that we couldn't find anything which matches the layout. */
774 log_notice("No conversion to virtual console map found for \"%s\".",
775 c->x11_layout);
776
777 if (!streq_ptr(c->vc_keymap, new_keymap)) {
778 free_and_replace(c->vc_keymap, new_keymap);
779 c->vc_keymap_toggle = mfree(c->vc_keymap_toggle);
780 modified = true;
781 }
782 }
783
784 if (modified)
785 log_info("Changing virtual console keymap to '%s' toggle '%s'",
786 strempty(c->vc_keymap), strempty(c->vc_keymap_toggle));
787 else
788 log_debug("Virtual console keymap was not modified.");
789
790 return modified;
791 }