cut.c (schily-2021-08-14.tar.bz2) | : | cut.c (schily-2021-09-18.tar.bz2) | ||
---|---|---|---|---|
/* @(#)cut.c 1.21 15/11/17 Copyright 1985-2015 J. Schilling */ | /* @(#)cut.c 1.23 21/08/20 Copyright 1985-2021 J. Schilling */ | |||
#include <schily/mconfig.h> | #include <schily/mconfig.h> | |||
#ifndef lint | #ifndef lint | |||
static const char sccsid[] = | static const char sccsid[] = | |||
"@(#)cut.c 1.21 15/11/17 Copyright 1985-2015 J. Schilling"; | "@(#)cut.c 1.23 21/08/20 Copyright 1985-2021 J. Schilling"; | |||
#endif | #endif | |||
/* | /* | |||
* Cut files into fields | * Cut files into fields | |||
* | * | |||
* Copyright (c) 1985-2015 J. Schilling | * Copyright (c) 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 33 | skipping to change at line 33 | |||
* 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/mconfig.h> | #include <schily/mconfig.h> | |||
#include <schily/stdio.h> | #include <schily/stdio.h> | |||
#include <schily/stdlib.h> | #include <schily/stdlib.h> | |||
#include <schily/unistd.h> /* For sys/types.h to make off_t available */ | #include <schily/unistd.h> /* For sys/types.h to make off_t available */ | |||
#include <schily/inttypes.h> | #include <schily/inttypes.h> | |||
#include <schily/string.h> | #include <schily/string.h> | |||
#include <schily/standard.h> | #include <schily/standard.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 NO_NUMBER -1 /* No number found */ | #define NO_NUMBER -1 /* No number found */ | |||
#define CUT_NONE 0 /* No cut type yet */ | #define CUT_NONE 0 /* No cut type yet */ | |||
#define CUT_FIELDS 1 /* Cut by fields */ | #define CUT_FIELDS 1 /* Cut by fields */ | |||
#define CUT_COLS 2 /* Cut by columns */ | #define CUT_COLS 2 /* Cut by columns */ | |||
#define MAX_FIELDS 1024 /* Max # of fields */ | #define MAX_FIELDS 1024 /* Max # of fields */ | |||
LOCAL char inp_delim = '\t'; /* The input delimiter */ | LOCAL char inp_delim = '\t'; /* The input delimiter */ | |||
skipping to change at line 104 | skipping to change at line 107 | |||
BOOL help = FALSE; | BOOL help = FALSE; | |||
BOOL prvers = FALSE; | BOOL prvers = FALSE; | |||
int cut_type = CUT_NONE; | int cut_type = CUT_NONE; | |||
char *c_range = NULL; | char *c_range = NULL; | |||
char *f_range = NULL; | char *f_range = NULL; | |||
FILE *fp = NULL; /* Keep silly gcc happy */ | FILE *fp = NULL; /* Keep silly gcc happy */ | |||
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 "cut" /* 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 */ | ||||
cac = --ac; | cac = --ac; | |||
cav = ++av; | cav = ++av; | |||
if (getallargs(&cac, &cav, options, | if (getallargs(&cac, &cav, options, | |||
&inp_delim, &outp_delim, | &inp_delim, &outp_delim, | |||
&no_odelim, | &no_odelim, | |||
&c_range, &f_range, &sup_nodel, &help, &prvers) < 0) { | &c_range, &f_range, &sup_nodel, &help, &prvers) < 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 (prvers) { | if (prvers) { | |||
/* CSTYLED */ | /* CSTYLED */ | |||
printf("Cut release %s (%s-%s-%s) Copyright (C) 1985-2015 Jörg Sc | gtprintf("Cut release %s (%s-%s-%s) Copyright (C) 1985-2021 %s\n" | |||
hilling\n", | , | |||
"1.21", | "1.23", | |||
HOST_CPU, HOST_VENDOR, HOST_OS); | HOST_CPU, HOST_VENDOR, HOST_OS, | |||
_("Jörg Schilling")); | ||||
exit(0); | exit(0); | |||
} | } | |||
if (c_range && f_range) { | if (c_range && f_range) { | |||
errmsgno(EX_BAD, | errmsgno(EX_BAD, | |||
"Can't have both character and field specified.\n"); | "Can't have both character and field specified.\n"); | |||
usage(EX_BAD); | usage(EX_BAD); | |||
} | } | |||
if (c_range) { | if (c_range) { | |||
End of changes. 7 change blocks. | ||||
7 lines changed or deleted | 33 lines changed or added |