aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-02-28 21:30:26 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-02-28 21:30:26 +0000
commitbe64968040dcbab18ffe3dc9c14966e681f8ff83 (patch)
treeb8f2af715239a6cc428902c60040eec226fbc2cc /usr.bin
parent2e477b5e5e1f41e19378ba3a1e5f23ab60b017f6 (diff)
parentc4e929946ca6e5fa4f39b8966d21080bf164f2e8 (diff)
downloadsrc-be64968040dcbab18ffe3dc9c14966e681f8ff83.tar.gz
src-be64968040dcbab18ffe3dc9c14966e681f8ff83.zip
Merge ^/head r314270 through r314419.
Notes
Notes: svn path=/projects/clang400-import/; revision=314421
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/dc/bcode.c55
-rw-r--r--usr.bin/dc/dc.16
-rw-r--r--usr.bin/dc/dc.c4
-rw-r--r--usr.bin/dc/stack.c23
-rw-r--r--usr.bin/fortune/datfiles/freebsd-tips136
5 files changed, 163 insertions, 61 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c
index 52ce85c00c9d..e6a980e4ac23 100644
--- a/usr.bin/dc/bcode.c
+++ b/usr.bin/dc/bcode.c
@@ -69,6 +69,7 @@ static __inline struct number *pop_number(void);
static __inline char *pop_string(void);
static __inline void clear_stack(void);
static __inline void print_tos(void);
+static void print_err(void);
static void pop_print(void);
static void pop_printn(void);
static __inline void print_stack(void);
@@ -198,6 +199,7 @@ static const struct jump_entry jump_table_data[] = {
{ 'a', to_ascii },
{ 'c', clear_stack },
{ 'd', dup },
+ { 'e', print_err },
{ 'f', print_stack },
{ 'i', set_ibase },
{ 'k', set_scale },
@@ -508,6 +510,18 @@ print_tos(void)
}
static void
+print_err(void)
+{
+ struct value *value = tos();
+ if (value != NULL) {
+ print_value(stderr, value, "", bmachine.obase);
+ (void)putc('\n', stderr);
+ }
+ else
+ warnx("stack empty");
+}
+
+static void
pop_print(void)
{
struct value *value = pop();
@@ -960,9 +974,8 @@ badd(void)
struct number *a, *b, *r;
a = pop_number();
- if (a == NULL) {
+ if (a == NULL)
return;
- }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -987,9 +1000,8 @@ bsub(void)
struct number *a, *b, *r;
a = pop_number();
- if (a == NULL) {
+ if (a == NULL)
return;
- }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1035,9 +1047,8 @@ bmul(void)
struct number *a, *b, *r;
a = pop_number();
- if (a == NULL) {
+ if (a == NULL)
return;
- }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1060,9 +1071,8 @@ bdiv(void)
u_int scale;
a = pop_number();
- if (a == NULL) {
+ if (a == NULL)
return;
- }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1097,9 +1107,8 @@ bmod(void)
u_int scale;
a = pop_number();
- if (a == NULL) {
+ if (a == NULL)
return;
- }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1134,9 +1143,8 @@ bdivmod(void)
u_int scale;
a = pop_number();
- if (a == NULL) {
+ if (a == NULL)
return;
- }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1176,9 +1184,8 @@ bexp(void)
u_int rscale;
p = pop_number();
- if (p == NULL) {
+ if (p == NULL)
return;
- }
a = pop_number();
if (a == NULL) {
push_number(p);
@@ -1299,9 +1306,8 @@ bsqrt(void)
onecount = 0;
n = pop_number();
- if (n == NULL) {
+ if (n == NULL)
return;
- }
if (BN_is_zero(n->number)) {
r = new_number();
push_number(r);
@@ -1342,9 +1348,8 @@ not(void)
struct number *a;
a = pop_number();
- if (a == NULL) {
+ if (a == NULL)
return;
- }
a->scale = 0;
bn_check(BN_set_word(a->number, BN_get_word(a->number) ? 0 : 1));
push_number(a);
@@ -1363,9 +1368,8 @@ equal_numbers(void)
struct number *a, *b, *r;
a = pop_number();
- if (a == NULL) {
+ if (a == NULL)
return;
- }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1383,9 +1387,8 @@ less_numbers(void)
struct number *a, *b, *r;
a = pop_number();
- if (a == NULL) {
+ if (a == NULL)
return;
- }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1403,9 +1406,8 @@ lesseq_numbers(void)
struct number *a, *b, *r;
a = pop_number();
- if (a == NULL) {
+ if (a == NULL)
return;
- }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1736,9 +1738,8 @@ eval_tos(void)
char *p;
p = pop_string();
- if (p == NULL)
- return;
- eval_string(p);
+ if (p != NULL)
+ eval_string(p);
}
void
diff --git a/usr.bin/dc/dc.1 b/usr.bin/dc/dc.1
index 507bbe6777d3..43ba6cf01cd4 100644
--- a/usr.bin/dc/dc.1
+++ b/usr.bin/dc/dc.1
@@ -35,7 +35,7 @@
.\"
.\" @(#)dc.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd April 16, 2014
+.Dd February 27, 2017
.Dt DC 1
.Os
.Sh NAME
@@ -196,6 +196,10 @@ operator is a non-portable extension.
All values on the stack are popped.
.It Ic d
The top value on the stack is duplicated.
+.It Ic e
+Equivalent to
+.Ic p ,
+except that the output is written to the standard error stream.
.It Ic f
All values on the stack are printed, separated by newlines.
.It Ic G
diff --git a/usr.bin/dc/dc.c b/usr.bin/dc/dc.c
index 8f2cf51fb3bd..a2cf8c92e346 100644
--- a/usr.bin/dc/dc.c
+++ b/usr.bin/dc/dc.c
@@ -125,8 +125,8 @@ main(int argc, char *argv[])
if (!preproc_done)
init_bmachine(extended_regs);
- setlinebuf(stdout);
- setlinebuf(stderr);
+ (void)setvbuf(stdout, NULL, _IOLBF, 0);
+ (void)setvbuf(stderr, NULL, _IOLBF, 0);
if (argc > 1)
usage();
diff --git a/usr.bin/dc/stack.c b/usr.bin/dc/stack.c
index 3364ae228c52..33082c77ec04 100644
--- a/usr.bin/dc/stack.c
+++ b/usr.bin/dc/stack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stack.c,v 1.11 2009/10/27 23:59:37 deraadt Exp $ */
+/* $OpenBSD: stack.c,v 1.12 2014/11/26 15:05:51 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -68,10 +68,8 @@ stack_free_value(struct value *v)
free(v->u.string);
break;
}
- if (v->array != NULL) {
- array_free(v->array);
- v->array = NULL;
- }
+ array_free(v->array);
+ v->array = NULL;
}
/* Copy number or string content into already allocated target */
@@ -225,10 +223,8 @@ stack_popnumber(struct stack *stack)
if (stack_empty(stack))
return (NULL);
- if (stack->stack[stack->sp].array != NULL) {
- array_free(stack->stack[stack->sp].array);
- stack->stack[stack->sp].array = NULL;
- }
+ array_free(stack->stack[stack->sp].array);
+ stack->stack[stack->sp].array = NULL;
if (stack->stack[stack->sp].type != BCODE_NUMBER) {
warnx("not a number"); /* XXX remove */
return (NULL);
@@ -242,10 +238,8 @@ stack_popstring(struct stack *stack)
if (stack_empty(stack))
return (NULL);
- if (stack->stack[stack->sp].array != NULL) {
- array_free(stack->stack[stack->sp].array);
- stack->stack[stack->sp].array = NULL;
- }
+ array_free(stack->stack[stack->sp].array);
+ stack->stack[stack->sp].array = NULL;
if (stack->stack[stack->sp].type != BCODE_STRING) {
warnx("not a string"); /* XXX remove */
return (NULL);
@@ -257,9 +251,8 @@ void
stack_clear(struct stack *stack)
{
- while (stack->sp >= 0) {
+ while (stack->sp >= 0)
stack_free_value(&stack->stack[stack->sp--]);
- }
free(stack->stack);
stack_init(stack);
}
diff --git a/usr.bin/fortune/datfiles/freebsd-tips b/usr.bin/fortune/datfiles/freebsd-tips
index 97675860d175..57e6cbbaf9ab 100644
--- a/usr.bin/fortune/datfiles/freebsd-tips
+++ b/usr.bin/fortune/datfiles/freebsd-tips
@@ -7,6 +7,7 @@ a root login. You can add a user to the wheel group by editing /etc/group.
%
By pressing "Scroll Lock" you can use the arrow keys to scroll backward
through the console output. Press "Scroll Lock" again to turn it off.
+Don't have a "Scroll Lock" key? The "Pause / Break" key acts alike.
%
Can't remember if you've installed a certain port or not? Try "pkg info
-x port_name".
@@ -40,8 +41,8 @@ Having trouble using fetch through a firewall? Try setting the environment
variable FTP_PASSIVE_MODE to yes, and see fetch(3) for more details.
%
If other operating systems have damaged your Master Boot Record, you can
-reinstall it with boot0cfg(8). See
-"man boot0cfg" for details.
+reinstall it with gpart(8). See
+"man gpart" for details.
%
If you accidentally end up inside vi, you can quit it by pressing Escape, colon
(:), q (q), bang (!) and pressing return.
@@ -116,7 +117,7 @@ In order to support national characters for European languages in tools like
less without creating other nationalisation aspects, set the environment
variable LC_ALL to 'en_US.ISO8859-1'.
%
-"man firewall" will give advice for building a FreeBSD firewall
+"man firewall" will give advice for building a FreeBSD firewall using ipfw(8).
-- David Scheidt <dscheidt@tumbolia.com>
%
"man hier" will explain the way FreeBSD filesystems are normally laid out.
@@ -141,7 +142,8 @@ FreeBSD system.
-- David Scheidt <dscheidt@tumbolia.com>
%
Need to do a search in a manpage or in a file you've sent to a pager? Use
-"/search_word". To repeat the same search, type "n" for next.
+"/search_word". To repeat the same search, type "n" for next or "p" for
+previous.
-- Dru <genesis@istar.ca>
%
Need to find the location of a program? Use "locate program_name".
@@ -183,7 +185,7 @@ flag is your gateway.
Nice bash prompt: PS1='(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$ '
-- Mathieu <mathieu@hal.interactionvirtuelle.com>
%
-Over quota? "du -s * | sort -n " will give you a sorted list of your
+Over quota? "du -sh * | sort -h " will give you a sorted list of your
directory sizes.
-- David Scheidt <dscheidt@tumbolia.com>
%
@@ -191,7 +193,8 @@ nc(1) (or netcat) is useful not only for redirecting input/output to
TCP or UDP connections, but also for proxying them with inetd(8).
%
sh (the default Bourne shell in FreeBSD) supports command-line editing. Just
-``set -o emacs'' or ``set -o vi'' to enable it.
+``set -o emacs'' or ``set -o vi'' to enable it. Use "<TAB>" key to complete
+paths.
%
Simple tcsh prompt: set prompt = '%# '
%
@@ -215,6 +218,8 @@ the scroll lock key and use your page up button. When you're finished,
press the scroll lock key again to get your prompt back.
-- Dru <genesis@istar.ca>
%
+You can press Ctrl-L while in the shell to clear the screen.
+%
To determine whether a file is a text file, executable, or some other type
of file, use
@@ -231,10 +236,10 @@ is running FreeBSD at the time) to quickly find files based on name only.
To erase a line you've written at the command prompt, use "Ctrl-U".
-- Dru <genesis@istar.ca>
%
-To find the hostname associated with an IP address, use
+To find out the hostname associated with an IP address, use
drill -x IP_address
- -- Allan Jude <allanjude@FreeBSD.org>
+ -- Dru <genesis@istar.ca>
%
To obtain a neat PostScript rendering of a manual page, use ``-t'' switch
of the man(1) utility: ``man -t <topic>''. For example:
@@ -247,7 +252,8 @@ To quickly create an empty file, use "touch filename".
-- Dru <genesis@istar.ca>
%
To read a compressed file without having to first uncompress it, use
-"zcat" or "zless" to view it.
+"zcat" or "zless" to view it. There is also "bzcat", "bzless", "xzcat"
+and "xzless".
-- Dru <genesis@istar.ca>
%
To repeat the last command in the C shell, type "!!".
@@ -283,7 +289,7 @@ To see how much disk space is left on your partitions, use
%
To see the 10 largest files on a directory or partition, use
- du /partition_or_directory_name | sort -rn | head
+ du -h /partition_or_directory_name | sort -rh | head
-- Dru <genesis@istar.ca>
%
To see the IP addresses currently set on your active interfaces, type
@@ -291,7 +297,8 @@ To see the IP addresses currently set on your active interfaces, type
-- Dru <genesis@istar.ca>
%
To see the last 10 lines of a long file, use "tail filename". To see the
-first 10 lines, use "head filename".
+first 10 lines, use "head filename". To see new lines as they're appended
+to a file, use "tail -f filename".
-- Dru <genesis@istar.ca>
%
To see the last time that you logged in, use lastlogin(8).
@@ -343,6 +350,9 @@ write
This won't work if you don't have write permissions to the directory
and probably won't be suitable if you're editing through a symbolic link.
+
+If you have sudo(8) installed and permissions to use it, type
+``<ESC>w ! sudo tee %'' to force a write.
%
You can adjust the volume of various parts of the sound system in your
computer by typing 'mixer <type> <volume>'. To get a list of what you can
@@ -393,7 +403,7 @@ You can make a log of your terminal session with script(1).
You can often get answers to your questions about FreeBSD by searching in the
FreeBSD mailing list archives at
- http://www.FreeBSD.org/search/search.html
+ http://freebsd.markmail.org
%
You can open up a new split-screen window in (n)vi with :N or :E and then
use ^w to switch between the two.
@@ -408,8 +418,6 @@ You can press Ctrl-D to quickly exit from a shell, or logout from a
login shell.
-- Konstantinos Konstantinidis <kkonstan@duth.gr>
%
-You can press Ctrl-L while in the shell to clear the screen.
-%
You can press up-arrow or down-arrow to walk through a list of
previous commands in tcsh.
%
@@ -439,7 +447,9 @@ aliases, you can usually type just 'alias'.
%
You can use /etc/make.conf to control the options used to compile software
on this system. Example entries are in
-/usr/share/examples/etc/make.conf.
+/usr/share/examples/etc/make.conf and in make.conf(5).
+For options that are set for building FreeBSD's kernel and its world, see
+src.conf(5).
%
You can use "pkg info" to see a list of packages you have installed.
%
@@ -457,8 +467,102 @@ Try "whereis firefox" and "whereis whereis".
-- Konstantinos Konstantinidis <kkonstan@duth.gr>
%
Want to run the same command again?
-In tcsh you can type "!!"
+In tcsh you can type "!!".
%
Want to go the directory you were just in?
Type "cd -"
%
+Can't delete /usr/obj? Enter "chflags -R noschg /usr/obj" to remove the
+system immutable flag for all files in /usr/obj.
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+Want to list all files of an installed package? Enter
+"pkg info -l packagename".
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+Are you looking for a package? Search for it with
+"pkg search part_of_package_name"
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+If you want to recursively copy a directory preserving file and directory
+attributes use
+"cp -a source target"
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+Do you wonder what a terminal program is doing at the moment? dd(1) does not
+show any throughput? Hit "^T" (Control + t) to send SIGINFO to the process
+and see what it is doing.
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+Do you want to know which version of FreeBSD you are running? Enter
+"freebsd-version -ku" to display kernel and userland version.
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+If you want to end one or more processes at a time using a regular expression
+enter "pkill regex".
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+Do you want to run a program directly after some other process has ended? Use
+"pwait pid && new_program"
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+When you want your users to be able to reboot or shutdown FreeBSD, add them
+to the group "operator" and they are allowed to use shutdown(8) and poweroff(8).
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+If you need to create a FAT32 formatted USB thumb drive, find out its devicename
+running dmesg(8) after inserting it. Then create an MBR schema, a single slice and
+format it:
+
+# gpart create -s MBR ${devicename}
+# gpart add -t fat32 ${devicename}
+# newfs_msdos -F 32 -L thumbdrive ${devicename}s1
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+If you want to get a sorted list of all services that are started when FreeBSD boots,
+enter "service -e".
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+To easily configure your installed FreeBSD use bsdconfig(8).
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+After you compiled and installed a new version of FreeBSD, use etcupdate(8) to merge
+configuration updates.
+Run "etcupdate extract" once when your sources match your running system, then run
+"etcupdate" after every upgrade and "etcupdate resolve" to resolve any conflicts.
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+Do you want to do a binary upgrade of your running FreeBSD installation? Use freebsd-update(8).
+
+To install updates and patches for the running branch use
+# freebsd-update fetch install
+
+To upgrade to a newer release use
+# freebsd-update upgrade -r ${name_of_release}
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+To run rc scripts in /etc/rc.d and /usr/local/etc/rc.d use service(8).
+Run "service ${name_of_rc_script} start" to start a daemon and
+"service ${name_of_rc_script} stop" to stop it.
+
+ -- Lars Engels <lme@FreeBSD.org>
+%
+If you don't want to edit /etc/rc.conf directly, use sysrc(8) to add and remove entries.
+Use "sysrc name=value" to add an entry and "sysrc -x name" to delete an entry.
+
+ -- Lars Engels <lme@FreeBSD.org>
+%