translit.c (schily-2021-08-14.tar.bz2) | : | translit.c (schily-2021-09-18.tar.bz2) | ||
---|---|---|---|---|
/* @(#)translit.c 1.18 15/12/26 Copyright 1985-2015 J. Schilling */ | /* @(#)translit.c 1.19 21/08/20 Copyright 1985-2021 J. Schilling */ | |||
#include <schily/mconfig.h> | #include <schily/mconfig.h> | |||
#ifndef lint | #ifndef lint | |||
static UConst char sccsid[] = | static UConst char sccsid[] = | |||
"@(#)translit.c 1.18 15/12/26 Copyright 1985-2015 J. Schilling"; | "@(#)translit.c 1.19 21/08/20 Copyright 1985-2021 J. Schilling"; | |||
#endif | #endif | |||
/* | /* | |||
* translit - translate characters | * translit - translate characters | |||
* | * | |||
* translit fromset toset file1...filen | * translit fromset toset file1...filen | |||
* | * | |||
* Copyright 1985-2015 J. Schilling | * Copyright 1985-2021 J. Schilling | |||
*/ | */ | |||
/* | /* | |||
* The contents of this file are subject to the terms of the | * The contents of this file are subject to the terms of the | |||
* Common Development and Distribution License, Version 1.0 only | * Common Development and Distribution License, Version 1.0 only | |||
* (the "License"). You may not use this file except in compliance | * (the "License"). You may not use this file except in compliance | |||
* with the License. | * with the License. | |||
* | * | |||
* See the file CDDL.Schily.txt in this distribution for details. | * See the file CDDL.Schily.txt in this distribution for details. | |||
* A copy of the CDDL is also available via the Internet at | * A copy of the CDDL is also available via the Internet at | |||
* http://www.opensource.org/licenses/cddl1.txt | * http://www.opensource.org/licenses/cddl1.txt | |||
skipping to change at line 35 | skipping to change at line 35 | |||
* When distributing Covered Code, include this CDDL HEADER in each | * When distributing Covered Code, include this CDDL HEADER in each | |||
* file and include the License file CDDL.Schily.txt from this distribution. | * file and include the License file CDDL.Schily.txt from this distribution. | |||
*/ | */ | |||
#include <schily/stdio.h> | #include <schily/stdio.h> | |||
#include <schily/standard.h> | #include <schily/standard.h> | |||
#include <schily/stdlib.h> | #include <schily/stdlib.h> | |||
#include <schily/unistd.h> /* Include sys/types.h */ | #include <schily/unistd.h> /* Include sys/types.h */ | |||
#include <schily/utypes.h> | #include <schily/utypes.h> | |||
#include <schily/string.h> | #include <schily/string.h> | |||
#define GT_COMERR /* #define comerr gtcomerr */ | ||||
#define GT_ERROR /* #define error gterror */ | ||||
#include <schily/schily.h> | #include <schily/schily.h> | |||
#include <schily/nlsdefs.h> | ||||
#define TBUFSIZE 4096 /* Scratch buffer size for unescaped char s */ | #define TBUFSIZE 4096 /* Scratch buffer size for unescaped char s */ | |||
#define NUMCHARS 256 /* TYPE_MAXVAL(Uchar) + 1 * / | #define NUMCHARS 256 /* TYPE_MAXVAL(Uchar) + 1 * / | |||
LOCAL Uchar trchars[256]; /* Character translation table */ | LOCAL Uchar trchars[256]; /* Character translation table */ | |||
LOCAL Uchar delchars[256]; /* Chars to delete from output */ | LOCAL Uchar delchars[256]; /* Chars to delete from output */ | |||
LOCAL Uchar sqchars[256]; /* Multchars to replace w. single char */ | LOCAL Uchar sqchars[256]; /* Multchars to replace w. single char */ | |||
LOCAL BOOL cflag = FALSE; | LOCAL BOOL cflag = FALSE; | |||
LOCAL BOOL foldflag = FALSE; | LOCAL BOOL foldflag = FALSE; | |||
LOCAL Uchar foldchar = '\0'; | LOCAL Uchar foldchar = '\0'; | |||
skipping to change at line 92 | skipping to change at line 95 | |||
Uchar *toset = NULL; | Uchar *toset = NULL; | |||
Uchar *sqset = NULL; | Uchar *sqset = NULL; | |||
BOOL help = FALSE; | BOOL help = FALSE; | |||
BOOL prversion = FALSE; | BOOL prversion = FALSE; | |||
BOOL delflg = FALSE; | BOOL delflg = FALSE; | |||
BOOL sqflg = FALSE; | BOOL sqflg = FALSE; | |||
int cac; | int cac; | |||
char * const* cav; | char * const* cav; | |||
save_args(ac, av); | save_args(ac, av); | |||
(void) setlocale(LC_ALL, ""); | ||||
#ifdef USE_NLS | ||||
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ | ||||
#define TEXT_DOMAIN "translit" /* Use this only if it weren't */ | ||||
#endif | ||||
{ char *dir; | ||||
dir = searchfileinpath("share/locale", F_OK, | ||||
SIP_ANY_FILE|SIP_NO_PATH, NULL); | ||||
if (dir) | ||||
(void) bindtextdomain(TEXT_DOMAIN, dir); | ||||
else | ||||
#if defined(PROTOTYPES) && defined(INS_BASE) | ||||
(void) bindtextdomain(TEXT_DOMAIN, INS_BASE "/share/locale"); | ||||
#else | ||||
(void) bindtextdomain(TEXT_DOMAIN, "/usr/share/locale"); | ||||
#endif | ||||
(void) textdomain(TEXT_DOMAIN); | ||||
} | ||||
#endif /* USE_NLS */ | ||||
is_translit = streql(filename(av[0]), "translit"); | is_translit = streql(filename(av[0]), "translit"); | |||
cac = --ac; | cac = --ac; | |||
cav = ++av; | cav = ++av; | |||
file_raise((FILE *)NULL, FALSE); | file_raise((FILE *)NULL, FALSE); | |||
if (getallargs(&cac, &cav, opts, &help, &prversion, | if (getallargs(&cac, &cav, opts, &help, &prversion, | |||
&cflag, &delflg, &sqflg) < 0) { | &cflag, &delflg, &sqflg) < 0) { | |||
errmsgno(EX_BAD, "Bad flag: %s.\n", cav[0]); | errmsgno(EX_BAD, "Bad flag: %s.\n", cav[0]); | |||
usage(EX_BAD); | usage(EX_BAD); | |||
} | } | |||
if (help) | if (help) | |||
usage(0); | usage(0); | |||
if (prversion) { | if (prversion) { | |||
printf( | gtprintf( | |||
"Translit release %s (%s-%s-%s) Copyright (C) 1985-2015 Jörg Schilling\n", | "Translit release %s (%s-%s-%s) Copyright (C) 1985-2021 %s\n", | |||
"1.18", | "1.19", | |||
HOST_CPU, HOST_VENDOR, HOST_OS); | HOST_CPU, HOST_VENDOR, HOST_OS, | |||
_("Jörg Schilling")); | ||||
exit(0); | exit(0); | |||
} | } | |||
cac = ac; | cac = ac; | |||
cav = av; | cav = av; | |||
if (getfiles(&cac, &cav, opts) <= 0) { | if (getfiles(&cac, &cav, opts) <= 0) { | |||
errmsgno(EX_BAD, "No 'from' string given.\n"); | errmsgno(EX_BAD, "No 'from' string given.\n"); | |||
usage(EX_BAD); | usage(EX_BAD); | |||
} | } | |||
fromset = (Uchar *)cav[0]; | fromset = (Uchar *)cav[0]; | |||
End of changes. 7 change blocks. | ||||
7 lines changed or deleted | 33 lines changed or added |