Просмотр исходного кода

Rework common badusage strings to allow for possible translation reuse

Use cmdinfo long name instead of hard-coding it in the literal string,
and reword some strings to make them more generally usable.
Guillem Jover лет назад: 14
Родитель
Сommit
ff5ac5ced0
4 измененных файлов с 16 добавлено и 14 удалено
  1. 2 1
      dpkg-deb/build.c
  2. 3 2
      dpkg-deb/info.c
  3. 10 10
      src/main.c
  4. 1 1
      src/statcmd.c

+ 2 - 1
dpkg-deb/build.c

@@ -406,7 +406,8 @@ do_build(const char *const *argv)
   if (debar != NULL) {
     struct stat debarstab;
 
-    if (*argv) badusage(_("--build takes at most two arguments"));
+    if (*argv)
+      badusage(_("--%s takes at most two arguments"), cipaction->olong);
 
     if (stat(debar, &debarstab)) {
       if (errno != ENOENT)

+ 3 - 2
dpkg-deb/info.c

@@ -323,9 +323,10 @@ do_field(const char *const *argv)
 int
 do_contents(const char *const *argv)
 {
-  const char *debar;
+  const char *debar = *argv++;
 
-  if (!(debar= *argv++) || *argv) badusage(_("--contents takes exactly one argument"));
+  if (debar == NULL || *argv)
+    badusage(_("--%s takes exactly one argument"), cipaction->olong);
   extracthalf(debar, NULL, "tv", 0);
 
   return 0;

+ 10 - 10
src/main.c

@@ -320,7 +320,8 @@ static void setdebug(const struct cmdinfo *cpi, const char *value) {
   }
 
   mask = strtoul(value, &endp, 8);
-  if (value == endp || *endp) badusage(_("--debug requires an octal argument"));
+  if (value == endp || *endp)
+    badusage(_("--%s requires an octal argument"), cpi->olong);
 
   debug_set_mask(mask);
 }
@@ -349,14 +350,15 @@ static void ignoredepends(const struct cmdinfo *cip, const char *value) {
     if (*p != ',') continue;
     *p++ = '\0';
     if (!*p || *p==',' || p==copy+1)
-      badusage(_("null package name in --ignore-depends comma-separated list `%.250s'"),
-               value);
+      badusage(_("null package name in --%s comma-separated list '%.250s'"),
+               cip->olong, value);
   }
   p= copy;
   while (*p) {
     pnerr = pkg_name_is_illegal(p);
-    if (pnerr) ohshit(_("--ignore-depends requires a legal package name. "
-                       "`%.250s' is not; %s"), p, pnerr);
+    if (pnerr)
+      ohshit(_("--%s needs a valid package name but '%.250s' is not: %s"),
+              cip->olong, p, pnerr);
 
     pkg_list_prepend(&ignoredependss, pkg_db_find(p));
 
@@ -718,14 +720,12 @@ commandfd(const char *const *argv)
   bool skipchar;
 
   pipein = *argv++;
-  if (pipein == NULL)
-    badusage(_("--command-fd takes one argument, not zero"));
-  if (*argv)
-    badusage(_("--command-fd only takes one argument"));
+  if (pipein == NULL || *argv)
+    badusage(_("--%s takes exactly one argument"), cipaction->olong);
   errno = 0;
   infd = strtoul(pipein, &endptr, 10);
   if (pipein == endptr || *endptr || infd > INT_MAX)
-    ohshite(_("invalid integer for --%s: `%.250s'"), "command-fd", pipein);
+    ohshite(_("invalid integer for --%s: `%.250s'"), cipaction->olong, pipein);
   if ((in= fdopen(infd, "r")) == NULL)
     ohshite(_("couldn't open `%i' for stream"), (int) infd);
 

+ 1 - 1
src/statcmd.c

@@ -224,7 +224,7 @@ statoverride_add(const char *const *argv)
 	struct file_stat **filestat;
 
 	if (!user || !group || !mode || !path || argv[4])
-		badusage(_("--add needs four arguments"));
+		badusage(_("--%s needs four arguments"), cipaction->olong);
 
 	if (strchr(path, '\n'))
 		badusage(_("file may not contain newlines"));