aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-05-19 18:24:06 +0200
committerDuncaen <mail@duncano.de>2017-05-19 18:41:03 +0200
commit332065efb70839ca6e39b55b7dfba2a5f913f7c1 (patch)
treeb0df0b63c254d7d3d9f29626f55c7a5fe085035c
parentfd46ad192ac1b9f2e29ff94f574d537e90683383 (diff)
downloadlobase-332065efb70839ca6e39b55b7dfba2a5f913f7c1.tar.gz
usr.bin/printf: update to OPENBSD_6_1
-rw-r--r--usr.bin/printf/printf.115
-rw-r--r--usr.bin/printf/printf.c28
2 files changed, 22 insertions, 21 deletions
diff --git a/usr.bin/printf/printf.1 b/usr.bin/printf/printf.1
index 0f94c15..c9a5de9 100644
--- a/usr.bin/printf/printf.1
+++ b/usr.bin/printf/printf.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: printf.1,v 1.29 2015/02/28 21:51:57 bentley Exp $
+.\" $OpenBSD: printf.1,v 1.30 2016/11/18 15:59:10 schwarze Exp $
.\"
.\" Copyright (c) 1989, 1990 The Regents of the University of California.
.\" All rights reserved.
@@ -32,7 +32,7 @@
.\"
.\" from: @(#)printf.1 5.11 (Berkeley) 7/24/91
.\"
-.Dd $Mdocdate: February 28 2015 $
+.Dd $Mdocdate: November 18 2016 $
.Dt PRINTF 1
.Os
.Sh NAME
@@ -196,7 +196,7 @@ for
.Cm e
and
.Cm f
-formats, or the maximum number of characters to be printed
+formats, or the maximum number of bytes to be printed
from a string; if the digit string is missing, the precision is treated
as zero.
.It Format:
@@ -338,7 +338,7 @@ is printed.
.It Cm s
Characters from the string
.Ar argument
-are printed until the end is reached or until the number of characters
+are printed until the end is reached or until the number of bytes
indicated by the precision specification is reached; however if the
precision is 0 or missing, all characters in the string are printed.
.It Cm \&%
@@ -369,7 +369,12 @@ The
.Nm
utility is compliant with the
.St -p1003.1-2008
-specification.
+specification, but in order to produce predictable output
+it deliberately ignores the
+.Xr locale 1
+and always operates as if
+.Ev LC_ALL Ns =C
+were set.
.Pp
The escape sequences \ee and \e' are extensions to that specification.
.Sh HISTORY
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c
index 73eb5b2..30feac0 100644
--- a/usr.bin/printf/printf.c
+++ b/usr.bin/printf/printf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printf.c,v 1.24 2015/10/09 01:37:08 deraadt Exp $ */
+/* $OpenBSD: printf.c,v 1.26 2016/11/18 15:53:16 schwarze Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@@ -30,14 +30,13 @@
*/
#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
-#include <limits.h>
-#include <locale.h>
-#include <errno.h>
-#include <err.h>
+#include <unistd.h>
static int print_escape_str(const char *);
static int print_escape(const char *);
@@ -50,7 +49,7 @@ static unsigned long getulong(void);
static char *getstr(void);
static char *mklong(const char *, int);
static void check_conversion(const char *, const char *);
-static void usage(void);
+static void __dead usage(void);
static int rval;
static char **gargv;
@@ -80,8 +79,6 @@ main(int argc, char *argv[])
char convch, nextch;
char *format;
- setlocale (LC_ALL, "");
-
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
@@ -91,10 +88,8 @@ main(int argc, char *argv[])
argv++;
}
- if (argc < 2) {
+ if (argc < 2)
usage();
- return (1);
- }
format = *++argv;
gargv = ++argv;
@@ -439,7 +434,7 @@ getlong(void)
return(0L);
if (**gargv == '\"' || **gargv == '\'')
- return (long) *((*gargv++)+1);
+ return (unsigned char) *((*gargv++)+1);
errno = 0;
val = strtol (*gargv, &ep, 0);
@@ -457,7 +452,7 @@ getulong(void)
return(0UL);
if (**gargv == '\"' || **gargv == '\'')
- return (unsigned long) *((*gargv++)+1);
+ return (unsigned char) *((*gargv++)+1);
errno = 0;
val = strtoul (*gargv, &ep, 0);
@@ -475,7 +470,7 @@ getdouble(void)
return(0.0);
if (**gargv == '\"' || **gargv == '\'')
- return (double) *((*gargv++)+1);
+ return (unsigned char) *((*gargv++)+1);
errno = 0;
val = strtod (*gargv, &ep);
@@ -498,8 +493,9 @@ check_conversion(const char *s, const char *ep)
}
}
-static void
+static void __dead
usage(void)
{
(void)fprintf(stderr, "usage: printf format [argument ...]\n");
+ exit(1);
}