Debian Codegraph @

src/permut.c

raw symbols SCIP
1 /* Conversion of files between different charsets and surfaces.
2 Copyright © 1997-2018 Free Software Foundation, Inc.
3 Contributed by François Pinard <[email protected]>, 1997.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License
7 as published by the Free Software Foundation; either version 3 of the
8 License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be
11 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the Recode Library; see the file `COPYING.LIB'.
17 If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "config.h"
21 #include "common.h"
22 #include "decsteps.h"
23
24 static bool
25 permute_21 (RECODE_SUBTASK subtask)
26 {
27 int character1;
28 int character2;
29
30 while (true)
31 {
32 character1 = recode_get_byte (subtask);
33 if (character1 == EOF)
34 break;
35
36 character2 = recode_get_byte (subtask);
37 if (character2 == EOF)
38 {
39 recode_put_byte (character1, subtask);
40 break;
41 }
42
43 recode_put_byte (character2, subtask);
44 recode_put_byte (character1, subtask);
45 }
46
47 SUBTASK_RETURN (subtask);
48 }
49
50 static bool
51 permute_4321 (RECODE_SUBTASK subtask)
52 {
53 int character1;
54 int character2;
55 int character3;
56 int character4;
57
58 while (true)
59 {
60 character1 = recode_get_byte (subtask);
61 if (character1 == EOF)
62 break;
63
64 character2 = recode_get_byte (subtask);
65 if (character2 == EOF)
66 {
67 recode_put_byte (character1, subtask);
68 break;
69 }
70
71 character3 = recode_get_byte (subtask);
72 if (character3 == EOF)
73 {
74 recode_put_byte (character2, subtask);
75 recode_put_byte (character1, subtask);
76 break;
77 }
78
79 character4 = recode_get_byte (subtask);
80 if (character4 == EOF)
81 {
82 recode_put_byte (character3, subtask);
83 recode_put_byte (character2, subtask);
84 recode_put_byte (character1, subtask);
85 break;
86 }
87
88 recode_put_byte (character4, subtask);
89 recode_put_byte (character3, subtask);
90 recode_put_byte (character2, subtask);
91 recode_put_byte (character1, subtask);
92 }
93
94 SUBTASK_RETURN (subtask);
95 }
96
97 bool
98 module_permutations (RECODE_OUTER outer)
99 {
100 return
101 recode_declare_single (outer, "data", "21-Permutation",
102 outer->quality_variable_to_variable,
103 NULL, permute_21)
104 && recode_declare_single (outer, "21-Permutation", "data",
105 outer->quality_variable_to_variable,
106 NULL, permute_21)
107 && recode_declare_single (outer, "data", "4321-Permutation",
108 outer->quality_variable_to_variable,
109 NULL, permute_4321)
110 && recode_declare_single (outer, "4321-Permutation", "data",
111 outer->quality_variable_to_variable,
112 NULL, permute_4321)
113 && recode_declare_alias (outer, "swabytes", "21-Permutation");
114 }
115
116 void
117 delmodule_permutations (_GL_UNUSED RECODE_OUTER outer)
118 {
119 }