Skip to content

Commit

Permalink
5428 provide fts(), reallocarray(), and strtonum()
Browse files Browse the repository at this point in the history
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Joshua M. Clulow <josh@sysmgr.org>
  • Loading branch information
Yuri Pankov authored and jclulow committed Jun 13, 2017
1 parent 61304e4 commit 4585130
Show file tree
Hide file tree
Showing 42 changed files with 3,964 additions and 1,782 deletions.
2 changes: 1 addition & 1 deletion usr/src/cmd/cmd-inet/usr.bin/nc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#

PROG= nc
OBJS= atomicio.o netcat.o socks.o strtonum.o
OBJS= atomicio.o netcat.o socks.o

SRCS= $(OBJS:%.o=%.c)

Expand Down
15 changes: 0 additions & 15 deletions usr/src/cmd/cmd-inet/usr.bin/nc/THIRDPARTYLICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,3 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Re-written nc(1) for OpenBSD. Original implementation by
*Hobbit* <hobbit@avian.org>.

Copyright (c) 2004 Ted Unangst and Todd Miller
All rights reserved.

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1 change: 0 additions & 1 deletion usr/src/cmd/cmd-inet/usr.bin/nc/netcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
#include <signal.h>

#include "atomicio.h"
#include "strtonum.h"

#ifndef SUN_LEN
#define SUN_LEN(su) \
Expand Down
31 changes: 0 additions & 31 deletions usr/src/cmd/cmd-inet/usr.bin/nc/strtonum.h

This file was deleted.

6 changes: 2 additions & 4 deletions usr/src/cmd/mandoc/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
# Copyright 2016 Nexenta Systems, Inc.
# Copyright 2017 Nexenta Systems, Inc.
#

PROG= mandoc
Expand Down Expand Up @@ -61,9 +61,7 @@ OBJS= att.o \
term_ps.o \
tree.o

OBJS += compat_ohash.o \
compat_reallocarray.o \
compat_strtonum.o
OBJS += compat_ohash.o

CFLAGS += $(CC_VERBOSE)
C99MODE = $(C99_ENABLE)
Expand Down
76 changes: 0 additions & 76 deletions usr/src/cmd/mandoc/compat_strtonum.c

This file was deleted.

3 changes: 2 additions & 1 deletion usr/src/cmd/mdb/common/mdb/mdb_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -2785,7 +2785,8 @@ cmd_delete(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
spec.spec_base = mdb_get_dot();
else if (argv->a_type == MDB_TYPE_STRING &&
strcmp(argv->a_un.a_str, "all") != 0)
spec.spec_id = (int)(intmax_t)strtonum(argv->a_un.a_str, 10);
spec.spec_id = (int)(intmax_t)mdb_strtonum(argv->a_un.a_str,
10);
else if (argv->a_type == MDB_TYPE_IMMEDIATE)
spec.spec_id = (int)(intmax_t)argv->a_un.a_val;

Expand Down
4 changes: 1 addition & 3 deletions usr/src/cmd/mdb/common/mdb/mdb_evset.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
* Use is subject to license terms.
*/

#pragma ident "%Z%%M% %I% %E% SMI"

#include <mdb/mdb_target.h>
#include <mdb/mdb_modapi.h>
#include <mdb/mdb_string.h>
Expand Down Expand Up @@ -110,7 +108,7 @@ cmd_evset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
}
} else if (argv->a_un.a_str[0] != '-') {
idv[idc++] = (int)(intmax_t)
strtonum(argv->a_un.a_str, 10);
mdb_strtonum(argv->a_un.a_str, 10);
} else
return (DCMD_USAGE);
} else
Expand Down
14 changes: 7 additions & 7 deletions usr/src/cmd/mdb/common/mdb/mdb_lex.l
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ RGX_COMMENT "//".*\n
* Immediate value -- in the format list, all immediates
* are assumed to be in decimal.
*/
yylval.l_immediate = strtonum(yytext, 10);
yylval.l_immediate = mdb_strtonum(yytext, 10);
return (MDB_TOK_IMMEDIATE);
}

Expand Down Expand Up @@ -415,7 +415,7 @@ RGX_COMMENT "//".*\n
/*
* Binary immediate value.
*/
yylval.l_immediate = strtonum(yytext + 2, 2);
yylval.l_immediate = mdb_strtonum(yytext + 2, 2);
return (MDB_TOK_IMMEDIATE);
}

Expand All @@ -424,7 +424,7 @@ RGX_COMMENT "//".*\n
/*
* Octal immediate value.
*/
yylval.l_immediate = strtonum(yytext + 2, 8);
yylval.l_immediate = mdb_strtonum(yytext + 2, 8);
return (MDB_TOK_IMMEDIATE);
}

Expand All @@ -443,7 +443,7 @@ RGX_COMMENT "//".*\n
if ((p = strsplit(yytext, '.')) == NULL)
yyerror("internal scanning error -- expected '.'\n");

d = (double)strtonum(yytext + 2, 10);
d = (double)mdb_strtonum(yytext + 2, 10);

