mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-19 11:31:26 +01:00
fix return code and tests of printf and comment above bslashquote func (16064)
This commit is contained in:
parent
6ef62b386b
commit
4aaa5b3257
4 changed files with 43 additions and 19 deletions
|
@ -1,3 +1,9 @@
|
|||
2001-10-16 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 16064: Src/builtin.c, Src/utils.c, Test/B03print.ztst:
|
||||
fix return code of printf after math errors, incomplete comment
|
||||
in utils.c and tests of printf now that math evaluation is used
|
||||
|
||||
2001-10-16 Clint Adams <clint@zsh.org>
|
||||
|
||||
* 16062: Src/Modules/zftp.c: use O_EXCL
|
||||
|
|
|
@ -3125,6 +3125,10 @@ bin_print(char *name, char **args, char *ops, int func)
|
|||
|
||||
if (*c == '*') {
|
||||
if (*args) width = (int)mathevali(*args++);
|
||||
if (errflag) {
|
||||
errflag = 0;
|
||||
ret = 1;
|
||||
}
|
||||
c++;
|
||||
} else if (idigit(*c)) {
|
||||
width = strtoul(c, &endptr, 0);
|
||||
|
@ -3136,6 +3140,10 @@ bin_print(char *name, char **args, char *ops, int func)
|
|||
c++;
|
||||
if (*c == '*') {
|
||||
prec = (*args) ? (int)mathevali(*args++) : 0;
|
||||
if (errflag) {
|
||||
errflag = 0;
|
||||
ret = 1;
|
||||
}
|
||||
c++;
|
||||
} else if (idigit(*c)) {
|
||||
prec = strtoul(c, &endptr, 0);
|
||||
|
@ -3147,7 +3155,6 @@ bin_print(char *name, char **args, char *ops, int func)
|
|||
/* ignore any size modifier */
|
||||
if (*c == 'l' || *c == 'L' || *c == 'h') c++;
|
||||
|
||||
errflag = 0;
|
||||
d[1] = '\0';
|
||||
switch (*d = *c) {
|
||||
case 'c':
|
||||
|
@ -3226,6 +3233,7 @@ bin_print(char *name, char **args, char *ops, int func)
|
|||
if (errflag) {
|
||||
zlongval = 0;
|
||||
errflag = 0;
|
||||
ret = 1;
|
||||
}
|
||||
print_val(zlongval)
|
||||
break;
|
||||
|
@ -3238,11 +3246,12 @@ bin_print(char *name, char **args, char *ops, int func)
|
|||
if (errflag) {
|
||||
doubleval = 0;
|
||||
errflag = 0;
|
||||
ret = 1;
|
||||
}
|
||||
print_val(doubleval)
|
||||
break;
|
||||
case 3:
|
||||
#ifdef ZSH_64_BIT_TYPE
|
||||
#ifdef ZSH_64_BIT_UTYPE
|
||||
*d++ = 'l';
|
||||
#endif
|
||||
*d++ = 'l', *d++ = *c, *d = '\0';
|
||||
|
@ -3250,6 +3259,7 @@ bin_print(char *name, char **args, char *ops, int func)
|
|||
if (errflag) {
|
||||
doubleval = 0;
|
||||
errflag = 0;
|
||||
ret = 1;
|
||||
}
|
||||
print_val(zulongval)
|
||||
}
|
||||
|
|
|
@ -2929,8 +2929,9 @@ hasspecial(char const *s)
|
|||
* pointer it points to may point to a position in s and in e the position *
|
||||
* of the corresponding character in the quoted string is returned. *
|
||||
* The last argument should be zero if this is to be used outside a string, *
|
||||
* one if it is to be quoted for the inside of a single quoted string, and *
|
||||
* two if it is for the inside of double quoted string. *
|
||||
* one if it is to be quoted for the inside of a single quoted string, *
|
||||
* two if it is for the inside of a double quoted string, and *
|
||||
* three if it is for the inside of a posix quoted string. *
|
||||
* The string may be metafied and contain tokens. */
|
||||
|
||||
/**/
|
||||
|
|
|
@ -78,6 +78,10 @@
|
|||
0:initial quote to get numeric value of character with double
|
||||
>6.6E+01
|
||||
|
||||
printf '%x\n' $(printf '"\xf0')
|
||||
0:numeric value of high numbered character
|
||||
>f0
|
||||
|
||||
# code will probably be changed to print the literal `%s' in this case
|
||||
printf '\x25s\n' arg
|
||||
0:using \x25 to introduce a format specifier
|
||||
|
@ -95,24 +99,15 @@
|
|||
0:width/precision specified in arguments
|
||||
> 10.20
|
||||
|
||||
printf '%d\n' 3000000000
|
||||
1d:out of range numeric result
|
||||
?(eval):printf:1: `3000000000' arithmetic overflow
|
||||
|
||||
printf '%G\n' letters
|
||||
1:non numeric argument
|
||||
?(eval):printf:1: `letters' expected numeric value
|
||||
>0
|
||||
|
||||
print -f '%d\n' 2e4
|
||||
1:letters in numeric argument
|
||||
?(eval):print:1: `2e4' not completely converted
|
||||
>2
|
||||
|
||||
printf '%z'
|
||||
1:test invalid directive
|
||||
1:use of invalid directive
|
||||
?(eval):printf:1: %z: invalid directive
|
||||
|
||||
printf '%d\n' 3a
|
||||
1:bad arithmetic expression
|
||||
?(eval):1: bad math expression: operator expected at `a'
|
||||
>0
|
||||
|
||||
print -m -f 'format - %s.\n' 'z' a b c
|
||||
0:format not printed if no arguments left after -m removal
|
||||
|
||||
|
@ -133,3 +128,15 @@
|
|||
>one a:0x1%
|
||||
>two b:0x2%
|
||||
>three c:0x3%
|
||||
|
||||
printf '%0+- #-08.5dx\n' 123
|
||||
0:maximal length format specification
|
||||
>+00123 x
|
||||
|
||||
printf '%*smorning\n' -5 good
|
||||
0:negative width specified
|
||||
>good morning
|
||||
|
||||
printf '%.*g\n' -1 .1
|
||||
0:negative precision specified
|
||||
>0.1
|
||||
|
|
Loading…
Reference in a new issue