| 1 | /* liblouis Braille Translation and Back-Translation Library |
| 2 | |
| 3 | Based on the Linux screenreader BRLTTY, copyright (C) 1999-2006 by |
| 4 | The BRLTTY Team |
| 5 | |
| 6 | Copyright (C) 2004, 2005, 2006, 2009 |
| 7 | ViewPlus Technologies, Inc. www.viewplus.com and |
| 8 | JJB Software, Inc. www.jjb-software.com |
| 9 | |
| 10 | This program is free software: you can redistribute it and/or modify |
| 11 | it under the terms of the GNU General Public License as published by |
| 12 | the Free Software Foundation, either version 3 of the License, or |
| 13 | (at your option) any later version. |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | GNU General Public License for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU General Public License |
| 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | */ |
| 23 | |
| 24 | #include <config.h>cxx . . $ `<file>/liblouis/config.h`/ |
| 25 | |
| 26 | #include <stdio.h>cxx . . $ `<file>/tools/gnulib/stdio.h`/ |
| 27 | #include <string.h>cxx . . $ `<file>/gnulib/string.h`/ |
| 28 | #include <stdlib.h>cxx . . $ `<file>/gnulib/stdlib.h`/ |
| 29 | #include <stdint.h> |
| 30 | #include "liblouis.h"cxx . . $ `<file>/liblouis/liblouis.h`/ |
| 31 | #include "internal.h"cxx . . $ `<file>/liblouis/internal.h`/ |
| 32 | #include <getopt.h> |
| 33 | #include "progname.h"cxx . . $ `<file>/tools/gnulib/progname.h`/ |
| 34 | #include "unistr.h"cxx . . $ `<file>/tools/gnulib/unistr.h`/ |
| 35 | #include "version-etc.h"cxx . . $ `<file>/tools/gnulib/version-etc.h`/ |
| 36 | |
| 37 | static const struct optioncxx . . $ option# longoptscxx . . $ longopts.[] = { |
| 38 | { "help", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 'h' }, |
| 39 | { "version", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 'v' }, |
| 40 | { NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 0, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 0 }, |
| 41 | }; |
| 42 | |
| 43 | const char version_etc_copyrightcxx . . $ version_etc_copyright.[] = |
| 44 | "Copyright %s %d ViewPlus Technologies, Inc. and JJB Software, Inc."; |
| 45 | |
| 46 | #define AUTHORScxx . . $ `tools/lou_allround.c:46:9`! "John J. Boyer" |
| 47 | |
| 48 | static void |
| 49 | print_helpcxx . . $ print_help(49f6e7a06ebc5aa8).(void) { |
| 50 | printfcxx . . $ printf(581fddd72a8db8fc).("\ |
| 51 | Usage: %s [OPTIONS]\n", |
| 52 | program_namecxx . . $ program_name.); |
| 53 | |
| 54 | fputscxx . . $ fputs(874fa6a5e59ab9bd).("\ |
| 55 | This program tests every capability of the liblouis library. It is\n\ |
| 56 | completely interactive. \n\n", |
| 57 | stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); |
| 58 | |
| 59 | fputscxx . . $ fputs(874fa6a5e59ab9bd).("\ |
| 60 | -h, --help display this help and exit\n\ |
| 61 | -v, --version display version information and exit\n", |
| 62 | stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); |
| 63 | |
| 64 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 65 | printfcxx . . $ printf(581fddd72a8db8fc).("Report bugs to %s.\n", PACKAGE_BUGREPORTcxx . . $ `liblouis/config.h:628:9`!); |
| 66 | |
| 67 | #ifdef PACKAGE_PACKAGER_BUG_REPORTS |
| 68 | printf("Report %s bugs to: %s\n", PACKAGE_PACKAGER, PACKAGE_PACKAGER_BUG_REPORTS); |
| 69 | #endif |
| 70 | #ifdef PACKAGE_URLcxx . . $ `liblouis/config.h:649:9`! |
| 71 | printfcxx . . $ printf(581fddd72a8db8fc).("%s home page: <%s>\n", PACKAGE_NAMEcxx . . $ `liblouis/config.h:631:9`!, PACKAGE_URLcxx . . $ `liblouis/config.h:649:9`!); |
| 72 | #endif |
| 73 | } |
| 74 | |
| 75 | #define BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`! 256 |
| 76 | |
| 77 | static char inputBuffercxx . . $ inputBuffer.[BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!]; |
| 78 | static const void *validTablecxx . . $ validTable. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 79 | static int forwardOnlycxx . . $ forwardOnly. = 0; |
| 80 | static int backOnlycxx . . $ backOnly. = 0; |
| 81 | static int showPositionscxx . . $ showPositions. = 0; |
| 82 | static int minimalistcxx . . $ minimalist. = 0; |
| 83 | static int outputSizecxx . . $ outputSize. = BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!; |
| 84 | static int showSizescxx . . $ showSizes. = 0; |
| 85 | static int enteredCursorPoscxx . . $ enteredCursorPos. = -1; |
| 86 | static unsigned int modecxx . . $ mode.; |
| 87 | static char tablecxx . . $ table.[BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!]; |
| 88 | static formtypecxx . . $ formtype# emphasiscxx . . $ emphasis.[BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!]; |
| 89 | static char enteredEmphasiscxx . . $ enteredEmphasis.[BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!]; |
| 90 | |
| 91 | static int |
| 92 | getInputcxx . . $ getInput(b126dc7c1de90089).(void) { |
| 93 | int inputLength; |
| 94 | inputBuffercxx . . $ inputBuffer.[0] = 0; |
| 95 | if (!fgetscxx . . $ fgets(efb0aaba7ac866ae).(inputBuffercxx . . $ inputBuffer., sizeof(inputBuffercxx . . $ inputBuffer.), stdincxx . . $ `<external>/232824719582829767/stdio.h:157:9`!)) exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!); |
| 96 | inputLength = strlencxx . . $ strlen(751346f8406fd082).(inputBuffercxx . . $ inputBuffer.) - 1; |
| 97 | if (inputLength < 0) /* EOF on script */ |
| 98 | { |
| 99 | lou_freecxx . . $ lou_free(49f6e7a06ebc5aa8).(); |
| 100 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!); |
| 101 | } |
| 102 | inputBuffercxx . . $ inputBuffer.[inputLength] = 0; |
| 103 | return inputLength; |
| 104 | } |
| 105 | |
| 106 | static int |
| 107 | getYNcxx . . $ getYN(b126dc7c1de90089).(void) { |
| 108 | printfcxx . . $ printf(581fddd72a8db8fc).("? y/n: "); |
| 109 | getInputcxx . . $ getInput(b126dc7c1de90089).(); |
| 110 | if (inputBuffercxx . . $ inputBuffer.[0] == 'y') return 1; |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | static void |
| 115 | paramLetterscxx . . $ paramLetters(49f6e7a06ebc5aa8).(void) { |
| 116 | printfcxx . . $ printf(581fddd72a8db8fc).("Press one of the letters in parentheses, then enter.\n"); |
| 117 | printfcxx . . $ printf(581fddd72a8db8fc).("(t)able, (r)un, (m)ode, (c)ursor, (e)mphasis, (h)elp,\n"); |
| 118 | printfcxx . . $ printf(581fddd72a8db8fc).("(q)uit, (f)orward-only, (b)ack-only, show-(p)ositions m(i)nimal.\n"); |
| 119 | printfcxx . . $ printf(581fddd72a8db8fc).("test-(l)engths.\n"); |
| 120 | } |
| 121 | |
| 122 | static int |
| 123 | getCommandscxx . . $ getCommands(b126dc7c1de90089).(void) { |
| 124 | paramLetterscxx . . $ paramLetters(49f6e7a06ebc5aa8).(); |
| 125 | do { |
| 126 | printfcxx . . $ printf(581fddd72a8db8fc).("Command: "); |
| 127 | getInputcxx . . $ getInput(b126dc7c1de90089).(); |
| 128 | switch (inputBuffercxx . . $ inputBuffer.[0]) { |
| 129 | case 0: |
| 130 | break; |
| 131 | case 't': |
| 132 | do { |
| 133 | printfcxx . . $ printf(581fddd72a8db8fc).("Enter the name of a table: "); |
| 134 | getInputcxx . . $ getInput(b126dc7c1de90089).(); |
| 135 | strcpycxx . . $ strcpy(b7b3a83273496486).(tablecxx . . $ table., inputBuffercxx . . $ inputBuffer.); |
| 136 | } while ((validTablecxx . . $ validTable. = lou_getTablecxx . . $ lou_getTable(fb668cd7b4a39b42).(tablecxx . . $ table.)) == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!); |
| 137 | break; |
| 138 | case 'r': |
| 139 | if (validTablecxx . . $ validTable. == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) { |
| 140 | printfcxx . . $ printf(581fddd72a8db8fc).("You must enter a valid table name.\n"); |
| 141 | inputBuffercxx . . $ inputBuffer.[0] = 0; |
| 142 | } |
| 143 | break; |
| 144 | case 'm': |
| 145 | printfcxx . . $ printf(581fddd72a8db8fc).("Reset mode"); |
| 146 | if (getYNcxx . . $ getYN(b126dc7c1de90089).()) modecxx . . $ mode. = 0; |
| 147 | printfcxx . . $ printf(581fddd72a8db8fc).("No contractions"); |
| 148 | modecxx . . $ mode. |= noContractionscxx . . $ noContractions. * getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 149 | printfcxx . . $ printf(581fddd72a8db8fc).("Computer Braille at cursor"); |
| 150 | modecxx . . $ mode. |= compbrlAtCursorcxx . . $ compbrlAtCursor. * getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 151 | printfcxx . . $ printf(581fddd72a8db8fc).("Dots input and output"); |
| 152 | modecxx . . $ mode. |= dotsIOcxx . . $ dotsIO. * getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 153 | printfcxx . . $ printf(581fddd72a8db8fc).("Computer Braille left of cursor"); |
| 154 | modecxx . . $ mode. |= compbrlLeftCursorcxx . . $ compbrlLeftCursor. * getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 155 | printfcxx . . $ printf(581fddd72a8db8fc).("Unicode Braille"); |
| 156 | modecxx . . $ mode. |= ucBrlcxx . . $ ucBrl. * getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 157 | printfcxx . . $ printf(581fddd72a8db8fc).("No undefined dots"); |
| 158 | modecxx . . $ mode. |= noUndefinedcxx . . $ noUndefined. * getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 159 | printfcxx . . $ printf(581fddd72a8db8fc).("Partial back-translation"); |
| 160 | modecxx . . $ mode. |= partialTranscxx . . $ partialTrans. * getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 161 | break; |
| 162 | case 'l': |
| 163 | printfcxx . . $ printf(581fddd72a8db8fc).("Do you want to test input and output lengths"); |
| 164 | showSizescxx . . $ showSizes. = getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 165 | if (!showSizescxx . . $ showSizes.) { |
| 166 | outputSizecxx . . $ outputSize. = BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!; |
| 167 | break; |
| 168 | } |
| 169 | printfcxx . . $ printf(581fddd72a8db8fc).("Enter a maximum output size: "); |
| 170 | getInputcxx . . $ getInput(b126dc7c1de90089).(); |
| 171 | outputSizecxx . . $ outputSize. = atoicxx . . $ atoi(5c4306d8553b3696).(inputBuffercxx . . $ inputBuffer.); |
| 172 | if (outputSizecxx . . $ outputSize. < 0 || outputSizecxx . . $ outputSize. > BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!) { |
| 173 | printfcxx . . $ printf(581fddd72a8db8fc).("Output size must be from 0 tu %d.\n", BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!); |
| 174 | outputSizecxx . . $ outputSize. = BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!; |
| 175 | showSizescxx . . $ showSizes. = 0; |
| 176 | } |
| 177 | break; |
| 178 | case 'c': |
| 179 | printfcxx . . $ printf(581fddd72a8db8fc).("Enter a cursor position: "); |
| 180 | getInputcxx . . $ getInput(b126dc7c1de90089).(); |
| 181 | enteredCursorPoscxx . . $ enteredCursorPos. = atoicxx . . $ atoi(5c4306d8553b3696).(inputBuffercxx . . $ inputBuffer.); |
| 182 | if (enteredCursorPoscxx . . $ enteredCursorPos. < -1 || enteredCursorPoscxx . . $ enteredCursorPos. > outputSizecxx . . $ outputSize.) { |
| 183 | printfcxx . . $ printf(581fddd72a8db8fc).("Cursor position must be from -1 to %d.\n", outputSizecxx . . $ outputSize.); |
| 184 | enteredCursorPoscxx . . $ enteredCursorPos. = -1; |
| 185 | } |
| 186 | break; |
| 187 | case 'e': |
| 188 | printfcxx . . $ printf(581fddd72a8db8fc).("(Enter an x to cancel emphasis.)\n"); |
| 189 | printfcxx . . $ printf(581fddd72a8db8fc).("Enter an emphasis string: "); |
| 190 | getInputcxx . . $ getInput(b126dc7c1de90089).(); |
| 191 | strcpycxx . . $ strcpy(b7b3a83273496486).(enteredEmphasiscxx . . $ enteredEmphasis., inputBuffercxx . . $ inputBuffer.); |
| 192 | break; |
| 193 | case 'h': |
| 194 | printfcxx . . $ printf(581fddd72a8db8fc).("Commands: action\n"); |
| 195 | printfcxx . . $ printf(581fddd72a8db8fc).("(t)able: Enter a table name\n"); |
| 196 | printfcxx . . $ printf(581fddd72a8db8fc).("(r)un: run the translation/back-translation loop\n"); |
| 197 | printfcxx . . $ printf(581fddd72a8db8fc).("(m)ode: Enter a mode parameter\n"); |
| 198 | printfcxx . . $ printf(581fddd72a8db8fc).("(c)ursor: Enter a cursor position\n"); |
| 199 | printfcxx . . $ printf(581fddd72a8db8fc).("(e)mphasis: Enter an emphasis string\n"); |
| 200 | printfcxx . . $ printf(581fddd72a8db8fc).("(h)elp: print this page\n"); |
| 201 | printfcxx . . $ printf(581fddd72a8db8fc).("(q)uit: leave the program\n"); |
| 202 | printfcxx . . $ printf(581fddd72a8db8fc).("(f)orward-only: do only forward translation\n"); |
| 203 | printfcxx . . $ printf(581fddd72a8db8fc).("(b)ack-only: do only back-translation\n"); |
| 204 | printfcxx . . $ printf(581fddd72a8db8fc).("show-(p)ositions: show input and output positions\n"); |
| 205 | printfcxx . . $ printf(581fddd72a8db8fc).("m(i)nimal: test translator and back-translator with minimal " |
| 206 | "parameters\n"); |
| 207 | printfcxx . . $ printf(581fddd72a8db8fc).("test-(l)engths: test accuracy of returned lengths\n"); |
| 208 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 209 | paramLetterscxx . . $ paramLetters(49f6e7a06ebc5aa8).(); |
| 210 | break; |
| 211 | case 'q': |
| 212 | lou_freecxx . . $ lou_free(49f6e7a06ebc5aa8).(); |
| 213 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!); |
| 214 | case 'f': |
| 215 | printfcxx . . $ printf(581fddd72a8db8fc).("Do only forward translation"); |
| 216 | forwardOnlycxx . . $ forwardOnly. = getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 217 | break; |
| 218 | case 'b': |
| 219 | printfcxx . . $ printf(581fddd72a8db8fc).("Do only backward translation"); |
| 220 | backOnlycxx . . $ backOnly. = getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 221 | break; |
| 222 | case 'p': |
| 223 | printfcxx . . $ printf(581fddd72a8db8fc).("Show input and output positions"); |
| 224 | showPositionscxx . . $ showPositions. = getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 225 | break; |
| 226 | case 'i': |
| 227 | printfcxx . . $ printf(581fddd72a8db8fc).("Test translation/back-translation loop with minimal parameters"); |
| 228 | minimalistcxx . . $ minimalist. = getYNcxx . . $ getYN(b126dc7c1de90089).(); |
| 229 | break; |
| 230 | default: |
| 231 | printfcxx . . $ printf(581fddd72a8db8fc).("Bad choice.\n"); |
| 232 | break; |
| 233 | } |
| 234 | if (forwardOnlycxx . . $ forwardOnly. && backOnlycxx . . $ backOnly.) |
| 235 | printfcxx . . $ printf(581fddd72a8db8fc).("You cannot specify both forward-only and backward-only " |
| 236 | "translation.\n"); |
| 237 | } while (inputBuffercxx . . $ inputBuffer.[0] != 'r'); |
| 238 | return 1; |
| 239 | } |
| 240 | |
| 241 | int |
| 242 | maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) { |
| 243 | uint8_tcxx . . $ uint8_t# *charbuf; |
| 244 | size_tcxx . . $ size_t# charlen; |
| 245 | widecharcxx . . $ widechar# inbuf[BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!]; |
| 246 | widecharcxx . . $ widechar# transbuf[BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!]; |
| 247 | widecharcxx . . $ widechar# outbuf[BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!]; |
| 248 | int outputPos[BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!]; |
| 249 | int inputPos[BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!]; |
| 250 | int inlen; |
| 251 | int translen; |
| 252 | int outlen; |
| 253 | int cursorPos = -1; |
| 254 | int realInlen = 0; |
| 255 | int optc; |
| 256 | |
| 257 | set_program_namecxx . . $ set_program_name(85c52e162fed56f9).(argv[0]); |
| 258 | |
| 259 | while ((optc = getopt_longcxx . . $ getopt_long(41f665c090816971).(argc, argv, "hv", longoptscxx . . $ longopts., NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!)) != -1) { |
| 260 | switch (optc) { |
| 261 | /* --help and --version exit immediately, per GNU coding standards. */ |
| 262 | case 'v': |
| 263 | version_etccxx . . $ version_etc(b5fd392babfe1cc5).( |
| 264 | stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!, program_namecxx . . $ program_name., PACKAGE_NAMEcxx . . $ `liblouis/config.h:631:9`!, VERSIONcxx . . $ `liblouis/config.h:804:9`!, AUTHORScxx . . $ `tools/lou_allround.c:46:9`!, (char *)NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!); |
| 265 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!); |
| 266 | break; |
| 267 | case 'h': |
| 268 | print_helpcxx . . $ print_help(49f6e7a06ebc5aa8).(); |
| 269 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!); |
| 270 | break; |
| 271 | default: |
| 272 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Try `%s --help' for more information.\n", program_namecxx . . $ program_name.); |
| 273 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!); |
| 274 | break; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | if (optindcxx . . $ optind. < argc) { |
| 279 | /* Print error message and exit. */ |
| 280 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: extra operand: %s\n", program_namecxx . . $ program_name., argv[optindcxx . . $ optind.]); |
| 281 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Try `%s --help' for more information.\n", program_namecxx . . $ program_name.); |
| 282 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!); |
| 283 | } |
| 284 | |
| 285 | validTablecxx . . $ validTable. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 286 | enteredCursorPoscxx . . $ enteredCursorPos. = -1; |
| 287 | modecxx . . $ mode. = 0; |
| 288 | while (1) { |
| 289 | getCommandscxx . . $ getCommands(b126dc7c1de90089).(); |
| 290 | printfcxx . . $ printf(581fddd72a8db8fc).("Type something, press enter, and view the results.\n"); |
| 291 | printfcxx . . $ printf(581fddd72a8db8fc).("A blank line returns to command entry.\n"); |
| 292 | if (minimalistcxx . . $ minimalist.) |
| 293 | while (1) { |
| 294 | translen = outputSizecxx . . $ outputSize.; |
| 295 | outlen = outputSizecxx . . $ outputSize.; |
| 296 | inlen = getInputcxx . . $ getInput(b126dc7c1de90089).(); |
| 297 | if (inlen == 0) break; |
| 298 | if (!(realInlen = _lou_extParseCharscxx . . $ _lou_extParseChars(c9bce2f4bcd31d4).(inputBuffercxx . . $ inputBuffer., inbuf))) break; |
| 299 | inlen = realInlen; |
| 300 | if (!lou_translateStringcxx . . $ lou_translateString(c5ef975c656107a8).( |
| 301 | tablecxx . . $ table., inbuf, &inlen, transbuf, &translen, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 0)) |
| 302 | break; |
| 303 | transbuf[translen] = 0; |
| 304 | printfcxx . . $ printf(581fddd72a8db8fc).("Translation:\n"); |
| 305 | #ifdef WIDECHARS_ARE_UCS4 |
| 306 | charbuf = u32_to_u8(transbuf, translen, NULL, &charlen); |
| 307 | #else |
| 308 | charbuf = u16_to_u8cxx . . $ u16_to_u8(e729bd8f99eea2d2).(transbuf, translen, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, &charlen); |
| 309 | #endif |
| 310 | printfcxx . . $ printf(581fddd72a8db8fc).("%.*s\n", (int)charlen, charbuf); |
| 311 | freecxx . . $ free(5d22bdacc48458e8).(charbuf); |
| 312 | if (showSizescxx . . $ showSizes.) |
| 313 | printfcxx . . $ printf(581fddd72a8db8fc).("input length = %d; output length = %d\n", inlen, translen); |
| 314 | lou_backTranslateStringcxx . . $ lou_backTranslateString(c5ef975c656107a8).( |
| 315 | tablecxx . . $ table., transbuf, &translen, outbuf, &outlen, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 0); |
| 316 | printfcxx . . $ printf(581fddd72a8db8fc).("Back-translation:\n"); |
| 317 | #ifdef WIDECHARS_ARE_UCS4 |
| 318 | charbuf = u32_to_u8(outbuf, outlen, NULL, &charlen); |
| 319 | #else |
| 320 | charbuf = u16_to_u8cxx . . $ u16_to_u8(e729bd8f99eea2d2).(outbuf, outlen, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, &charlen); |
| 321 | #endif |
| 322 | printfcxx . . $ printf(581fddd72a8db8fc).("%.*s\n", (int)charlen, charbuf); |
| 323 | freecxx . . $ free(5d22bdacc48458e8).(charbuf); |
| 324 | if (showSizescxx . . $ showSizes.) |
| 325 | printfcxx . . $ printf(581fddd72a8db8fc).("input length = %d; output length = %d.\n", translen, outlen); |
| 326 | if (outlen == realInlen) { |
| 327 | int k; |
| 328 | for (k = 0; k < realInlen; k++) |
| 329 | if (inbuf[k] != outbuf[k]) break; |
| 330 | if (k == realInlen) printfcxx . . $ printf(581fddd72a8db8fc).("Perfect roundtrip!\n"); |
| 331 | } |
| 332 | } |
| 333 | else |
| 334 | while (1) { |
| 335 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(emphasiscxx . . $ emphasis., 0, sizeof(formtypecxx . . $ formtype#) * BUFSIZEcxx . . $ `tools/lou_allround.c:75:9`!); |
| 336 | { |
| 337 | size_tcxx . . $ size_t# k = 0; |
| 338 | for (k = 0; k < strlencxx . . $ strlen(751346f8406fd082).(enteredEmphasiscxx . . $ enteredEmphasis.); k++) |
| 339 | emphasiscxx . . $ emphasis.[k] = (formtypecxx . . $ formtype#)enteredEmphasiscxx . . $ enteredEmphasis.[k] - '0'; |
| 340 | emphasiscxx . . $ emphasis.[k] = 0; |
| 341 | } |
| 342 | cursorPos = enteredCursorPoscxx . . $ enteredCursorPos.; |
| 343 | inlen = getInputcxx . . $ getInput(b126dc7c1de90089).(); |
| 344 | if (inlen == 0) break; |
| 345 | outlen = outputSizecxx . . $ outputSize.; |
| 346 | if (backOnlycxx . . $ backOnly.) { |
| 347 | if (!(translen = _lou_extParseCharscxx . . $ _lou_extParseChars(c9bce2f4bcd31d4).(inputBuffercxx . . $ inputBuffer., transbuf))) break; |
| 348 | inlen = realInlen; |
| 349 | } else { |
| 350 | translen = outputSizecxx . . $ outputSize.; |
| 351 | if (!(realInlen = _lou_extParseCharscxx . . $ _lou_extParseChars(c9bce2f4bcd31d4).(inputBuffercxx . . $ inputBuffer., inbuf))) break; |
| 352 | inlen = realInlen; |
| 353 | if (!lou_translatecxx . . $ lou_translate(62dc23c046bfbb96).(tablecxx . . $ table., inbuf, &inlen, transbuf, &translen, |
| 354 | emphasiscxx . . $ emphasis., NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, &outputPos[0], &inputPos[0], &cursorPos, |
| 355 | modecxx . . $ mode.)) |
| 356 | break; |
| 357 | transbuf[translen] = 0; |
| 358 | if (modecxx . . $ mode. & dotsIOcxx . . $ dotsIO.) { |
| 359 | printfcxx . . $ printf(581fddd72a8db8fc).("Translation dot patterns:\n"); |
| 360 | printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", _lou_showDotscxx . . $ _lou_showDots(dfd108baace36870).(transbuf, translen)); |
| 361 | } else { |
| 362 | printfcxx . . $ printf(581fddd72a8db8fc).("Translation:\n"); |
| 363 | #ifdef WIDECHARS_ARE_UCS4 |
| 364 | charbuf = u32_to_u8(transbuf, translen, NULL, &charlen); |
| 365 | #else |
| 366 | charbuf = u16_to_u8cxx . . $ u16_to_u8(e729bd8f99eea2d2).(transbuf, translen, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, &charlen); |
| 367 | #endif |
| 368 | printfcxx . . $ printf(581fddd72a8db8fc).("%.*s\n", (int)charlen, charbuf); |
| 369 | freecxx . . $ free(5d22bdacc48458e8).(charbuf); |
| 370 | if (showSizescxx . . $ showSizes.) |
| 371 | printfcxx . . $ printf(581fddd72a8db8fc).("input length = %d; output length = %d\n", inlen, |
| 372 | translen); |
| 373 | } |
| 374 | } |
| 375 | if (cursorPos != -1) printfcxx . . $ printf(581fddd72a8db8fc).("Cursor position: %d\n", cursorPos); |
| 376 | if (showPositionscxx . . $ showPositions.) { |
| 377 | printfcxx . . $ printf(581fddd72a8db8fc).("Output positions:\n"); |
| 378 | for (int k = 0; k < inlen; k++) printfcxx . . $ printf(581fddd72a8db8fc).("%d ", outputPos[k]); |
| 379 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 380 | printfcxx . . $ printf(581fddd72a8db8fc).("Input positions:\n"); |
| 381 | for (int k = 0; k < translen; k++) printfcxx . . $ printf(581fddd72a8db8fc).("%d ", inputPos[k]); |
| 382 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 383 | } |
| 384 | if (!forwardOnlycxx . . $ forwardOnly.) { |
| 385 | if (!lou_backTranslatecxx . . $ lou_backTranslate(62dc23c046bfbb96).(tablecxx . . $ table., transbuf, &translen, outbuf, &outlen, |
| 386 | emphasiscxx . . $ emphasis., NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, &outputPos[0], &inputPos[0], &cursorPos, |
| 387 | modecxx . . $ mode.)) |
| 388 | break; |
| 389 | printfcxx . . $ printf(581fddd72a8db8fc).("Back-translation:\n"); |
| 390 | #ifdef WIDECHARS_ARE_UCS4 |
| 391 | charbuf = u32_to_u8(outbuf, outlen, NULL, &charlen); |
| 392 | #else |
| 393 | charbuf = u16_to_u8cxx . . $ u16_to_u8(e729bd8f99eea2d2).(outbuf, outlen, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, &charlen); |
| 394 | #endif |
| 395 | printfcxx . . $ printf(581fddd72a8db8fc).("%.*s\n", (int)charlen, charbuf); |
| 396 | freecxx . . $ free(5d22bdacc48458e8).(charbuf); |
| 397 | if (showSizescxx . . $ showSizes.) |
| 398 | printfcxx . . $ printf(581fddd72a8db8fc).("input length = %d; output length = %d\n", translen, |
| 399 | outlen); |
| 400 | if (cursorPos != -1) printfcxx . . $ printf(581fddd72a8db8fc).("Cursor position: %d\n", cursorPos); |
| 401 | if (showPositionscxx . . $ showPositions.) { |
| 402 | printfcxx . . $ printf(581fddd72a8db8fc).("Output positions:\n"); |
| 403 | for (int k = 0; k < translen; k++) printfcxx . . $ printf(581fddd72a8db8fc).("%d ", outputPos[k]); |
| 404 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 405 | printfcxx . . $ printf(581fddd72a8db8fc).("Input positions:\n"); |
| 406 | for (int k = 0; k < outlen; k++) printfcxx . . $ printf(581fddd72a8db8fc).("%d ", inputPos[k]); |
| 407 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 408 | } |
| 409 | } |
| 410 | if (!(forwardOnlycxx . . $ forwardOnly. || backOnlycxx . . $ backOnly.)) { |
| 411 | if (outlen == realInlen) { |
| 412 | int k; |
| 413 | for (k = 0; k < realInlen; k++) |
| 414 | if (inbuf[k] != outbuf[k]) break; |
| 415 | if (k == realInlen) printfcxx . . $ printf(581fddd72a8db8fc).("Perfect roundtrip!\n"); |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | lou_freecxx . . $ lou_free(49f6e7a06ebc5aa8).(); |
| 421 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!); |
| 422 | } |