paste.c (schily-2021-08-14.tar.bz2) | : | paste.c (schily-2021-09-18.tar.bz2) | ||
---|---|---|---|---|
/* @(#)paste.c 1.21 15/08/06 Copyright 1985-2015 J. Schilling */ | /* @(#)paste.c 1.22 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[] = | |||
"@(#)paste.c 1.21 15/08/06 Copyright 1985-2015 J. Schilling"; | "@(#)paste.c 1.22 21/08/20 Copyright 1985-2021 J. Schilling"; | |||
#endif | #endif | |||
/* | /* | |||
* Paste some files together | * Paste some files together | |||
* | * | |||
* 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 | |||
* | * | |||
* 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/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/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 MIN_LINELEN 4096 /* Min line size */ | #define MIN_LINELEN 4096 /* Min line size */ | |||
#define INCR_LINELEN 4096 /* Increment for line size */ | #define INCR_LINELEN 4096 /* Increment for line size */ | |||
#define MAX_FILES (256-3) /* Max # of files */ | #define MAX_FILES (256-3) /* Max # of files */ | |||
LOCAL BOOL eofp[MAX_FILES]; /* Files that did hit EOF */ | LOCAL BOOL eofp[MAX_FILES]; /* Files that did hit EOF */ | |||
LOCAL FILE *filep[MAX_FILES] = {0}; /* Files to work on */ | LOCAL FILE *filep[MAX_FILES] = {0}; /* Files to work on */ | |||
LOCAL char *delim; | LOCAL char *delim; | |||
LOCAL int delimlen; | LOCAL int delimlen; | |||
LOCAL int empty; | LOCAL int empty; | |||
skipping to change at line 83 | skipping to change at line 86 | |||
int i = 0; /* Count # of input files */ | int i = 0; /* Count # of input files */ | |||
char *options = "help,version,d*,e,s,width#,w#"; | char *options = "help,version,d*,e,s,width#,w#"; | |||
int help = 0; | int help = 0; | |||
int prvers = 0; | int prvers = 0; | |||
int ser = 0; | int ser = 0; | |||
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 "paste" /* 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, &help, &prvers, | if (getallargs(&cac, &cav, options, &help, &prvers, | |||
&delim, &empty, &ser, | &delim, &empty, &ser, | |||
&linesize, &linesize) < 0) { | &linesize, &linesize) < 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("Paste release %s (%s-%s-%s) Copyright (C) 1985-2015 Jörg | gtprintf("Paste release %s (%s-%s-%s) Copyright (C) 1985-2021 %s\ | |||
Schilling\n", | n", | |||
"1.21", | "1.22", | |||
HOST_CPU, HOST_VENDOR, HOST_OS); | HOST_CPU, HOST_VENDOR, HOST_OS, | |||
_("Jörg Schilling")); | ||||
exit(0); | exit(0); | |||
} | } | |||
if (delim) { | if (delim) { | |||
delimlen = parsedelim(delim); | delimlen = parsedelim(delim); | |||
if (delimlen == 0) | if (delimlen == 0) | |||
comerrno(EX_BAD, "No delimiter.\n"); | comerrno(EX_BAD, "No delimiter.\n"); | |||
} else { | } else { | |||
delim = "\t"; | delim = "\t"; | |||
delimlen = 1; | delimlen = 1; | |||
End of changes. 7 change blocks. | ||||
7 lines changed or deleted | 33 lines changed or added |