commit: 916c618bd99370c1a44a1592a542cf553b2c7256
parent 924d3677d2c0720dc0fede0d002c87b137ff26e2
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 20 Sep 2024 03:43:27 +0200
cmd/pwd: unify error message formatting
Diffstat:
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/cmd/printf.c b/cmd/printf.c
@@ -183,7 +183,7 @@ main(int argc, char *argv[])
if(end == 1)
{
- warnx("missing format character");
+ warnx("warning: missing format character");
#ifdef SHELL
INTON;
#endif
@@ -262,7 +262,7 @@ printf_doformat(char *fmt, int *rval)
int idx = atoi(fmt);
if(fargv == NULL)
{
- warnx("incomplete use of n$");
+ warnx("warning: incomplete use of n$");
return (NULL);
}
if(idx <= myargc)
@@ -277,7 +277,7 @@ printf_doformat(char *fmt, int *rval)
}
else if(fargv != NULL)
{
- warnx("incomplete use of n$");
+ warnx("warning: incomplete use of n$");
return (NULL);
}
@@ -316,7 +316,7 @@ printf_doformat(char *fmt, int *rval)
int idx = atoi(fmt);
if(fargv == NULL)
{
- warnx("incomplete use of n$");
+ warnx("warning: incomplete use of n$");
return (NULL);
}
if(idx <= myargc)
@@ -331,7 +331,7 @@ printf_doformat(char *fmt, int *rval)
}
else if(fargv != NULL)
{
- warnx("incomplete use of n$");
+ warnx("warning: incomplete use of n$");
return (NULL);
}
@@ -357,7 +357,7 @@ printf_doformat(char *fmt, int *rval)
haveprec = 0;
if(!*fmt)
{
- warnx("missing format character");
+ warnx("warning: missing format character");
return (NULL);
}
*dptr++ = *fmt;
@@ -379,7 +379,7 @@ printf_doformat(char *fmt, int *rval)
fmt++;
if(!strchr("aAeEfFgG", *fmt))
{
- warnx("bad modifier L for %%%c", *fmt);
+ warnx("warning: bad modifier L for %%%c", *fmt);
return (NULL);
}
}
@@ -410,7 +410,7 @@ printf_doformat(char *fmt, int *rval)
start[strlen(start) - 1] = 's';
if((p = strdup(getstr())) == NULL)
{
- warnx("%s", strerror(ENOMEM));
+ warnx("warning: %s", strerror(ENOMEM));
return (NULL);
}
getout = escape(p, 0, &len);
@@ -477,7 +477,7 @@ printf_doformat(char *fmt, int *rval)
break;
}
default:
- warnx("illegal format character %c", convch);
+ warnx("warning: illegal format character %c", convch);
return (NULL);
}
*fmt = nextch;
@@ -499,7 +499,7 @@ mknum(char *str, char ch)
newlen = ((len + 1023) >> 10) << 10;
if((newcopy = realloc(copy, newlen)) == NULL)
{
- warnx("%s", strerror(ENOMEM));
+ warnx("warning: %s", strerror(ENOMEM));
return (NULL);
}
copy = newcopy;
@@ -642,7 +642,7 @@ getint(int *ip)
rval = 0;
if(val < INT_MIN || val > INT_MAX)
{
- warnx("%s: %s", *gargv, strerror(ERANGE));
+ warnx("warning: %s: %s", *gargv, strerror(ERANGE));
rval = 1;
}
*ip = (int)val;
@@ -676,17 +676,17 @@ getnum(intmax_t *ip, uintmax_t *uip, int signedconv)
*uip = strtoumax(*gargv, &ep, 0);
if(ep == *gargv)
{
- warnx("%s: expected numeric value", *gargv);
+ warnx("warning: %s: expected numeric value", *gargv);
rval = 1;
}
else if(*ep != '\0')
{
- warnx("%s: not completely converted", *gargv);
+ warnx("warning: %s: not completely converted", *gargv);
rval = 1;
}
if(errno == ERANGE)
{
- warnx("%s: %s", *gargv, strerror(ERANGE));
+ warnx("warning: %s: %s", *gargv, strerror(ERANGE));
rval = 1;
}
++gargv;
@@ -717,17 +717,17 @@ getfloating(long double *dp, int mod_ldbl)
*dp = strtod(*gargv, &ep);
if(ep == *gargv)
{
- warnx("%s: expected numeric value", *gargv);
+ warnx("warning: %s: expected numeric value", *gargv);
rval = 1;
}
else if(*ep != '\0')
{
- warnx("%s: not completely converted", *gargv);
+ warnx("warning: %s: not completely converted", *gargv);
rval = 1;
}
if(errno == ERANGE)
{
- warnx("%s: %s", *gargv, strerror(ERANGE));
+ warnx("warning: %s: %s", *gargv, strerror(ERANGE));
rval = 1;
}
++gargv;
diff --git a/cmd/pwd.c b/cmd/pwd.c
@@ -19,7 +19,7 @@ main(int argc, char *argv[])
if(getcwd(pwd, sizeof(pwd)) == NULL)
{
- perror("pwd: getcwd");
+ perror("pwd: error: getcwd");
return 1;
}
else
diff --git a/test-cmd/pwd.sh b/test-cmd/pwd.sh
@@ -23,7 +23,7 @@ then
cd "$oldpwd" || exit 1
rm -r "$tmpdir" || exit 1
)
- t --exit=1 enoent '' 'pwd: getcwd: No such file or directory
+ t --exit=1 enoent '' 'pwd: error: getcwd: No such file or directory
'
cd "$oldpwd"
else