for (i = 0; (c = *p++) != '\0'; i++)
d = d * 10 + c - '0';
Expand All @@ -461,7 +461,7 @@ RGX_COMMENT "//".*\n
/*
* Decimal immediate value.
*/
yylval.l_immediate = strtonum(yytext + 2, 10);
yylval.l_immediate = mdb_strtonum(yytext + 2, 10);
return (MDB_TOK_IMMEDIATE);
}

Expand All @@ -470,7 +470,7 @@ RGX_COMMENT "//".*\n
/*
* Hexadecimal value.
*/
yylval.l_immediate = strtonum(yytext + 2, 16);
yylval.l_immediate = mdb_strtonum(yytext + 2, 16);
return (MDB_TOK_IMMEDIATE);
}

Expand All @@ -488,7 +488,7 @@ RGX_COMMENT "//".*\n
MDB_TGT_OBJ_EVERY, yytext, &sym, NULL) == 0)
yylval.l_immediate = (uintmax_t)sym.st_value;
else
yylval.l_immediate = strtonum(yytext, mdb.m_radix);
yylval.l_immediate = mdb_strtonum(yytext, mdb.m_radix);
return (MDB_TOK_IMMEDIATE);
}

Expand Down
4 changes: 2 additions & 2 deletions usr/src/cmd/mdb/common/mdb/mdb_modapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ mdb_lookup_by_obj(const char *obj, const char *name, GElf_Sym *sym)

int
mdb_lookup_by_addr(uintptr_t addr, uint_t flags, char *buf,
size_t nbytes, GElf_Sym *sym)
size_t nbytes, GElf_Sym *sym)
{
return (mdb_tgt_lookup_by_addr(mdb.m_target, addr, flags,
buf, nbytes, sym, NULL));
Expand Down Expand Up @@ -246,7 +246,7 @@ mdb_strtoull(const char *s)
}
}

return (strtonum(s, radix));
return (mdb_strtonum(s, radix));
}

size_t
Expand Down
4 changes: 1 addition & 3 deletions usr/src/cmd/mdb/common/mdb/mdb_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
* Use is subject to license terms.
*/

#pragma ident "%Z%%M% %I% %E% SMI"

#include <netinet/in.h>
#include <limits.h>
#include <sys/types.h>
Expand Down Expand Up @@ -110,7 +108,7 @@ numtostr(uintmax_t uvalue, int base, uint_t flags)
* error message and longjmp back to the main loop using yyerror().
*/
uintmax_t
strtonum(const char *s, int base)
mdb_strtonum(const char *s, int base)
{
uintmax_t multmax = (uintmax_t)ULLONG_MAX / (uintmax_t)(uint_t)base;
uintmax_t val = 0;
Expand Down
4 changes: 1 addition & 3 deletions usr/src/cmd/mdb/common/mdb/mdb_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#ifndef _MDB_STRING_H
#define _MDB_STRING_H

#pragma ident "%Z%%M% %I% %E% SMI"

#include <sys/types.h>
#include <strings.h>

Expand All @@ -42,7 +40,7 @@ extern "C" {
#define NTOS_SHOWBASE 0x8 /* Show base under appropriate circumstances */

extern const char *numtostr(uintmax_t, int, uint_t);
extern uintmax_t strtonum(const char *, int);
extern uintmax_t mdb_strtonum(const char *, int);
extern ulong_t strntoul(const char *, size_t, int);
extern int strisnum(const char *);
extern int strisbasenum(const char *);
Expand Down
24 changes: 14 additions & 10 deletions usr/src/head/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,29 @@
# Use is subject to license terms.
# Copyright 2013 Garrett D'Amore <garrett@damore.org>
# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
# Copyright 2016 Nexenta Systems, Inc.
# Copyright 2017 Nexenta Systems, Inc.
#

#
# head/Makefile
#
# include global definitions
include ../Makefile.master

sparc_HDRS=
i386_HDRS= stack_unwind.h

# Headers are listed one per line so that TeamWare can auto-merge most changes

KRB5HDRS= mit_copyright.h mit-sipb-copyright.h
KRB5HDRS= \
mit_copyright.h \
mit-sipb-copyright.h

ATTRDB_HDRS= secdb.h auth_attr.h exec_attr.h prof_attr.h user_attr.h \
auth_list.h
ATTRDB_HDRS= \
auth_attr.h \
auth_list.h \
exec_attr.h \
prof_attr.h \
secdb.h \
user_attr.h

HDRS= $($(MACH)_HDRS) $(ATTRDB_HDRS) \
HDRS= $($(MACH)_HDRS) \
$(ATTRDB_HDRS) \
aio.h \
alloca.h \
apptrace.h \
Expand Down Expand Up @@ -81,6 +84,7 @@ HDRS= $($(MACH)_HDRS) $(ATTRDB_HDRS) \
floatingpoint.h \
fmtmsg.h \
fnmatch.h \
fts.h \
ftw.h \
gelf.h \
getopt.h \
Expand Down
Loading

0 comments on commit 4585130

Please sign in to comment.