diff options
author | Roland Mainz <roland.mainz@nrubsig.org> | 2009-10-28 10:36:39 -0700 |
---|---|---|
committer | Roland Mainz <roland.mainz@nrubsig.org> | 2009-10-28 10:36:39 -0700 |
commit | 34f9b3eef6fdadbda0a846aa4d68691ac40eace5 (patch) | |
tree | 0b0fdfb35f8eb9324728de5a99e50e939aca650f /usr/src/cmd/paste/paste.c | |
parent | 14969419acb89bb74e6c95fa472119b710224440 (diff) | |
download | illumos-joyent-34f9b3eef6fdadbda0a846aa4d68691ac40eace5.tar.gz |
Portions contributed by Olga Kryzhanovska <olga.kryzhanovska@gmail.com>
PSARC/2009/063 ksh93 update 2
PSARC/2009/248 ksh93 update to 2009-03-10
PSARC/2009/249 more ksh93 command conversions
6888396 libast sources should not include localedef.h
6605478 ksh93 profile shell option does not work
6631006 ksh93 hangs in situations that ksh handles okay
6661487 logname reports nothing after running the script command
6705126 first call to read doesn't honor new setting of HISTFILE
6764665 *libpp* Array overrun in libpp
6765756 *libast* Array overruns in libast
6769332 Recursive function+command substitutions terminate shell after 257 iterations
6777491 *ksh93* lacks arithmetric function iszero()
6778077 *ksh93* does not understand "THAW" as a signal for use with trap
6789247 [ku1] libast/ksh93 1-digit hexfloat base conversion rounds incorrectly
6791838 *ksh93* unset of a variable which is not set should return 0
6793714 RFE: Update /usr/bin/comm to AT&T AST "comm"
6793719 RFE: Update /usr/bin/cut to AT&T AST "cut"
6793721 RFE: Update /usr/bin/paste to AT&T AST "paste"
6793722 RFE: Update /usr/bin/cmp to AT&T AST "cmp"
6793726 RFE: Update /usr/bin/uniq to AT&T AST "uniq"
6793735 RFE: Update /usr/bin/wc to AT&T AST "wc"
6793744 RFE: Add /usr/share/doc/ksh/ for ksh93 documentation
6793747 RFE: Provide "print" builtin as /usr/bin/print for external applications
6793763 RFE: Update /usr/bin/ksh93 to ast-ksh.2009-05-05
6794952 RFE: Enable "globstar" mode in /etc/ksh.kshrc (= interactive ksh93 shells)
6805792 [ku1] Moving local compound var into array does not work
6805794 [ku1] printf returns "invalid character constant" for $ printf "%d\n" "'<euro>"
6805795 [ku1] ksh93 does not differ between -0 and +0
6805797 [ku1]Can't append to nodes of an array of compound vars if addressing them via nameref
6805799 Indexed compound variable arrays do not work...
6805800 [ku1] Declaring associative compound array does not work
6805813 RFE: Update /usr/bin/join to AT&T AST "join".
6805819 RFE: Update /usr/bin/tee to AT&T AST "tee".
6809663 shlint missing ending newline on errors
6811916 ksh93 repeatedly segfaults when "tee" builtin is interrupted via <ctrl-c> in interactive mode
6821113 SUNWosdem package issues
6828644 RFE: Update /usr/bin/logname to AT&T AST "logname".
6828692 RFE: Update /usr/bin/cksum to AT&T AST "cksum".
6834184 ksh93 gets SIGSEGV if HISTFILE is changed in place.
6834207 ksh93 gets SIGSEGV on interactive function definition with HISTSIZE unset
6835835 ksh93 "cat" builtin does not handle "-n" correctly
6841442 Need exception list for OS/Net trees managed via Subversion
6848486 "echo ${test}" with test undefined crashes the shell
6850672 ksh93 (VISUAL=vi) crashes with memory fault while scrolling through history
6855875 typeset -X x ; print $x # does not print sufficient digits to restore value
6857344 /usr/bin/hash core dump with invalid arguments
6866676 Need test suite module to test the kernel support for compiled shell scripts
6881017 Subshell doesn't exit, holds pipe open preventing callers from exiting
6884409 fts functions in libast library can result in segv with deep dir trees (similar to CERT VU#590371)
Diffstat (limited to 'usr/src/cmd/paste/paste.c')
-rw-r--r-- | usr/src/cmd/paste/paste.c | 268 |
1 files changed, 0 insertions, 268 deletions
diff --git a/usr/src/cmd/paste/paste.c b/usr/src/cmd/paste/paste.c deleted file mode 100644 index 14fc096b0e..0000000000 --- a/usr/src/cmd/paste/paste.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1994 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T - * All Rights Reserved - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <locale.h> -#include <widec.h> -#include <stdlib.h> -#include <limits.h> - - -#define MAXOPNF 12 /* maximal no. of open files (not with -s option) */ -#define MAXOPNF_STR "12" -#define RUB '\177' - - -/* - * Function prototypes - */ -static void diag(char *, char *); -static int move(char *, wchar_t *); -static void usage(); - -int -main(int argc, char **argv) -{ - int i, j, k, eofcount, nfiles, maxline, glue; - int delcount = 1; - int onefile = 0; - register int c; - wchar_t del[LINE_MAX]; - wchar_t outbuf[LINE_MAX], l, t; - register wchar_t *p; - FILE *inptr[MAXOPNF]; - int arg_ind; - int file_ind; - int error = 0; - - - /* Get locale variables from environment */ - (void) setlocale(LC_ALL, ""); - -#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ -#define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */ -#endif - (void) textdomain(TEXT_DOMAIN); - - del[0] = '\t'; - maxline = LINE_MAX -2; - - /* Get command arguments */ - while ((c = getopt(argc, argv, "d:s")) != EOF) { - switch (c) { - case 'd' : - delcount = move(optarg, del); - if (delcount < 1) - diag("paste: no delimiters\n", NULL); - break; - - case 's' : - onefile++; - break; - - case '?': - usage(); - - /* NOTREACHED */ - break; - } - } - - if (!onefile) { /* not -s option: parallel line merging */ - - /* Find explicit stdin and file names */ - for (file_ind = 0, arg_ind = optind; arg_ind < argc && - file_ind < MAXOPNF; arg_ind++) { - if (argv[arg_ind][0] == '-' && - argv[arg_ind][1] == '\0') { - inptr[file_ind++] = stdin; - } else if (arg_ind >= optind) { - inptr[file_ind++] = fopen(argv[arg_ind], "r"); - if (inptr[file_ind -1] == NULL) { - diag("paste: cannot open %s\n", - argv[arg_ind]); - } - } - } - if (arg_ind < argc) { - char maxopnf_buf[LINE_MAX]; - (void) sprintf(maxopnf_buf, "%d", MAXOPNF); - diag("paste: too many files- limit %s\n", maxopnf_buf); - } - nfiles = file_ind; - - do { - p = &outbuf[0]; - eofcount = 0; - j = k = 0; - for (i = 0; i < nfiles; i++) { - while ((c = fgetwc(inptr[i])) != '\n' && - c != EOF) { - if (++j <= maxline) - *p++ = c; - else { - diag( - "paste: line too long\n", - NULL); - } - } - if ((l = del[k]) != RUB) - *p++ = l; - - k = (k + 1) % delcount; - - if (c == EOF) - eofcount++; - } - if (l != RUB) - *--p = '\n'; - else - *p = '\n'; - *++p = 0; - if (eofcount < nfiles) - (void) printf("%ws", outbuf); - } while (eofcount < nfiles); - - } else { /* -s option: serial file pasting (old 127 paste command) */ - - for (i = optind; i < argc; i++) { - p = &outbuf[0]; - glue = 0; - j = 0; - k = 0; - t = 0; - if (argv[i][0] == '-' && - argv[i][1] == '\0') { - inptr[0] = stdin; - } else if (i >= optind) { - inptr[0] = fopen(argv[i], "r"); - if (inptr[0] == NULL) { - (void) fprintf(stderr, gettext( - "paste: cannot open %s\n"), argv[i]); - error = 1; - } - } - - /* Argument not a file name */ - if (inptr[0] == NULL) { - continue; - } - - while ((c = fgetwc(inptr[0])) != EOF) { - if (j >= maxline) { - t = *--p; - *++p = 0; - (void) printf("%ws", outbuf); - p = &outbuf[0]; - j = 0; - } - if (glue) { - glue = 0; - l = del[k]; - if (l != RUB) { - *p++ = l; - t = l; - j++; - } - k = (k + 1) % delcount; - } - if (c != '\n') { - *p++ = c; - t = c; - j++; - } else glue++; - } - if (t != '\n') { - *p++ = '\n'; - j++; - } - if (j > 0) { - *p = 0; - (void) printf("%ws", outbuf); - } - } - } - return (error); -} - - -static void -diag(char *s, char *arg) -{ - (void) fprintf(stderr, gettext(s), arg); - exit(1); -} - - -static int -move(char *from, wchar_t *to) -{ - int i, n; - wchar_t wc; - - i = 0; - while (*from) { - n = mbtowc(&wc, from, MB_CUR_MAX); - if (n <= 0) - return (0); /* invalid character as a delimiter */ - from += n; - if (wc != L'\\') *to++ = wc; - else { - n = mbtowc(&wc, from, MB_CUR_MAX); - if (n <= 0) - return (0); - from += n; - switch (wc) { - case L'0' : *to++ = RUB; - break; - case L't' : *to++ = L'\t'; - break; - case L'n' : *to++ = L'\n'; - break; - default : *to++ = wc; - break; - } - } - i++; - } - return (i); -} - - -static void -usage() -{ - (void) fprintf(stderr, gettext( - "usage: paste [-s] [-d list] file \n\n")); - exit(1); -} |