Browse Source

Add an unrecognized option error, with translations from skarnet

signals
Gavin Howard 3 years ago
parent
commit
00382e90b3
Signed by untrusted user who does not match committer: gavin
GPG Key ID: C08038BDF280D33E
  1. 3
      include/status.h
  2. 4
      locale_install.sh
  3. 1
      locales/de_DE.ISO8859-1.msg
  4. 1
      locales/de_DE.UTF-8.msg
  5. 1
      locales/en_US.msg
  6. 1
      locales/fr_FR.ISO8859-1.msg
  7. 1
      locales/fr_FR.UTF-8.msg
  8. 16
      src/args.c
  9. 3
      src/data.c
  10. 10
      tests/all.sh

3
include/status.h

@ -62,7 +62,8 @@ typedef enum BcError {
BC_ERROR_FATAL_FILE_ERR,
BC_ERROR_FATAL_BIN_FILE,
BC_ERROR_FATAL_PATH_DIR,
BC_ERROR_FATAL_OPTION,
BC_ERROR_FATAL_BAD_OPT,
BC_ERROR_FATAL_UNRECOGNIZED_OPT,
BC_ERROR_EXEC_IBASE,
BC_ERROR_EXEC_OBASE,

4
locale_install.sh

@ -49,8 +49,6 @@ scriptdir=$(dirname "$script")
. "$scriptdir/functions.sh"
INSTALL="$scriptdir/safe-install.sh"
test "$#" -ge 2 || usage
nlspath="$1"
@ -59,6 +57,8 @@ shift
main_exec="$1"
shift
"$scriptdir/locale_uninstall.sh" "$nlspath" "$main_exec"
locales_dir="$scriptdir/locales"
locales=$(locale -a)

1
locales/de_DE.ISO8859-1.msg

@ -76,3 +76,4 @@ $set 6
4 "Datei ist nicht ASCII: %s"
5 "Pfad ist ein Verzeichnis: %s"
6 "ungültige Befehlszeilenoption: '%c' (\"%s\")"
7 "unerkannt Befehlszeilenoption"

1
locales/de_DE.UTF-8.msg

@ -76,3 +76,4 @@ $set 6
4 "Datei ist nicht ASCII: %s"
5 "Pfad ist ein Verzeichnis: %s"
6 "ungültige Befehlszeilenoption: '%c' (\"%s\")"
7 "unerkannt Befehlszeilenoption"

1
locales/en_US.msg

@ -104,3 +104,4 @@ $set 6
4 "file is not ASCII: %s"
5 "path is a directory: %s"
6 "invalid command-line option: '%c' (\"%s\")"
7 "unrecognized command-line option"

1
locales/fr_FR.ISO8859-1.msg

@ -104,3 +104,4 @@ $set 6
4 "fichier non ASCII : %s"
5 "le chemin est un répertoire : %s"
6 "option de ligne de commande invalide : '%c' (\"%s\")"
7 "option de ligne de commande non reconnue"

1
locales/fr_FR.UTF-8.msg

@ -104,3 +104,4 @@ $set 6
4 "fichier non ASCII : %s"
5 "le chemin est un répertoire : %s"
6 "option de ligne de commande invalide : '%c' (\"%s\")"
7 "option de ligne de commande non reconnue"

16
src/args.c

@ -189,17 +189,23 @@ BcStatus bc_args(int argc, char *argv[]) {
case '?':
default:
{
return BC_STATUS_ERROR_VM;
err = '?';
break;
}
}
if (BC_ERR(err)) {
for (i = 0; bc_args_lopt[i].name; ++i) {
if (bc_args_lopt[i].val == err) break;
}
if (err == '?') return bc_vm_err(BC_ERROR_FATAL_UNRECOGNIZED_OPT);
else {
return bc_vm_verr(BC_ERROR_FATAL_OPTION, err, bc_args_lopt[i].name);
for (i = 0; bc_args_lopt[i].name; ++i) {
if (bc_args_lopt[i].val == err) break;
}
return bc_vm_verr(BC_ERROR_FATAL_BAD_OPT,
err, bc_args_lopt[i].name);
}
}
}

3
src/data.c

@ -76,7 +76,7 @@ const uchar bc_err_ids[] = {
BC_ERR_IDX_MATH, BC_ERR_IDX_MATH, BC_ERR_IDX_MATH, BC_ERR_IDX_MATH,
BC_ERR_IDX_FATAL, BC_ERR_IDX_FATAL, BC_ERR_IDX_FATAL, BC_ERR_IDX_FATAL,
BC_ERR_IDX_FATAL, BC_ERR_IDX_FATAL,
BC_ERR_IDX_FATAL, BC_ERR_IDX_FATAL, BC_ERR_IDX_FATAL,
BC_ERR_IDX_EXEC, BC_ERR_IDX_EXEC, BC_ERR_IDX_EXEC, BC_ERR_IDX_EXEC,
BC_ERR_IDX_EXEC, BC_ERR_IDX_EXEC, BC_ERR_IDX_EXEC, BC_ERR_IDX_EXEC,
@ -109,6 +109,7 @@ const char* const bc_err_msgs[] = {
"file is not ASCII: %s",
"path is a directory: %s",
"bad command-line option: '%c' (\"%s\")",
"unrecognized command-line option",
"bad ibase: must be [%lu, %lu]",
"bad obase: must be [%lu, %lu]",

10
tests/all.sh

@ -191,6 +191,16 @@ err="$?"
checktest "$err" "invalid long option argument" "$out2" "$d"
"$exe" "$@" "-u" -e "$exprs" > /dev/null 2> "$out2"
err="$?"
checktest "$err" "unrecognized option argument" "$out2" "$d"
"$exe" "$@" "--uniform" -e "$exprs" > /dev/null 2> "$out2"
err="$?"
checktest "$err" "unrecognized long option argument" "$out2" "$d"
printf 'Running %s directory test...\n' "$d"
"$exe" "$@" "$testdir" > /dev/null 2> "$out2"

Loading…
Cancel
Save