diff options
author | Roger A. Faulkner <Roger.Faulkner@Oracle.COM> | 2010-08-12 14:55:22 -0700 |
---|---|---|
committer | Roger A. Faulkner <Roger.Faulkner@Oracle.COM> | 2010-08-12 14:55:22 -0700 |
commit | 23a1ccea6aac035f084a7a4cdc968687d1b02daf (patch) | |
tree | 6ed5e310ce6dd96f997b0c0f9735805d513d898a | |
parent | 29c3196fe2acc65721d8b9b5ea708d3a87facde0 (diff) | |
download | illumos-joyent-23a1ccea6aac035f084a7a4cdc968687d1b02daf.tar.gz |
PSARC 2010/299 GNU/Linux/BSD compatibility functions
6960818 add get_nprocs(), getline(), strdupa(), strndup() to libc
6901783 strndup would be nice
6824404 libc should provide ffsl() & ffsll()
6793969 RFE: Add|stpcpy|to libc
6735446 Want a __progname symbol for BSD-style source compatibility
6421095 Solaris should provide strcasestr
6275498 Provide string compare functions wcscasecmp,wcsncasecmp in solaris like linux
--HG--
rename : usr/src/lib/libc/port/gen/strcasecmp.c => usr/src/lib/libc/port/gen/ascii_strcasecmp.c
rename : usr/src/lib/libc/port/gen/strncasecmp.c => usr/src/lib/libc/port/gen/ascii_strncasecmp.c
rename : usr/src/lib/libc/sparc/gen/strcasecmp.s => usr/src/lib/libc/sparc/gen/ascii_strcasecmp.s
rename : usr/src/lib/libc/sparcv9/gen/strcasecmp.s => usr/src/lib/libc/sparcv9/gen/ascii_strcasecmp.s
170 files changed, 2274 insertions, 1501 deletions
diff --git a/usr/src/cmd/acctadm/main.c b/usr/src/cmd/acctadm/main.c index 8176214b9e..83cb63b314 100644 --- a/usr/src/cmd/acctadm/main.c +++ b/usr/src/cmd/acctadm/main.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/acctctl.h> @@ -134,7 +134,7 @@ main(int argc, char *argv[]) (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); - (void) setprogname(argv[0]); + (void) setpname(argv[0]); for (; optind < argc; optind++) { while ((c = getopt(argc, argv, OPTS)) != (int)EOF) { diff --git a/usr/src/cmd/acctadm/utils.c b/usr/src/cmd/acctadm/utils.c index 53afbce282..289111e210 100644 --- a/usr/src/cmd/acctadm/utils.c +++ b/usr/src/cmd/acctadm/utils.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <assert.h> @@ -85,7 +85,7 @@ die(char *format, ...) } char * -setprogname(char *arg0) +setpname(char *arg0) { char *p = strrchr(arg0, '/'); diff --git a/usr/src/cmd/acctadm/utils.h b/usr/src/cmd/acctadm/utils.h index 66a1aab6a1..e40fa53f01 100644 --- a/usr/src/cmd/acctadm/utils.h +++ b/usr/src/cmd/acctadm/utils.h @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _UTILS_H @@ -42,7 +42,7 @@ extern dladm_handle_t dld_handle; extern void warn(const char *, ...); extern void die(char *, ...); -extern char *setprogname(char *); +extern char *setpname(char *); extern const char *ac_type_name(int); extern int open_exacct_file(const char *, int); extern boolean_t verify_exacct_file(const char *, int); diff --git a/usr/src/cmd/awk/awk.h b/usr/src/cmd/awk/awk.h index 9e26f2d511..987028fea2 100644 --- a/usr/src/cmd/awk/awk.h +++ b/usr/src/cmd/awk/awk.h @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -362,6 +361,6 @@ extern Cell *bltin(Node **, int); extern Cell *call(Node **, int); extern Cell *arg(Node **, int); extern Cell *getnf(Node **, int); -extern Cell *getline(Node **, int); +extern Cell *getaline(Node **, int); #endif /* AWK_H */ diff --git a/usr/src/cmd/awk/maketab.c b/usr/src/cmd/awk/maketab.c index c80e6e1c28..5c7d8601ea 100644 --- a/usr/src/cmd/awk/maketab.c +++ b/usr/src/cmd/awk/maketab.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -101,7 +100,7 @@ struct xx { { CALL, "call", "call" }, { ARG, "arg", "arg" }, { VARNF, "getnf", "NF" }, - { GETLINE, "getline", "getline" }, + { GETLINE, "getaline", "getline" }, { 0, "", "" }, }; diff --git a/usr/src/cmd/awk/run.c b/usr/src/cmd/awk/run.c index 62f247ac6b..3cc8341d84 100644 --- a/usr/src/cmd/awk/run.c +++ b/usr/src/cmd/awk/run.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -359,7 +358,7 @@ jump(Node **a, int n) } Cell * -getline(Node **a, int n) +getaline(Node **a, int n) { /* a[0] is variable, a[1] is operator, a[2] is filename */ register Cell *r, *x; diff --git a/usr/src/cmd/bnu/sysfiles.c b/usr/src/cmd/bnu/sysfiles.c index c6a472517b..db147774d0 100644 --- a/usr/src/cmd/bnu/sysfiles.c +++ b/usr/src/cmd/bnu/sysfiles.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,17 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 1998 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - #include "uucp.h" #include <unistd.h> @@ -55,7 +51,7 @@ /* private variables */ static void tokenize(), nameparse(), setfile(), setioctl(), scansys(), scancfg(), setconfig(); -static int namematch(), nextdialers(), nextdevices(), nextsystems(), getline(); +static int namematch(), nextdialers(), nextdevices(), nextsystems(), getaline(); /* pointer arrays might be dynamically allocated */ static char *Systems[64] = {0}; /* list of Systems files */ @@ -164,7 +160,7 @@ char *service; Systems[0] = Devices[0] = Dialers[0] = NULL; if ((f = fopen(SYSFILES, "r")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Sysfiles */ /* strtok's of this buf continue in tokenize() */ tok = strtok(buf, " \t"); @@ -215,7 +211,7 @@ char *service, *device; msgtime = MSGTIME; if ((f = fopen(DEVCONFIG, "r")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Devconfig */ /* strtok's of this buf continue in tokenize() */ tok = strtok(buf, " \t"); @@ -241,7 +237,7 @@ char *service, *device; */ static int -getline(f, line) +getaline(f, line) FILE *f; char *line; { char *lptr, *lend; @@ -484,7 +480,7 @@ char *buf; ASSERT(len >= BUFSIZ, "BUFFER TOO SMALL", "getsysline", 0); for(;;) { - while (getline(fsystems, buf) != NULL) + while (getaline(fsystems, buf) != NULL) if ((*buf != '#') && (*buf != ' ') && (*buf != '\t') && (*buf != '\n')) { (void) _uu_resetlocale(LC_ALL, prev); @@ -752,7 +748,7 @@ setconfig() extern char _ProtoCfg[]; if ((f = fopen(CONFIG, "r")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Config file */ tok = strtok(buf, " \t"); if ( (tok != NULL) && (*tok != '#') ) { diff --git a/usr/src/cmd/boot/bootadm/bootadm_hyper.c b/usr/src/cmd/boot/bootadm/bootadm_hyper.c index eef7fe1d3d..01e7dd3e69 100644 --- a/usr/src/cmd/boot/bootadm/bootadm_hyper.c +++ b/usr/src/cmd/boot/bootadm/bootadm_hyper.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdio.h> @@ -347,9 +347,8 @@ cvt_metal_option(char *optstr) if ((strncmp(optstr, "ttya-mode", namlen) == 0) || (strncmp(optstr, "ttyb-mode", namlen) == 0)) { - char *port = alloca(namlen + 1); + char *port = strndupa(optstr, namlen); - (void) strlcpy(port, optstr, namlen + 1); return (serial_metal_to_hyper(port, value)); } @@ -840,19 +839,15 @@ cvt_to_hyper(menu_t *mp, char *osroot, char *extra_args) * Process important lines from menu.lst boot entry. */ if (lp->flags == BAM_TITLE) { - title = alloca(strlen(lp->arg) + 1); - (void) strcpy(title, lp->arg); + title = strdupa(lp->arg); } else if (lp->cmd != NULL) { if (strcmp(lp->cmd, "findroot") == 0) { - findroot = alloca(strlen(lp->arg) + 1); - (void) strcpy(findroot, lp->arg); + findroot = strdupa(lp->arg); } else if (strcmp(lp->cmd, "bootfs") == 0) { - bootfs = alloca(strlen(lp->arg) + 1); - (void) strcpy(bootfs, lp->arg); + bootfs = strdupa(lp->arg); } else if (strcmp(lp->cmd, menu_cmds[MODULE_DOLLAR_CMD]) == 0) { - module = alloca(strlen(lp->arg) + 1); - (void) strcpy(module, lp->arg); + module = strdupa(lp->arg); } else if ((strcmp(lp->cmd, menu_cmds[KERNEL_DOLLAR_CMD]) == 0) && (ret = cvt_metal_kernel(lp->arg, @@ -1065,25 +1060,19 @@ cvt_to_metal(menu_t *mp, char *osroot, char *menu_root) * Process important lines from menu.lst boot entry. */ if (lp->flags == BAM_TITLE) { - title = alloca(strlen(lp->arg) + 1); - (void) strcpy(title, lp->arg); + title = strdupa(lp->arg); } else if (lp->cmd != NULL) { if (strcmp(lp->cmd, "findroot") == 0) { - findroot = alloca(strlen(lp->arg) + 1); - (void) strcpy(findroot, lp->arg); + findroot = strdupa(lp->arg); } else if (strcmp(lp->cmd, "bootfs") == 0) { - bootfs = alloca(strlen(lp->arg) + 1); - (void) strcpy(bootfs, lp->arg); + bootfs = strdupa(lp->arg); } else if (strcmp(lp->cmd, menu_cmds[MODULE_DOLLAR_CMD]) == 0) { if (strstr(lp->arg, "boot_archive") == NULL) { - module = alloca(strlen(lp->arg) + 1); - (void) strcpy(module, lp->arg); + module = strdupa(lp->arg); cvt_hyper_module(module, &kern_path); } else { - barchive_path = - alloca(strlen(lp->arg) + 1); - (void) strcpy(barchive_path, lp->arg); + barchive_path = strdupa(lp->arg); } } else if ((strcmp(lp->cmd, menu_cmds[KERNEL_DOLLAR_CMD]) == 0) && diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/Makefile index 010d42c6b9..c20b6fe882 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/Makefile @@ -1,6 +1,5 @@ # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. # PROG= in.ftpd ftpcount ftpshut ftprestart privatepw @@ -15,8 +14,7 @@ FTPD_OBJS= $(COMMON_OBJS) ftpd.o ftpcmd.o glob.o logwtmp.o popen.o \ access.o extensions.o realpath.o acl.o private.o \ authenticate.o conversions.o rdservers.o paths.o hostacc.o \ routevector.o restrict.o domain.o wu_fnmatch.o timeout.o \ - getpwnam.o strsep.o strcasestr.o inet.o xferlog.o gssutil.o \ - privs.o + getpwnam.o inet.o xferlog.o gssutil.o privs.o FTPCOUNT_OBJS= $(COMMON_OBJS) ftpcount.o rdservers.o inet.o FTPSHUT_OBJS= $(COMMON_OBJS) ftpshut.o rdservers.o inet.o FTPREST_OBJS= $(COMMON_OBJS) ftprestart.o rdservers.o inet.o diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/proto.h b/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/proto.h index 5fd37d8a10..5730d2120e 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/proto.h +++ b/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/proto.h @@ -336,8 +336,3 @@ void chown_priv_off(uid_t); */ char *getusershell(void); void endusershell(void); - -/* - ** support/strcasestr.c - */ -char *strcasestr(register char *s, register char *find); diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/strcasestr.c b/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/strcasestr.c deleted file mode 100644 index ec80947aa7..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/strcasestr.c +++ /dev/null @@ -1,49 +0,0 @@ -#pragma ident "%Z%%M% %I% %E% SMI" - -/**************************************************************************** - - Copyright (c) 1999,2000 WU-FTPD Development Group. - All rights reserved. - - Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994 - The Regents of the University of California. - Portions Copyright (c) 1993, 1994 Washington University in Saint Louis. - Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc. - Portions Copyright (c) 1989 Massachusetts Institute of Technology. - Portions Copyright (c) 1998 Sendmail, Inc. - Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman. - Portions Copyright (c) 1997 by Stan Barber. - Portions Copyright (c) 1997 by Kent Landfield. - Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 - Free Software Foundation, Inc. - - Use and distribution of this software and its source code are governed - by the terms and conditions of the WU-FTPD Software License ("LICENSE"). - - If you did not receive a copy of the license, it may be obtained online - at http://www.wu-ftpd.org/license.html. - - $Id: strcasestr.c,v 1.5 2000/07/01 18:36:29 wuftpd Exp $ - -****************************************************************************/ -#include <string.h> -/* - * Find the first occurrence of find in s. - */ -char *strcasestr(register char *s, register char *find) -{ - register char c, sc; - register size_t len; - - if ((c = *find++) != 0) { - len = strlen(find); - do { - do { - if ((sc = *s++) == 0) - return (NULL); - } while (sc != c); - } while (strncasecmp(s, find, len) != 0); - s--; - } - return ((char *) s); -} diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/strsep.c b/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/strsep.c deleted file mode 100644 index 98657c4dd3..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/strsep.c +++ /dev/null @@ -1,67 +0,0 @@ -#pragma ident "%Z%%M% %I% %E% SMI" - -/**************************************************************************** - - Copyright (c) 1999,2000 WU-FTPD Development Group. - All rights reserved. - - Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994 - The Regents of the University of California. - Portions Copyright (c) 1993, 1994 Washington University in Saint Louis. - Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc. - Portions Copyright (c) 1989 Massachusetts Institute of Technology. - Portions Copyright (c) 1998 Sendmail, Inc. - Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman. - Portions Copyright (c) 1997 by Stan Barber. - Portions Copyright (c) 1997 by Kent Landfield. - Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 - Free Software Foundation, Inc. - - Use and distribution of this software and its source code are governed - by the terms and conditions of the WU-FTPD Software License ("LICENSE"). - - If you did not receive a copy of the license, it may be obtained online - at http://www.wu-ftpd.org/license.html. - - $Id: strsep.c,v 1.6 2000/07/01 18:36:29 wuftpd Exp $ - -****************************************************************************/ -#include <string.h> -#include <stdio.h> - -/* - * Get next token from string *stringp, where tokens are nonempty - * strings separated by characters from delim. - * - * Writes NULLs into the string at *stringp to end tokens. - * delim need not remain constant from call to call. - * On return, *stringp points past the last NUL written (if there might - * be further tokens), or is NULL (if there are definitely no more tokens). - * - * If *stringp is NULL, strsep returns NULL. - */ -char *strsep(register char **stringp, register const char *delim) -{ - register char *s; - register const char *spanp; - register int c, sc; - char *tok; - - if ((s = *stringp) == NULL) - return (NULL); - for (tok = s;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - *stringp = s; - return (tok); - } - } while (sc != 0); - } - /* NOTREACHED */ -} diff --git a/usr/src/cmd/cpc/common/strtoset.c b/usr/src/cmd/cpc/common/strtoset.c index 974f1555ea..dda5a227a0 100644 --- a/usr/src/cmd/cpc/common/strtoset.c +++ b/usr/src/cmd/cpc/common/strtoset.c @@ -18,14 +18,13 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdio.h> #include <stdlib.h> -#include <alloca.h> #include <errno.h> #include <libintl.h> @@ -491,7 +490,7 @@ cpc_strtoset(cpc_t *cpcin, const char *spec, int smt) toks[x] = NULL; - opts = strcpy(alloca(strlen(spec) + 1), spec); + opts = strdupa(spec); while (*opts != '\0') { int idx = getsubopt(&opts, toks, &val); diff --git a/usr/src/cmd/csplit/csplit.c b/usr/src/cmd/csplit/csplit.c index 4f1055eda2..5506dbe139 100644 --- a/usr/src/cmd/csplit/csplit.c +++ b/usr/src/cmd/csplit/csplit.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ /* * csplit - Context or line file splitter @@ -83,7 +79,7 @@ static void fatal(char *, char *); static offset_t findline(char *, offset_t); static void flush(void); static FILE *getfile(void); -static char *getline(int); +static char *getaline(int); static void line_arg(char *); static void num_arg(char *, int); static void re_arg(char *); @@ -143,13 +139,13 @@ main(int argc, char **argv) if (errno == ENOSPC) { (void) fprintf(stderr, "csplit: "); (void) fprintf(stderr, gettext( - "No space left on device\n")); + "No space left on device\n")); exit(1); } else { (void) fprintf(stderr, "csplit: "); (void) fprintf(stderr, gettext( - "Bad write to temporary " - "file\n")); + "Bad write to temporary " + "file\n")); exit(1); } @@ -294,7 +290,7 @@ fatal(char *string, char *arg) * Its arguments are a pointer to the compiled regular expression(expr), * and an offset(oset). The variable lncnt is used to count the number * of lines searched. First the current stream location is saved via - * ftello(), and getline is called so that R.E. searching starts at the + * ftello(), and getaline is called so that R.E. searching starts at the * line after the previously referenced line. The while loop checks * that there are more lines(error if none), bumps the line count, and * checks for the R.E. on each line. If the R.E. matches on one of the @@ -310,11 +306,11 @@ findline(char *expr, offset_t oset) saveloc = ftello(infile); if (curline != (offset_t)1 || benhere) /* If first line, first time, */ - (void) getline(FALSE); /* then don't skip */ + (void) getaline(FALSE); /* then don't skip */ else lncnt--; benhere = 1; - while (getline(FALSE) != NULL) { + while (getaline(FALSE) != NULL) { lncnt++; if ((sptr = strrchr(linbuf, '\n')) != NULL) *sptr = '\0'; @@ -362,7 +358,8 @@ getfile() if (create) { if (fptr == 0) - for (fptr = file; *fptr != NULL; fptr++); + for (fptr = file; *fptr != NULL; fptr++) + continue; (void) sprintf(fptr, "%.*d", fiwidth, ctr++); /* check for suffix length overflow */ @@ -406,12 +403,12 @@ getfile() /* * Getline gets a line via fgets from the input stream "infile". * The line is put into linbuf and may not be larger than LINSIZ. - * If getline is called with a non-zero value, the current line + * If getaline is called with a non-zero value, the current line * is bumped, otherwise it is not(for R.E. searching). */ static char * -getline(int bumpcur) +getaline(int bumpcur) { char *ret; if (bumpcur) @@ -570,15 +567,15 @@ to_line(offset_t ln) if (curline > ln) fatal("%s - out of range\n", targ); while (curline < ln) { - if (getline(TRUE) == NULL) + if (getaline(TRUE) == NULL) fatal("%s - out of range\n", targ); flush(); } } else /* last file */ - if (getline(TRUE) != NULL) { + if (getaline(TRUE) != NULL) { flush(); for (;;) { - if (getline(TRUE) == NULL) + if (getaline(TRUE) == NULL) break; flush(); } @@ -591,7 +588,7 @@ static void usage() { (void) fprintf(stderr, gettext( - "usage: csplit [-ks] [-f prefix] [-n number] " - "file arg1 ...argn\n")); + "usage: csplit [-ks] [-f prefix] [-n number] " + "file arg1 ...argn\n")); exit(1); } diff --git a/usr/src/cmd/devctl/devctl.c b/usr/src/cmd/devctl/devctl.c index 5516d51f14..15b76da9ac 100644 --- a/usr/src/cmd/devctl/devctl.c +++ b/usr/src/cmd/devctl/devctl.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,14 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - - /* * devctl - device control utility * @@ -107,7 +103,7 @@ typedef struct cmds { extern int errno; -static void setprogname(char *name); +static void setpname(char *name); static void print_bus_state(char *devname, uint_t state); static void print_dev_state(char *devname, uint_t state); static int dev_getstate(devctl_hdl_t); @@ -191,7 +187,7 @@ main(int argc, char *argv[]) devctl_hdl_t dcp; struct stat stat_buf; - setprogname(argv[0]); + setpname(argv[0]); while ((c = getopt(argc, argv, "vd")) != -1) { switch (c) { case 'v': @@ -255,8 +251,8 @@ main(int argc, char *argv[]) if ((pathlen = readlink(orig_path, devctl_device, MAXPATHLEN)) == -1) { (void) fprintf(stderr, - "devctl: readlink(%s) - %s\n", - orig_path, strerror(errno)); + "devctl: readlink(%s) - %s\n", + orig_path, strerror(errno)); exit(-1); } devctl_device[pathlen] = '\0'; @@ -308,16 +304,16 @@ main(int argc, char *argv[]) dcp = devctl_pm_dev_acquire(devctl_device, 0); if (dcp == NULL) { (void) fprintf(stderr, - "devctl: device_pm_dev_acquire %s - %s\n", - devctl_device, strerror(errno)); + "devctl: device_pm_dev_acquire %s - %s\n", + devctl_device, strerror(errno)); exit(-1); } } else { dcp = devctl_device_acquire(devctl_device, 0); if (dcp == NULL) { (void) fprintf(stderr, - "devctl: device_acquire %s - %s\n", - devctl_device, strerror(errno)); + "devctl: device_acquire %s - %s\n", + devctl_device, strerror(errno)); exit(-1); } } @@ -516,7 +512,7 @@ print_dev_state(char *devname, uint_t state) } static void -setprogname(char *name) +setpname(char *name) { register char *p; diff --git a/usr/src/cmd/diff3/diff3prog.c b/usr/src/cmd/diff3/diff3prog.c index 085a93eee3..0eb5d6b2e8 100644 --- a/usr/src/cmd/diff3/diff3prog.c +++ b/usr/src/cmd/diff3/diff3prog.c @@ -18,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ #include <stdio.h> #include <stdlib.h> @@ -105,7 +102,7 @@ static int readin(char *name, struct diff *dd); static int number(char **lc); static int digit(int c); static int getchange(FILE *b); -static int getline(FILE *b); +static int getaline(FILE *b); static void merge(int m1, int m2); static void separate(char *s); static void change(int i, struct range *rold, int dup); @@ -154,9 +151,9 @@ main(int argc, char **argv) usage(); if (oflag) { (void) snprintf(f1mark, sizeof (f1mark), "<<<<<<< %s", - argc >= 7 ? argv[6] : argv[3]); + argc >= 7 ? argv[6] : argv[3]); (void) snprintf(f3mark, sizeof (f3mark), ">>>>>>> %s", - argc >= 8 ? argv[7] : argv[5]); + argc >= 8 ? argv[7] : argv[5]); } m = readin(argv[1], d13); @@ -165,7 +162,7 @@ main(int argc, char **argv) if ((fp[i] = fopen(argv[i+3], "r")) == NULL) { save_err = errno; (void) fprintf(stderr, "diff3: can't open %s: ", - argv[i+3]); + argv[i+3]); errno = save_err; perror(""); exit(1); @@ -250,14 +247,14 @@ digit(int c) static int getchange(FILE *b) { - while (getline(b)) + while (getaline(b)) if (digit(line[0])) return (1); return (0); } static int -getline(FILE *b) +getaline(FILE *b) { int i, c; for (i = 0; i < sizeof (line)-1; i++) { @@ -288,10 +285,10 @@ merge(int m1, int m2) for (; (t1 = d1 < d13+m1) | (t2 = d2 < d23+m2); ) { if (debug) { (void) printf("%d,%d=%d,%d %d,%d=%d,%d\n", - d1->old.from, d1->old.to, - d1->new.from, d1->new.to, - d2->old.from, d2->old.to, - d2->new.from, d2->new.to); + d1->old.from, d1->old.to, + d1->new.from, d1->new.to, + d2->old.from, d2->old.to, + d2->new.from, d2->new.to); } /* first file is different from others */ @@ -454,7 +451,7 @@ skip(int i, int from, char *pr) { int j, n; for (n = 0; cline[i] < from-1; n += j) { - if ((j = getline(fp[i])) == 0) + if ((j = getaline(fp[i])) == 0) trouble(); if (pr) (void) printf("%s%s", pr, line); diff --git a/usr/src/cmd/dis/dis_target.c b/usr/src/cmd/dis/dis_target.c index e27a307bc0..54eb8a3bb5 100644 --- a/usr/src/cmd/dis/dis_target.c +++ b/usr/src/cmd/dis/dis_target.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <assert.h> @@ -100,10 +99,9 @@ struct dis_scn { Elf_Data *ds_data; }; -/* Lifted from Psymtab.c */ +/* Lifted from Psymtab.c, omitting STT_TLS */ #define DATA_TYPES \ - ((1 << STT_OBJECT) | (1 << STT_FUNC) | \ - (1 << STT_COMMON) | (1 << STT_TLS)) + ((1 << STT_OBJECT) | (1 << STT_FUNC) | (1 << STT_COMMON)) #define IS_DATA_TYPE(tp) (((1 << (tp)) & DATA_TYPES) != 0) /* diff --git a/usr/src/cmd/ed/ed.c b/usr/src/cmd/ed/ed.c index 48fe227631..06dde94ba2 100644 --- a/usr/src/cmd/ed/ed.c +++ b/usr/src/cmd/ed/ed.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ /* * Editor @@ -331,7 +327,7 @@ static void nonzero(void); static void setzeroasone(void); static long putline(void); static LINE address(void); -static char *getline(long); +static char *getaline(long); static char *getblock(long, long); static char *place(char *, char *, char *); static void comple(wchar_t); @@ -693,7 +689,7 @@ swch: putd(); putchr('\t'); } - puts(getline((a1++)->cur)); + puts(getaline((a1++)->cur)); } while (a1 <= addr2); dot = addr2; @@ -1441,7 +1437,7 @@ putfile(void) fp = genbuf; a1 = addr1; do { - lp = getline(a1++->cur); + lp = getaline(a1++->cur); if (fss.Ffill && fss.Flim && lenchk(linebuf, &fss) < 0) { write(1, gettext("line too long: lno = "), strlen(gettext("line too long: lno = "))); @@ -1676,7 +1672,7 @@ gdelete(void) } static char * -getline(long tl) +getaline(long tl) { char *bp, *lp; int nl; @@ -1911,7 +1907,7 @@ join(void) return; gp = genbuf; for (a1 = addr1; a1 <= addr2; a1++) { - lp = getline(a1->cur); + lp = getaline(a1->cur); while (*gp = *lp++) if (gp++ > &genbuf[LBSIZE-1]) (void) error(27); @@ -2259,7 +2255,7 @@ getcopy(void) if (addr1 > addr2) return (EOF); - (void) getline((addr1++)->cur); + (void) getaline((addr1++)->cur); return (0); } @@ -2292,7 +2288,7 @@ execute(int gf, LINE addr) else { if (addr == zero) return (0); - p1 = getline(addr->cur); + p1 = getaline(addr->cur); locs = 0; } return (step(p1, expbuf)); @@ -2595,7 +2591,7 @@ globaln(int k) if (a1->cur & 01) { a1->cur &= ~01; dot = a1; - puts(getline(a1->cur)); + puts(getaline(a1->cur)); if ((c = get_wchr()) == EOF) (void) error(52); if (c == 'a' || c == 'i' || c == 'c') diff --git a/usr/src/cmd/eeprom/common/error.c b/usr/src/cmd/eeprom/common/error.c index c7bf4cf14b..a92ab86c92 100644 --- a/usr/src/cmd/eeprom/common/error.c +++ b/usr/src/cmd/eeprom/common/error.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,11 +18,9 @@ * * CDDL HEADER END */ -#pragma ident "%Z%%M% %I% %E% SMI" /* - * Copyright 1989-2003 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <stdio.h> @@ -36,7 +33,7 @@ char *progname; void -setprogname(char *name) +setpname(char *name) { register char *p = name, c; diff --git a/usr/src/cmd/eeprom/i386/benv.c b/usr/src/cmd/eeprom/i386/benv.c index b0c55a05a2..f032a3e064 100644 --- a/usr/src/cmd/eeprom/i386/benv.c +++ b/usr/src/cmd/eeprom/i386/benv.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -39,7 +40,7 @@ extern void get_kbenv(void); extern void close_kbenv(void); extern caddr_t get_propval(char *name, char *node); -extern void setprogname(char *prog); +extern void setpname(char *prog); extern char *getbootcmd(void); char *boottree; @@ -1052,7 +1053,7 @@ main(int argc, char **argv) benv_des_t *bd; char *file = NULL; - setprogname(argv[0]); + setpname(argv[0]); while ((c = getopt(argc, argv, "f:Itv")) != -1) switch (c) { diff --git a/usr/src/cmd/eeprom/sparc/openprom.c b/usr/src/cmd/eeprom/sparc/openprom.c index d23fa6fe62..31043ea172 100644 --- a/usr/src/cmd/eeprom/sparc/openprom.c +++ b/usr/src/cmd/eeprom/sparc/openprom.c @@ -1,7 +1,9 @@ /* * Open Boot Prom eeprom utility - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + */ + +/* + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ /* @@ -42,7 +44,7 @@ typedef union { } Oppbuf; extern int _error(int do_perror, char *fmt, ...); -extern void setprogname(char *); +extern void setpname(char *); static int get_password(char *, int); extern int loadlogo(char *, int, int, char *); @@ -133,7 +135,7 @@ main(int argc, char **argv) "[variable[=value] ...]", argv[0])); } - setprogname(argv[0]); + setpname(argv[0]); /* * If no arguments, dump all fields. diff --git a/usr/src/cmd/env/env.c b/usr/src/cmd/env/env.c index bbd146bc62..ff2b2c4b31 100644 --- a/usr/src/cmd/env/env.c +++ b/usr/src/cmd/env/env.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,23 +18,22 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T - * All Rights Reserved + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* + * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved */ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */ - /* * env [ - ] [ name=value ]... [command arg...] * set environment, then execute command (or print environment) * - says start fresh, otherwise merge with inherited environment */ - #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -49,7 +47,6 @@ static void Usage(); -static char *nullp = NULL; extern char **environ; @@ -70,7 +67,7 @@ main(int argc, char **argv) /* check for non-standard "-" option */ if ((argc > 1) && (strcmp(argv[1], "-")) == 0) { - environ = &nullp; + (void) clearenv(); for (i = 1; i < argc; i++) argv[i] = argv[i+1]; argc--; @@ -80,7 +77,7 @@ main(int argc, char **argv) while ((opt = getopt(argc, argv, "i")) != EOF) { switch (opt) { case 'i': - environ = &nullp; + (void) clearenv(); break; default: diff --git a/usr/src/cmd/eqn/io.c b/usr/src/cmd/eqn/io.c index 3aaf5d8092..129f8ab604 100644 --- a/usr/src/cmd/eqn/io.c +++ b/usr/src/cmd/eqn/io.c @@ -1,6 +1,5 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -12,8 +11,6 @@ * specifies the terms and conditions for redistribution. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "e.h" #include <stdlib.h> #include <locale.h> @@ -27,7 +24,7 @@ void error(int, char *, char *); static void do_inline(void); int eqn(int, char *[]); -static int getline(char *); +static int getaline(char *); static void init(void); void nrwid(int, int, int); int oalloc(void); @@ -53,7 +50,7 @@ eqn(int argc, char *argv[]) setfile(argc, argv); init_tbl(); /* install keywords in tables */ - while ((type = getline(in)) != EOF) { + while ((type = getaline(in)) != EOF) { eqline = linect; if (in[0] == '.' && in[1] == 'E' && in[2] == 'Q') { for (i = 11; i < 100; used[i++] = 0) @@ -96,7 +93,7 @@ eqn(int argc, char *argv[]) } static int -getline(char *s) +getaline(char *s) { int c; while ((*s++ = c = gtc()) != '\n' && c != EOF && c != lefteq) @@ -130,7 +127,7 @@ do_inline(void) ofree(eqnreg); } printf(".ps \\n(99\n.ft \\n(98\n"); - } while (getline(in) == lefteq); + } while (getaline(in) == lefteq); if (*in) printf(".as %d \"%s", ds, in); printf(".ps \\n(99\n.ft \\n(98\n"); diff --git a/usr/src/cmd/fm/fmd/common/fmd_idspace.c b/usr/src/cmd/fm/fmd/common/fmd_idspace.c index 187dd3b67d..ce0f90563e 100644 --- a/usr/src/cmd/fm/fmd/common/fmd_idspace.c +++ b/usr/src/cmd/fm/fmd/common/fmd_idspace.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <fmd_alloc.h> #include <fmd_subr.h> #include <fmd_conf.h> @@ -34,47 +31,6 @@ #include <fmd_idspace.h> #include <fmd.h> -static int -highbit(ulong_t i) -{ - int h = 1; - - if (i == 0) - return (0); - -#ifdef _LP64 - if (i & 0xffffffff00000000ul) { - h += 32; - i >>= 32; - } -#endif - - if (i & 0xffff0000) { - h += 16; - i >>= 16; - } - - if (i & 0xff00) { - h += 8; - i >>= 8; - } - - if (i & 0xf0) { - h += 4; - i >>= 4; - } - - if (i & 0xc) { - h += 2; - i >>= 2; - } - - if (i & 0x2) - h += 1; - - return (h); -} - fmd_idspace_t * fmd_idspace_create(const char *name, id_t min, id_t max) { @@ -93,7 +49,7 @@ fmd_idspace_create(const char *name, id_t min, id_t max) (void) fmd_conf_getprop(fmd.d_conf, "ids.max", &ids_max); hashmax = max - min + 1; - hashlen = 1 << highbit(hashmax / ids_avg); + hashlen = 1 << fls(hashmax / ids_avg); if (hashlen > ids_max) hashlen = ids_max; diff --git a/usr/src/cmd/fm/fmd/common/fmd_module.c b/usr/src/cmd/fm/fmd/common/fmd_module.c index 79db40e65e..ad3b8f424d 100644 --- a/usr/src/cmd/fm/fmd/common/fmd_module.c +++ b/usr/src/cmd/fm/fmd/common/fmd_module.c @@ -958,8 +958,7 @@ fmd_module_dc_opendict(fmd_module_t *mp, const char *dict) ASSERT(fmd_module_locked(mp)); - dictnam = alloca(strlen(dict) + 1); - (void) strcpy(dictnam, fmd_strbasename(dict)); + dictnam = strdupa(fmd_strbasename(dict)); if ((p = strrchr(dictnam, '.')) != NULL && strcmp(p, ".dict") == 0) diff --git a/usr/src/cmd/fm/modules/common/ip-transport/ip.c b/usr/src/cmd/fm/modules/common/ip-transport/ip.c index fc2e2f3abd..e338dd7f3e 100644 --- a/usr/src/cmd/fm/modules/common/ip-transport/ip.c +++ b/usr/src/cmd/fm/modules/common/ip-transport/ip.c @@ -34,7 +34,6 @@ #include <strings.h> #include <unistd.h> #include <pthread.h> -#include <alloca.h> #include <fcntl.h> #include <errno.h> #include <netdb.h> @@ -1028,8 +1027,7 @@ _fmd_init(fmd_hdl_t *hdl) (void) nvlist_add_uint8(ip_auth, FM_VERSION, FM_FMRI_AUTH_VERSION); - s = alloca(strlen(auth) + 1); - (void) strcpy(s, auth); + s = strdupa(auth); fmd_prop_free_string(hdl, auth); for (p = strtok_r(s, ",", &q); p != NULL; diff --git a/usr/src/cmd/format/label.c b/usr/src/cmd/format/label.c index 4740baebb2..3da51d9cc7 100644 --- a/usr/src/cmd/format/label.c +++ b/usr/src/cmd/format/label.c @@ -18,22 +18,15 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ /* * This file contains the code relating to label manipulation. */ -#include "global.h" -#include "label.h" -#include "misc.h" -#include "main.h" -#include "partition.h" -#include "ctlr_scsi.h" -#include "checkdev.h" #include <string.h> #include <stdlib.h> #include <memory.h> @@ -43,6 +36,13 @@ #include <sys/uuid.h> #include <errno.h> #include <devid.h> +#include "global.h" +#include "label.h" +#include "misc.h" +#include "main.h" +#include "partition.h" +#include "ctlr_scsi.h" +#include "checkdev.h" #if defined(_FIRMWARE_NEEDS_FDISK) #include <sys/dktp/fdisk.h> diff --git a/usr/src/cmd/format/modify_partition.c b/usr/src/cmd/format/modify_partition.c index b2bc580e69..02fee8c67b 100644 --- a/usr/src/cmd/format/modify_partition.c +++ b/usr/src/cmd/format/modify_partition.c @@ -18,14 +18,16 @@ * * CDDL HEADER END */ + /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ /* * This file contains functions to implement the partition menu commands. */ +#include <stdlib.h> +#include <string.h> #include "global.h" #include "partition.h" #include "menu_partition.h" @@ -36,9 +38,6 @@ #include "label.h" #include "auto_sense.h" -#include <stdlib.h> -#include <string.h> - #ifdef __STDC__ /* Function prototypes for ANSI C Compilers */ diff --git a/usr/src/cmd/format/partition.c b/usr/src/cmd/format/partition.c index 11ae4488a1..3d06272904 100644 --- a/usr/src/cmd/format/partition.c +++ b/usr/src/cmd/format/partition.c @@ -18,21 +18,21 @@ * * CDDL HEADER END */ + /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ /* * This file contains functions that operate on partition tables. */ +#include <string.h> +#include <stdlib.h> #include "global.h" #include "partition.h" #include "misc.h" #include "menu_command.h" #include "menu_partition.h" -#include <string.h> -#include <stdlib.h> /* diff --git a/usr/src/cmd/fps/Makefile b/usr/src/cmd/fps/Makefile index 3ea353c733..b6430ed033 100644 --- a/usr/src/cmd/fps/Makefile +++ b/usr/src/cmd/fps/Makefile @@ -19,8 +19,7 @@ # CDDL HEADER END # # -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # include ../Makefile.cmd @@ -42,16 +41,12 @@ all clean clobber install lint _msg: $(SUBDIRS) check: fpsd # -# Note that the compilation of fptest is handled differently. -# If the primary compiler is not a Sun Studio compiler, fptest will -# *not* be compiled. This is because fptest is dependent on some Sun +# The compilation of fptest is forced to be done with the Sun +# Studio compiler. This is because fptest is dependent on some Sun # performance libraries provided as part of the Sun Studio compiler -# installation. fptest statically links libsunperf.a, libfui.a, -# libfai.a, libfsu.a, and libsunmath.a. The other SUBDIRS will be -# compiled. -# -# If the make macro __GNUC is "#", it means Sun Studio compiler is being -# used for the compilation. +# installation. fptest statically links libsunperf.a, libfui.a, +# libfai.a, libfsu.a, and libsunmath.a. The other SUBDIRS will be +# compiled normally. # $(SUBDIRS): FRC @@ -63,14 +58,11 @@ $(SUBDIRS): FRC *) \ if [ $@ != fptest ]; \ then \ - cd $@; pwd; VERSION='$(VERSION)' $(MAKE) \ - $(TARGET); \ + cd $@; pwd; VERSION='$(VERSION)' \ + $(MAKE) $(TARGET); \ else \ - if [ "$(__GNUC)" = "#" ]; \ - then \ - cd $@; pwd; VERSION='$(VERSION)' \ - $(MAKE) $(TARGET); \ - fi \ + cd $@; pwd; VERSION='$(VERSION)' \ + $(MAKE) __GNUC=$(POUND_SIGN) $(TARGET); \ fi \ ;; \ esac diff --git a/usr/src/cmd/fs.d/nfs/lib/nfslog_config.c b/usr/src/cmd/fs.d/nfs/lib/nfslog_config.c index 5b89c0b581..aff081912b 100644 --- a/usr/src/cmd/fs.d/nfs/lib/nfslog_config.c +++ b/usr/src/cmd/fs.d/nfs/lib/nfslog_config.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <ctype.h> #include <errno.h> #include <locale.h> @@ -90,7 +87,7 @@ static void complete_with_global(char **, char **, char **, char **, static void remove_config(nfsl_config_t **, nfsl_config_t *, nfsl_config_t **); void nfsl_printconfig(nfsl_config_t *); #endif /* DEBUG */ -static char *getline(FILE *, char *, char *, int); +static char *gataline(FILE *, char *, char *, int); static int get_info(char *, char **, char **, char **, char **, char **, char **, int *); static void free_config(nfsl_config_t *); @@ -286,7 +283,7 @@ getconfiglist(nfsl_config_t **listpp, boolean_t updating) assert (*listpp != NULL); tail = getlastconfig(*listpp); - while (getline(fp, NFSL_CONFIG_FILE_PATH, linebuf, sizeof (linebuf))) { + while (gataline(fp, NFSL_CONFIG_FILE_PATH, linebuf, sizeof (linebuf))) { if (linebuf[0] == '\0') { /* * ignore lines that exceed max size @@ -939,13 +936,13 @@ is_legal_tag(char *tag) } /* - * getline attempts to get a line from the configuration file, + * gataline attempts to get a line from the configuration file, * upto LINESZ. A line in the file is a concatenation of lines if the * continuation symbol '\' is used at the end of the line. Returns * line on success, a NULL on EOF, and an empty string on lines > linesz. */ static char * -getline(FILE *fp, char *path, char *line, int linesz) { +gataline(FILE *fp, char *path, char *line, int linesz) { register char *p = line; register int len; int excess = 0; diff --git a/usr/src/cmd/fs.d/udfs/fsck/utilities.c b/usr/src/cmd/fs.d/udfs/fsck/utilities.c index c39845c7b3..2deb71a9eb 100644 --- a/usr/src/cmd/fs.d/udfs/fsck/utilities.c +++ b/usr/src/cmd/fs.d/udfs/fsck/utilities.c @@ -1,6 +1,5 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -25,8 +24,6 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <fcntl.h> #include <errno.h> @@ -64,7 +61,7 @@ static struct bufarea *getblk(struct bufarea *, daddr_t, long); void flush(int32_t, struct bufarea *); int32_t bread(int32_t, char *, daddr_t, long); void bwrite(int, char *, daddr_t, long); -static int32_t getline(FILE *, char *, int32_t); +static int32_t getaline(FILE *, char *, int32_t); void errexit(char *, ...) __NORETURN; static long diskreads, totalreads; /* Disk cache statistics */ offset_t llseek(); @@ -86,7 +83,7 @@ pfatal(char *fmt, ...) (void) printf("\n"); (void) printf( gettext("%s: UNEXPECTED INCONSISTENCY; RUN fsck " - "MANUALLY.\n"), devname); + "MANUALLY.\n"), devname); va_end(args); exit(36); } @@ -172,7 +169,7 @@ getfilentry(uint32_t block, int len) if (len > fsbsize) { (void) printf(gettext("File entry at %x is too long " - "(%d bytes)\n"), block, len); + "(%d bytes)\n"), block, len); len = fsbsize; } bp = getdatablk((daddr_t)(block + part_start), fsbsize); @@ -185,7 +182,7 @@ getfilentry(uint32_t block, int len) err = verifytag(&fp->fe_tag, block, &fp->fe_tag, UD_FILE_ENTRY); if (err) { (void) printf(gettext("Tag error %s or bad file entry, " - "tag=%d\n"), tagerrs[err], fp->fe_tag.tag_id); + "tag=%d\n"), tagerrs[err], fp->fe_tag.tag_id); bp->b_flags &= ~B_INUSE; return (NULL); } @@ -220,7 +217,7 @@ reply(char *question) (void) printf(gettext(" yes\n\n")); return (1); } - if (getline(stdin, line, sizeof (line)) == EOF) + if (getaline(stdin, line, sizeof (line)) == EOF) errexit("\n"); (void) printf("\n"); if (line[0] == 'y' || line[0] == 'Y') @@ -232,7 +229,7 @@ reply(char *question) } int32_t -getline(FILE *fp, char *loc, int32_t maxlen) +getaline(FILE *fp, char *loc, int32_t maxlen) { int n; register char *p, *lastloc; @@ -337,7 +334,7 @@ flush(int32_t fd, struct bufarea *bp) return; if (bp->b_errs != 0) pfatal(gettext("WRITING ZERO'ED BLOCK %d TO DISK\n"), - bp->b_bno); + bp->b_bno); bp->b_dirty = 0; bp->b_errs = 0; bwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size); @@ -370,7 +367,7 @@ ckfini() pbp = pdirbp = NULL; if (bufhead.b_size != cnt) errexit(gettext("Panic: lost %d buffers\n"), - bufhead.b_size - cnt); + bufhead.b_size - cnt); if (debug) (void) printf("cache missed %ld of %ld (%ld%%)\n", diskreads, totalreads, @@ -461,7 +458,7 @@ catchquit() extern int returntosingle; (void) printf(gettext("returning to single-user after filesystem " - "check\n")); + "check\n")); returntosingle = 1; (void) signal(SIGQUIT, SIG_DFL); } @@ -498,7 +495,7 @@ dofix(struct inodesc *idesc, char *msg) default: errexit(gettext("UNKNOWN INODESC FIX MODE %d\n"), - idesc->id_fix); + idesc->id_fix); } /* NOTREACHED */ } @@ -535,7 +532,7 @@ mounted(char *name) continue; if (device_stat.st_rdev == mount_stat.st_dev) { (void) strncpy(mnt.mnt_mountp, mountpoint, - sizeof (mountpoint)); + sizeof (mountpoint)); if (hasmntopt(&mnt, MNTOPT_RO) != 0) found = 2; /* mounted as RO */ else diff --git a/usr/src/cmd/fs.d/ufs/fsck/utilities.c b/usr/src/cmd/fs.d/ufs/fsck/utilities.c index 899402f0e0..d87830669a 100644 --- a/usr/src/cmd/fs.d/ufs/fsck/utilities.c +++ b/usr/src/cmd/fs.d/ufs/fsck/utilities.c @@ -1,6 +1,5 @@ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -70,7 +69,7 @@ static void vdirerror(fsck_ino_t, caddr_t, va_list); static struct mnttab *search_mnttab(caddr_t, caddr_t, caddr_t, size_t); static struct vfstab *search_vfstab(caddr_t, caddr_t, caddr_t, size_t); static void vpwarn(caddr_t, va_list); -static int getline(FILE *, caddr_t, int); +static int getaline(FILE *, caddr_t, int); static struct bufarea *alloc_bufarea(void); static void rwerror(caddr_t, diskaddr_t, int rval); static void debugclean(void); @@ -156,7 +155,7 @@ reply(caddr_t fmt, ...) return (1); } (void) fflush(stdout); - if (getline(stdin, line, sizeof (line)) == EOF) + if (getaline(stdin, line, sizeof (line)) == EOF) errexit("\n"); (void) printf("\n"); if (line[0] == 'y' || line[0] == 'Y') { @@ -167,7 +166,7 @@ reply(caddr_t fmt, ...) } int -getline(FILE *fp, caddr_t loc, int maxlen) +getaline(FILE *fp, caddr_t loc, int maxlen) { int n; caddr_t p, lastloc; diff --git a/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c b/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c index 70922cc33c..4fa2683a64 100644 --- a/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c +++ b/usr/src/cmd/fs.d/ufs/mkfs/mkfs.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -420,7 +420,7 @@ static void block_sigint(sigset_t *old_mask); static void unblock_sigint(sigset_t *old_mask); static void recover_from_sigint(int signum); static int confirm_abort(void); -static int getline(FILE *fp, char *loc, int maxlen); +static int getaline(FILE *fp, char *loc, int maxlen); static void flush_writes(void); static long compute_maxcpg(long, long, long, long, long); static int in_64bit_mode(void); @@ -5498,7 +5498,7 @@ confirm_abort(void) "you will be given instructions on how to\nrecover " "the filesystem. Do you wish to cancel the filesystem " "grow\noperation (y/n)?")); - if (getline(stdin, line, sizeof (line)) == EOF) + if (getaline(stdin, line, sizeof (line)) == EOF) line[0] = 'y'; printf("\n"); @@ -5510,7 +5510,7 @@ confirm_abort(void) } static int -getline(FILE *fp, char *loc, int maxlen) +getaline(FILE *fp, char *loc, int maxlen) { int n; char *p, *lastloc; diff --git a/usr/src/cmd/idmap/idmap/idmap.c b/usr/src/cmd/idmap/idmap/idmap.c index 290d2950f0..3be65fd6d9 100644 --- a/usr/src/cmd/idmap/idmap/idmap.c +++ b/usr/src/cmd/idmap/idmap/idmap.c @@ -18,11 +18,11 @@ * * CDDL HEADER END */ + /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. */ - #include <stdio.h> #include <stdlib.h> #include <locale.h> @@ -1607,23 +1607,6 @@ cleanup: } /* - * The same as strdup, but length chars is duplicated, no matter on - * '\0'. The caller must guarantee "length" chars in "from". - */ -static char * -strndup(char *from, size_t length) -{ - char *out = (char *)malloc(length + 1); - if (out == NULL) { - print_error(NULL, gettext("Not enough memory\n")); - return (NULL); - } - (void) strncpy(out, from, length); - out[length] = '\0'; - return (out); -} - -/* * Convert pid from string to it's numerical representation. If it is * a valid string, i.e. number of a proper length, return 1. Otherwise * print an error message and return 0. diff --git a/usr/src/cmd/ipf/lib/common/getline.c b/usr/src/cmd/ipf/lib/common/getline.c index 7d06d4367b..79e7f09bce 100644 --- a/usr/src/cmd/ipf/lib/common/getline.c +++ b/usr/src/cmd/ipf/lib/common/getline.c @@ -18,17 +18,14 @@ * Similar to fgets(3) but can handle '\\' and NL is converted to NUL. * Returns NULL if error occured, EOF encounterd or input line is too long. */ -char *getline(str, size, file, linenum) -register char *str; -size_t size; -FILE *file; -int *linenum; +char * +getaline(char *str, size_t size, FILE *file, int *linenum) { char *p; int s, len; do { - for (p = str, s = size;; p += (len - 1), s -= (len - 1)) { + for (p = str, s = size; ; p += (len - 1), s -= (len - 1)) { /* * if an error occured, EOF was encounterd, or there * was no room to put NUL, return NULL. diff --git a/usr/src/cmd/ldap/common/ldaptest.c b/usr/src/cmd/ldap/common/ldaptest.c index 66f18bc2ad..d6024b5490 100644 --- a/usr/src/cmd/ldap/common/ldaptest.c +++ b/usr/src/cmd/ldap/common/ldaptest.c @@ -1,12 +1,7 @@ /* - * - * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <ctype.h> #include <string.h> @@ -40,7 +35,7 @@ static void free_list(); char *dnsuffix; static char * -getline( char *line, int len, FILE *fp, char *prompt ) +getaline( char *line, int len, FILE *fp, char *prompt ) { printf(prompt); @@ -62,7 +57,7 @@ get_list( char *prompt ) num = 0; result = (char **) 0; while ( 1 ) { - getline( buf, sizeof(buf), stdin, prompt ); + getaline( buf, sizeof(buf), stdin, prompt ); if ( *buf == '\0' ) break; @@ -161,14 +156,14 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 ) result = NULL; while ( 1 ) { if ( prompt1 ) { - getline( buf, sizeof(buf), stdin, prompt1 ); + getaline( buf, sizeof(buf), stdin, prompt1 ); tmp.mod_op = atoi( buf ); if ( tmp.mod_op == -1 || buf[0] == '\0' ) break; } - getline( buf, sizeof(buf), stdin, prompt2 ); + getaline( buf, sizeof(buf), stdin, prompt2 ); if ( buf[0] == '\0' ) break; tmp.mod_type = strdup( buf ); @@ -229,7 +224,7 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp, if ( !freeit ) { #ifdef KERBEROS - getline( dn, sizeof(dn), stdin, + getaline( dn, sizeof(dn), stdin, "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " ); if (( *authmethodp = atoi( dn )) == 3 ) { *authmethodp = LDAP_AUTH_KRBV4; @@ -240,12 +235,12 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp, *authmethodp = LDAP_AUTH_SIMPLE; #endif /* KERBEROS */ - getline( dn, sizeof(dn), stdin, "re-bind dn? " ); + getaline( dn, sizeof(dn), stdin, "re-bind dn? " ); strcat( dn, dnsuffix ); *dnp = dn; if ( *authmethodp == LDAP_AUTH_SIMPLE && dn[0] != '\0' ) { - getline( passwd, sizeof(passwd), stdin, + getaline( passwd, sizeof(passwd), stdin, "re-bind password? " ); } else { passwd[0] = '\0'; @@ -394,7 +389,7 @@ main(int argc, char **argv ) timelimit.tv_usec = 0; (void) memset( line, '\0', sizeof(line) ); - while ( getline( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) { + while ( getaline( line, sizeof(line), stdin, "\ncommand? " ) != NULL ) { command1 = line[0]; command2 = line[1]; command3 = line[2]; @@ -403,7 +398,7 @@ main(int argc, char **argv ) case 'a': /* add or abandon */ switch ( command2 ) { case 'd': /* add */ - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); if ( (attrs = get_modlist( NULL, "attr? ", "value? " )) == NULL ) @@ -424,7 +419,7 @@ main(int argc, char **argv ) break; case 'b': /* abandon */ - getline( line, sizeof(line), stdin, "msgid? " ); + getaline( line, sizeof(line), stdin, "msgid? " ); id = atoi( line ); if ( ldap_abandon( ld, id ) != 0 ) ldap_perror( ld, "ldap_abandon" ); @@ -438,17 +433,17 @@ main(int argc, char **argv ) case 'b': /* asynch bind */ #ifdef KERBEROS - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "method (0->simple, 1->krbv41, 2->krbv42)? " ); method = atoi( line ) | 0x80; #else /* KERBEROS */ method = LDAP_AUTH_SIMPLE; #endif /* KERBEROS */ - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); if ( method == LDAP_AUTH_SIMPLE && dn[0] != '\0' ) - getline( passwd, sizeof(passwd), stdin, + getaline( passwd, sizeof(passwd), stdin, "password? " ); else passwd[0] = '\0'; @@ -464,7 +459,7 @@ main(int argc, char **argv ) case 'B': /* synch bind */ #ifdef KERBEROS - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "method 0->simple 1->krbv41 2->krbv42 3->krb? " ); method = atoi( line ); if ( method == 3 ) @@ -472,12 +467,12 @@ main(int argc, char **argv ) else method = method | 0x80; #else /* KERBEROS */ - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "method 0->simple, 1->SASL? "); method = atoi (line); if (method == 1){ method = LDAP_AUTH_SASL; - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "mechanism 0->CRAM_MD5, 1->TLS? "); theInt = atoi(line); if (theInt == 0){ @@ -491,11 +486,11 @@ main(int argc, char **argv ) } #endif /* KERBEROS */ - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); if ( dn[0] != '\0' ) - getline( passwd, sizeof(passwd), stdin, + getaline( passwd, sizeof(passwd), stdin, "password? " ); else passwd[0] = '\0'; @@ -531,10 +526,10 @@ main(int argc, char **argv ) break; case 'c': /* compare */ - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); - getline( attr, sizeof(attr), stdin, "attr? " ); - getline( value, sizeof(value), stdin, "value? " ); + getaline( attr, sizeof(attr), stdin, "attr? " ); + getaline( value, sizeof(value), stdin, "value? " ); if (ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, &i) == LDAP_SUCCESS && i == LDAP_VERSION3){ bv.bv_val = value; @@ -553,7 +548,7 @@ main(int argc, char **argv ) case 'd': /* turn on debugging */ #ifdef LDAP_DEBUG - getline( line, sizeof(line), stdin, "debug level? " ); + getaline( line, sizeof(line), stdin, "debug level? " ); ldap_debug = atoi( line ); if ( ldap_debug & LDAP_DEBUG_PACKETS ) { lber_debug = ldap_debug; @@ -564,7 +559,7 @@ main(int argc, char **argv ) break; case 'E': /* explode a dn */ - getline( line, sizeof(line), stdin, "dn? " ); + getaline( line, sizeof(line), stdin, "dn? " ); exdn = ldap_explode_dn( line, 0 ); for ( i = 0; exdn != NULL && exdn[i] != NULL; i++ ) { printf( "\t%s\n", exdn[i] ); @@ -572,19 +567,19 @@ main(int argc, char **argv ) break; case 'g': /* set next msgid */ - getline( line, sizeof(line), stdin, "msgid? " ); + getaline( line, sizeof(line), stdin, "msgid? " ); ld->ld_msgid = atoi( line ); break; case 'v': /* set version number */ - getline( line, sizeof(line), stdin, "version? " ); + getaline( line, sizeof(line), stdin, "version? " ); theInt = atoi(line); ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &theInt); break; case 'm': /* modify or modifyrdn */ if ( strncmp( line, "modify", 4 ) == 0 ) { - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); if ( (mods = get_modlist( "mod (0=>add, 1=>delete, 2=>replace -1=>done)? ", @@ -604,10 +599,10 @@ main(int argc, char **argv ) printf( "Modify initiated with id %d\n", id ); } } else if ( strncmp( line, "modrdn", 4 ) == 0 ) { - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); - getline( rdn, sizeof(rdn), stdin, "newrdn? " ); - getline( line, sizeof(line), stdin, "delete old rdn (0=>no, 1=>yes)?"); + getaline( rdn, sizeof(rdn), stdin, "newrdn? " ); + getaline( line, sizeof(line), stdin, "delete old rdn (0=>no, 1=>yes)?"); delrdn = atoi(line); if (ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, &i) == LDAP_SUCCESS && i == LDAP_VERSION3){ if ((err = ldap_rename(ld, dn, rdn, NULL, delrdn, NULL,NULL, &id)) != LDAP_SUCCESS){ @@ -640,13 +635,13 @@ main(int argc, char **argv ) case 'r': /* result or remove */ switch ( command3 ) { case 's': /* result */ - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "msgid (-1=>any)? " ); if ( line[0] == '\0' ) id = -1; else id = atoi( line ); - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "all (0=>any, 1=>all)? " ); if ( line[0] == '\0' ) all = 1; @@ -667,7 +662,7 @@ main(int argc, char **argv ) break; case 'm': /* remove */ - getline( dn, sizeof(dn), stdin, "dn? " ); + getaline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); if (ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, &i) == LDAP_SUCCESS && i == LDAP_VERSION3){ if ((err = ldap_delete_ext( ld, dn, NULL, NULL, &id )) != LDAP_SUCCESS ) @@ -689,21 +684,21 @@ main(int argc, char **argv ) break; case 's': /* search */ - getline( dn, sizeof(dn), stdin, "searchbase? " ); + getaline( dn, sizeof(dn), stdin, "searchbase? " ); strcat( dn, dnsuffix ); - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "scope (0=Base, 1=One Level, 2=Subtree)? " ); scope = atoi( line ); - getline( filter, sizeof(filter), stdin, + getaline( filter, sizeof(filter), stdin, "search filter (e.g. sn=jones)? " ); types = get_list( "attrs to return? " ); - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "attrsonly (0=attrs&values, 1=attrs only)? " ); attrsonly = atoi( line ); if ( cldapflg ) { #ifdef CLDAP - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Requestor DN (for logging)? " ); if ( cldap_search_s( ld, dn, scope, filter, types, attrsonly, &res, line ) != 0 ) { @@ -719,7 +714,7 @@ main(int argc, char **argv ) theInt = 0; if (ldap_get_option(ld, LDAP_OPT_PROTOCOL_VERSION, &i) == LDAP_SUCCESS && i == LDAP_VERSION3){ resultusetimelimit = 1; - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "ldap_search_ext (0=>no, 1=>yes - default: yes)? " ); if (line[0] == '\0') theInt = 1; @@ -727,10 +722,10 @@ main(int argc, char **argv ) theInt = atoi( line ); } if (theInt){ - getline(line, sizeof(line), stdin, "time limit?"); + getaline(line, sizeof(line), stdin, "time limit?"); timelimit.tv_sec = atoi(line); resultusetimelimit = 1; - getline(line, sizeof(line), stdin, "size limit?"); + getaline(line, sizeof(line), stdin, "size limit?"); sizelimit = atoi(line); if (( err = ldap_search_ext(ld, dn, scope, filter, types, attrsonly, NULL, NULL, &timelimit, sizelimit, &id)) != LDAP_SUCCESS){ @@ -751,20 +746,20 @@ main(int argc, char **argv ) break; case 't': /* set timeout value */ - getline( line, sizeof(line), stdin, "timeout? " ); + getaline( line, sizeof(line), stdin, "timeout? " ); timeout.tv_sec = atoi( line ); break; case 'U': /* set ufn search prefix */ - getline( line, sizeof(line), stdin, "ufn prefix? " ); + getaline( line, sizeof(line), stdin, "ufn prefix? " ); ldap_ufn_setprefix( ld, line ); break; case 'u': /* user friendly search w/optional timeout */ - getline( dn, sizeof(dn), stdin, "ufn? " ); + getaline( dn, sizeof(dn), stdin, "ufn? " ); strcat( dn, dnsuffix ); types = get_list( "attrs to return? " ); - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "attrsonly (0=attrs&values, 1=attrs only)? " ); attrsonly = atoi( line ); @@ -787,10 +782,10 @@ main(int argc, char **argv ) break; case 'l': /* URL search */ - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "attrsonly (0=attrs&values, 1=attrs only)? " ); attrsonly = atoi( line ); - getline( line, sizeof(line), stdin, "LDAP URL? " ); + getaline( line, sizeof(line), stdin, "LDAP URL? " ); if (( id = ldap_url_search( ld, line, attrsonly )) == -1 ) { ldap_perror( ld, "ldap_url_search" ); @@ -800,7 +795,7 @@ main(int argc, char **argv ) break; case 'p': /* parse LDAP URL */ - getline( line, sizeof(line), stdin, "LDAP URL? " ); + getaline( line, sizeof(line), stdin, "LDAP URL? " ); if (( i = ldap_url_parse( line, &ludp )) != 0 ) { fprintf( stderr, "ldap_url_parse: error %d\n", i ); } else { @@ -842,7 +837,7 @@ main(int argc, char **argv ) break; case 'n': /* set dn suffix, for convenience */ - getline( line, sizeof(line), stdin, "DN suffix? " ); + getaline( line, sizeof(line), stdin, "DN suffix? " ); strcpy( dnsuffix, line ); break; @@ -850,9 +845,9 @@ main(int argc, char **argv ) #ifdef NO_CACHE printf( NOCACHEERRMSG ); #else /* NO_CACHE */ - getline( line, sizeof(line), stdin, "Cache timeout (secs)? " ); + getaline( line, sizeof(line), stdin, "Cache timeout (secs)? " ); i = atoi( line ); - getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " ); + getaline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " ); if ( ldap_enable_cache( ld, i, atoi( line )) == 0 ) { printf( "local cache is on\n" ); } else { @@ -865,7 +860,7 @@ main(int argc, char **argv ) #ifdef NO_CACHE printf( NOCACHEERRMSG ); #else /* NO_CACHE */ - getline( line, sizeof(line), stdin, "DN? " ); + getaline( line, sizeof(line), stdin, "DN? " ); ldap_uncache_entry( ld, line ); #endif /* NO_CACHE */ break; @@ -874,33 +869,33 @@ main(int argc, char **argv ) #ifdef NO_CACHE printf( NOCACHEERRMSG ); #else /* NO_CACHE */ - getline( line, sizeof(line), stdin, "request msgid? " ); + getaline( line, sizeof(line), stdin, "request msgid? " ); ldap_uncache_request( ld, atoi( line )); #endif /* NO_CACHE */ break; case 'o': /* set ldap options */ - getline( line, sizeof(line), stdin, "alias deref (0=never, 1=searching, 2=finding, 3=always)?" ); + getaline( line, sizeof(line), stdin, "alias deref (0=never, 1=searching, 2=finding, 3=always)?" ); theInt = atoi(line); ldap_set_option(ld, LDAP_OPT_DEREF, &theInt ); - getline( line, sizeof(line), stdin, "timelimit?" ); + getaline( line, sizeof(line), stdin, "timelimit?" ); theInt = atoi(line); ldap_set_option(ld, LDAP_OPT_TIMELIMIT, &theInt); - getline( line, sizeof(line), stdin, "sizelimit?" ); + getaline( line, sizeof(line), stdin, "sizelimit?" ); theInt = atoi(line); ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &theInt); ld->ld_options = 0; #ifdef STR_TRANSLATION - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Automatic translation of T.61 strings (0=no, 1=yes)?" ); if ( atoi( line ) == 0 ) { ld->ld_lberoptions &= ~LBER_TRANSLATE_STRINGS; } else { ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS; #ifdef LDAP_CHARSET_8859 - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Translate to/from ISO-8859 (0=no, 1=yes?" ); if ( atoi( line ) != 0 ) { ldap_set_string_translators( ld, @@ -912,18 +907,18 @@ main(int argc, char **argv ) #endif /* STR_TRANSLATION */ #ifdef LDAP_DNS - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Use DN & DNS to determine where to send requests (0=no, 1=yes)?" ); if ( atoi( line ) != 0 ) { ld->ld_options |= LDAP_OPT_DNS; } #endif /* LDAP_DNS */ - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Recognize and chase referrals (0=no, 1=yes)?" ); if ( atoi( line ) != 0 ) { theInt = LDAP_OPT_ON; - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Prompt for bind credentials when chasing referrals (0=no, 1=yes)?" ); if ( atoi( line ) != 0 ) { ldap_set_option( ld, LDAP_OPT_REBIND_FN, bind_prompt ); @@ -935,7 +930,7 @@ main(int argc, char **argv ) break; case 'k': /* Set some controls */ - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Set control: (0 for none, 1 for ManageDSA, 2 for preferredLang, 3 for BAD)?"); theInt = atoi(line); switch (theInt){ @@ -949,7 +944,7 @@ main(int argc, char **argv ) ldap_set_option(ld, LDAP_OPT_SERVER_CONTROLS, ctrls); break; case 2: - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Preferred Language Control : lang ?"); aCtrl.ldctl_oid = "1.3.6.1.4.1.1466.20035"; aCtrl.ldctl_iscritical = 1; @@ -959,7 +954,7 @@ main(int argc, char **argv ) ldap_set_option(ld, LDAP_OPT_SERVER_CONTROLS, ctrls); break; default: - getline( line, sizeof(line), stdin, + getaline( line, sizeof(line), stdin, "Bad Control is critical (0=false, 1=true)?"); aCtrl.ldctl_oid = "1.1.1.1.1.1"; aCtrl.ldctl_iscritical = atoi(line); @@ -973,7 +968,7 @@ main(int argc, char **argv ) #ifdef NO_CACHE printf( NOCACHEERRMSG ); #else /* NO_CACHE */ - getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" ); + getaline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" ); switch( atoi( line )) { case 0: ldap_set_cache_options( ld, 0 ); diff --git a/usr/src/cmd/mail/copymt.c b/usr/src/cmd/mail/copymt.c index 75960842c5..3d2289a8b6 100644 --- a/usr/src/cmd/mail/copymt.c +++ b/usr/src/cmd/mail/copymt.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,11 +18,14 @@ * * CDDL HEADER END */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 2.1 */ /* NAME copymt - copy mail (f1) to temp (f2) @@ -62,7 +64,7 @@ register FILE *f1, *f2; nextadr = let[nlet].adr; } - while ((n = getline(line, sizeof line, f1)) > 0) { + while ((n = getaline(line, sizeof line, f1)) > 0) { if (!newline) { goto putout; } else if ((hdr = isheader (line, &ctf)) == FALSE) { diff --git a/usr/src/cmd/mail/gethead.c b/usr/src/cmd/mail/gethead.c index be671b8a23..3dcae88535 100644 --- a/usr/src/cmd/mail/gethead.c +++ b/usr/src/cmd/mail/gethead.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,16 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "mail.h" #define MAXHDRSIZE 100 /* Maximum length of header line */ @@ -129,7 +126,8 @@ gethead(int current, int all) } /* skip past trailing white space after header tag */ - for (rc = 5; wline[rc] == ' ' || wline[rc] == '\t'; ++rc); + for (rc = 5; wline[rc] == ' ' || wline[rc] == '\t'; ++rc) + ; (void) strlcpy(hold, wline + rc, MAXHDRSIZE); fgets(wline, MAXHDRSIZE, file); @@ -171,12 +169,15 @@ gethead(int current, int all) * delimiting white space. */ for (; hold[rc] != '\0' && hold[rc] != ' ' && - hold[rc] != '\t'; ++rc); - for (; hold[rc] == ' ' || hold[rc] == '\t'; ++rc); + hold[rc] != '\t'; ++rc) + ; + for (; hold[rc] == ' ' || hold[rc] == '\t'; ++rc) + ; /* Get the date information. */ (void) strlcpy(wline, hold + rc, MAXHDRSIZE); - for (rc = 0; wline[rc] != '\0' && wline[rc] != '\n'; ++rc); + for (rc = 0; wline[rc] != '\0' && wline[rc] != '\n'; ++rc) + ; wline[rc] = '\0'; if (!flgh && current == ln) mark = '>'; @@ -224,7 +225,7 @@ wtmpf(char *str, int length) * return number of bytes in length */ int -getline(char *ptr2line, int max, FILE *f) +getaline(char *ptr2line, int max, FILE *f) { int i, ch; for (i = 0; i < max-1 && (ch = getc(f)) != EOF; ) @@ -243,9 +244,9 @@ mktmp(void) int fd = mkstemp(lettmp = tmpl); if (fd < 0 || (tmpf = fdopen(fd, "w+")) == NULL) { - fprintf(stderr, + fprintf(stderr, "%s: Can't open '%s', type: w+\n", program, lettmp); - done(0); + done(0); } } diff --git a/usr/src/cmd/mail/mail.h b/usr/src/cmd/mail/mail.h index 08dbd66d75..8371d520d6 100644 --- a/usr/src/cmd/mail/mail.h +++ b/usr/src/cmd/mail/mail.h @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ #ifndef _MAIL_H #define _MAIL_H -#pragma ident "%Z%%M% %I% %E% SMI" - /* * All global externs defined here. All variables are initialized * in init.c @@ -304,7 +301,7 @@ extern int findSurg(int letnum, string *execbuf, int flag, int *psurr_num, int * extern void gendeliv(FILE *fp, int rc, char *name); extern int getcomment(char *s, char *q); extern int gethead(int current, int all); -extern int getline(char *ptr2line, int max, FILE *f); +extern int getaline(char *ptr2line, int max, FILE *f); extern int getnumbr(char *s); extern int getsurr(FILE *fp, string *buf, int firstfield); extern void goback(int letnum); diff --git a/usr/src/cmd/mail/sendmail.c b/usr/src/cmd/mail/sendmail.c index 976dc275fa..9bd6444b6a 100644 --- a/usr/src/cmd/mail/sendmail.c +++ b/usr/src/cmd/mail/sendmail.c @@ -18,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ #include "mail.h" #include <sys/param.h> @@ -160,7 +157,7 @@ char **argv; } } - while ((n = getline(line, sizeof (line), stdin)) > 0) { + while ((n = getaline(line, sizeof (line), stdin)) > 0) { last1c = line[n-1]; if (pushrest) { if (!wtmpf(line, n)) { @@ -287,7 +284,7 @@ char **argv; } if (n == 1 && last1c == '\n') { /* blank line -- suppress */ - n = getline(buf, sizeof (buf), stdin); + n = getaline(buf, sizeof (buf), stdin); if (n == 0 || (ttyf && !strncmp(buf, ".\n", 2))) { /* * no content: put mime-version, content-type @@ -385,7 +382,7 @@ char **argv; } count += n; n = ttyf - ? getline(buf, sizeof (buf), stdin) + ? getaline(buf, sizeof (buf), stdin) : fread(buf, 1, sizeof (buf), stdin); } setsig(SIGINT, saveint); diff --git a/usr/src/cmd/mailx/collect.c b/usr/src/cmd/mailx/collect.c index e05a586bb6..980e4f4355 100644 --- a/usr/src/cmd/mailx/collect.c +++ b/usr/src/cmd/mailx/collect.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,15 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 1998 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1985, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California @@ -38,8 +36,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * mailx -- a modified version of a University of California at Berkeley * mail program @@ -244,7 +240,7 @@ collect(struct header *hp) hdrs = 0; continue; } - if ((nread = getline(linebuf,LINESIZE,stdin,&hasnulls)) == NULL) { + if ((nread = getaline(linebuf,LINESIZE,stdin,&hasnulls)) == NULL) { if (intty && value("ignoreeof") != NOSTR) { if (++eof > 35) break; @@ -1227,7 +1223,7 @@ intack(int s) passed must be 1 larger than "size" for the trailing NUL byte. */ int -getline(char *line, int size, FILE *f, int *hasnulls) +getaline(char *line, int size, FILE *f, int *hasnulls) { register int i, ch; for (i = 0; (i < size) && ((ch=getc(f)) != EOF); ) { diff --git a/usr/src/cmd/mailx/hdr/def.h b/usr/src/cmd/mailx/hdr/def.h index 53a9fe9842..d0e48820ea 100644 --- a/usr/src/cmd/mailx/hdr/def.h +++ b/usr/src/cmd/mailx/hdr/def.h @@ -20,8 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1985, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -40,8 +39,6 @@ #ifndef _MAILX_DEF_H #define _MAILX_DEF_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -474,7 +471,7 @@ extern int from(int *msgvec); extern off_t fsize(FILE *iob); extern int getfold(char *name); extern int gethfield(register FILE *f, char linebuf[], register long rem); -extern int getline(char *line, int size, FILE *f, int *hasnulls); +extern int getaline(char *line, int size, FILE *f, int *hasnulls); extern int getmessage(char *buf, int *vector, int flags); extern int getmsglist(char *buf, int *vector, int flags); extern int getname(uid_t uid, char namebuf[]); diff --git a/usr/src/cmd/mailx/send.c b/usr/src/cmd/mailx/send.c index 6979cbe522..ca2b6a3b93 100644 --- a/usr/src/cmd/mailx/send.c +++ b/usr/src/cmd/mailx/send.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -21,8 +20,7 @@ */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1985, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -38,8 +36,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "rcv.h" #include <locale.h> @@ -96,7 +92,7 @@ msend( lc = 0; clearerr(obuf); while (c > 0L) { - nread = getline(line, LINESIZE, ibuf, &unused); + nread = getaline(line, LINESIZE, ibuf, &unused); c -= nread; lc++; if (ishead) { diff --git a/usr/src/cmd/mdb/common/modules/libc/libc.c b/usr/src/cmd/mdb/common/modules/libc/libc.c index 1032977d05..da8bbc6828 100644 --- a/usr/src/cmd/mdb/common/modules/libc/libc.c +++ b/usr/src/cmd/mdb/common/modules/libc/libc.c @@ -845,11 +845,12 @@ d_uberdata(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) prt_addr(uberdata.ulwp_replace_last, 1), prt_addr(uberdata.atforklist, 0)); - HD("robustlocks robustlist"); - mdb_printf(OFFSTR "%s %s\n", + HD("robustlocks robustlist progname"); + mdb_printf(OFFSTR "%s %s %s\n", OFFSET(robustlocks), prt_addr(uberdata.robustlocks, 1), - prt_addr(uberdata.robustlist, 0)); + prt_addr(uberdata.robustlist, 1), + prt_addr(uberdata.progname, 0)); HD("tdb_bootstrap tdb_sync_addr_hash tdb_'count tdb_'fail"); mdb_printf(OFFSTR "%s %s %-10d %d\n", diff --git a/usr/src/cmd/more/more.c b/usr/src/cmd/more/more.c index 56bd47a6e1..523d87e7cd 100644 --- a/usr/src/cmd/more/more.c +++ b/usr/src/cmd/more/more.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -39,8 +39,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * @(#) more.c 1.1 88/03/29 more:more.c */ @@ -224,7 +222,7 @@ static void set_tty(void); static void reset_tty(void); static void rdline(register FILE *f); static off_t command(char *filename, register FILE *f); -static int getline(register FILE *f, int *length); +static int getaline(register FILE *f, int *length); static int number(char *cmd); static int colon(char *filename, int cmd, off_t nlines); @@ -504,7 +502,7 @@ screen(register FILE *f, register off_t num_lines) for (;;) { while (num_lines > 0 && !Pause) { - if ((nchars = getline (f, &length)) == EOF) + if ((nchars = getaline (f, &length)) == EOF) { if (clreol) clreos(); return; @@ -726,7 +724,7 @@ wait_eof(void) */ static int -getline(register FILE *f, int *length) +getaline(register FILE *f, int *length) { register int c; register char *p; diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_dtime.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_dtime.c index 125d9f27c0..132f88a2da 100644 --- a/usr/src/cmd/ndmpd/ndmp/ndmpd_dtime.c +++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_dtime.c @@ -184,12 +184,12 @@ ddates_pathname(char *buf) /* - * getline + * getaline * * Get a line from the file and handle the continued lines. */ static char * -getline(FILE *fp, char *line, int llen) +getaline(FILE *fp, char *line, int llen) { char *save; int len; @@ -483,7 +483,7 @@ getrecord(FILE *fp, dumpdates_t *ddatep, int *recno) return (-1); do { - if (getline(fp, tbuf, sizeof (tbuf)) != tbuf) + if (getaline(fp, tbuf, sizeof (tbuf)) != tbuf) return (-1); } while (!*tbuf); diff --git a/usr/src/cmd/nscd/nscd_initf.c b/usr/src/cmd/nscd/nscd_initf.c index 010e82b438..2a3abdc931 100644 --- a/usr/src/cmd/nscd/nscd_initf.c +++ b/usr/src/cmd/nscd/nscd_initf.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -236,10 +237,11 @@ nss_db_initf_t nscd_nss_db_initf[] = { _nss_initf_passwd_compat, _nss_initf_group_compat, /* - * no initf() for pseudo-databases: passwd, shadow, user_attr, - * and group (when called from the compat backend) + * no initf() for pseudo-databases: passwd, shadow, audit_user, + * user_attr, and group (when called from the compat backend) */ NULL, NULL, NULL, + NULL, NULL}; diff --git a/usr/src/cmd/oawk/makeprctab.c b/usr/src/cmd/oawk/makeprctab.c index 622ac04e44..1a8c420432 100644 --- a/usr/src/cmd/oawk/makeprctab.c +++ b/usr/src/cmd/oawk/makeprctab.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -85,7 +84,7 @@ struct xx { BREAK, "jump", "break"}, { CONTINUE, "jump", "continue"}, { FNCN, "fncn", "fncn"}, - { GETLINE, "getline", "getline"}, + { GETLINE, "getaline", "getline"}, { 0, ""}, }; #define SIZE LASTTOKEN - FIRSTTOKEN diff --git a/usr/src/cmd/oawk/run.c b/usr/src/cmd/oawk/run.c index 3f230500dc..88d666e5fa 100644 --- a/usr/src/cmd/oawk/run.c +++ b/usr/src/cmd/oawk/run.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -156,7 +155,7 @@ program(NODE **a, int n) CELL * -getline(void) +getaline(void) { CELL *x; diff --git a/usr/src/cmd/pg/pg.c b/usr/src/cmd/pg/pg.c index 22f54c6886..5408ee79c0 100644 --- a/usr/src/cmd/pg/pg.c +++ b/usr/src/cmd/pg/pg.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -91,7 +90,7 @@ static void prompt(char *); static void error(char *); static void terminit(); static void compact(); -static off_t getline(FILE *); +static off_t getaline(FILE *); static int mrdchar(); static off_t find(int, off_t); static int search(char *, off_t); @@ -159,7 +158,7 @@ static wchar_t leave_search = L't'; static short nfiles; static char *shell; static char *promptstr = ":"; -static off_t nchars; /* return from getline in find() */ +static off_t nchars; /* return from getaline in find() */ static jmp_buf restore; static char Line[LINSIZ+2]; @@ -1369,7 +1368,7 @@ off_t line; else (void) fseeko(f, (off_t)dol->l_addr, SEEK_SET); dot = dol - 1; - while ((nchars = getline(f)) != EOF) { + while ((nchars = getaline(f)) != EOF) { dot++; newdol(f); if (where == dot->l_no || brk_hit) @@ -1396,7 +1395,7 @@ off_t line; } else { dot = zero + where - 1; (void) fseeko(f, (off_t)dot->l_addr, SEEK_SET); - nchars = getline(f); + nchars = getaline(f); return (dot->l_no); } } @@ -1416,7 +1415,7 @@ mrdchar() */ static off_t -getline(f) +getaline(f) FILE *f; { char *p; @@ -1432,7 +1431,7 @@ FILE *f; rdchar = (int (*)())fgetwc; fileptr = f; - /* copy overlap from previous call to getline */ + /* copy overlap from previous call to getaline */ if (savlength) (void) strncpy(Line, multic, (size_t)savlength); for (column = 0, p = Line + savlength; ; ) { @@ -1482,7 +1481,7 @@ FILE *f; if (c != '\n') { /* We're stopping in the middle of the line */ if (column != columns || !auto_right_margin) *p++ = '\n'; /* for the display */ - /* save overlap for next call to getline */ + /* save overlap for next call to getaline */ savlength = length; if (savlength == 0) { /* diff --git a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.c b/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.c index 3d935c1f47..462ccc1dec 100644 --- a/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.c +++ b/usr/src/cmd/picl/plugins/sun4u/blade/bsc/picllom.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This plugin creates PICL nodes and properties for objects handled through * the blade support chip (BSC). The BSC Solaris land device driver exposes @@ -102,7 +99,6 @@ static int read_fan_status(ptree_rarg_t *parg, void *buf); static int lookup_led_status(int8_t state, const char **string); static int read_led_status(ptree_rarg_t *parg, void *buf); static void convert_node_name(char *ptr); -static const char *strcasestr(const char *s1, const char *s2); static int add_temp_sensors(int lom_fd, picl_nodehdl_t lominfh); static int add_voltage_monitors(int lom_fd, picl_nodehdl_t lominfh); @@ -300,7 +296,7 @@ get_lom_device_path(picl_nodehdl_t *lominfh) char devices_path[PATH_MAX]; err = ptree_get_propval_by_name(*lominfh, PICL_PROP_DEVFS_PATH, - devfs_path, sizeof (devfs_path)); + devfs_path, sizeof (devfs_path)); /* Build up the full device path and set the global */ strcpy(devices_path, "/devices"); @@ -854,24 +850,6 @@ convert_node_name(char *ptr) } } -/* - * find first occurrence of string s2 within string s1 (ignoring case) - */ -static const char * -strcasestr(const char *s1, const char *s2) -{ - int len1 = strlen(s1); - int len2 = strlen(s2); - int i; - - for (i = 0; i <= len1 - len2; i++) { - if (strncasecmp(s1 + i, s2, len2) == 0) - return (s1 + i); - } - - return (NULL); -} - static int add_temp_sensors(int lom_fd, picl_nodehdl_t lominfh) { @@ -1060,10 +1038,10 @@ add_led(const lom_led_state_t *led_state, picl_nodehdl_t lominfh) */ if ((led_state->colour != LOM_LED_COLOUR_NONE) && (led_state->colour != LOM_LED_COLOUR_ANY)) { - err = add_regular_prop(ledh, PICL_PROP_COLOR, - PICL_PTYPE_CHARSTRING, PICL_READ, - colour_lkup[led_state->index].size, - colour_lkup[led_state->index].str_colour, &proph); + err = add_regular_prop(ledh, PICL_PROP_COLOR, + PICL_PTYPE_CHARSTRING, PICL_READ, + colour_lkup[led_state->index].size, + colour_lkup[led_state->index].str_colour, &proph); } if (err != PICL_SUCCESS) return; diff --git a/usr/src/cmd/prctl/prctl.c b/usr/src/cmd/prctl/prctl.c index 006ca6aee5..3b405d2aa7 100644 --- a/usr/src/cmd/prctl/prctl.c +++ b/usr/src/cmd/prctl/prctl.c @@ -18,12 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ - #include <unistd.h> #include <rctl.h> #include <libproc.h> @@ -223,7 +222,7 @@ main(int argc, char **argv) (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); - (void) setprogname(argv[0]); + (void) setpname(argv[0]); while ((opt = getopt(argc, argv, "sPp:Fd:e:i:n:rt:v:x")) != EOF) { diff --git a/usr/src/cmd/prctl/utils.c b/usr/src/cmd/prctl/utils.c index fc2f29d7f9..20b84befd0 100644 --- a/usr/src/cmd/prctl/utils.c +++ b/usr/src/cmd/prctl/utils.c @@ -18,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <libintl.h> #include <string.h> @@ -44,7 +42,7 @@ static char EOL_FMT[] = "\n"; static char *pname; char * -setprogname(char *arg0) +setpname(char *arg0) { char *p = strrchr(arg0, '/'); diff --git a/usr/src/cmd/prctl/utils.h b/usr/src/cmd/prctl/utils.h index 1afa19fe90..2cc1452dd3 100644 --- a/usr/src/cmd/prctl/utils.h +++ b/usr/src/cmd/prctl/utils.h @@ -18,16 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _UTILS_H #define _UTILS_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -35,7 +33,7 @@ extern "C" { #include <sys/types.h> extern void warn(const char *, ...); -extern char *setprogname(char *); +extern char *setpname(char *); /* * scale_t diff --git a/usr/src/cmd/prtconf/prtconf.c b/usr/src/cmd/prtconf/prtconf.c index 8a4a97d29f..8b6c8f3a9a 100644 --- a/usr/src/cmd/prtconf/prtconf.c +++ b/usr/src/cmd/prtconf/prtconf.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -25,7 +26,6 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - #include <stdio.h> #include <stdarg.h> #include <stdlib.h> @@ -50,7 +50,7 @@ static const char *usage = #endif /* __x86 */ static void -setprogname(const char *name) +setpname(const char *name) { char *p; @@ -178,7 +178,7 @@ main(int argc, char *argv[]) int c, ret; char hw_provider[SYS_NMLN]; - setprogname(argv[0]); + setpname(argv[0]); opts.o_promdev = "/dev/openprom"; while ((c = getopt(argc, argv, optstring)) != -1) { diff --git a/usr/src/cmd/prtdiag/main.c b/usr/src/cmd/prtdiag/main.c index 6a666c8c7c..8807cde8d9 100644 --- a/usr/src/cmd/prtdiag/main.c +++ b/usr/src/cmd/prtdiag/main.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -21,8 +20,7 @@ */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* @@ -30,8 +28,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <locale.h> #include <stdlib.h> @@ -43,7 +39,7 @@ extern int do_prominfo(int, char *, int, int); static char * -setprogname(char *name) +setpname(char *name) { char *p; @@ -58,7 +54,7 @@ main(int argc, char *argv[]) { int c; int syserrlog = 0; - char *progname = setprogname(argv[0]); + char *progname = setpname(argv[0]); int print_flag = 1; int logging = 0; diff --git a/usr/src/cmd/rcap/common/utils.c b/usr/src/cmd/rcap/common/utils.c index b641a13a13..799fdcef23 100644 --- a/usr/src/cmd/rcap/common/utils.c +++ b/usr/src/cmd/rcap/common/utils.c @@ -18,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <libintl.h> #include <stdarg.h> @@ -154,7 +152,7 @@ info(char *format, ...) } char * -setprogname(char *arg0) +setpname(char *arg0) { char *p = strrchr(arg0, '/'); diff --git a/usr/src/cmd/rcap/common/utils.h b/usr/src/cmd/rcap/common/utils.h index 4c78d11ff0..7196cfb4ce 100644 --- a/usr/src/cmd/rcap/common/utils.h +++ b/usr/src/cmd/rcap/common/utils.h @@ -18,16 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _UTILS_H #define _UTILS_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <assert.h> #include <libintl.h> #include <stdarg.h> @@ -93,7 +91,7 @@ extern void info(char *, ...); extern rcm_level_t get_message_priority(void); extern rcm_level_t set_message_priority(rcm_level_t); extern rcm_dst_t set_message_destination(rcm_dst_t); -extern char *setprogname(char *); +extern char *setpname(char *); extern void warn(const char *, ...); extern int valid_abspath(char *); extern void vdprintfe(int, const char *, va_list); diff --git a/usr/src/cmd/rcap/rcapadm/rcapadm.c b/usr/src/cmd/rcap/rcapadm/rcapadm.c index f8e6269221..92888b2071 100644 --- a/usr/src/cmd/rcap/rcapadm/rcapadm.c +++ b/usr/src/cmd/rcap/rcapadm/rcapadm.c @@ -18,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> @@ -129,7 +127,7 @@ out: else (void) printf(gettext(" " "state: %s\n"), *persistent ? gettext("enabled") : - gettext("disabled")); + gettext("disabled")); (void) printf(gettext(" memory cap enforcement" " threshold: %d%%\n"), conf.rcfg_memory_cap_enforcement_pressure); @@ -190,7 +188,7 @@ main(int argc, char *argv[]) char *zonename; char *maxrss = NULL; - (void) setprogname("rcapadm"); + (void) setpname("rcapadm"); (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); diff --git a/usr/src/cmd/rcap/rcapd/rcapd_main.c b/usr/src/cmd/rcap/rcapd/rcapd_main.c index bb0a13f129..d18b2c9e04 100644 --- a/usr/src/cmd/rcap/rcapd/rcapd_main.c +++ b/usr/src/cmd/rcap/rcapd/rcapd_main.c @@ -18,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * rcapd is a long-running daemon enforcing project-based resource caps (see * rcapd(1M)). Each instance of a process aggregate (project or, generically, @@ -1217,7 +1215,7 @@ update_statistics(void) if (fchmod(fd, 0644) == 0 && write(fd, &rs, sizeof (rs)) == sizeof (rs)) { list_walk_collection(report_collection_cb, - (void *)(intptr_t)fd); + (void *)(intptr_t)fd); /* * Replace the existing statistics file with this new * one. @@ -1447,7 +1445,7 @@ main(int argc, char *argv[]) hrtime_t next_rss_sample; /* (latest) time of next RSS sample */ (void) set_message_priority(RCM_INFO); - (void) setprogname("rcapd"); + (void) setpname("rcapd"); rcapd_pid = getpid(); (void) chdir("/"); should_run = 1; diff --git a/usr/src/cmd/rcap/rcapstat/rcapstat.c b/usr/src/cmd/rcap/rcapstat/rcapstat.c index edac6dd56d..fb83f861ae 100644 --- a/usr/src/cmd/rcap/rcapstat/rcapstat.c +++ b/usr/src/cmd/rcap/rcapstat/rcapstat.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/types.h> @@ -365,7 +365,7 @@ main(int argc, char *argv[]) (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); - (void) setprogname("rcapstat"); + (void) setpname("rcapstat"); global = unformatted = 0; while ((opt = getopt(argc, argv, "gpuzT:")) != (int)EOF) { diff --git a/usr/src/cmd/rctladm/rctladm.c b/usr/src/cmd/rctladm/rctladm.c index 1748970a8b..c60cb9471b 100644 --- a/usr/src/cmd/rctladm/rctladm.c +++ b/usr/src/cmd/rctladm/rctladm.c @@ -18,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/rctl_impl.h> #include <sys/types.h> #include <sys/stat.h> @@ -452,7 +450,7 @@ main(int argc, char *argv[]) (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); - (void) setprogname(argv[0]); + (void) setpname(argv[0]); while ((c = getopt(argc, argv, OPTS)) != EOF) { switch (c) { diff --git a/usr/src/cmd/rctladm/utils.c b/usr/src/cmd/rctladm/utils.c index 0b3f727622..1a7d5227a2 100644 --- a/usr/src/cmd/rctladm/utils.c +++ b/usr/src/cmd/rctladm/utils.c @@ -18,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <libintl.h> #include <string.h> @@ -73,7 +71,7 @@ die(char *format, ...) } char * -setprogname(char *arg0) +setpname(char *arg0) { char *p = strrchr(arg0, '/'); diff --git a/usr/src/cmd/rctladm/utils.h b/usr/src/cmd/rctladm/utils.h index 2d5ccd8abe..ae0dff31e0 100644 --- a/usr/src/cmd/rctladm/utils.h +++ b/usr/src/cmd/rctladm/utils.h @@ -18,16 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _UTILS_H #define _UTILS_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -44,7 +42,7 @@ extern "C" { extern void warn(const char *, ...); extern void die(char *, ...) __NORETURN; -extern char *setprogname(char *); +extern char *setpname(char *); #ifdef __cplusplus } diff --git a/usr/src/cmd/sendmail/db/clib/strsep.c b/usr/src/cmd/sendmail/db/clib/strsep.c index 093a1c9328..02f8dae826 100644 --- a/usr/src/cmd/sendmail/db/clib/strsep.c +++ b/usr/src/cmd/sendmail/db/clib/strsep.c @@ -36,18 +36,15 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + /* - * Copyright (c) 1998 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. */ #include "config.h" -#pragma ident "%Z%%M% %I% %E% SMI" - #ifndef lint static const char sccsid[] = "@(#)strsep.c 10.1 (Sleepycat) 4/12/97"; -static const char sccsi2[] = "%W% (Sun) %G%"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -70,6 +67,9 @@ static const char sccsi2[] = "%W% (Sun) %G%"; * PUBLIC: char *strsep __P((char **, const char *)); * PUBLIC: #endif */ + +#ifndef HAVE_STRSEP + char * strsep(stringp, delim) register char **stringp; @@ -98,3 +98,5 @@ strsep(stringp, delim) } /* NOTREACHED */ } + +#endif /* HAVE_STRSEP */ diff --git a/usr/src/cmd/sgs/crle/common/print.c b/usr/src/cmd/sgs/crle/common/print.c index 9399495bd5..2692018dfc 100644 --- a/usr/src/cmd/sgs/crle/common/print.c +++ b/usr/src/cmd/sgs/crle/common/print.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/types.h> @@ -33,7 +32,6 @@ #include <unistd.h> #include <errno.h> #include <limits.h> -#include <alloca.h> #include "sgs.h" #include "rtc.h" #include "conv.h" @@ -346,7 +344,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) /* * Construct the original command line argument. */ - cmd = strcpy(alloca(MSG_CMD_64_SIZE + 1), MSG_ORIG(MSG_CMD_64)); + cmd = strdupa(MSG_ORIG(MSG_CMD_64)); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -383,7 +381,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) */ (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_CONF), crle->c_confil); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); @@ -395,7 +393,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_FLAGS), conv_dl_flag(head->ch_dlflags, CONV_FMT_ALT_CRLE, &dl_flag_buf)); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -443,13 +441,13 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) */ (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_OUTPUT), crle->c_objdir); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_DUMPGRP), (strtbl + obj->co_name)); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -488,7 +486,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_EDLIB), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -555,7 +553,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_ESLIB), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -607,7 +605,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_ADLIB), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -647,7 +645,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_ASLIB), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); } @@ -707,7 +705,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) } (void) printf(pfmt, str); (void) snprintf(_cmd, PATH_MAX, sfmt, str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); @@ -808,7 +806,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) /* LINTED */ (void) snprintf(_cmd, PATH_MAX, getformat(dobj->co_flags), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); @@ -901,8 +899,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_OUTPUT), crle->c_objdir); - cmd = strcpy(alloca(strlen(_cmd) + 1), - _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); @@ -911,7 +908,7 @@ scanconfig(Crle_desc * crle, Addr addr, int c_class) /* LINTED */ (void) snprintf(_cmd, PATH_MAX, getformat(flags), str); - cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd); + cmd = strdupa(_cmd); if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) return (INSCFG_RET_FAIL); diff --git a/usr/src/cmd/sgs/libconv/common/demangle.c b/usr/src/cmd/sgs/libconv/common/demangle.c index aa3589a51c..8b590d87e0 100644 --- a/usr/src/cmd/sgs/libconv/common/demangle.c +++ b/usr/src/cmd/sgs/libconv/common/demangle.c @@ -20,10 +20,8 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" #include <stdio.h> #include <demangle.h> @@ -50,8 +48,7 @@ * buffer). One model is: * * if ((_name1 = demangle(name1)) != name1) { - * char * __name1 = alloca(strlen(_name1) + 1); - * (void) strcpy(__name1, _name1); + * char * __name1 = strdupa(_name1); * name1 = (const char *)__name1; * } * name2 = demangle(name2); diff --git a/usr/src/cmd/sgs/lorder/lorder.sh b/usr/src/cmd/sgs/lorder/lorder.sh index 81ba58df7b..4b518e3d61 100644 --- a/usr/src/cmd/sgs/lorder/lorder.sh +++ b/usr/src/cmd/sgs/lorder/lorder.sh @@ -3,9 +3,8 @@ # 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. +# Common Development and Distribution License (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. @@ -22,12 +21,9 @@ # # Copyright (c) 1989 AT&T # All Rights Reserved - - -# Copyright 1998-2003 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. - -#pragma ident "%Z%%M% %I% %E% SMI" +# +# Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. +# # COMMON LORDER # @@ -91,7 +87,7 @@ esac # ${WHERE}/${PFX}nm -p $* 2>$TDIR/$$tmp | sed -e '/^[ ]*$/d' -e ' /^[0-9]* R $/d - / [a-zFS] /d + / [a-zFLS] /d /[^]]:$/{ s/:// h diff --git a/usr/src/cmd/sgs/rtld/common/external.c b/usr/src/cmd/sgs/rtld/common/external.c index 91b4227f16..82766906b5 100644 --- a/usr/src/cmd/sgs/rtld/common/external.c +++ b/usr/src/cmd/sgs/rtld/common/external.c @@ -582,6 +582,26 @@ thr_min_stack() } /* + * Local str[n]casecmp() interfaces for the dynamic linker, + * to avoid problems when linking with libc_pic.a + */ +int +strcasecmp(const char *s1, const char *s2) +{ + extern int ascii_strcasecmp(const char *, const char *); + + return (ascii_strcasecmp(s1, s2)); +} + +int +strncasecmp(const char *s1, const char *s2, size_t n) +{ + extern int ascii_strncasecmp(const char *, const char *, size_t); + + return (ascii_strncasecmp(s1, s2, n)); +} + +/* * The following functions are cancellation points in libc. * They are called from other functions in libc that we extract * and use directly. We don't do cancellation while we are in diff --git a/usr/src/cmd/ssh/include/config.h b/usr/src/cmd/ssh/include/config.h index c718d259ad..884e177d9b 100644 --- a/usr/src/cmd/ssh/include/config.h +++ b/usr/src/cmd/ssh/include/config.h @@ -1,9 +1,9 @@ /* config.h. Generated by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* $Id: acconfig.h,v 1.145 2002/09/26 00:38:48 tim Exp $ */ + /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _CONFIG_H @@ -214,7 +214,7 @@ extern "C" { /* #undef USE_EXTERNAL_ASKPASS */ /* Define if libc defines __progname */ -/* #undef HAVE___PROGNAME */ +#define HAVE___PROGNAME 1 /* Define if compiler implements __FUNCTION__ */ #define HAVE___FUNCTION__ 1 diff --git a/usr/src/cmd/svr4pkg/libinst/dockdeps.c b/usr/src/cmd/svr4pkg/libinst/dockdeps.c index 195a680727..ec7da35dd7 100644 --- a/usr/src/cmd/svr4pkg/libinst/dockdeps.c +++ b/usr/src/cmd/svr4pkg/libinst/dockdeps.c @@ -20,15 +20,12 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - - #include <stdio.h> #include <errno.h> #include <limits.h> @@ -92,7 +89,7 @@ static void prereq(char *pkginst, char *pkgname, boolean_t a_preinstallCheck); static void incompat(char *pkginst, char *pkgname, boolean_t a_preinstallCheck); -static int getline(FILE *fp); +static int getaline(FILE *fp); /* * ***************************************************************************** @@ -124,7 +121,7 @@ dockdeps(char *a_depfile, int a_removeFlag, boolean_t a_preinstallCheck) } } - while (getline(fp)) { + while (getaline(fp)) { switch (type) { case 'I': case 'P': @@ -323,7 +320,7 @@ deponme(char *pkginst, char *pkgname, boolean_t a_preinstallCheck) } static int -getline(FILE *fp) +getaline(FILE *fp) { register int i, c, found; char *pt, *new, line[LSIZE]; @@ -422,7 +419,7 @@ ckpreq(FILE *fp, char *dname, boolean_t a_preinstallCheck) register int i; char *inst; - while (getline(fp)) { + while (getaline(fp)) { if (type != 'P') continue; diff --git a/usr/src/cmd/vi/misc/ctags.c b/usr/src/cmd/vi/misc/ctags.c index 910257d04a..d6e2de739b 100644 --- a/usr/src/cmd/vi/misc/ctags.c +++ b/usr/src/cmd/vi/misc/ctags.c @@ -1,6 +1,5 @@ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ @@ -43,9 +42,6 @@ char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of " "California.\nAll rights reserved.\n"; #endif -#pragma ident "%Z%%M% %I% %E% SMI" - /* from UCB 5.1 5/31/85 */ - #include <stdio.h> #include <ctype.h> #include <locale.h> @@ -172,7 +168,7 @@ static void C_entries(); static int start_entry(char **lp, char *token, int *f); static void Y_entries(); static char *toss_comment(char *start); -static void getline(long int where); +static void getaline(long int where); static void free_tree(NODE *node); static void add_node(NODE *node, NODE *cur_node); static void put_entries(NODE *node); @@ -371,7 +367,7 @@ char *file; * throw away all the code before the second "%%" */ toss_yysec(); - getline(lineftell); + getaline(lineftell); pfnote("yylex", lineno, TRUE); toss_yysec(); C_entries(); @@ -684,7 +680,7 @@ dotoken: if (start_entry(&sp, token, &f)) { (void) strncpy(tok, token, tp-token+1); tok[tp-token+1] = 0; - getline(tokftell); + getaline(tokftell); pfnote(tok, pfline, f); gotone = f; /* function */ } @@ -844,7 +840,7 @@ Y_entries() char tok[BUFSIZ]; brace = 0; - getline(lineftell); + getaline(lineftell); pfnote("yyparse", lineno, TRUE); while (fgets(line, sizeof (line), inf) != NULL) for (sp = line; *sp; sp++) @@ -951,7 +947,7 @@ char *start; } static void -getline(where) +getaline(where) long int where; { long saveftell = ftell(inf); diff --git a/usr/src/cmd/vi/port/ex.h b/usr/src/cmd/vi/port/ex.h index 4f6ee98a04..820937be46 100644 --- a/usr/src/cmd/vi/port/ex.h +++ b/usr/src/cmd/vi/port/ex.h @@ -18,22 +18,19 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* Copyright (c) 1981 Regents of the University of California */ #ifndef _EX_H #define _EX_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -604,7 +601,7 @@ void vroll(int); void vrollR(int); void vnline(unsigned char *); void noerror(); -void getline(line); +void getaline(line); void viprintf(); void gettmode(void); void setterm(unsigned char *); diff --git a/usr/src/cmd/vi/port/ex_cmds.c b/usr/src/cmd/vi/port/ex_cmds.c index 3ca2af395a..ab7146ce0f 100644 --- a/usr/src/cmd/vi/port/ex_cmds.c +++ b/usr/src/cmd/vi/port/ex_cmds.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -29,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" @@ -1005,7 +1003,7 @@ caseline: nonzero(); if (seensemi) addr1 = addr2; - getline(*addr1); + getaline(*addr1); if (c == CTRL('k')) { flush1(); destline--; diff --git a/usr/src/cmd/vi/port/ex_cmdsub.c b/usr/src/cmd/vi/port/ex_cmdsub.c index 7a121a6e12..4e7e4b0005 100644 --- a/usr/src/cmd/vi/port/ex_cmdsub.c +++ b/usr/src/cmd/vi/port/ex_cmdsub.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" @@ -253,7 +250,7 @@ join(int c) cp = genbuf; *cp = 0; for (a1 = addr1; a1 <= addr2; a1++) { - getline(*a1); + getaline(*a1); cp1 = linebuf; if (a1 != addr1 && c == 0) { while (*cp1 == ' ' || *cp1 == '\t') @@ -410,7 +407,7 @@ getcopy(void) if (tad1 > addr2) return (EOF); - getline(*tad1++); + getaline(*tad1++); return (0); } @@ -423,7 +420,7 @@ getput(void) if (tad1 > unddol) return (EOF); - getline(*tad1++); + getaline(*tad1++); tad1++; return (0); } @@ -490,7 +487,7 @@ pragged(bool kill) * Get last line of undo area ("3") into linebuf. */ - getline(*unddol); + getaline(*unddol); if (kill) *pkill[1] = 0; @@ -518,7 +515,7 @@ pragged(bool kill) * So linebuf = "1" */ - getline(dol[1]); + getaline(dol[1]); if (kill) strcLIN(pkill[0]); @@ -1129,7 +1126,7 @@ zop2(int nlines, int op) if (addr1 > addr2) return; if (op == EOF && zhadpr) { - getline(*addr1); + getaline(*addr1); putchar((int)('\r' | QUOTE)); shudclob = 1; } else if (znoclear == 0 && clear_screen != NOSTR && !inopen) { @@ -1165,7 +1162,7 @@ plines(line *adr1, line *adr2, bool movedot) pofix(); for (addr = adr1; addr <= adr2; addr++) { - getline(*addr); + getaline(*addr); pline(lineno(addr)); if (inopen) putchar((int)('\n' | QUOTE)); diff --git a/usr/src/cmd/vi/port/ex_get.c b/usr/src/cmd/vi/port/ex_get.c index 129aa91031..95be2c3d20 100644 --- a/usr/src/cmd/vi/port/ex_get.c +++ b/usr/src/cmd/vi/port/ex_get.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" @@ -300,5 +297,5 @@ setin(line *addr) if (addr == zero) lastin = 0; else - getline(*addr), lastin = smunch(0, linebuf); + getaline(*addr), lastin = smunch(0, linebuf); } diff --git a/usr/src/cmd/vi/port/ex_io.c b/usr/src/cmd/vi/port/ex_io.c index 0a569bd894..e63fab87ae 100644 --- a/usr/src/cmd/vi/port/ex_io.c +++ b/usr/src/cmd/vi/port/ex_io.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" @@ -480,7 +477,7 @@ rop2(void) for (a=first; a<=last; a++) { if (a==first+5 && last-first > 10) a = last - 4; - getline(*a); + getaline(*a); chkmdln(linebuf); } } @@ -767,7 +764,7 @@ putfile(int isfilter) nib = BUFSIZE; fp = genbuf; do { - getline(*a1++); + getaline(*a1++); lp = linebuf; for (;;) { if (--nib < 0) { diff --git a/usr/src/cmd/vi/port/ex_re.c b/usr/src/cmd/vi/port/ex_re.c index ac58cf65d4..3d3f1a036a 100644 --- a/usr/src/cmd/vi/port/ex_re.c +++ b/usr/src/cmd/vi/port/ex_re.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_re.h" @@ -1107,7 +1104,7 @@ execute(int gf, line *addr) if (addr == zero) return (0); p1 = linebuf; - getline(*addr); + getaline(*addr); if(value(vi_IGNORECASE)) { p1 = genbuf; p2 = linebuf; diff --git a/usr/src/cmd/vi/port/ex_set.c b/usr/src/cmd/vi/port/ex_set.c index 2308ae588c..fb2de4cb5f 100644 --- a/usr/src/cmd/vi/port/ex_set.c +++ b/usr/src/cmd/vi/port/ex_set.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_temp.h" #include "ex_tty.h" @@ -189,7 +186,7 @@ set(void) viprintf("%d\n", tmpadr); else { viprintf("%d\t", tmpadr); - getline(*tmpadr); + getaline(*tmpadr); pline(lineno(tmpadr)); putchar('\n'); } @@ -231,7 +228,7 @@ set(void) viprintf("%d\n", tmpadr); else { viprintf("%d\t", tmpadr); - getline(*tmpadr); + getaline(*tmpadr); pline(lineno(tmpadr)); putchar('\n'); } diff --git a/usr/src/cmd/vi/port/ex_subr.c b/usr/src/cmd/vi/port/ex_subr.c index d5193dbe26..ea3f4b3929 100644 --- a/usr/src/cmd/vi/port/ex_subr.c +++ b/usr/src/cmd/vi/port/ex_subr.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/stropts.h> #include <sys/eucioctl.h> #ifndef PRESUNEUC @@ -219,7 +216,7 @@ void getDOT(void) { - getline(*dot); + getaline(*dot); } line * diff --git a/usr/src/cmd/vi/port/ex_temp.c b/usr/src/cmd/vi/port/ex_temp.c index c7040ff575..fd061b83e3 100644 --- a/usr/src/cmd/vi/port/ex_temp.c +++ b/usr/src/cmd/vi/port/ex_temp.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_temp.h" #include "ex_vis.h" @@ -157,7 +154,7 @@ cleanup(bool all) } void -getline(line tl) +getaline(line tl) { unsigned char *bp, *lp; int nl; @@ -688,7 +685,7 @@ YANKreg(int c) } CP(savelb, linebuf); for (addr = addr1; addr <= addr2; addr++) { - getline(*addr); + getaline(*addr); if (sp->rg_flags) { if (addr == addr2) *wcursor = 0; diff --git a/usr/src/cmd/vi/port/ex_vadj.c b/usr/src/cmd/vi/port/ex_vadj.c index 3be4add496..3eb419abb6 100644 --- a/usr/src/cmd/vi/port/ex_vadj.c +++ b/usr/src/cmd/vi/port/ex_vadj.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tune.h" #include "ex_tty.h" @@ -90,7 +87,7 @@ vopen(line *tp, int p) * and so it's not worth optimizing. */ vdirty(vcline+1, WECHO); - getline(*tp); + getaline(*tp); /* * If we are opening at the top of the window, can try a window @@ -685,7 +682,7 @@ vredraw(int p) if (l == vcline) strcLIN(temp); else - getline(*tp); + getaline(*tp); /* * Delete junk between displayed lines. @@ -729,7 +726,7 @@ vredraw(int p) vcline = l; for (; tp <= dol && Peekkey != ATTN; tp++) { - getline(*tp); + getaline(*tp); if (p + vdepth() - 1 > WBOT) break; vopen(tp, p); @@ -897,7 +894,7 @@ vsync1(int p) if (l == vcline) strcLIN(temp); else - getline(dot[l - vcline]); + getaline(dot[l - vcline]); /* * Be careful that a long line doesn't cause the * screen to shoot up. diff --git a/usr/src/cmd/vi/port/ex_vget.c b/usr/src/cmd/vi/port/ex_vget.c index b0b0260331..c96d4bc29c 100644 --- a/usr/src/cmd/vi/port/ex_vget.c +++ b/usr/src/cmd/vi/port/ex_vget.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -755,7 +752,7 @@ unsigned char *s; fprintf(trace, "linebuf = '%s'\n", linebuf); for (p=zero+1; p<=truedol; p++) { fprintf(trace, "%o ", *p); - getline(*p); + getaline(*p); fprintf(trace, "'%s'\n", linebuf); } fprintf(trace, "]\n"); diff --git a/usr/src/cmd/vi/port/ex_voper.c b/usr/src/cmd/vi/port/ex_voper.c index 825996d0c4..8ce2904af2 100644 --- a/usr/src/cmd/vi/port/ex_voper.c +++ b/usr/src/cmd/vi/port/ex_voper.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -747,7 +747,7 @@ errlab: markDOT(); if (wcursor) { vsave(); - getline(*wdot); + getaline(*wdot); if (wcursor > strend(linebuf)) wcursor = 0; else { diff --git a/usr/src/cmd/vi/port/ex_vops.c b/usr/src/cmd/vi/port/ex_vops.c index 104bcd3988..71dba8cf5a 100644 --- a/usr/src/cmd/vi/port/ex_vops.c +++ b/usr/src/cmd/vi/port/ex_vops.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -29,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -526,7 +524,7 @@ vchange(unsigned char c) */ *cursor = 0; strcpy(genbuf, linebuf); - getline(*wdot); + getaline(*wdot); if (strlen(genbuf) + strlen(wcursor) > LBSIZE - 2) { getDOT(); (void) beep(); @@ -910,7 +908,7 @@ xdw(void) if (vpastwh(linebuf) >= cursor) wcursor = 0; else { - getline(*wdot); + getaline(*wdot); wcursor = strend(linebuf); getDOT(); } diff --git a/usr/src/cmd/vi/port/ex_vops2.c b/usr/src/cmd/vi/port/ex_vops2.c index 2ef2d8aec1..f47b9adcdf 100644 --- a/usr/src/cmd/vi/port/ex_vops2.c +++ b/usr/src/cmd/vi/port/ex_vops2.c @@ -18,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -29,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -781,7 +779,7 @@ imultlinerep(int savecnt, line *startsrcline, int startsrccol, int endsrccol) * of the repeated insert, then copy this line to the temp file. */ (void) strlcpy((char *)genbuf, (char *)linebuf, sizeof (genbuf)); - getline(*startsrcline); + getaline(*startsrcline); if (strlcpy((char *)(genbuf + endsrccol + 1), (char *)(linebuf + startsrccol), destsize) >= destsize) { error(gettext("Line too long")); @@ -808,7 +806,7 @@ imultlinerep(int savecnt, line *startsrcline, int startsrccol, int endsrccol) getDOT(); cursor = linebuf + endsrccol; } else { - getline(*srcline); + getaline(*srcline); /* copy linebuf to temp file */ vdoappend(linebuf); vcline++; @@ -840,7 +838,7 @@ omultlinerep(int savecnt, line *startsrcline, int endsrccol) */ while (tmpcnt <= savecnt) { for (srcline = startsrcline; srcline <= endsrcline; ++srcline) { - getline(*srcline); + getaline(*srcline); /* copy linebuf to temp file */ vdoappend(linebuf); vcline++; diff --git a/usr/src/cmd/vi/port/ex_vops3.c b/usr/src/cmd/vi/port/ex_vops3.c index d90a4d3c3c..733903ca9f 100644 --- a/usr/src/cmd/vi/port/ex_vops3.c +++ b/usr/src/cmd/vi/port/ex_vops3.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -331,7 +328,7 @@ again: int cnt = 0; addr--; - getline(*addr); + getaline(*addr); for (cp = linebuf; *cp; cp++) if (*cp == '(') cnt++; @@ -548,7 +545,7 @@ lnext(void) return (0); } wdot++; - getline(*wdot); + getaline(*wdot); wcursor = linebuf; return (1); } else { @@ -562,7 +559,7 @@ lnext(void) return (0); } wdot--; - getline(*wdot); + getaline(*wdot); if(!*linebuf) wcursor = linebuf; else { @@ -585,7 +582,7 @@ lbrack(int c, int (*f)()) addr -= dir; break; } - getline(*addr); + getaline(*addr); if (linebuf[0] == '{' || #ifdef XPG4 /* POSIX 1003.2 Section 5.35.7.1: control-L */ @@ -595,7 +592,7 @@ lbrack(int c, int (*f)()) isa(svalue(vi_SECTIONS))) { if (c == ']' && f != vmove) { addr--; - getline(*addr); + getaline(*addr); } break; } diff --git a/usr/src/cmd/vi/port/ex_vwind.c b/usr/src/cmd/vi/port/ex_vwind.c index 6b74f723bc..cdaf577a2b 100644 --- a/usr/src/cmd/vi/port/ex_vwind.c +++ b/usr/src/cmd/vi/port/ex_vwind.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,9 +18,9 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -30,8 +29,6 @@ /* Copyright (c) 1981 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -201,24 +198,24 @@ vcontext(line *addr, unsigned char where) { line *top; - getline(*addr); + getaline(*addr); if (state != VISUAL) top = addr; else switch (where) { case '^': addr = vback(addr, basWLINES - vdepth()); - getline(*addr); + getaline(*addr); /* fall into ... */ case '-': top = vback(addr, basWLINES - vdepth()); - getline(*addr); + getaline(*addr); break; case '.': top = vback(addr, basWLINES / 2 - vdepth()); - getline(*addr); + getaline(*addr); break; default: @@ -334,7 +331,7 @@ vback(tp, cnt) if (cnt > 0) for (; tp > one; tp--) { - getline(tp[-1]); + getaline(tp[-1]); d = vdepth(); if (d > cnt) break; @@ -354,7 +351,7 @@ vfit(line *tp, int cnt) j = 0; while (cnt > 0) { cnt--; - getline(tp[cnt]); + getaline(tp[cnt]); j += vdepth(); } if (tp > dot) diff --git a/usr/src/cmd/vi/port/exrecover.c b/usr/src/cmd/vi/port/exrecover.c index 044e1ce2e5..a09ea0611a 100644 --- a/usr/src/cmd/vi/port/exrecover.c +++ b/usr/src/cmd/vi/port/exrecover.c @@ -18,10 +18,10 @@ * * CDDL HEADER END */ + /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. -*/ + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ @@ -707,7 +707,7 @@ rputfile(void) #ifdef DEBUG fprintf(stderr,"GETTING A LINE \n"); #endif - getline(*a1++); + getaline(*a1++); lp = linebuf; #ifdef DEBUG fprintf(stderr,"LINE:%s\n",linebuf); @@ -755,7 +755,7 @@ clrstats(void) #define WRITE 1 void -getline(line tl) +getaline(line tl) { unsigned char *bp, *lp; int nl; diff --git a/usr/src/cmd/ypcmd/mknetid/getname.c b/usr/src/cmd/ypcmd/mknetid/getname.c index 5f60fd801e..36d3198939 100644 --- a/usr/src/cmd/ypcmd/mknetid/getname.c +++ b/usr/src/cmd/ypcmd/mknetid/getname.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,14 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* SMI4.1 1.3 */ - #include <stdio.h> #include <string.h> @@ -35,12 +31,12 @@ #define isignore(c) (strchr(ignore, c) != NULL) /* - * getline() + * getaline() * Read a line from a file. * What's returned is a cookie to be passed to getname */ char ** -getline(line, maxlinelen, f, lcount, com) +getaline(line, maxlinelen, f, lcount, com) char *line; int maxlinelen; FILE *f; diff --git a/usr/src/cmd/ypcmd/mknetid/mknetid.c b/usr/src/cmd/ypcmd/mknetid/mknetid.c index 23434ccbfa..85a1661b81 100644 --- a/usr/src/cmd/ypcmd/mknetid/mknetid.c +++ b/usr/src/cmd/ypcmd/mknetid/mknetid.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,14 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* SMI4.1 1.5 */ - /* * Network name to unix credential database generator. * Uses /etc/passwd, /etc/group, /etc/hosts and /etc/netid to @@ -57,7 +53,7 @@ #define NUMGIDS (NGROUPS_MAX + 1) /* group-access-list + gid */ -extern char **getline(); +extern char **getaline(); extern char *malloc(); extern char *strcpy(); @@ -172,7 +168,7 @@ domapfile(mapfile, mf) curfile = mapfile; curline = 0; - while (lp = getline(line, sizeof (line), mf, &curline, "#")) { + while (lp = getaline(line, sizeof (line), mf, &curline, "#")) { check_getname(lp, name, WHITE, WHITE, "#"); if (wasprinted(name)) { multdef(name); @@ -219,7 +215,7 @@ dogrpfile(grpfile, gf) curfile = grpfile; curline = 0; - while (lp = getline(line, sizeof (line), gf, &curline, "")) { + while (lp = getaline(line, sizeof (line), gf, &curline, "")) { check_getname(lp, name, WHITE, COLON, ""); if (name[0] == '+') { continue; @@ -252,7 +248,7 @@ dopwdfile(pwdfile, pf) curfile = pwdfile; curline = 0; - while (lp = getline(line, sizeof (line), pf, &curline, "")) { + while (lp = getaline(line, sizeof (line), pf, &curline, "")) { check_getname(lp, user, WHITE, COLON, ""); /* username */ if (user[0] == '-' || user[0] == '+') { continue; /* NIS entry */ @@ -291,7 +287,7 @@ dohostfile(hostfile, hf) curfile = hostfile; curline = 0; - while (lp = getline(line, sizeof (line), hf, &curline, "#")) { + while (lp = getaline(line, sizeof (line), hf, &curline, "#")) { check_getname(lp, name, WHITE, WHITE, "#"); if (getname(name, MAXNAMELEN, WHITE, WHITE, lp, "#") != 1) { continue; diff --git a/usr/src/cmd/ypcmd/revnetgroup/revnetgroup.c b/usr/src/cmd/ypcmd/revnetgroup/revnetgroup.c index 41f161e913..f19a33cd4d 100644 --- a/usr/src/cmd/ypcmd/revnetgroup/revnetgroup.c +++ b/usr/src/cmd/ypcmd/revnetgroup/revnetgroup.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,16 +18,13 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1994, by Sun Microsystems, Inc. - * All rights reserved. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ - + /* * For SUNWnskit - version 1.1 - * - * Based on: - * #pragma ident "%Z%%M% %I% %E% SMI" (SMI4.1 1.6) */ #include <stdlib.h> @@ -277,7 +273,7 @@ loadtable(FILE *nf) char *group; char *line; - while (getline(buf, MAXGROUPLEN, nf)) { + while (getaline(buf, MAXGROUPLEN, nf)) { for (p = buf; *p && isspace((int)*p); p++) ; /* skip leading blanks */ for (; *p && *p != '#' && *p != ' ' && *p != '\t'; p++) diff --git a/usr/src/cmd/ypcmd/revnetgroup/util.c b/usr/src/cmd/ypcmd/revnetgroup/util.c index 511bf34b5b..cde75016b5 100644 --- a/usr/src/cmd/ypcmd/revnetgroup/util.c +++ b/usr/src/cmd/ypcmd/revnetgroup/util.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright (c) 1996-2001 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SMI4.1 1.4 */ - #include <stdio.h> #include <string.h> #include "util.h" @@ -38,7 +35,7 @@ * of a line */ char * -getline(line, maxlen, fp) +getaline(line, maxlen, fp) char *line; int maxlen; FILE *fp; diff --git a/usr/src/cmd/ypcmd/revnetgroup/util.h b/usr/src/cmd/ypcmd/revnetgroup/util.h index e83ba1ed0f..3a6db7ffd7 100644 --- a/usr/src/cmd/ypcmd/revnetgroup/util.h +++ b/usr/src/cmd/ypcmd/revnetgroup/util.h @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,17 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 1995 Sun Microsystems Inc. - * All rights reserved. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ - #ifndef __UTIL_H #define __UTIL_H -#pragma ident "%Z%%M% %I% %E% SMI" /* SMI4.1 1.5 */ - #ifdef __cplusplus extern "C" { #endif @@ -57,7 +53,7 @@ extern char *malloc(); */ extern char *alloca(); -char *getline(); +char *getaline(); void fatal(); #ifdef __cplusplus diff --git a/usr/src/common/net/wanboot/boot_http.c b/usr/src/common/net/wanboot/boot_http.c index 9f0fa7d158..3909d08714 100644 --- a/usr/src/common/net/wanboot/boot_http.c +++ b/usr/src/common/net/wanboot/boot_http.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <errno.h> #include <sys/types.h> #include <sys/socket.h> @@ -180,7 +177,7 @@ static int free_ctx_ssl(http_conn_t *); static int get_chunk_header(http_conn_t *); static int init_bread(http_conn_t *); static int get_msgcnt(http_conn_t *, ssize_t *); -static int getline(http_conn_t *, char *, int, boolean_t); +static int getaline(http_conn_t *, char *, int, boolean_t); static int getbytes(http_conn_t *, char *, int); static int http_srv_send(http_conn_t *, const void *, size_t); static int http_srv_recv(http_conn_t *, void *, size_t); @@ -945,7 +942,7 @@ http_process_headers(http_handle_t handle, http_respinfo_t **resp) * check the response status line, expecting * HTTP/1.1 200 OK */ - i = getline(c_id, line, sizeof (line), B_FALSE); + i = getaline(c_id, line, sizeof (line), B_FALSE); if (i == 0) { if (resp != NULL) { *resp = lresp; @@ -1150,7 +1147,7 @@ http_process_part_headers(http_handle_t handle, http_respinfo_t **resp) /* Look for the boundary line. */ count = 0; - while ((i = getline(c_id, line, sizeof (line), B_TRUE)) == 0 && + while ((i = getaline(c_id, line, sizeof (line), B_TRUE)) == 0 && count < FAILSAFE) count ++; if (i < 0 || count > limit) { @@ -1662,7 +1659,7 @@ http_req(http_handle_t handle, const char *abs_path, http_req_t type, * Allow for concat(basic_auth_userid ":" basic_auth_password) */ authlen = strlen(c_id->basic_auth_userid) + 2 + - strlen(c_id->basic_auth_password); + strlen(c_id->basic_auth_password); if ((authstr = malloc(authlen + 1)) == NULL) { free(request); SET_ERR(c_id, ERRSRC_LIBHTTP, EHTTP_NOMEM); @@ -1680,7 +1677,7 @@ http_req(http_handle_t handle, const char *abs_path, http_req_t type, } (void) EVP_EncodeBlock((unsigned char *)authencstr, - (unsigned char *)authstr, authlen); + (unsigned char *)authstr, authlen); /* * Finally do concat(Authorization: Basic " authencstr "\r\n") @@ -2186,7 +2183,7 @@ check_cert_chain(http_conn_t *c_id, char *host) if ((verify_err = SSL_get_verify_result(c_id->ssl)) != X509_V_OK) { SET_ERR(c_id, ERRSRC_VERIFERR, verify_err); libbootlog(BOOTLOG_CRIT, - "check_cert_chain: Certificate doesn't verify"); + "check_cert_chain: Certificate doesn't verify"); return (-1); } @@ -2207,7 +2204,7 @@ check_cert_chain(http_conn_t *c_id, char *host) return (-1); } (void) X509_NAME_get_text_by_NID(X509_get_subject_name(peer), - NID_commonName, peer_CN, 256); + NID_commonName, peer_CN, 256); if (verbosemode) libbootlog(BOOTLOG_VERBOSE, @@ -2283,7 +2280,7 @@ print_ciphers(SSL *ssl) * c_id->resphdr. * * Note that I/O errors are put into the error stack by http_srv_recv(), - * which is called by getline(). + * which is called by getaline(). */ static int read_headerlines(http_conn_t *c_id, boolean_t bread) @@ -2298,7 +2295,7 @@ read_headerlines(http_conn_t *c_id, boolean_t bread) /* process headers, stop when we get to an empty line */ cur = 0; next = 0; - while ((n = getline(c_id, line, sizeof (line), bread)) > 0) { + while ((n = getaline(c_id, line, sizeof (line), bread)) > 0) { if (verbosemode) libbootlog(BOOTLOG_VERBOSE, @@ -2430,11 +2427,11 @@ get_chunk_header(http_conn_t *c_id) ok = 1; c_id->is_firstchunk = B_FALSE; } else { - ok = ((i = getline(c_id, line, sizeof (line), B_FALSE)) == 0); + ok = ((i = getaline(c_id, line, sizeof (line), B_FALSE)) == 0); } if (ok) - i = getline(c_id, line, sizeof (line), B_FALSE); + i = getaline(c_id, line, sizeof (line), B_FALSE); if (!ok || i < 0) { /* * If I/O error, the Cause was already put into @@ -2619,7 +2616,7 @@ get_msgcnt(http_conn_t *c_id, ssize_t *msgcnt) } /* - * getline - Get lines of data from the HTTP response, up to 'len' bytes. + * getaline - Get lines of data from the HTTP response, up to 'len' bytes. * NOTE: the line will not end with a NULL if all 'len' bytes * were read. * @@ -2642,7 +2639,7 @@ get_msgcnt(http_conn_t *c_id, ssize_t *msgcnt) * Note that I/O errors are put into the error stack by http_srv_recv().1 */ static int -getline(http_conn_t *c_id, char *line, int len, boolean_t bread) +getaline(http_conn_t *c_id, char *line, int len, boolean_t bread) { int i = 0; ssize_t msgcnt = 0; @@ -2724,7 +2721,7 @@ getline(http_conn_t *c_id, char *line, int len, boolean_t bread) * * Note that all reads performed here assume that a message body is being * read. If this changes in the future, then the logic should more closely - * resemble getline(). + * resemble getaline(). * * Note that I/O errors are put into the error stack by http_srv_recv(). */ @@ -2758,7 +2755,7 @@ getbytes(http_conn_t *c_id, char *line, int len) if (c_id->inbuf.n != c_id->inbuf.i) { nbytes = (int)MIN(cnt, c_id->inbuf.n - c_id->inbuf.i); (void) memcpy(line, &c_id->inbuf.buf[c_id->inbuf.i], - nbytes); + nbytes); c_id->inbuf.i += nbytes; } else { nbytes = http_srv_recv(c_id, line, cnt); diff --git a/usr/src/head/poll.h b/usr/src/head/poll.h index cc3094be98..900bca5368 100644 --- a/usr/src/head/poll.h +++ b/usr/src/head/poll.h @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,19 +18,49 @@ * * CDDL HEADER END */ + +/* + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + */ + /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ - #ifndef _POLL_H #define _POLL_H -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ - /* * Poll system call interface definitions. */ +#include <sys/feature_tests.h> #include <sys/poll.h> +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +#include <time.h> +#include <signal.h> +#endif /* defined(__EXTENSIONS__) ... */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) + +#if defined(__STDC__) + +extern int ppoll(struct pollfd *_RESTRICT_KYWD, nfds_t, + const struct timespec *_RESTRICT_KYWD, const sigset_t *_RESTRICT_KYWD); + +#else /* __STDC__ */ + +extern int ppoll(); + +#endif /* __STDC__ */ + +#endif /* defined(__EXTENSIONS__) ... */ + +#ifdef __cplusplus +} +#endif #endif /* _POLL_H */ diff --git a/usr/src/head/stdio.h b/usr/src/head/stdio.h index 25c9fc3a43..d4178a4c0e 100644 --- a/usr/src/head/stdio.h +++ b/usr/src/head/stdio.h @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ @@ -261,6 +260,15 @@ extern FILE *_lastbuf; #endif /* !__PRAGMA_REDEFINE_EXTNAME */ #endif /* _LP64 && _LARGEFILE64_SOURCE */ +#ifndef _SSIZE_T +#define _SSIZE_T +#if defined(_LP64) || defined(_I32LPx) +typedef long ssize_t; /* size of something in bytes or -1 */ +#else +typedef int ssize_t; /* (historical version) */ +#endif +#endif /* !_SSIZE_T */ + #if defined(__STDC__) #if defined(__EXTENSIONS__) || \ @@ -271,6 +279,7 @@ extern char *tmpnam_r(char *); #if defined(__EXTENSIONS__) || \ (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) +extern int fcloseall(void); extern void setbuffer(FILE *, char *, size_t); extern int setlinebuf(FILE *); /* PRINTFLIKE2 */ @@ -279,6 +288,15 @@ extern int asprintf(char **, const char *, ...); extern int vasprintf(char **, const char *, __va_list); #endif +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern ssize_t getdelim(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD, + int, FILE *_RESTRICT_KYWD); +extern ssize_t getline(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD, + FILE *_RESTRICT_KYWD); +#endif /* __EXTENSIONS__ ... */ + /* * The following are known to POSIX and XOPEN, but not to ANSI-C. */ @@ -333,7 +351,7 @@ extern int putw(int, FILE *); /* * The following are defined as part of the Large File Summit interfaces. */ -#if defined(_LARGEFILE_SOURCE) || defined(_XPG5) +#if defined(_LARGEFILE_SOURCE) || defined(_XPG5) extern int fseeko(FILE *, off_t, int); extern off_t ftello(FILE *); #endif @@ -342,7 +360,7 @@ extern off_t ftello(FILE *); * The following are defined as part of the transitional Large File Summit * interfaces. */ -#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ !defined(__PRAGMA_REDEFINE_EXTNAME)) extern FILE *fopen64(const char *, const char *); extern FILE *freopen64(const char *, const char *, FILE *); @@ -367,19 +385,26 @@ extern char *tmpnam_r(); #endif #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +extern int fcloseall(); extern void setbuffer(); extern int setlinebuf(); extern int asprintf(); extern int vasprintf(); #endif +#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) + /* || defined(_XPG7) */ +extern ssize_t getdelim(); +extern ssize_t getline(); +#endif /* __EXTENSIONS__ ... */ + #if defined(__EXTENSIONS__) || defined(__XOPEN_OR_POSIX) extern FILE *fdopen(); extern char *ctermid(); extern int fileno(); #endif /* defined(__EXTENSIONS__) || defined(__XOPEN_OR_POSIX) */ -#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ +#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ (_POSIX_C_SOURCE - 0 >= 199506L) extern void flockfile(); extern int ftrylockfile(); @@ -410,12 +435,12 @@ extern int putw(); #endif /* defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE) */ -#if defined(_LARGEFILE_SOURCE) || defined(_XPG5) +#if defined(_LARGEFILE_SOURCE) || defined(_XPG5) extern int fseeko(); extern off_t ftello(); #endif -#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ !defined(__PRAGMA_REDEFINE_EXTNAME)) extern FILE *fopen64(); extern FILE *freopen64(); @@ -430,7 +455,7 @@ extern off64_t ftello64(); #if !defined(__lint) -#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ +#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ (_POSIX_C_SOURCE - 0 >= 199506L) #ifndef _LP64 #ifdef __STDC__ diff --git a/usr/src/head/stdlib.h b/usr/src/head/stdlib.h index ba1343433d..66a4bb444a 100644 --- a/usr/src/head/stdlib.h +++ b/usr/src/head/stdlib.h @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ @@ -212,6 +211,8 @@ extern int unsetenv(const char *); #if defined(__EXTENSIONS__) || \ (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) +extern char *canonicalize_file_name(const char *); +extern int clearenv(void); extern void closefrom(int); extern int daemon(int, int); extern int dup2(int, int); @@ -232,6 +233,8 @@ extern int isatty(int); extern void *memalign(size_t, size_t); extern char *ttyname(int); extern char *mkdtemp(char *); +extern const char *getprogname(void); +extern void setprogname(const char *); #if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) extern char *lltostr(long long, char *); @@ -315,6 +318,8 @@ extern int unsetenv(); #endif #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +extern char *canonicalize_file_name(); +extern int clearenv(); extern void closefrom(); extern int daemon(); extern int dup2(); @@ -335,6 +340,8 @@ extern int isatty(); extern void *memalign(); extern char *ttyname(); extern char *mkdtemp(); +extern char *getprogname(); +extern void setprogname(); #if defined(_LONGLONG_TYPE) extern char *lltostr(); diff --git a/usr/src/head/string.h b/usr/src/head/string.h index a0f380c32d..f786eb72d8 100644 --- a/usr/src/head/string.h +++ b/usr/src/head/string.h @@ -18,15 +18,14 @@ * * CDDL HEADER END */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + #ifndef _STRING_H #define _STRING_H @@ -89,16 +88,33 @@ extern void *memccpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD, #if defined(__EXTENSIONS__) || \ (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, size_t); +extern char *stpcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD); +extern char *stpncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t); +extern char *strndup(const char *, size_t); +extern size_t strnlen(const char *, size_t); +extern char *strsignal(int); +#endif + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) extern int uucopy(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t); extern int uucopystr(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t); -extern char *strsignal(int); -extern size_t strnlen(const char *, size_t); extern int ffs(int); -extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, size_t); +extern int ffsl(long); +extern int ffsll(long long); +extern int fls(int); +extern int flsl(long); +extern int flsll(long long); +extern void *memmem(const void *, size_t, const void *, size_t); +extern char *strcasestr(const char *, const char *); +extern char *strnstr(const char *, const char *, size_t); extern size_t strlcpy(char *, const char *, size_t); extern size_t strlcat(char *, const char *, size_t); extern char *strsep(char **stringp, const char *delim); +extern char *strchrnul(const char *, int); #endif /* defined(__EXTENSIONS__)... */ #if defined(__EXTENSIONS__) || \ @@ -107,6 +123,60 @@ extern char *strsep(char **stringp, const char *delim); extern char *strdup(const char *); #endif +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) +#if defined(__GNUC__) + +/* + * gcc provides this inlining facility but Studio C does not. + * We should use it exclusively once Studio C also provides it. + */ +extern void *__builtin_alloca(size_t); + +#define strdupa(s) \ + (__extension__( \ + { \ + char *__str = (char *)(s); \ + strcpy((char *)__builtin_alloca(strlen(__str) + 1), __str); \ + })) + +#define strndupa(s, n) \ + (__extension__( \ + { \ + char *__str = (char *)(s); \ + size_t __len = strnlen(__str, (n)); \ + (__str = strncpy((char *)__builtin_alloca(__len + 1), \ + __str, __len), \ + __str[__len] = '\0', __str); \ + })) + +#else /* __GNUC__ */ + +#if defined(unix) /* excludes c99 */ +/* + * Studio C currently can't do the gcc-style inlining, + * so we use thread-local storage instead. + */ +extern void *__builtin_alloca(size_t); +extern __thread char *__strdupa_str; +extern __thread size_t __strdupa_len; + +#define strdupa(s) \ + (__strdupa_str = (char *)(s), \ + strcpy((char *)__builtin_alloca(strlen(__strdupa_str) + 1), \ + __strdupa_str)) + +#define strndupa(s, n) \ + (__strdupa_str = (char *)(s), \ + __strdupa_len = strnlen(__strdupa_str, (n)), \ + __strdupa_str = strncpy((char *)__builtin_alloca(__strdupa_len + 1), \ + __strdupa_str, __strdupa_len), \ + __strdupa_str[__strdupa_len] = '\0', __strdupa_str) +#endif /* unix */ + +#endif /* __GNUC__ */ +#endif /* __EXTENSIONS__ ... */ + #else /* __STDC__ */ #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \ @@ -124,17 +194,34 @@ extern char *strtok_r(); extern void *memccpy(); #endif -#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern int strcasecmp(); +extern int strncasecmp(); +extern char *stpcpy(); +extern char *stpncpy(); +extern char *strndup(); +extern size_t strnlen(); +extern char *strsignal(); +#endif + +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) extern int uucopy(); extern int uucopystr(); -extern char *strsignal(); -extern size_t strnlen(); extern int ffs(); -extern int strcasecmp(); -extern int strncasecmp(); +extern int ffsl(); +extern int ffsll(); +extern int fls(); +extern int flsl(); +extern int flsll(); +extern char *strcasestr(); +extern char *strnstr(); extern size_t strlcpy(); extern size_t strlcat(); extern char *strsep(); +extern char *strchrnul(); #endif /* defined(__EXTENSIONS__) ... */ #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) diff --git a/usr/src/head/unistd.h b/usr/src/head/unistd.h index 153773ca60..2ea8c42c15 100644 --- a/usr/src/head/unistd.h +++ b/usr/src/head/unistd.h @@ -162,11 +162,11 @@ extern "C" { * which need mutexes to support priority inheritance/ceiling. */ #if defined(_XPG6) -#define _POSIX_THREAD_PRIO_INHERIT 200112L -#define _POSIX_THREAD_PRIO_PROTECT 200112L +#define _POSIX_THREAD_PRIO_INHERIT 200112L +#define _POSIX_THREAD_PRIO_PROTECT 200112L #else -#define _POSIX_THREAD_PRIO_INHERIT 1 -#define _POSIX_THREAD_PRIO_PROTECT 1 +#define _POSIX_THREAD_PRIO_INHERIT 1 +#define _POSIX_THREAD_PRIO_PROTECT 1 #endif #ifndef _POSIX_VDISABLE @@ -558,6 +558,10 @@ extern int renameat(int, const char *, int, const char *); extern int symlinkat(const char *, int, const char *); extern int unlinkat(int, const char *, int); #endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int get_nprocs(void); +extern int get_nprocs_conf(void); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ /* transitional large file interface versions */ #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ @@ -855,6 +859,10 @@ extern int renameat(); extern int symlinkat(); extern int unlinkat(); #endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ +#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) +extern int get_nprocs(); +extern int get_nprocs_conf(); +#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ /* transitional large file interface versions */ #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ diff --git a/usr/src/head/wchar.h b/usr/src/head/wchar.h index 41a36de3ac..781b57afb8 100644 --- a/usr/src/head/wchar.h +++ b/usr/src/head/wchar.h @@ -20,17 +20,13 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _WCHAR_H #define _WCHAR_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/feature_tests.h> - #include <iso/wchar_iso.h> #include <iso/wchar_c99.h> @@ -146,6 +142,18 @@ extern int wcwidth(wchar_t); extern wctype_t wctype(const char *); #endif /* !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE)... */ +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern wchar_t *wcsdup(const wchar_t *); +extern size_t wcsnlen(const wchar_t *, size_t); +extern wchar_t *wcpcpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD); +extern wchar_t *wcpncpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, + size_t); +extern int wcscasecmp(const wchar_t *, const wchar_t *); +extern int wcsncasecmp(const wchar_t *, const wchar_t *, size_t); +#endif + #else /* __STDC__ */ #if !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) @@ -169,6 +177,17 @@ extern int wcwidth(); extern wctype_t wctype(); #endif /* !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE)... */ +#if defined(__EXTENSIONS__) || \ + (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) + /* || defined(_XPG7) */ +extern wchar_t *wcsdup(); +extern size_t wcsnlen(); +extern wchar_t *wcpcpy(); +extern wchar_t *wcpncpy(); +extern int wcscasecmp(); +extern int wcsncasecmp(); +#endif + #endif /* __STDC__ */ #ifdef __cplusplus diff --git a/usr/src/lib/fm/libfmd_msg/common/fmd_msg.c b/usr/src/lib/fm/libfmd_msg/common/fmd_msg.c index 86cf4ddf75..5735942fae 100644 --- a/usr/src/lib/fm/libfmd_msg/common/fmd_msg.c +++ b/usr/src/lib/fm/libfmd_msg/common/fmd_msg.c @@ -1380,9 +1380,7 @@ fmd_msg_getitem(fmd_msg_hdl_t *h, if (locale != NULL && strcmp(h->fmh_locale, locale) == 0) locale = NULL; /* simplify later tests */ - dict = alloca((size_t)(p - code) + 1); - (void) strncpy(dict, code, (size_t)(p - code)); - dict[(size_t)(p - code)] = '\0'; + dict = strndupa(code, p - code); fmd_msg_lock(); @@ -1392,8 +1390,7 @@ fmd_msg_getitem(fmd_msg_hdl_t *h, */ if (h->fmh_binding != NULL) { p = bindtextdomain(dict, NULL); - old_b = alloca(strlen(p) + 1); - (void) strcpy(old_b, p); + old_b = strdupa(p); (void) bindtextdomain(dict, h->fmh_binding); } @@ -1412,8 +1409,7 @@ fmd_msg_getitem(fmd_msg_hdl_t *h, * the text for a different locale, switch locales now under the lock. */ p = setlocale(LC_ALL, NULL); - old_c = alloca(strlen(p) + 1); - (void) strcpy(old_c, p); + old_c = strdupa(p); if (locale != NULL) (void) setlocale(LC_ALL, locale); @@ -1559,9 +1555,7 @@ fmd_msg_gettext(fmd_msg_hdl_t *h, if (locale != NULL && strcmp(h->fmh_locale, locale) == 0) locale = NULL; /* simplify later tests */ - dict = alloca((size_t)(p - code) + 1); - (void) strncpy(dict, code, (size_t)(p - code)); - dict[(size_t)(p - code)] = '\0'; + dict = strndupa(code, p - code); fmd_msg_lock(); @@ -1571,8 +1565,7 @@ fmd_msg_gettext(fmd_msg_hdl_t *h, */ if (h->fmh_binding != NULL) { p = bindtextdomain(dict, NULL); - old_b = alloca(strlen(p) + 1); - (void) strcpy(old_b, p); + old_b = strdupa(p); (void) bindtextdomain(dict, h->fmh_binding); } @@ -1591,8 +1584,7 @@ fmd_msg_gettext(fmd_msg_hdl_t *h, * the text for a different locale, switch locales now under the lock. */ p = setlocale(LC_ALL, NULL); - old_c = alloca(strlen(p) + 1); - (void) strcpy(old_c, p); + old_c = strdupa(p); if (locale != NULL) (void) setlocale(LC_ALL, locale); diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile index 8ece7c4add..d950c2b819 100644 --- a/usr/src/lib/libc/amd64/Makefile +++ b/usr/src/lib/libc/amd64/Makefile @@ -89,7 +89,6 @@ COMOBJS= \ bcopy.o \ bsearch.o \ bzero.o \ - ffs.o \ qsort.o \ strtol.o \ strtoul.o \ @@ -325,6 +324,8 @@ PORTGEN= \ a64l.o \ abort.o \ addsev.o \ + ascii_strcasecmp.o \ + ascii_strncasecmp.o \ assert.o \ atof.o \ atoi.o \ @@ -367,6 +368,8 @@ PORTGEN= \ fattach.o \ fdetach.o \ fdopendir.o \ + ffs.o \ + fls.o \ fmtmsg.o \ ftime.o \ ftok.o \ @@ -388,6 +391,7 @@ PORTGEN= \ getlogin.o \ getmntent.o \ getnetgrent.o \ + get_nprocs.o \ getopt.o \ getopt_long.o \ getpagesize.o \ @@ -435,6 +439,7 @@ PORTGEN= \ madvise.o \ malloc.o \ memalign.o \ + memmem.o \ mkdev.o \ mkdtemp.o \ mkfifo.o \ @@ -498,18 +503,20 @@ PORTGEN= \ sigsetops.o \ ssignal.o \ stack.o \ + stpcpy.o \ + stpncpy.o \ str2sig.o \ strcase_charmap.o \ - strcasecmp.o \ strcat.o \ strchr.o \ + strchrnul.o \ strcspn.o \ strdup.o \ strerror.o \ strlcat.o \ strlcpy.o \ - strncasecmp.o \ strncat.o \ + strndup.o \ strpbrk.o \ strrchr.o \ strsep.o \ @@ -539,6 +546,7 @@ PORTGEN= \ tfind.o \ time_data.o \ time_gdata.o \ + tls_data.o \ truncate.o \ tsdalloc.o \ tsearch.o \ @@ -613,6 +621,7 @@ PORTSTDIO= \ fwrite.o \ getc.o \ getchar.o \ + getline.o \ getpass.o \ gets.o \ getw.o \ @@ -645,7 +654,11 @@ PORTI18N= \ getwchar.o \ putwchar.o \ putws.o \ + strcasecmp.o \ + strcasestr.o \ + strncasecmp.o \ strtows.o \ + wcsnlen.o \ wcsstr.o \ wcstoimax.o \ wcstol.o \ @@ -940,8 +953,10 @@ BUILD.s= $(AS) $(ASFLAGS) $< -o $@ C99MODE= $(C99_ENABLE) # libc method of building an archive +# The "$(GREP) -v ' L '" part is necessary only until +# lorder is fixed to ignore thread-local variables. BUILD.AR= $(RM) $@ ; \ - $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%)| $(TSORT)` + $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)` # extra files for the clean target CLEANFILES= \ @@ -998,6 +1013,7 @@ TIL= \ atfork.o \ cancel.o \ door_calls.o \ + err.o \ errno.o \ lwp.o \ ma.o \ diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com index 55a006e315..570925e853 100644 --- a/usr/src/lib/libc/i386/Makefile.com +++ b/usr/src/lib/libc/i386/Makefile.com @@ -90,7 +90,6 @@ COMOBJS= \ bcopy.o \ bsearch.o \ bzero.o \ - ffs.o \ qsort.o \ strtol.o \ strtoul.o \ @@ -355,6 +354,8 @@ PORTGEN= \ a64l.o \ abort.o \ addsev.o \ + ascii_strcasecmp.o \ + ascii_strncasecmp.o \ assert.o \ atof.o \ atoi.o \ @@ -398,6 +399,8 @@ PORTGEN= \ fattach.o \ fdetach.o \ fdopendir.o \ + ffs.o \ + fls.o \ fmtmsg.o \ ftime.o \ ftok.o \ @@ -419,6 +422,7 @@ PORTGEN= \ getlogin.o \ getmntent.o \ getnetgrent.o \ + get_nprocs.o \ getopt.o \ getopt_long.o \ getpagesize.o \ @@ -466,6 +470,7 @@ PORTGEN= \ madvise.o \ malloc.o \ memalign.o \ + memmem.o \ mkdev.o \ mkdtemp.o \ mkfifo.o \ @@ -530,15 +535,17 @@ PORTGEN= \ sigsetops.o \ ssignal.o \ stack.o \ + stpcpy.o \ + stpncpy.o \ str2sig.o \ strcase_charmap.o \ - strcasecmp.o \ + strchrnul.o \ strcspn.o \ strdup.o \ strerror.o \ strlcat.o \ strlcpy.o \ - strncasecmp.o \ + strndup.o \ strpbrk.o \ strsep.o \ strsignal.o \ @@ -567,6 +574,7 @@ PORTGEN= \ tfind.o \ time_data.o \ time_gdata.o \ + tls_data.o \ truncate.o \ tsdalloc.o \ tsearch.o \ @@ -655,6 +663,7 @@ PORTSTDIO= \ fwrite.o \ getc.o \ getchar.o \ + getline.o \ getpass.o \ gets.o \ getw.o \ @@ -687,7 +696,11 @@ PORTI18N= \ getwchar.o \ putwchar.o \ putws.o \ + strcasecmp.o \ + strcasestr.o \ + strncasecmp.o \ strtows.o \ + wcsnlen.o \ wcsstr.o \ wcstoimax.o \ wcstol.o \ @@ -995,8 +1008,10 @@ BUILD.s= $(AS) $(ASFLAGS) $< -o $@ C99MODE= $(C99_ENABLE) # libc method of building an archive +# The "$(GREP) -v ' L '" part is necessary only until +# lorder is fixed to ignore thread-local variables. BUILD.AR= $(RM) $@ ; \ - $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%)| $(TSORT)` + $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)` # extra files for the clean target CLEANFILES= \ @@ -1056,6 +1071,7 @@ TIL= \ atfork.o \ cancel.o \ door_calls.o \ + err.o \ errno.o \ lwp.o \ ma.o \ diff --git a/usr/src/lib/libc/inc/thr_uberdata.h b/usr/src/lib/libc/inc/thr_uberdata.h index ca53ccf701..c7ae35b0da 100644 --- a/usr/src/lib/libc/inc/thr_uberdata.h +++ b/usr/src/lib/libc/inc/thr_uberdata.h @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _THR_UBERDATA_H @@ -905,6 +905,7 @@ typedef struct uberdata { atfork_t *atforklist; /* circular Q for fork handlers */ robust_t **robustlocks; /* table of registered robust locks */ robust_t *robustlist; /* list of registered robust locks */ + char *progname; /* the basename of the program, from argv[0] */ struct uberdata **tdb_bootstrap; tdb_t tdb; /* thread debug interfaces (for libc_db) */ } uberdata_t; @@ -1348,6 +1349,7 @@ extern void do_sigcancel(void); extern void setup_cancelsig(int); extern void init_sigev_thread(void); extern void init_aio(void); +extern void init_progname(void); extern void _cancelon(void); extern void _canceloff(void); extern void _canceloff_nocancel(void); diff --git a/usr/src/lib/libc/port/gen/strcasecmp.c b/usr/src/lib/libc/port/gen/ascii_strcasecmp.c index c8e7ba62ac..b04f562c65 100644 --- a/usr/src/lib/libc/port/gen/strcasecmp.c +++ b/usr/src/lib/libc/port/gen/ascii_strcasecmp.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -32,8 +31,6 @@ * under license from the Regents of the University of California. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include <sys/types.h> #include <strings.h> @@ -47,7 +44,7 @@ extern const char strcase_charmap[]; int -strcasecmp(const char *s1, const char *s2) +ascii_strcasecmp(const char *s1, const char *s2) { const unsigned char *cm = (const unsigned char *)strcase_charmap; const unsigned char *us1 = (const unsigned char *)s1; diff --git a/usr/src/lib/libc/port/gen/strncasecmp.c b/usr/src/lib/libc/port/gen/ascii_strncasecmp.c index d06b7ac9c4..33a8baf173 100644 --- a/usr/src/lib/libc/port/gen/strncasecmp.c +++ b/usr/src/lib/libc/port/gen/ascii_strncasecmp.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -32,8 +31,6 @@ * under license from the Regents of the University of California. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include <sys/types.h> #include <strings.h> @@ -47,7 +44,7 @@ extern const char strcase_charmap[]; int -strncasecmp(const char *s1, const char *s2, size_t n) +ascii_strncasecmp(const char *s1, const char *s2, size_t n) { const unsigned char *cm = (const unsigned char *)strcase_charmap; const unsigned char *us1 = (const unsigned char *)s1; diff --git a/usr/src/lib/libc/port/gen/err.c b/usr/src/lib/libc/port/gen/err.c index 016d5e0b89..7c3695e785 100644 --- a/usr/src/lib/libc/port/gen/err.c +++ b/usr/src/lib/libc/port/gen/err.c @@ -20,15 +20,13 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include "file64.h" #include "mtlib.h" +#include "thr_uberdata.h" #include <sys/types.h> #include <err.h> #include <stdio.h> @@ -36,11 +34,51 @@ #include <stdarg.h> #include <string.h> #include <errno.h> +#include <dlfcn.h> #include "stdiom.h" /* Function exit/warning functions and global variables. */ -static const char *progname; +const char *__progname; /* GNU/Linux/BSD compatibility */ + +#define PROGNAMESIZE 128 /* buffer size for __progname */ + +const char * +getprogname(void) +{ + return (__progname); +} + +void +setprogname(const char *argv0) +{ + uberdata_t *udp = curthread->ul_uberdata; + const char *progname; + + if ((progname = strrchr(argv0, '/')) == NULL) + progname = argv0; + else + progname++; + + if (udp->progname == NULL) + udp->progname = lmalloc(PROGNAMESIZE); + (void) strlcpy(udp->progname, progname, PROGNAMESIZE); + __progname = udp->progname; +} + +/* called only from libc_init() */ +void +init_progname(void) +{ + Dl_argsinfo_t args; + const char *argv0; + + if (dlinfo(RTLD_SELF, RTLD_DI_ARGSINFO, &args) < 0) + argv0 = "UNKNOWN"; + else + argv0 = args.dla_argv[0]; + setprogname(argv0); +} /* * warncore() is the workhorse of these functions. Everything else has @@ -49,22 +87,12 @@ static const char *progname; static rmutex_t * warncore(FILE *fp, const char *fmt, va_list args) { - const char *execname; rmutex_t *lk; FLOCKFILE(lk, fp); - if (progname == NULL) { - execname = getexecname(); - if ((execname != NULL) && - ((progname = strrchr(execname, '/')) != NULL)) - progname++; - else - progname = execname; - } - - if (progname != NULL) - (void) fprintf(fp, "%s: ", progname); + if (__progname != NULL) + (void) fprintf(fp, "%s: ", __progname); if (fmt != NULL) { (void) vfprintf(fp, fmt, args); diff --git a/usr/src/lib/libc/port/gen/ffs.c b/usr/src/lib/libc/port/gen/ffs.c new file mode 100644 index 0000000000..ff787de122 --- /dev/null +++ b/usr/src/lib/libc/port/gen/ffs.c @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <string.h> +#include <strings.h> +#include <sys/types.h> + +static int +ffs_impl(uint64_t bits) +{ + int i = 1; + uint32_t bits32; + + if (bits == 0) + return (0); + + if ((bits32 = (uint32_t)bits) == 0) { + bits32 = (uint32_t)(bits >> 32); + i += 32; + } + + if ((bits32 & 0xffff) == 0) { + bits32 >>= 16; + i += 16; + } + if ((bits32 & 0xff) == 0) { + bits32 >>= 8; + i += 8; + } + if ((bits32 & 0xf) == 0) { + bits32 >>= 4; + i += 4; + } + if ((bits32 & 0x3) == 0) { + bits32 >>= 2; + i += 2; + } + if ((bits32 & 0x1) == 0) + i += 1; + + return (i); +} + +int +ffs(int bits) +{ + return (ffs_impl((uint64_t)(uint_t)bits)); +} + +int +ffsl(long bits) +{ + return (ffs_impl((uint64_t)(ulong_t)bits)); +} + +int +ffsll(long long bits) +{ + return (ffs_impl((uint64_t)(u_longlong_t)bits)); +} diff --git a/usr/src/lib/libc/port/gen/fls.c b/usr/src/lib/libc/port/gen/fls.c new file mode 100644 index 0000000000..e685451c3e --- /dev/null +++ b/usr/src/lib/libc/port/gen/fls.c @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <string.h> +#include <strings.h> +#include <sys/types.h> + +static int +fls_impl(uint64_t bits) +{ + int i = 1; + uint32_t bits32; + + if (bits == 0) + return (0); + + if ((bits32 = (uint32_t)(bits >> 32)) != 0) + i += 32; + else + bits32 = (uint32_t)bits; + + if ((bits32 & 0xffff0000) != 0) { + bits32 >>= 16; + i += 16; + } + if ((bits32 & 0xff00) != 0) { + bits32 >>= 8; + i += 8; + } + if ((bits32 & 0xf0) != 0) { + bits32 >>= 4; + i += 4; + } + if ((bits32 & 0xc) != 0) { + bits32 >>= 2; + i += 2; + } + if ((bits32 & 0x2) != 0) + i += 1; + + return (i); +} + +int +fls(int bits) +{ + return (fls_impl((uint64_t)(uint_t)bits)); +} + +int +flsl(long bits) +{ + return (fls_impl((uint64_t)(ulong_t)bits)); +} + +int +flsll(long long bits) +{ + return (fls_impl((uint64_t)(u_longlong_t)bits)); +} diff --git a/usr/src/lib/libc/port/gen/get_nprocs.c b/usr/src/lib/libc/port/gen/get_nprocs.c new file mode 100644 index 0000000000..555dceafae --- /dev/null +++ b/usr/src/lib/libc/port/gen/get_nprocs.c @@ -0,0 +1,45 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <unistd.h> + +/* + * get_nprocs(3C) - return the number of online processors + */ +int +get_nprocs(void) +{ + return ((int)sysconf(_SC_NPROCESSORS_ONLN)); +} + +/* + * get_nprocs_conf(3C) - return the number of configured processors + */ +int +get_nprocs_conf(void) +{ + return ((int)sysconf(_SC_NPROCESSORS_CONF)); +} diff --git a/usr/src/lib/libc/port/gen/getenv.c b/usr/src/lib/libc/port/gen/getenv.c index 464632ac6c..c345226d0c 100644 --- a/usr/src/lib/libc/port/gen/getenv.c +++ b/usr/src/lib/libc/port/gen/getenv.c @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #pragma weak _putenv = putenv #include "lint.h" @@ -445,6 +442,30 @@ unsetenv(const char *name) } /* + * Dump entire environment. + */ +int +clearenv(void) +{ + /* + * Just drop the entire environment list on the floor, as it + * would be non-trivial to try and free the used memory. + */ + static const char *nullp = NULL; + + lmutex_lock(&update_lock); + _environ = &nullp; + my_environ = NULL; + environ_base = NULL; + environ_size = 0; + environ_gen++; + membar_producer(); + lmutex_unlock(&update_lock); + + return (0); +} + +/* * At last, a lockless implementation of getenv()! */ char * diff --git a/usr/src/lib/libc/port/gen/getmntent.c b/usr/src/lib/libc/port/gen/getmntent.c index af342cdfd4..ef63aacf85 100644 --- a/usr/src/lib/libc/port/gen/getmntent.c +++ b/usr/src/lib/libc/port/gen/getmntent.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ @@ -342,7 +341,7 @@ resetmnttab(FILE *fp) * an ioctl() call. */ static int -getline(char *lp, FILE *fp) +getaline(char *lp, FILE *fp) { char *cp; @@ -372,7 +371,7 @@ getmntent_compat(FILE *fp, struct mnttab *mp) } /* skip leading spaces and comments */ - if ((ret = getline(line, fp)) != 0) + if ((ret = getaline(line, fp)) != 0) return (ret); /* split up each field */ diff --git a/usr/src/lib/libc/port/gen/getvfsent.c b/usr/src/lib/libc/port/gen/getvfsent.c index bf6cf11c1a..13ce57d19f 100644 --- a/usr/src/lib/libc/port/gen/getvfsent.c +++ b/usr/src/lib/libc/port/gen/getvfsent.c @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include <mtlib.h> #include <stdio.h> @@ -66,7 +63,7 @@ static const char sepstr[] = " \t\n"; static const char dash[] = "-"; -static int getline(char *, FILE *); +static int getaline(char *, FILE *); int getvfsspec(FILE *fd, struct vfstab *vgetp, char *special) @@ -78,8 +75,8 @@ getvfsspec(FILE *fd, struct vfstab *vgetp, char *special) if (special && stat64(special, &statb) == 0 && - ((bmode = (statb.st_mode & S_IFMT)) == S_IFBLK || - bmode == S_IFCHR)) { + ((bmode = (statb.st_mode & S_IFMT)) == S_IFBLK || + bmode == S_IFCHR)) { bstat = 1; brdev = statb.st_rdev; } else @@ -119,12 +116,12 @@ getvfsany(FILE *fd, struct vfstab *vgetp, struct vfstab *vrefp) /* Match by straight strcmp */ while ((ret = getvfsent(fd, vgetp)) == 0 && - (DIFF(vfs_special) || DIFF(vfs_fsckdev) || - DIFF(vfs_mountp) || - DIFF(vfs_fstype) || - DIFF(vfs_fsckpass) || - DIFF(vfs_automnt) || - DIFF(vfs_mntopts))) + (DIFF(vfs_special) || DIFF(vfs_fsckdev) || + DIFF(vfs_mountp) || + DIFF(vfs_fstype) || + DIFF(vfs_fsckpass) || + DIFF(vfs_automnt) || + DIFF(vfs_mntopts))) ; /* If something other than EOF, return it */ @@ -139,31 +136,31 @@ getvfsany(FILE *fd, struct vfstab *vgetp, struct vfstab *vrefp) (void) fseeko64(fd, start, SEEK_SET); if (vrefp->vfs_special && stat64(vrefp->vfs_special, &statb) == 0 && - ((bmode = (statb.st_mode & S_IFMT)) == S_IFBLK || - bmode == S_IFCHR)) { + ((bmode = (statb.st_mode & S_IFMT)) == S_IFBLK || + bmode == S_IFCHR)) { bstat = 1; brdev = statb.st_rdev; } else bstat = 0; if (vrefp->vfs_fsckdev && stat64(vrefp->vfs_fsckdev, &statb) == 0 && - ((cmode = (statb.st_mode & S_IFMT)) == S_IFBLK || - cmode == S_IFCHR)) { + ((cmode = (statb.st_mode & S_IFMT)) == S_IFBLK || + cmode == S_IFCHR)) { cstat = 1; crdev = statb.st_rdev; } else cstat = 0; while ((ret = getvfsent(fd, vgetp)) == 0 && - ((bstat == 0 && DIFF(vfs_special)) || - (bstat == 1 && SDIFF(vfs_special, bmode, brdev)) || - (cstat == 0 && DIFF(vfs_fsckdev)) || - (cstat == 1 && SDIFF(vfs_fsckdev, cmode, crdev)) || - DIFF(vfs_mountp) || - DIFF(vfs_fstype) || - DIFF(vfs_fsckpass) || - DIFF(vfs_automnt) || - DIFF(vfs_mntopts))) + ((bstat == 0 && DIFF(vfs_special)) || + (bstat == 1 && SDIFF(vfs_special, bmode, brdev)) || + (cstat == 0 && DIFF(vfs_fsckdev)) || + (cstat == 1 && SDIFF(vfs_fsckdev, cmode, crdev)) || + DIFF(vfs_mountp) || + DIFF(vfs_fstype) || + DIFF(vfs_fsckpass) || + DIFF(vfs_automnt) || + DIFF(vfs_mntopts))) ; return (ret); } @@ -179,7 +176,7 @@ getvfsent(FILE *fd, struct vfstab *vp) return (0); /* skip leading spaces and comments */ - if ((ret = getline(line, fd)) != 0) + if ((ret = getaline(line, fd)) != 0) return (ret); /* split up each field */ @@ -199,7 +196,7 @@ getvfsent(FILE *fd, struct vfstab *vp) } static int -getline(char *lp, FILE *fd) +getaline(char *lp, FILE *fd) { char *cp; diff --git a/usr/src/lib/libc/port/gen/memmem.c b/usr/src/lib/libc/port/gen/memmem.c new file mode 100644 index 0000000000..a0f396e7c4 --- /dev/null +++ b/usr/src/lib/libc/port/gen/memmem.c @@ -0,0 +1,87 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Copyright (c) 2005 Pascal Gloor <pascal.gloor@spale.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <string.h> + +/* + * Find the first occurrence of the byte string s in byte string l. + */ + +void * +memmem(const void *l, size_t l_len, const void *s, size_t s_len) +{ + char *cur, *last; + const char *cl = (const char *)l; + const char *cs = (const char *)s; + + /* we need something to compare */ + if (l_len == 0 || s_len == 0) + return (NULL); + + /* "s" must be smaller or equal to "l" */ + if (l_len < s_len) + return (NULL); + + /* special case where s_len == 1 */ + if (s_len == 1) + return (memchr(l, (int)*cs, l_len)); + + /* the last position where its possible to find "s" in "l" */ + last = (char *)cl + l_len - s_len; + + for (cur = (char *)cl; cur <= last; cur++) + if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0) + return (cur); + + return (NULL); +} diff --git a/usr/src/lib/libc/port/gen/mkdtemp.c b/usr/src/lib/libc/port/gen/mkdtemp.c index 37e60c2b96..abe0afedc6 100644 --- a/usr/src/lib/libc/port/gen/mkdtemp.c +++ b/usr/src/lib/libc/port/gen/mkdtemp.c @@ -20,18 +20,14 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * mkdtemp(3C) - create a directory with a unique name. */ #include "lint.h" -#include <alloca.h> #include <errno.h> #include <stdlib.h> #include <string.h> @@ -40,11 +36,11 @@ char * mkdtemp(char *template) { - char *t = alloca(strlen(template) + 1); + char *t; char *r; /* Save template */ - (void) strcpy(t, template); + t = strdupa(template); for (;;) { r = mktemp(template); diff --git a/usr/src/lib/libc/port/gen/mktemp.c b/usr/src/lib/libc/port/gen/mktemp.c index e8e7105d39..5f58501e64 100644 --- a/usr/src/lib/libc/port/gen/mktemp.c +++ b/usr/src/lib/libc/port/gen/mktemp.c @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * mktemp() expects a string with up to six trailing 'X's. * These will be overlaid with letters, digits and symbols from @@ -97,29 +94,6 @@ chars[64] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '_', }; -/* - * Find highest one bit set. - * Returns bit number of highest bit that is set. - * Low order bit is number 0, high order bit is number 31. - */ -static int -highbit(uint_t i) -{ - int h = 0; - - if (i & 0xffff0000) - h += 16, i >>= 16; - if (i & 0xff00) - h += 8, i >>= 8; - if (i & 0xf0) - h += 4, i >>= 4; - if (i & 0xc) - h += 2, i >>= 2; - if (i & 0x2) - h += 1; - return (h); -} - char * libc_mktemps(char *as, int slen) { @@ -162,7 +136,7 @@ libc_mktemps(char *as, int slen) /* for all possible values of pid, 0 <= pid < (1 << pidshift) */ if (pidshift == 0) /* one-time initialization */ - pidshift = highbit((uint_t)MAXPID) + 1; + pidshift = fls((uint_t)MAXPID); /* high bit number */ /* count the X's */ xcnt = 0; diff --git a/usr/src/lib/libc/port/gen/poll.c b/usr/src/lib/libc/port/gen/poll.c index e186a30b12..e23b103f3b 100644 --- a/usr/src/lib/libc/port/gen/poll.c +++ b/usr/src/lib/libc/port/gen/poll.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #pragma weak _poll = poll #include "lint.h" @@ -34,6 +31,14 @@ #include "libc.h" int +ppoll(struct pollfd *_RESTRICT_KYWD fds, nfds_t nfd, + const struct timespec *_RESTRICT_KYWD tsp, + const sigset_t *_RESTRICT_KYWD sigmask) +{ + return (_pollsys(fds, nfd, tsp, sigmask)); +} + +int poll(struct pollfd *fds, nfds_t nfd, int timeout) { timespec_t ts; diff --git a/usr/src/lib/libc/port/gen/realpath.c b/usr/src/lib/libc/port/gen/realpath.c index 08223f8f5c..a6b116c250 100644 --- a/usr/src/lib/libc/port/gen/realpath.c +++ b/usr/src/lib/libc/port/gen/realpath.c @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include <sys/types.h> #include <dirent.h> @@ -42,18 +39,18 @@ /* * Canonicalize the path given in file_name, resolving away all symbolic link * components. Store the result into the buffer named by resolved_name, which - * must be long enough (MAXPATHLEN bytes will suffice). Returns NULL + * must be long enough (PATH_MAX bytes will suffice). Returns NULL * on failure and resolved_name on success. On failure, to maintain * compatibility with the past, the contents of file_name will be copied * into resolved_name. */ -char * -realpath(const char *file_name, char *resolved_name) +static char * +realpath_impl(const char *file_name, char *resolved_name) { char cwd[PATH_MAX]; int len; - if (file_name == NULL || resolved_name == NULL) { + if (file_name == NULL) { errno = EINVAL; return (NULL); } @@ -121,3 +118,32 @@ realpath(const char *file_name, char *resolved_name) (void) strcpy(resolved_name, cwd); return (resolved_name); } + +/* + * Canonicalize the path given in file_name, resolving away all symbolic link + * components. If resolved_name is a null pointer, return a malloc()d + * buffer containing the result, else store the result into resolved_name + * and return resolved_name. Return NULL on failure. + */ +char * +realpath(const char *file_name, char *resolved_name) +{ + char buffer[PATH_MAX]; + + if (resolved_name != NULL) + return (realpath_impl(file_name, resolved_name)); + + if (realpath_impl(file_name, buffer) != NULL) + return (strdup(buffer)); + + return (NULL); +} + +/* + * GNU extension. + */ +char * +canonicalize_file_name(const char *path) +{ + return (realpath(path, NULL)); +} diff --git a/usr/src/lib/libc/port/gen/stpcpy.c b/usr/src/lib/libc/port/gen/stpcpy.c new file mode 100644 index 0000000000..ee1439e61c --- /dev/null +++ b/usr/src/lib/libc/port/gen/stpcpy.c @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#include "lint.h" +#include <string.h> +#include <sys/types.h> + +/* + * Copy string s2 to s1. s1 must be large enough. + * return a pointer to the terminating null character of s1. + */ +char * +stpcpy(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2) +{ + (void) strcpy(s1, s2); + return (s1 + strlen(s1)); +} diff --git a/usr/src/lib/libc/port/gen/stpncpy.c b/usr/src/lib/libc/port/gen/stpncpy.c new file mode 100644 index 0000000000..5a69e370e5 --- /dev/null +++ b/usr/src/lib/libc/port/gen/stpncpy.c @@ -0,0 +1,46 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#include "lint.h" +#include <string.h> +#include <sys/types.h> + +/* + * Copy s2 to s1, truncating or null-padding to always copy n bytes + * return a pointer to the terminating null byte in s1, or, + * if s1 is not null-terminated, s1 + n. + */ +char * +stpncpy(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2, size_t n) +{ + size_t len = strnlen(s2, n); + + (void) strncpy(s1, s2, n); + + return ((len < n) ? s1 + len : s1 + n); +} diff --git a/usr/src/lib/libc/port/gen/strchrnul.c b/usr/src/lib/libc/port/gen/strchrnul.c new file mode 100644 index 0000000000..3355ec4d93 --- /dev/null +++ b/usr/src/lib/libc/port/gen/strchrnul.c @@ -0,0 +1,37 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include <string.h> + +char * +strchrnul(const char *s, int c) +{ + char *ptr = strchr(s, c); + + if (ptr == NULL) + ptr = (char *)s + strlen(s); + + return (ptr); +} diff --git a/usr/src/lib/libc/port/gen/strndup.c b/usr/src/lib/libc/port/gen/strndup.c new file mode 100644 index 0000000000..a31f60827c --- /dev/null +++ b/usr/src/lib/libc/port/gen/strndup.c @@ -0,0 +1,44 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <string.h> +#include <stdlib.h> +#include <sys/types.h> + +/* + * Create a copy of string s, but only duplicate the first n bytes. + * Return NULL if the new string can't be allocated. + */ +char * +strndup(const char *s1, size_t n) +{ + char *s2; + + n = strnlen(s1, n); + if ((s2 = malloc(n + 1)) != NULL) + (void) strlcpy(s2, s1, n + 1); + return (s2); +} diff --git a/usr/src/lib/libc/port/gen/strstr.c b/usr/src/lib/libc/port/gen/strstr.c index a8d8d655af..1f87034ada 100644 --- a/usr/src/lib/libc/port/gen/strstr.c +++ b/usr/src/lib/libc/port/gen/strstr.c @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include <string.h> #include <stddef.h> @@ -37,9 +34,9 @@ /* * strstr() locates the first occurrence in the string as1 of * the sequence of characters (excluding the terminating null - * character) in the string as2. strstr() returns a pointer + * character) in the string as2. strstr() returns a pointer * to the located string, or a null pointer if the string is - * not found. If as2 is "", the function returns as1. + * not found. If as2 is empty, the function returns as1. */ char * @@ -54,19 +51,61 @@ strstr(const char *as1, const char *as2) if (s2 == NULL || *s2 == '\0') return ((char *)s1); + c = *s2; + while (*s1 != '\0') { + if (c == *s1++) { + tptr = s1; + while ((c = *++s2) == *s1++ && c != '\0') + continue; + if (c == '\0') + return ((char *)tptr - 1); + s1 = tptr; + s2 = as2; + c = *s2; + } + } - while (*s1) - if (*s1++ == c) { + return (NULL); +} + +/* + * strnstr() locates the first occurrence in the string as1 of + * the sequence of characters (excluding the terminating null + * character) in the string as2, where not more than n characters + * from the string as1 are searched. strnstr() returns a pointer + * to the located string, or a null pointer if the string is + * not found. If as2 is empty, the function returns as1. + */ + +char * +strnstr(const char *as1, const char *as2, size_t n) +{ + const char *s1, *s2; + const char *tptr; + size_t k; + char c; + + s1 = as1; + s2 = as2; + + if (s2 == NULL || *s2 == '\0') + return ((char *)s1); + + c = *s2; + while (*s1 != '\0' && n--) { + if (c == *s1++) { + k = n; tptr = s1; - while ((c = *++s2) == *s1++ && c) - ; - if (c == 0) + while ((c = *++s2) == *s1++ && c != '\0' && k--) + continue; + if (c == '\0') return ((char *)tptr - 1); s1 = tptr; s2 = as2; c = *s2; } + } return (NULL); } diff --git a/usr/src/lib/libc/port/gen/tls_data.c b/usr/src/lib/libc/port/gen/tls_data.c new file mode 100644 index 0000000000..b0cf94470a --- /dev/null +++ b/usr/src/lib/libc/port/gen/tls_data.c @@ -0,0 +1,34 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include <string.h> + +/* + * Thread-local variables. + * Needed by strdupa() and strndupa() macros when compiling with Studio C. + */ +__thread char *__strdupa_str; +__thread size_t __strdupa_len; diff --git a/usr/src/lib/libc/port/i18n/strcasecmp.c b/usr/src/lib/libc/port/i18n/strcasecmp.c new file mode 100644 index 0000000000..44bcf2c9e4 --- /dev/null +++ b/usr/src/lib/libc/port/i18n/strcasecmp.c @@ -0,0 +1,63 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#include "lint.h" +#include <sys/types.h> +#include <strings.h> +#include <ctype.h> + +int +strcasecmp(const char *s1, const char *s2) +{ + extern int charset_is_ascii; + extern int ascii_strcasecmp(const char *s1, const char *s2); + int *cm; + const uchar_t *us1; + const uchar_t *us2; + + /* + * If we are in a locale that uses the ASCII character set + * (C or POSIX), use the fast ascii_strcasecmp() function. + */ + if (charset_is_ascii) + return (ascii_strcasecmp(s1, s2)); + + cm = __trans_lower; + us1 = (const uchar_t *)s1; + us2 = (const uchar_t *)s2; + + while (cm[*us1] == cm[*us2++]) + if (*us1++ == '\0') + return (0); + return (cm[*us1] - cm[*(us2 - 1)]); +} diff --git a/usr/src/lib/libc/port/i18n/strcasestr.c b/usr/src/lib/libc/port/i18n/strcasestr.c new file mode 100644 index 0000000000..a8f590263a --- /dev/null +++ b/usr/src/lib/libc/port/i18n/strcasestr.c @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +#include "lint.h" +#include <string.h> +#include <ctype.h> +#include <sys/types.h> + +/* + * strcasestr() locates the first occurrence in the string s1 of the + * sequence of characters (excluding the terminating null character) + * in the string s2, ignoring case. strcasestr() returns a pointer + * to the located string, or a null pointer if the string is not found. + * If s2 is empty, the function returns s1. + */ + +char * +strcasestr(const char *s1, const char *s2) +{ + int *cm = __trans_lower; + const uchar_t *us1 = (const uchar_t *)s1; + const uchar_t *us2 = (const uchar_t *)s2; + const uchar_t *tptr; + int c; + + if (us2 == NULL || *us2 == '\0') + return ((char *)us1); + + c = cm[*us2]; + while (*us1 != '\0') { + if (c == cm[*us1++]) { + tptr = us1; + while (cm[c = *++us2] == cm[*us1++] && c != '\0') + continue; + if (c == '\0') + return ((char *)tptr - 1); + us1 = tptr; + us2 = (const uchar_t *)s2; + c = cm[*us2]; + } + } + + return (NULL); +} diff --git a/usr/src/lib/libc/port/i18n/strncasecmp.c b/usr/src/lib/libc/port/i18n/strncasecmp.c new file mode 100644 index 0000000000..67c6687e08 --- /dev/null +++ b/usr/src/lib/libc/port/i18n/strncasecmp.c @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#include "lint.h" +#include <sys/types.h> +#include <strings.h> +#include <ctype.h> + +int +strncasecmp(const char *s1, const char *s2, size_t n) +{ + extern int charset_is_ascii; + extern int ascii_strncasecmp(const char *s1, const char *s2, size_t n); + int *cm; + const uchar_t *us1; + const uchar_t *us2; + + /* + * If we are in a locale that uses the ASCII character set + * (C or POSIX), use the fast ascii_strncasecmp() function. + */ + if (charset_is_ascii) + return (ascii_strncasecmp(s1, s2, n)); + + cm = __trans_lower; + us1 = (const uchar_t *)s1; + us2 = (const uchar_t *)s2; + + while (n != 0 && cm[*us1] == cm[*us2++]) { + if (*us1++ == '\0') + return (0); + n--; + } + return (n == 0 ? 0 : cm[*us1] - cm[*(us2 - 1)]); +} diff --git a/usr/src/lib/libc/port/i18n/wcsnlen.c b/usr/src/lib/libc/port/i18n/wcsnlen.c new file mode 100644 index 0000000000..37565ea88c --- /dev/null +++ b/usr/src/lib/libc/port/i18n/wcsnlen.c @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +/* + * Returns the number of non-NULL characters in str, + * but not more than maxlen. Does not look past str + maxlen. + */ + +#include "lint.h" +#include <stdlib.h> +#include <wchar.h> + +size_t +wcsnlen(const wchar_t *str, size_t maxlen) +{ + const wchar_t *ptr = str; + + if (maxlen != 0) { + do { + if (*ptr++ == L'\0') { + ptr--; + break; + } + } while (--maxlen != 0); + } + + return (ptr - str); +} diff --git a/usr/src/lib/libc/port/i18n/wscasecmp.c b/usr/src/lib/libc/port/i18n/wscasecmp.c index d3926bcc07..c8855ded41 100644 --- a/usr/src/lib/libc/port/i18n/wscasecmp.c +++ b/usr/src/lib/libc/port/i18n/wscasecmp.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Compare strings ignoring case difference. * returns: s1>s2: >0 s1==s2: 0 s1<s2: <0 @@ -40,7 +37,7 @@ #include "libc.h" int -wscasecmp(const wchar_t *s1, const wchar_t *s2) +wcscasecmp(const wchar_t *s1, const wchar_t *s2) { if (s1 == s2) return (0); @@ -50,3 +47,9 @@ wscasecmp(const wchar_t *s1, const wchar_t *s2) return (0); return (towlower(*s1) - towlower(*(s2 - 1))); } + +int +wscasecmp(const wchar_t *s1, const wchar_t *s2) +{ + return (wcscasecmp(s1, s2)); +} diff --git a/usr/src/lib/libc/port/i18n/wscpy.c b/usr/src/lib/libc/port/i18n/wscpy.c index cab7faa736..83c249ab22 100644 --- a/usr/src/lib/libc/port/i18n/wscpy.c +++ b/usr/src/lib/libc/port/i18n/wscpy.c @@ -20,18 +20,18 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1986 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* - * Copy string s2 to s1. S1 must be large enough. + * wcscpy(): copy string s2 to s1. S1 must be large enough. * Return s1. + * + * wcpcpy(): copy string s2 to s1. S1 must be large enough. + * Return a pointer to the terminating null character of s1. */ #pragma weak _wcscpy = wcscpy @@ -47,7 +47,7 @@ wcscpy(wchar_t *s1, const wchar_t *s2) wchar_t *os1 = s1; while (*s1++ = *s2++) - ; + continue; return (os1); } @@ -56,3 +56,11 @@ wscpy(wchar_t *s1, const wchar_t *s2) { return (wcscpy(s1, s2)); } + +wchar_t * +wcpcpy(wchar_t *s1, const wchar_t *s2) +{ + while (*s1++ = *s2++) + continue; + return (s1 - 1); +} diff --git a/usr/src/lib/libc/port/i18n/wsdup.c b/usr/src/lib/libc/port/i18n/wsdup.c index 98d8a43d85..af69e2c81a 100644 --- a/usr/src/lib/libc/port/i18n/wsdup.c +++ b/usr/src/lib/libc/port/i18n/wsdup.c @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1986 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * string duplication * returns pointer to a new string which is the duplicate of string @@ -42,10 +39,16 @@ #include "libc.h" wchar_t * -wsdup(const wchar_t *s1) +wcsdup(const wchar_t *s1) { wchar_t *s2; s2 = malloc((wcslen(s1) + 1) * sizeof (wchar_t)); return (s2 == NULL ? NULL : wcscpy(s2, s1)); } + +wchar_t * +wsdup(const wchar_t *s1) +{ + return (wcsdup(s1)); +} diff --git a/usr/src/lib/libc/port/i18n/wsncasecmp.c b/usr/src/lib/libc/port/i18n/wsncasecmp.c index f7603146fc..ee4fbb6028 100644 --- a/usr/src/lib/libc/port/i18n/wsncasecmp.c +++ b/usr/src/lib/libc/port/i18n/wsncasecmp.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Compare strings ignoring case difference. * returns: s1>s2: >0 s1==s2: 0 s1<s2: <0 @@ -40,7 +37,7 @@ #include "libc.h" int -wsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) +wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) { if (s1 == s2) return (0); @@ -51,3 +48,9 @@ wsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) return (0); return ((n == 0) ? 0 : (towlower(*s1) - towlower(*(s2 - 1)))); } + +int +wsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) +{ + return (wcsncasecmp(s1, s2, n)); +} diff --git a/usr/src/lib/libc/port/i18n/wsncpy.c b/usr/src/lib/libc/port/i18n/wsncpy.c index 8161863b74..07a11eab58 100644 --- a/usr/src/lib/libc/port/i18n/wsncpy.c +++ b/usr/src/lib/libc/port/i18n/wsncpy.c @@ -20,20 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1986 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Copy s2 to s1, truncating or null-padding to always copy n characters. - * Return s1. - */ - #pragma weak _wcsncpy = wcsncpy #pragma weak _wsncpy = wsncpy @@ -41,14 +33,18 @@ #include <stdlib.h> #include <wchar.h> +/* + * Copy s2 to s1, truncating or null-padding to always copy n + * wide-character codes. Return s1. + */ wchar_t * wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n) { wchar_t *os1 = s1; n++; - while ((--n > 0) && ((*s1++ = *s2++) != 0)) - ; + while (--n > 0 && (*s1++ = *s2++) != 0) + continue; if (n > 0) while (--n > 0) *s1++ = 0; @@ -60,3 +56,26 @@ wsncpy(wchar_t *s1, const wchar_t *s2, size_t n) { return (wcsncpy(s1, s2, n)); } + +/* + * Same as wcsncpy(), except return a pointer to the terminating null + * wide-character code in s1, or, if s1 is not null-terminated, s1 + n. + */ +wchar_t * +wcpncpy(wchar_t *s1, const wchar_t *s2, size_t n) +{ + wchar_t *os1 = s1; + + n++; + while (--n != 0) { + if ((*s1++ = *s2++) == 0) { + os1 = s1 - 1; + break; + } + os1 = s1; + } + if (n != 0) + while (--n != 0) + *s1++ = 0; + return (os1); +} diff --git a/usr/src/lib/libc/port/llib-lc b/usr/src/lib/libc/port/llib-lc index 0d639fc49d..9d51444d93 100644 --- a/usr/src/lib/libc/port/llib-lc +++ b/usr/src/lib/libc/port/llib-lc @@ -20,13 +20,14 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ /* LINTLIBRARY */ /* PROTOLIB1 */ +#define __EXTENSIONS__ + #include <aio.h> #include <alloca.h> #include <attr.h> @@ -58,6 +59,7 @@ #include <ndbm.h> #include <limits.h> #include <nl_types.h> +#include <poll.h> #include <project.h> #include <priv.h> #include <pwd.h> @@ -103,7 +105,6 @@ #include <sys/mount.h> #include <sys/msg.h> #include <sys/param.h> -#include <sys/poll.h> #include <sys/priocntl.h> #include <sys/procset.h> #include <sys/processor.h> @@ -167,6 +168,12 @@ char **environ; /* + * This is a GNU/Linux/BSD compatibility interface, + * not declared in any header file. + */ +const char *__progname; + +/* * POSIX versions of standard libc routines; these aren't extracted * from the headers above since we cannot #define _POSIX_C_SOURCE. */ diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers index 3ceea9bac4..187e3c691a 100644 --- a/usr/src/lib/libc/port/mapfile-vers +++ b/usr/src/lib/libc/port/mapfile-vers @@ -124,6 +124,8 @@ $endif backtrace; backtrace_symbols; backtrace_symbols_fd; + canonicalize_file_name; + clearenv; clock_getres; clock_gettime; clock_nanosleep; @@ -147,17 +149,29 @@ $endif errx; faccessat; fchmodat; + fcloseall; fdatasync; + ffsl; + ffsll; fgetattr; + fls; + flsl; + flsll; forkallx; forkx; fsetattr; getattrat; + getdelim; + getline; + get_nprocs; + get_nprocs_conf; + getprogname; htonl; htonll; htons; linkat; lio_listio; + memmem; mkdirat; mkdtemp; mkfifoat; @@ -187,6 +201,7 @@ $endif posix_spawn_file_actions_addclosefrom_np; posix_spawnattr_getsigignore_np; posix_spawnattr_setsigignore_np; + ppoll; priv_basicset; pthread_key_create_once_np; pthread_mutexattr_getrobust; @@ -213,6 +228,7 @@ $endif sem_unlink; sem_wait; setattrat; + setprogname; _sharefs; shm_open; shm_unlink; @@ -220,7 +236,13 @@ $endif sigtimedwait; sigwaitinfo; smt_pause; + stpcpy; + stpncpy; + strcasestr; + strchrnul; + strndup; strnlen; + strnstr; strsep; symlinkat; thr_keycreate_once; @@ -245,6 +267,12 @@ $endif vwarnx; warn; warnx; + wcpcpy; + wcpncpy; + wcscasecmp; + wcsdup; + wcsncasecmp; + wcsnlen; $if lf64 aio_cancel64; @@ -2531,8 +2559,11 @@ SYMBOL_VERSION SUNWprivate_1.1 { __nis_preftype; __nis_server; _nss_default_finders; + __progname { FLAGS = NODIRECT }; _smbuf; _sp; + __strdupa_str { FLAGS = NODIRECT }; + __strdupa_len { FLAGS = NODIRECT }; _tdb_bootstrap; __threaded; thr_probe_getfunc_addr; diff --git a/usr/src/lib/libc/port/stdio/flush.c b/usr/src/lib/libc/port/stdio/flush.c index fb8d058e4c..7d3549ca0d 100644 --- a/usr/src/lib/libc/port/stdio/flush.c +++ b/usr/src/lib/libc/port/stdio/flush.c @@ -20,15 +20,12 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include "mtlib.h" #include "file64.h" @@ -723,6 +720,55 @@ fclose(FILE *iop) return (res); } +/* close all open streams */ +int +fcloseall(void) +{ + FPDECL(iop); + + struct _link_ *lp; + rmutex_t *lk; + + if (__libc_threaded) + cancel_safe_mutex_lock(&_first_link_lock); + + lp = &__first_link; + + do { + int i; + + FIRSTFP(lp, iop); + for (i = lp->niob; --i >= 0; NEXTFP(iop)) { + /* code stolen from fclose(), above */ + + FLOCKFILE(lk, iop); + if (iop->_flag == 0) { + FUNLOCKFILE(lk); + continue; + } + + /* Not unbuffered and opened for read and/or write? */ + if (!(iop->_flag & _IONBF) && + (iop->_flag & (_IOWRT | _IOREAD | _IORW))) + (void) _fflush_u(iop); + (void) close(GET_FD(iop)); + if (iop->_flag & _IOMYBUF) + free((char *)iop->_base - PUSHBACK); + iop->_base = NULL; + iop->_ptr = NULL; + iop->_cnt = 0; + iop->_flag = 0; /* marks it as available */ + FUNLOCKFILE(lk); + fcloses++; + } + } while ((lp = lp->next) != NULL); + + if (__libc_threaded) + cancel_safe_mutex_unlock(&_first_link_lock); + + return (0); +} + /* flush buffer, close fd but keep the stream used by freopen() */ int close_fd(FILE *iop) diff --git a/usr/src/lib/libc/port/stdio/getline.c b/usr/src/lib/libc/port/stdio/getline.c new file mode 100644 index 0000000000..bb55b40159 --- /dev/null +++ b/usr/src/lib/libc/port/stdio/getline.c @@ -0,0 +1,106 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#include "lint.h" +#include "file64.h" +#include "mtlib.h" +#include <stdio.h> +#include <errno.h> +#include <thread.h> +#include <synch.h> +#include <unistd.h> +#include <limits.h> +#include <malloc.h> +#include <sys/types.h> +#include "stdiom.h" + +#define LINESZ 128 /* initial guess for a NULL *lineptr */ + +ssize_t +getdelim(char **_RESTRICT_KYWD lineptr, size_t *_RESTRICT_KYWD n, + int delimiter, FILE *_RESTRICT_KYWD iop) +{ + rmutex_t *lk; + char *ptr; + size_t size; + int c; + size_t cnt; + + if (lineptr == NULL || n == NULL || + delimiter < 0 || delimiter > UCHAR_MAX) { + errno = EINVAL; + return (-1); + } + + if (*lineptr == NULL || *n < LINESZ) { /* initial allocation */ + if ((*lineptr = realloc(*lineptr, LINESZ)) == NULL) { + errno = ENOMEM; + return (-1); + } + *n = LINESZ; + } + ptr = *lineptr; + size = *n; + cnt = 0; + + FLOCKFILE(lk, iop); + + _SET_ORIENTATION_BYTE(iop); + + do { + c = (--iop->_cnt < 0) ? __filbuf(iop) : *iop->_ptr++; + if (c == EOF) + break; + *ptr++ = c; + if (++cnt == size) { /* must reallocate */ + if ((ptr = realloc(*lineptr, 2 * size)) == NULL) { + FUNLOCKFILE(lk); + ptr = *lineptr + size - 1; + *ptr = '\0'; + errno = ENOMEM; + return (-1); + } + *lineptr = ptr; + ptr += size; + *n = size = 2 * size; + } + } while (c != delimiter); + + *ptr = '\0'; + + FUNLOCKFILE(lk); + if (cnt > SSIZE_MAX) { + errno = EOVERFLOW; + return (-1); + } + return (cnt ? cnt : -1); +} + +ssize_t +getline(char **_RESTRICT_KYWD lineptr, size_t *_RESTRICT_KYWD n, + FILE *_RESTRICT_KYWD iop) +{ + return (getdelim(lineptr, n, '\n', iop)); +} diff --git a/usr/src/lib/libc/port/threads/alloc.c b/usr/src/lib/libc/port/threads/alloc.c index 1751e76708..5851212ad4 100644 --- a/usr/src/lib/libc/port/threads/alloc.c +++ b/usr/src/lib/libc/port/threads/alloc.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include "thr_uberdata.h" #include <sys/syscall.h> @@ -148,10 +145,14 @@ initial_allocation(bucket_t *bp) /* &__uberdata.bucket[0] */ ASSERT(((caddr_t)ptr - (caddr_t)base + 4 * SUBCHUNKSIZE) == BASE_SIZE); } +/* + * This highbit code is the same as the code in fls_impl(). + * We inline it here for speed. + */ static int getbucketnum(size_t size) { - int highbit = 0; + int highbit = 1; if (size-- <= MINSIZE) return (0); @@ -171,8 +172,8 @@ getbucketnum(size_t size) if (size & 0x2) highbit += 1; - ASSERT(highbit >= MINSHIFT); - return (highbit - (MINSHIFT - 1)); + ASSERT(highbit > MINSHIFT); + return (highbit - MINSHIFT); } void * diff --git a/usr/src/lib/libc/port/threads/thr.c b/usr/src/lib/libc/port/threads/thr.c index 98906802c5..ae55fbddf5 100644 --- a/usr/src/lib/libc/port/threads/thr.c +++ b/usr/src/lib/libc/port/threads/thr.c @@ -132,6 +132,7 @@ uberdata_t __uberdata = { NULL, /* atforklist */ NULL, /* robustlocks */ NULL, /* robustlist */ + NULL, /* progname */ NULL, /* __tdb_bootstrap */ { /* tdb */ NULL, /* tdb_sync_addr_hash */ @@ -1259,6 +1260,7 @@ libc_init(void) __tdb_bootstrap = oldself->ul_uberdata->tdb_bootstrap; mutex_setup(); atfork_init(); /* every link map needs atfork() processing */ + init_progname(); return; } @@ -1458,9 +1460,11 @@ libc_init(void) /* * When we have initialized the primary link map, inform * the dynamic linker about our interface functions. + * Set up our pointer to the program name. */ if (self->ul_primarymap) _ld_libc((void *)rtld_funcs); + init_progname(); /* * Defer signals until TLS constructors have been called. diff --git a/usr/src/lib/libc/sparc/Makefile.com b/usr/src/lib/libc/sparc/Makefile.com index fd8b30caa4..5d850c7dff 100644 --- a/usr/src/lib/libc/sparc/Makefile.com +++ b/usr/src/lib/libc/sparc/Makefile.com @@ -101,7 +101,9 @@ FPASMOBJS= \ fpgetsticky.o \ fpsetmask.o \ fpsetrnd.o \ - fpsetsticky.o \ + fpsetsticky.o + +$(__GNUC)FPASMOBJS += \ __quad.o ATOMICOBJS= \ @@ -115,7 +117,6 @@ COMOBJS= \ bcopy.o \ bzero.o \ bsearch.o \ - ffs.o \ memccpy.o \ qsort.o \ strtol.o \ @@ -131,6 +132,7 @@ GENOBJS= \ _xregs_clrptr.o \ abs.o \ alloca.o \ + ascii_strcasecmp.o \ byteorder.o \ cuexit.o \ ecvt.o \ @@ -151,7 +153,6 @@ GENOBJS= \ siglongjmp.o \ smt_pause.o \ sparc_data.o \ - strcasecmp.o \ strchr.o \ strcmp.o \ strlcpy.o \ @@ -384,6 +385,7 @@ PORTGEN= \ a64l.o \ abort.o \ addsev.o \ + ascii_strncasecmp.o \ assert.o \ atof.o \ atoi.o \ @@ -427,6 +429,8 @@ PORTGEN= \ fattach.o \ fdetach.o \ fdopendir.o \ + ffs.o \ + fls.o \ fmtmsg.o \ ftime.o \ ftok.o \ @@ -448,6 +452,7 @@ PORTGEN= \ getlogin.o \ getmntent.o \ getnetgrent.o \ + get_nprocs.o \ getopt.o \ getopt_long.o \ getpagesize.o \ @@ -496,6 +501,7 @@ PORTGEN= \ madvise.o \ malloc.o \ memalign.o \ + memmem.o \ mkdev.o \ mkdtemp.o \ mkfifo.o \ @@ -560,15 +566,18 @@ PORTGEN= \ sigsetops.o \ ssignal.o \ stack.o \ + stpcpy.o \ + stpncpy.o \ str2sig.o \ strcase_charmap.o \ strcat.o \ + strchrnul.o \ strcspn.o \ strdup.o \ strerror.o \ - strncat.o \ strlcat.o \ - strncasecmp.o \ + strncat.o \ + strndup.o \ strpbrk.o \ strrchr.o \ strsep.o \ @@ -598,6 +607,7 @@ PORTGEN= \ tfind.o \ time_data.o \ time_gdata.o \ + tls_data.o \ truncate.o \ tsdalloc.o \ tsearch.o \ @@ -686,6 +696,7 @@ PORTSTDIO= \ fwrite.o \ getc.o \ getchar.o \ + getline.o \ getpass.o \ gets.o \ getw.o \ @@ -718,7 +729,11 @@ PORTI18N= \ getwchar.o \ putwchar.o \ putws.o \ + strcasecmp.o \ + strcasestr.o \ + strncasecmp.o \ strtows.o \ + wcsnlen.o \ wcstoimax.o \ wcstol.o \ wcstoul.o \ @@ -1022,8 +1037,10 @@ BUILD.s= $(AS) $(ASFLAGS) $< -o $@ C99MODE= $(C99_ENABLE) # libc method of building an archive +# The "$(GREP) -v ' L '" part is necessary only until +# lorder is fixed to ignore thread-local variables. BUILD.AR= $(RM) $@ ; \ - $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%)| $(TSORT)` + $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)` # extra files for the clean target CLEANFILES= \ @@ -1087,6 +1104,7 @@ TIL= \ atfork.o \ cancel.o \ door_calls.o \ + err.o \ errno.o \ getctxt.o \ lwp.o \ @@ -1120,6 +1138,9 @@ TIL= \ $(TIL:%=pics/%) := CFLAGS += $(LIBCBASE)/threads/sparc.il +# This hack is needed until the sparc gcc is fixed for TLS +pics/tls_data.o := CC = env 'CW_NO_SHADOW=1' $(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc + # special kludge for inlines with 'cas': pics/rwlock.o pics/synch.o pics/lwp.o pics/door_calls.o := \ sparc_CFLAGS += -_gcc=-Wa,-xarch=v8plus diff --git a/usr/src/lib/libc/sparc/gen/strcasecmp.s b/usr/src/lib/libc/sparc/gen/ascii_strcasecmp.s index c1f4a0d055..621ad9058f 100644 --- a/usr/src/lib/libc/sparc/gen/strcasecmp.s +++ b/usr/src/lib/libc/sparc/gen/ascii_strcasecmp.s @@ -20,13 +20,11 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ - .file "strcasecmp.s" /* - * The strcasecmp() function is a case insensitive versions of strcmp(). + * The ascii_strcasecmp() function is a case insensitive versions of strcmp(). * It assumes the ASCII character set and ignores differences in case * when comparing lower and upper case characters. In other words, it * behaves as if both strings had been converted to lower case using @@ -72,7 +70,7 @@ * }; * * int - * strcasecmp(const char *s1, const char *s2) + * ascii_strcasecmp(const char *s1, const char *s2) * { * const unsigned char *cm = (const unsigned char *)charmap; * const unsigned char *us1 = (const unsigned char *)s1; @@ -122,7 +120,7 @@ ! lower-case if they are upper-case, and are checked against ! the source string. - ENTRY(strcasecmp) + ENTRY(ascii_strcasecmp) .align 32 @@ -346,4 +344,4 @@ ret ! return restore %i0, %g0, %o0 ! return 0 or byte difference - SET_SIZE(strcasecmp) + SET_SIZE(ascii_strcasecmp) diff --git a/usr/src/lib/libc/sparcv9/Makefile.com b/usr/src/lib/libc/sparcv9/Makefile.com index f96202fec0..4f8489c629 100644 --- a/usr/src/lib/libc/sparcv9/Makefile.com +++ b/usr/src/lib/libc/sparcv9/Makefile.com @@ -119,7 +119,6 @@ COMOBJS= \ bcopy.o \ bsearch.o \ bzero.o \ - ffs.o \ memccpy.o \ qsort.o \ strtol.o \ @@ -132,6 +131,7 @@ GENOBJS= \ _xregs_clrptr.o \ abs.o \ alloca.o \ + ascii_strcasecmp.o \ byteorder.o \ cuexit.o \ ecvt.o \ @@ -146,7 +146,6 @@ GENOBJS= \ siglongjmp.o \ smt_pause.o \ sparc_data.o \ - strcasecmp.o \ strchr.o \ strcmp.o \ strlcpy.o \ @@ -350,6 +349,7 @@ PORTGEN= \ a64l.o \ abort.o \ addsev.o \ + ascii_strncasecmp.o \ assert.o \ attrat.o \ atof.o \ @@ -393,6 +393,8 @@ PORTGEN= \ fattach.o \ fdetach.o \ fdopendir.o \ + ffs.o \ + fls.o \ fmtmsg.o \ ftime.o \ ftok.o \ @@ -414,6 +416,7 @@ PORTGEN= \ getlogin.o \ getmntent.o \ getnetgrent.o \ + get_nprocs.o \ getopt.o \ getopt_long.o \ getpagesize.o \ @@ -462,6 +465,7 @@ PORTGEN= \ madvise.o \ malloc.o \ memalign.o \ + memmem.o \ mkdev.o \ mkdtemp.o \ mkfifo.o \ @@ -525,15 +529,18 @@ PORTGEN= \ sigsetops.o \ ssignal.o \ stack.o \ + stpcpy.o \ + stpncpy.o \ str2sig.o \ strcase_charmap.o \ strcat.o \ + strchrnul.o \ strcspn.o \ strdup.o \ strerror.o \ - strncat.o \ strlcat.o \ - strncasecmp.o \ + strncat.o \ + strndup.o \ strpbrk.o \ strrchr.o \ strsep.o \ @@ -563,6 +570,7 @@ PORTGEN= \ tfind.o \ time_data.o \ time_gdata.o \ + tls_data.o \ truncate.o \ tsdalloc.o \ tsearch.o \ @@ -637,6 +645,7 @@ PORTSTDIO= \ fwrite.o \ getc.o \ getchar.o \ + getline.o \ getpass.o \ gets.o \ getw.o \ @@ -669,7 +678,11 @@ PORTI18N= \ getwchar.o \ putwchar.o \ putws.o \ + strcasecmp.o \ + strcasestr.o \ + strncasecmp.o \ strtows.o \ + wcsnlen.o \ wcstoimax.o \ wcstol.o \ wcstoul.o \ @@ -964,8 +977,10 @@ BUILD.s= $(AS) $(ASFLAGS) $< -o $@ C99MODE= $(C99_ENABLE) # libc method of building an archive +# The "$(GREP) -v ' L '" part is necessary only until +# lorder is fixed to ignore thread-local variables. BUILD.AR= $(RM) $@ ; \ - $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%)| $(TSORT)` + $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)` # extra files for the clean target CLEANFILES= \ @@ -1023,6 +1038,7 @@ TIL= \ atfork.o \ cancel.o \ door_calls.o \ + err.o \ errno.o \ getctxt.o \ lwp.o \ @@ -1056,6 +1072,9 @@ TIL= \ $(TIL:%=pics/%) := CFLAGS64 += $(LIBCBASE)/threads/sparcv9.il +# This hack is needed until the sparc gcc is fixed for TLS +pics/tls_data.o := CC = env 'CW_NO_SHADOW=1' $(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc + # Files in fp, port/fp subdirectories that need base.il inline template IL= \ __flt_decim.o \ diff --git a/usr/src/lib/libc/sparcv9/gen/strcasecmp.s b/usr/src/lib/libc/sparcv9/gen/ascii_strcasecmp.s index bdf6557190..361bf1c71e 100644 --- a/usr/src/lib/libc/sparcv9/gen/strcasecmp.s +++ b/usr/src/lib/libc/sparcv9/gen/ascii_strcasecmp.s @@ -20,14 +20,11 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ - .file "strcasecmp.s" - /* - * The strcasecmp() function is a case insensitive versions of strcmp(). + * The ascii_strcasecmp() function is a case insensitive versions of strcmp(). * It assumes the ASCII character set and ignores differences in case * when comparing lower and upper case characters. In other words, it * behaves as if both strings had been converted to lower case using @@ -73,7 +70,7 @@ * }; * * int - * strcasecmp(const char *s1, const char *s2) + * ascii_strcasecmp(const char *s1, const char *s2) * { * const unsigned char *cm = (const unsigned char *)charmap; * const unsigned char *us1 = (const unsigned char *)s1; @@ -123,7 +120,7 @@ ! lower-case if they are upper-case, and are checked against ! the source string. - ENTRY(strcasecmp) + ENTRY(ascii_strcasecmp) .align 32 @@ -348,4 +345,4 @@ ret ! return restore %i0, %g0, %o0 ! return tolower(*s1) - tolower(*s2) - SET_SIZE(strcasecmp) + SET_SIZE(ascii_strcasecmp) diff --git a/usr/src/lib/libcpc/i386/event_pentium.c b/usr/src/lib/libcpc/i386/event_pentium.c index 423de87694..3619bc4036 100644 --- a/usr/src/lib/libcpc/i386/event_pentium.c +++ b/usr/src/lib/libcpc/i386/event_pentium.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Routines to capture processor-dependencies in event specification. */ @@ -33,7 +30,6 @@ #include <sys/types.h> #include <string.h> #include <strings.h> -#include <alloca.h> #include <stdlib.h> #include <stdio.h> #include <libintl.h> @@ -407,7 +403,7 @@ cpc_strtoevent(int cpuver, const char *spec, cpc_event_t *event) pic[0] = pic[1] = NULL; - opts = strcpy(alloca(strlen(spec) + 1), spec); + opts = strdupa(spec); while (*opts != '\0') { const struct keyval *kv; int idx = getsubopt(&opts, tokens, &value); @@ -629,7 +625,8 @@ cpc_eventtostr(cpc_event_t *event) xpes[0].inv, xpes[1].inv, 0, tokens[D_inv]); flagstostr(buffer, xpes[0].pc, xpes[1].pc, 0, tokens[D_pc]); - } break; + break; + } case CPC_PENTIUM_MMX: case CPC_PENTIUM: { @@ -654,7 +651,8 @@ cpc_eventtostr(cpc_event_t *event) xcesr.clk[0], xcesr.clk[1], 0, tokens[D_noedge]); flagstostr(buffer, xcesr.pc[0], xcesr.pc[1], 0, tokens[D_pc]); - } break; + break; + } default: return (NULL); } diff --git a/usr/src/lib/libcpc/sparc/event_ultra.c b/usr/src/lib/libcpc/sparc/event_ultra.c index c99e706bb2..a0e895ebea 100644 --- a/usr/src/lib/libcpc/sparc/event_ultra.c +++ b/usr/src/lib/libcpc/sparc/event_ultra.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Routines to capture processor-dependencies in event specification. */ @@ -33,7 +30,6 @@ #include <sys/types.h> #include <string.h> #include <strings.h> -#include <alloca.h> #include <stdlib.h> #include <stdio.h> #include <libintl.h> @@ -243,7 +239,7 @@ cpc_strtoevent(int cpuver, const char *spec, cpc_event_t *event) pic[0] = pic[1] = NULL; - opts = strcpy(alloca(strlen(spec) + 1), spec); + opts = strdupa(spec); while (*opts != '\0') { const struct keyval *kv; int idx = getsubopt(&opts, tokens, &value); diff --git a/usr/src/lib/libdtrace/common/dt_decl.c b/usr/src/lib/libdtrace/common/dt_decl.c index bb77984040..d2a0b29ca8 100644 --- a/usr/src/lib/libdtrace/common/dt_decl.c +++ b/usr/src/lib/libdtrace/common/dt_decl.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <strings.h> #include <stdlib.h> #include <limits.h> @@ -703,8 +700,7 @@ dt_decl_enumerator(char *s, dt_node_t *dnp) char *name; int value; - name = alloca(strlen(s) + 1); - (void) strcpy(name, s); + name = strdupa(s); free(s); if (dsp == NULL) diff --git a/usr/src/lib/libdtrace/common/dt_ident.c b/usr/src/lib/libdtrace/common/dt_ident.c index c437e0ab03..3dfa058b16 100644 --- a/usr/src/lib/libdtrace/common/dt_ident.c +++ b/usr/src/lib/libdtrace/common/dt_ident.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/sysmacros.h> #include <strings.h> #include <stdlib.h> @@ -181,8 +178,7 @@ dt_idcook_func(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args) int i = 0; assert(idp->di_iarg != NULL); - s = alloca(strlen(idp->di_iarg) + 1); - (void) strcpy(s, idp->di_iarg); + s = strdupa(idp->di_iarg); if ((p2 = strrchr(s, ')')) != NULL) *p2 = '\0'; /* mark end of parameter list string */ diff --git a/usr/src/lib/libdtrace/common/dt_parser.c b/usr/src/lib/libdtrace/common/dt_parser.c index 9aabc18565..6ad30a9ac5 100644 --- a/usr/src/lib/libdtrace/common/dt_parser.c +++ b/usr/src/lib/libdtrace/common/dt_parser.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -21,12 +20,9 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * DTrace D Language Parser * @@ -472,9 +468,9 @@ dt_node_name(const dt_node_t *dnp, char *buf, size_t len) case DT_NODE_XLATOR: (void) snprintf(buf, len, "translator <%s> (%s)", dt_type_name(dnp->dn_xlator->dx_dst_ctfp, - dnp->dn_xlator->dx_dst_type, n1, sizeof (n1)), + dnp->dn_xlator->dx_dst_type, n1, sizeof (n1)), dt_type_name(dnp->dn_xlator->dx_src_ctfp, - dnp->dn_xlator->dx_src_type, n2, sizeof (n2))); + dnp->dn_xlator->dx_src_type, n2, sizeof (n2))); break; case DT_NODE_PROG: (void) snprintf(buf, len, "%s", "program"); @@ -1440,9 +1436,9 @@ dt_node_decl(void) "\t current: %s\n\tprevious: %s\n", dmp->dm_name, dsp->ds_ident, dt_type_name(dtt.dtt_ctfp, dtt.dtt_type, - n1, sizeof (n1)), + n1, sizeof (n1)), dt_type_name(ott.dtt_ctfp, ott.dtt_type, - n2, sizeof (n2))); + n2, sizeof (n2))); } else if (!exists && dt_module_extern(dtp, dmp, dsp->ds_ident, &dtt) == NULL) { xyerror(D_UNKNOWN, @@ -1452,7 +1448,7 @@ dt_node_decl(void) dt_dprintf("extern %s`%s type=<%s>\n", dmp->dm_name, dsp->ds_ident, dt_type_name(dtt.dtt_ctfp, dtt.dtt_type, - n1, sizeof (n1))); + n1, sizeof (n1))); } break; } @@ -1756,8 +1752,7 @@ dt_node_offsetof(dt_decl_t *ddp, char *s) ctf_id_t type; uint_t kind; - name = alloca(strlen(s) + 1); - (void) strcpy(name, s); + name = strdupa(s); free(s); err = dt_decl_type(ddp, &dtt); diff --git a/usr/src/lib/libdtrace/common/dt_pragma.c b/usr/src/lib/libdtrace/common/dt_pragma.c index a8bab85c00..9cb3c3b8d6 100644 --- a/usr/src/lib/libdtrace/common/dt_pragma.c +++ b/usr/src/lib/libdtrace/common/dt_pragma.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <assert.h> #include <strings.h> #include <alloca.h> @@ -337,8 +334,7 @@ dt_pragma_option(const char *prname, dt_node_t *dnp) "superfluous arguments specified for #pragma %s\n", prname); } - opt = alloca(strlen(dnp->dn_string) + 1); - (void) strcpy(opt, dnp->dn_string); + opt = strdupa(dnp->dn_string); if ((val = strchr(opt, '=')) != NULL) *val++ = '\0'; diff --git a/usr/src/lib/libdtrace/common/dt_string.c b/usr/src/lib/libdtrace/common/dt_string.c index 3a5315eef9..782d66c2b8 100644 --- a/usr/src/lib/libdtrace/common/dt_string.c +++ b/usr/src/lib/libdtrace/common/dt_string.c @@ -29,23 +29,6 @@ #include <ctype.h> #include <dt_string.h> -#include <dt_impl.h> - -/* - * Create a copy of string s, but only duplicate the first n bytes. - */ -char * -strndup(const char *s, size_t n) -{ - char *s2 = malloc(n + 1); - - if (s2 == NULL) - longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM); - - (void) strncpy(s2, s, n); - s2[n] = '\0'; - return (s2); -} /* * Transform string s inline, converting each embedded C escape sequence string diff --git a/usr/src/lib/libdtrace/common/dt_string.h b/usr/src/lib/libdtrace/common/dt_string.h index 1fd412b1ad..a9bb7a1eb7 100644 --- a/usr/src/lib/libdtrace/common/dt_string.h +++ b/usr/src/lib/libdtrace/common/dt_string.h @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,16 +18,14 @@ * * CDDL HEADER END */ + /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _DT_STRING_H #define _DT_STRING_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <strings.h> @@ -36,7 +33,6 @@ extern "C" { #endif -extern char *strndup(const char *, size_t); extern size_t stresc2chr(char *); extern char *strchr2esc(const char *, size_t); extern const char *strbasename(const char *); diff --git a/usr/src/lib/libdtrace/common/dt_subr.c b/usr/src/lib/libdtrace/common/dt_subr.c index 97221c84d6..f586504cfb 100644 --- a/usr/src/lib/libdtrace/common/dt_subr.c +++ b/usr/src/lib/libdtrace/common/dt_subr.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/sysmacros.h> @@ -222,8 +221,7 @@ dtrace_str2attr(const char *str, dtrace_attribute_t *attr) return (-1); /* invalid function arguments */ *attr = _dtrace_maxattr; - p = alloca(strlen(str) + 1); - (void) strcpy(p, str); + p = strdupa(str); if ((p = dt_getstrattr(p, &q)) == NULL) return (0); diff --git a/usr/src/lib/libnsl/dial/sysfiles.c b/usr/src/lib/libnsl/dial/sysfiles.c index 0a69da143d..d06462db71 100644 --- a/usr/src/lib/libnsl/dial/sysfiles.c +++ b/usr/src/lib/libnsl/dial/sysfiles.c @@ -19,14 +19,13 @@ * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + #include "mt.h" #include "uucp.h" @@ -64,7 +63,7 @@ static int namematch(const char *label, char *line, const char *name); static int nextdialers(void); static int nextdevices(void); static int nextsystems(void); -static int getline(FILE *, char *); +static int getaline(FILE *, char *); /* pointer arrays might be dynamically allocated */ static char *Systems[64]; /* list of Systems files */ @@ -189,7 +188,7 @@ scansys(const char *service) } if ((f = fopen(SYSFILES, "rF")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Sysfiles */ /* strtok's of this buf continue in tokenize() */ tok = strtok(buf, " \t"); @@ -239,7 +238,7 @@ scancfg(char *service, char *device) expecttime = EXPECTTIME; if ((f = fopen(DEVCONFIG, "rF")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Devconfig */ /* strtok's of this buf continue in tokenize() */ tok = strtok(buf, " \t"); @@ -264,7 +263,7 @@ scancfg(char *service, char *device) */ static int -getline(FILE *f, char *line) +getaline(FILE *f, char *line) { char *lptr, *lend; lptr = line; @@ -734,7 +733,7 @@ setconfig(void) extern char _ProtoCfg[]; if ((f = fopen(CONFIG, "rF")) != 0) { - while (getline(f, buf) > 0) { + while (getaline(f, buf) > 0) { /* got a (logical) line from Config file */ tok = strtok(buf, " \t"); if ((tok != NULL) && (*tok != '#')) { diff --git a/usr/src/lib/libpicltree/picltree.c b/usr/src/lib/libpicltree/picltree.c index 101defc4d0..6a9260b13c 100644 --- a/usr/src/lib/libpicltree/picltree.c +++ b/usr/src/lib/libpicltree/picltree.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,13 +18,11 @@ * * CDDL HEADER END */ + /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This module implements the PTree interface and the PICL to PTree calls */ @@ -2796,12 +2793,10 @@ get_child_by_path(picl_nodehdl_t rooth, char *prl, if (prl == NULL) return (PICL_FAILURE); - path = alloca(strlen(prl) + 1); + path = strdupa(prl); if (path == NULL) return (PICL_FAILURE); - (void) strcpy(path, prl); - plist = NULL; nodename = NULL; baddr = NULL; @@ -2912,10 +2907,9 @@ ptree_get_node_by_path(const char *piclprl, picl_nodehdl_t *handle) int npflg; /* namepath flag */ - path = alloca(strlen(piclprl) + 1); + path = strdupa(piclprl); if (path == NULL) return (PICL_FAILURE); - (void) strcpy(path, piclprl); npflg = 1; /* default */ defprop = path; diff --git a/usr/src/lib/libproc/common/proc_arg.c b/usr/src/lib/libproc/common/proc_arg.c index d866127a57..c546e54cc6 100644 --- a/usr/src/lib/libproc/common/proc_arg.c +++ b/usr/src/lib/libproc/common/proc_arg.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/types.h> @@ -180,8 +179,7 @@ proc_grab_common(const char *arg, const char *path, int oflag, int gflag, *perr = G_BADLWPS; return (NULL); } - core = alloca(strlen(arg) + 1); - (void) strcpy(core, arg); + core = strdupa(arg); if ((Pr = Pfgrab_core(fd, path == NULL ? dirname(core) : path, perr)) != NULL) { if (psp) { @@ -216,8 +214,7 @@ proc_grab_common(const char *arg, const char *path, int oflag, int gflag, } if ((oflag & PR_ARG_CORES) && (fd = open_core(arg, perr)) != -1) { - core = alloca(strlen(arg) + 1); - (void) strcpy(core, arg); + core = strdupa(arg); if ((Pr = Pfgrab_core(fd, path == NULL ? dirname(core) : path, perr)) != NULL) { if (psp) { diff --git a/usr/src/lib/libproc/common/proc_names.c b/usr/src/lib/libproc/common/proc_names.c index 3b7d1e25bf..aa92006fbb 100644 --- a/usr/src/lib/libproc/common/proc_names.c +++ b/usr/src/lib/libproc/common/proc_names.c @@ -28,7 +28,6 @@ #include <string.h> #undef __EXTENSIONS__ #include <signal.h> -#include <alloca.h> #include <errno.h> #include "libproc.h" @@ -613,7 +612,7 @@ proc_sysset2str(const sysset_t *set, const char *delim, int m, char * proc_str2fltset(const char *s, const char *delim, int m, fltset_t *set) { - char *p, *q, *t = alloca(strlen(s) + 1); + char *p, *q, *t; int flt; if (m) { @@ -622,7 +621,7 @@ proc_str2fltset(const char *s, const char *delim, int m, fltset_t *set) prfillset(set); } - (void) strcpy(t, s); + t = strdupa(s); for (p = strtok_r(t, delim, &q); p != NULL; p = strtok_r(NULL, delim, &q)) { @@ -646,7 +645,7 @@ proc_str2fltset(const char *s, const char *delim, int m, fltset_t *set) char * proc_str2sigset(const char *s, const char *delim, int m, sigset_t *set) { - char *p, *q, *t = alloca(strlen(s) + 1); + char *p, *q, *t; int sig; if (m) { @@ -655,7 +654,7 @@ proc_str2sigset(const char *s, const char *delim, int m, sigset_t *set) prfillset(set); } - (void) strcpy(t, s); + t = strdupa(s); for (p = strtok_r(t, delim, &q); p != NULL; p = strtok_r(NULL, delim, &q)) { @@ -679,7 +678,7 @@ proc_str2sigset(const char *s, const char *delim, int m, sigset_t *set) char * proc_str2sysset(const char *s, const char *delim, int m, sysset_t *set) { - char *p, *q, *t = alloca(strlen(s) + 1); + char *p, *q, *t; int sys; if (m) { @@ -688,7 +687,7 @@ proc_str2sysset(const char *s, const char *delim, int m, sysset_t *set) prfillset(set); } - (void) strcpy(t, s); + t = strdupa(s); for (p = strtok_r(t, delim, &q); p != NULL; p = strtok_r(NULL, delim, &q)) { diff --git a/usr/src/lib/libresolv2/include/port_after.h b/usr/src/lib/libresolv2/include/port_after.h index 4b1b4a1f69..c3abf4b334 100644 --- a/usr/src/lib/libresolv2/include/port_after.h +++ b/usr/src/lib/libresolv2/include/port_after.h @@ -1,9 +1,7 @@ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. */ - /* * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2001-2003 Internet Software Consortium. @@ -65,7 +63,7 @@ const char *isc_strerror(int); #undef HAS_IN_ADDR6 #define HAVE_SOCKADDR_STORAGE 1 #undef NEED_GETTIMEOFDAY -#undef HAVE_STRNDUP +#define HAVE_STRNDUP #undef USE_FIONBIO_IOCTL #undef INNETGR_ARGS @@ -538,4 +536,4 @@ char *vsprintf(char *, const char *, va_list); /* Solaris-specific changes */ #include "sunw_port_after.h" -#endif +#endif /* port_after_h */ diff --git a/usr/src/lib/nsswitch/files/common/gethostent.c b/usr/src/lib/nsswitch/files/common/gethostent.c index c2d9530a86..aa8e9da993 100644 --- a/usr/src/lib/nsswitch/files/common/gethostent.c +++ b/usr/src/lib/nsswitch/files/common/gethostent.c @@ -20,12 +20,9 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <netdb.h> #include "files_common.h" #include <string.h> @@ -42,7 +39,6 @@ static int check_name(nss_XbyY_args_t *, const char *, int, int, const char **, int *, void *, int *); static char *do_aliases(); -static char *strcasestr(const char *as1, const char *as2); nss_status_t __nss_files_XY_hostbyname(); int __nss_files_2herrno(); static int __nss_files_get_addr(int, const char *, int, @@ -680,37 +676,6 @@ __nss_files_XY_hostbyname(be, args, filter, type) return (res); } -/* - * A case-insensitive version of strstr(). - */ -static char * -strcasestr(const char *as1, const char *as2) -{ - int c2; - register const char *tptr; - register const char *s1, *s2; - - s1 = as1; - s2 = as2; - - if (s2 == NULL || *s2 == '\0') - return (0); - - while (*s1) { - if (tolower(*s1++) == tolower(c2 = *s2)) { - tptr = s1; - while ((tolower(c2 = *++s2) == - tolower(*s1++)) && c2 != 0) - ; - if (c2 == 0) - return ((char *)tptr - 1); - s1 = tptr; - s2 = as2; - } - } - return (0); -} - static char * do_aliases(struct hostent *hp, char *abuf, char *end) diff --git a/usr/src/lib/print/libpapi-common/common/uri.c b/usr/src/lib/print/libpapi-common/common/uri.c index 303005ab94..31f6ce4eff 100644 --- a/usr/src/lib/print/libpapi-common/common/uri.c +++ b/usr/src/lib/print/libpapi-common/common/uri.c @@ -20,9 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ /* $Id: uri.c 146 2006-03-24 00:26:54Z njacobs $ */ @@ -37,23 +35,6 @@ #include <errno.h> #include "uri.h" -static char * -strndup(char *string, size_t length) -{ - char *result = NULL; - - if (length > 0) { - length++; - - - if ((result = calloc(1, length)) != NULL) - (void) strlcat(result, string, length); - } - - return (result); -} - - /* * This will handle the following forms: * scheme:scheme_data @@ -91,7 +72,8 @@ uri_from_string(char *string, uri_t **uri) string = ptr + 3; /* skip the :// */ if ((path = end = strchr(string, '/')) == NULL) - for (end = string; *end != '\0'; end++); + for (end = string; *end != '\0'; end++) + continue; u->host_part = strndup(string, end - string); @@ -101,7 +83,7 @@ uri_from_string(char *string, uri_t **uri) u->user_part = strndup(string, host-string); /* host+1 to end is the host part */ u->host_part = strndup(host + 1, - end - (host+1)); + end - (host+1)); user = string; host++; break; @@ -113,7 +95,7 @@ uri_from_string(char *string, uri_t **uri) for (password = user; (password < host - 1); password++) if (*password == ':') { u->password = strndup(password + 1, - host - password - 2); + host - password - 2); break; } u->user = strndup(user, password - user); @@ -146,13 +128,15 @@ uri_from_string(char *string, uri_t **uri) if ((query != NULL) && (*query != '\0')) { u->query = strdup(query + 1); end = query; - } else - for (end = path; *end != '\0'; end++); + } else { + for (end = path; *end != '\0'; end++) + continue; + } fragment = strrchr(name, '#'); if ((fragment != NULL) && (*fragment != '\0')) { u->fragment = strndup(fragment + 1, - end - fragment - 1); + end - fragment - 1); end = fragment; } @@ -215,7 +199,7 @@ uri_to_string(uri_t *uri, char *buffer, size_t buflen) (uri->query ? uri->query : "")); } else { (void) snprintf(buffer, buflen, "%s:%s", uri->scheme, - uri->scheme_part); + uri->scheme_part); } return (0); diff --git a/usr/src/lib/scsi/libses/common/ses_plugin.c b/usr/src/lib/scsi/libses/common/ses_plugin.c index 62c00b4ebc..bb62c92ff7 100644 --- a/usr/src/lib/scsi/libses/common/ses_plugin.c +++ b/usr/src/lib/scsi/libses/common/ses_plugin.c @@ -313,12 +313,9 @@ ses_plugin_load_dir(ses_target_t *tp, const char *pluginroot) * Create a local copy of the vendor/product/revision, strip out any * questionable characters, and then attempt to load each plugin. */ - vendor = alloca(strlen(libscsi_vendor(tp->st_target)) + 1); - product = alloca(strlen(libscsi_product(tp->st_target)) + 1); - revision = alloca(strlen(libscsi_revision(tp->st_target)) + 1); - (void) strcpy(vendor, libscsi_vendor(tp->st_target)); - (void) strcpy(product, libscsi_product(tp->st_target)); - (void) strcpy(revision, libscsi_revision(tp->st_target)); + vendor = strdupa(libscsi_vendor(tp->st_target)); + product = strdupa(libscsi_product(tp->st_target)); + revision = strdupa(libscsi_revision(tp->st_target)); ses_plugin_cleanstr(vendor); ses_plugin_cleanstr(product); diff --git a/usr/src/lib/scsi/libsmp/common/smp_plugin.c b/usr/src/lib/scsi/libsmp/common/smp_plugin.c index 3df5e6e649..98b1548e4e 100644 --- a/usr/src/lib/scsi/libsmp/common/smp_plugin.c +++ b/usr/src/lib/scsi/libsmp/common/smp_plugin.c @@ -31,7 +31,6 @@ #include <scsi/libsmp.h> #include <scsi/libsmp_plugin.h> -#include <alloca.h> #include <dlfcn.h> #include <link.h> #include <dirent.h> @@ -319,18 +318,13 @@ smp_plugin_load_dir(smp_target_t *tp, const char *pluginroot) return (0); if (tp->st_component_vendor != NULL) { - c_vendor = alloca(strlen(tp->st_component_vendor) + 1); - (void) strcpy(c_vendor, tp->st_component_vendor); + c_vendor = strdupa(tp->st_component_vendor); smp_plugin_cleanstr(c_vendor); } - vendor = alloca(strlen(tp->st_vendor) + 1); - product = alloca(strlen(tp->st_product) + 1); - revision = alloca(strlen(tp->st_revision) + 1); - - (void) strcpy(vendor, tp->st_vendor); - (void) strcpy(product, tp->st_product); - (void) strcpy(revision, tp->st_revision); + vendor = strdupa(tp->st_vendor); + product = strdupa(tp->st_product); + revision = strdupa(tp->st_revision); smp_plugin_cleanstr(vendor); smp_plugin_cleanstr(product); diff --git a/usr/src/lib/smbsrv/libmlsvc/sparc/Makefile b/usr/src/lib/smbsrv/libmlsvc/sparc/Makefile index 710c9eb3dd..afc42f3dbc 100644 --- a/usr/src/lib/smbsrv/libmlsvc/sparc/Makefile +++ b/usr/src/lib/smbsrv/libmlsvc/sparc/Makefile @@ -19,14 +19,16 @@ # CDDL HEADER END # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # include ../Makefile.com +# With compiling with gcc, the symbol table goes over +# the limit for Kpic, so we add -KPIC here. +$(__GNUC)sparc_C_PICFLAGS = -K PIC +$(__GNUC)sparc_CC_PICFLAGS = -KPIC + DYNFLAGS += -R/usr/lib/smbsrv install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/tools/cscope-fast/command.c b/usr/src/tools/cscope-fast/command.c index 4744178d0e..4e19850705 100644 --- a/usr/src/tools/cscope-fast/command.c +++ b/usr/src/tools/cscope-fast/command.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ /* * cscope - interactive C symbol or text cross-reference @@ -235,7 +231,7 @@ command(int commandc) } if (c != '\r' && c != '\n' && c != KEY_ENTER && c != KEY_BREAK && - getline(newpat, COLS - sizeof (appendprompt), c, + getaline(newpat, COLS - sizeof (appendprompt), c, NO) > 0) { shellpath(filename, sizeof (filename), newpat); if ((file = fopen(filename, s)) == NULL) { @@ -256,7 +252,7 @@ command(int commandc) case '<': /* read lines from a file */ (void) move(PRLINE, 0); (void) addstr(readprompt); - if (getline(newpat, COLS - sizeof (readprompt), '\0', + if (getaline(newpat, COLS - sizeof (readprompt), '\0', NO) > 0) { clearprompt(); shellpath(filename, sizeof (filename), newpat); @@ -278,7 +274,7 @@ command(int commandc) /* get the shell command */ (void) move(PRLINE, 0); (void) addstr(pipeprompt); - if (getline(newpat, + if (getaline(newpat, COLS - sizeof (pipeprompt), '\0', NO) == 0) { clearprompt(); return (NO); @@ -391,7 +387,7 @@ command(int commandc) } else { (void) move(PRLINE, 0); (void) addstr(selectionprompt); - if (getline(newpat, + if (getaline(newpat, COLS - sizeof (selectionprompt), commandc, NO) > 0 && (i = atoi(newpat)) > 0) { @@ -402,7 +398,7 @@ command(int commandc) } else if (isprint(commandc)) { /* this is the start of a pattern */ ispat: - if (getline(newpat, COLS - fldcolumn - 1, commandc, + if (getaline(newpat, COLS - fldcolumn - 1, commandc, caseless) > 0) { (void) strcpy(pattern, newpat); resetcmd(); /* reset history */ @@ -412,7 +408,7 @@ repeat: /* prompt for the new text */ (void) move(PRLINE, 0); (void) addstr(toprompt); - (void) getline(newpat, + (void) getaline(newpat, COLS - sizeof (toprompt), '\0', NO); } /* search for the pattern */ @@ -594,7 +590,7 @@ changestring(void) clearprompt(); (void) move(PRLINE, 0); (void) addstr(selectionprompt); - if (getline(buf, + if (getaline(buf, COLS - sizeof (selectionprompt), c, NO) > 0 && (i = atoi(buf)) > 0) { diff --git a/usr/src/tools/cscope-fast/global.h b/usr/src/tools/cscope-fast/global.h index 01ddae4dfb..2d963983f0 100644 --- a/usr/src/tools/cscope-fast/global.h +++ b/usr/src/tools/cscope-fast/global.h @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,23 +18,20 @@ * * CDDL HEADER END */ + +/* + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + */ + /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ - /* * cscope - interactive C symbol cross-reference * * global type, data, and function definitions */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - #include <ctype.h> /* isalpha, isdigit, etc. */ #include <signal.h> /* SIGINT and SIGQUIT */ #include <stdio.h> /* standard I/O package */ @@ -273,7 +269,7 @@ HISTORY *nextcmd(void); void catchint(int sig); int ungetch(int c); int mygetch(void); -int getline(char s[], size_t size, int firstchar, BOOL iscaseless); +int getaline(char s[], size_t size, int firstchar, BOOL iscaseless); void askforchar(void); void askforreturn(void); void shellpath(char *out, int limit, char *in); diff --git a/usr/src/tools/cscope-fast/input.c b/usr/src/tools/cscope-fast/input.c index 63e0bb4e22..7d3f7f7946 100644 --- a/usr/src/tools/cscope-fast/input.c +++ b/usr/src/tools/cscope-fast/input.c @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -19,16 +18,13 @@ * * CDDL HEADER END */ -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ /* * cscope - interactive C symbol cross-reference @@ -91,7 +87,7 @@ mygetch(void) /* get a line from the terminal in non-canonical mode */ int -getline(char s[], size_t size, int firstchar, BOOL iscaseless) +getaline(char s[], size_t size, int firstchar, BOOL iscaseless) { int c, i = 0; int j; diff --git a/usr/src/ucbcmd/users/users.c b/usr/src/ucbcmd/users/users.c index 4df492ea41..707bcff8ba 100644 --- a/usr/src/ucbcmd/users/users.c +++ b/usr/src/ucbcmd/users/users.c @@ -1,20 +1,16 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * users */ @@ -28,7 +24,6 @@ static char **names; static char **namp; -static char *strndup(char *p, int n); static int scmp(const void *p, const void *q); static void summary(void); @@ -59,7 +54,7 @@ main(int argc, char **argv) if (nusers == bufflen) { bufflen *= 2; names = (char **)realloc(names, - bufflen * sizeof (char *)); + bufflen * sizeof (char *)); namp = names + nusers; } *namp++ = strndup(utmpx->ut_name, sizeof (utmpx->ut_name)); @@ -72,17 +67,6 @@ main(int argc, char **argv) return (0); } -static char * -strndup(char *p, int n) -{ - - register char *x; - x = malloc(n + 1); - (void) strlcpy(x, p, n + 1); - return (x); - -} - static int scmp(const void *p, const void *q) { diff --git a/usr/src/uts/common/inet/ipf/ipf.h b/usr/src/uts/common/inet/ipf/ipf.h index 559349e3d9..1919d5da3f 100644 --- a/usr/src/uts/common/inet/ipf/ipf.h +++ b/usr/src/uts/common/inet/ipf/ipf.h @@ -6,15 +6,12 @@ * @(#)ipf.h 1.12 6/5/96 * $Id: ipf.h,v 2.71.2.7 2005/06/12 07:18:31 darrenr Exp $ * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef __IPF_H__ #define __IPF_H__ -#pragma ident "%Z%%M% %I% %E% SMI" - #if defined(__osf__) # define radix_mask ipf_radix_mask # define radix_node ipf_radix_node @@ -208,7 +205,7 @@ extern int gethost __P((char *, i6addr_t *, int)); extern int getport __P((struct frentry *, char *, u_short *)); extern int getportproto __P((char *, int)); extern int getproto __P((char *)); -extern char *getline __P((char *, size_t, FILE *, int *)); +extern char *getaline __P((char *, size_t, FILE *, int *)); extern int genmask __P((char *, u_32_t *)); extern char *getnattype __P((struct nat *, int)); extern char *getsumd __P((u_32_t)); diff --git a/usr/src/uts/common/io/audio/drv/audioemu10k/dsp/asm10k.c b/usr/src/uts/common/io/audio/drv/audioemu10k/dsp/asm10k.c index 81a51c408d..0a4ef058a3 100644 --- a/usr/src/uts/common/io/audio/drv/audioemu10k/dsp/asm10k.c +++ b/usr/src/uts/common/io/audio/drv/audioemu10k/dsp/asm10k.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ /* @@ -167,7 +166,7 @@ static int ngpr = 0; static char *infile; static int -getline(FILE *input, char **tokens) +getaline(FILE *input, char **tokens) { char *s, *ls; static char *stmt = NULL, *lasts = NULL; @@ -1040,7 +1039,7 @@ main(int argc, char *argv[]) init_compiler(); - while ((tokcnt = getline(input, tokens)) != -1) { + while ((tokcnt = getaline(input, tokens)) != -1) { /* skip empty lines */ if (tokcnt == 0) { continue; |