Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/localedef/localedef.c
Show All 40 Lines | |||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <libgen.h> | #include <libgen.h> | ||||
#include <stddef.h> | #include <stddef.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <limits.h> | #include <limits.h> | ||||
#include <locale.h> | #include <locale.h> | ||||
#include <dirent.h> | #include <dirent.h> | ||||
#include "collate.h" | |||||
#include "localedef.h" | #include "localedef.h" | ||||
#include "parser.h" | #include "parser.h" | ||||
#ifndef TEXT_DOMAIN | #ifndef TEXT_DOMAIN | ||||
#define TEXT_DOMAIN "SYS_TEST" | #define TEXT_DOMAIN "SYS_TEST" | ||||
#endif | #endif | ||||
static int bsd = 0; | static int bsd = 0; | ||||
int verbose = 0; | int verbose = 0; | ||||
int undefok = 0; | int undefok = 0; | ||||
int warnok = 0; | int warnok = 0; | ||||
static char *locname = NULL; | static char *locname = NULL; | ||||
static char locpath[PATH_MAX]; | static char locpath[PATH_MAX]; | ||||
char *version = NULL; | |||||
const char * | const char * | ||||
category_name(void) | category_name(void) | ||||
{ | { | ||||
switch (get_category()) { | switch (get_category()) { | ||||
case T_CHARMAP: | case T_CHARMAP: | ||||
return ("CHARMAP"); | return ("CHARMAP"); | ||||
case T_WIDTH: | case T_WIDTH: | ||||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | usage(void) | ||||
(void) fprintf(stderr, " -D : BSD-style output\n"); | (void) fprintf(stderr, " -D : BSD-style output\n"); | ||||
(void) fprintf(stderr, " -c : ignore warnings\n"); | (void) fprintf(stderr, " -c : ignore warnings\n"); | ||||
(void) fprintf(stderr, " -v : verbose output\n"); | (void) fprintf(stderr, " -v : verbose output\n"); | ||||
(void) fprintf(stderr, " -U : ignore undefined symbols\n"); | (void) fprintf(stderr, " -U : ignore undefined symbols\n"); | ||||
(void) fprintf(stderr, " -f charmap : use given charmap file\n"); | (void) fprintf(stderr, " -f charmap : use given charmap file\n"); | ||||
(void) fprintf(stderr, " -u encoding : assume encoding\n"); | (void) fprintf(stderr, " -u encoding : assume encoding\n"); | ||||
(void) fprintf(stderr, " -w widths : use screen widths file\n"); | (void) fprintf(stderr, " -w widths : use screen widths file\n"); | ||||
(void) fprintf(stderr, " -i locsrc : source file for locale\n"); | (void) fprintf(stderr, " -i locsrc : source file for locale\n"); | ||||
(void) fprintf(stderr, " -V version : version string for locale\n"); | |||||
exit(4); | exit(4); | ||||
} | } | ||||
int | int | ||||
main(int argc, char **argv) | main(int argc, char **argv) | ||||
{ | { | ||||
int c; | int c; | ||||
char *lfname = NULL; | char *lfname = NULL; | ||||
char *cfname = NULL; | char *cfname = NULL; | ||||
char *wfname = NULL; | char *wfname = NULL; | ||||
DIR *dir; | DIR *dir; | ||||
init_charmap(); | init_charmap(); | ||||
init_collate(); | init_collate(); | ||||
init_ctype(); | init_ctype(); | ||||
init_messages(); | init_messages(); | ||||
init_monetary(); | init_monetary(); | ||||
init_numeric(); | init_numeric(); | ||||
init_time(); | init_time(); | ||||
yydebug = 0; | yydebug = 0; | ||||
(void) setlocale(LC_ALL, ""); | (void) setlocale(LC_ALL, ""); | ||||
while ((c = getopt(argc, argv, "w:i:cf:u:vUD")) != -1) { | while ((c = getopt(argc, argv, "w:i:cf:u:vUDV:")) != -1) { | ||||
switch (c) { | switch (c) { | ||||
case 'D': | case 'D': | ||||
bsd = 1; | bsd = 1; | ||||
break; | break; | ||||
case 'v': | case 'v': | ||||
verbose++; | verbose++; | ||||
break; | break; | ||||
case 'i': | case 'i': | ||||
Show All 12 Lines | case 'c': | ||||
warnok++; | warnok++; | ||||
break; | break; | ||||
case 'w': | case 'w': | ||||
wfname = optarg; | wfname = optarg; | ||||
break; | break; | ||||
case '?': | case '?': | ||||
usage(); | usage(); | ||||
break; | break; | ||||
case 'V': | |||||
version = optarg; | |||||
break; | |||||
} | } | ||||
} | } | ||||
if ((argc - 1) != (optind)) { | if ((argc - 1) != (optind)) { | ||||
usage(); | usage(); | ||||
} | } | ||||
locname = argv[argc - 1]; | locname = argv[argc - 1]; | ||||
if (verbose) { | if (verbose) { | ||||
(void) printf("Processing locale %s.\n", locname); | (void) printf("Processing locale %s.\n", locname); | ||||
} | |||||
if (version && strlen(version) >= XLOCALE_VERSION_LEN) { | |||||
(void) fprintf(stderr, "Version string too long.\n"); | |||||
exit(1); | |||||
} | } | ||||
if (cfname) { | if (cfname) { | ||||
if (verbose) | if (verbose) | ||||
(void) printf("Loading charmap %s.\n", cfname); | (void) printf("Loading charmap %s.\n", cfname); | ||||
reset_scanner(cfname); | reset_scanner(cfname); | ||||
(void) yyparse(); | (void) yyparse(); | ||||
} | } | ||||
Show All 37 Lines |