Преглед изворни кода

libdpkg: Move basusage from ehandle to myopt

To reduce inter-dependencies due to usage of printforhelp.
Guillem Jover пре 17 година
родитељ
комит
c5ab80941d
6 измењених фајлова са 25 додато и 11 уклоњено
  1. 8 0
      ChangeLog
  2. 1 0
      dpkg-split/split.c
  3. 0 1
      lib/dpkg.h
  4. 0 10
      lib/ehandle.c
  5. 14 0
      lib/myopt.c
  6. 2 0
      lib/myopt.h

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-12-30  Guillem Jover  <guillem@debian.org>
+
+	* lib/ehandle.c (badusage): Move function to ...
+	* lib/myopt.c: ... here. Include <stdarg.h>.
+	* lib/dpkg.h (badusage): Move declaration to ...
+	* lib/myopt.h: ... here.
+	* dpkg-split/split.c: Include <myopt.h>.
+
 2008-12-30  Colin Watson  <cjwatson@ubuntu.com>
 
 	* src/help.c (preexecscript): Call chdir after chroot.

+ 1 - 0
dpkg-split/split.c

@@ -22,6 +22,7 @@
 #include <compat.h>
 
 #include <dpkg-i18n.h>
+#include <myopt.h>
 
 #include <stdio.h>
 #include <stdlib.h>

+ 0 - 1
lib/dpkg.h

@@ -195,7 +195,6 @@ void ohshit(const char *fmt, ...) NONRETURNING PRINTFFORMAT(1, 2);
 void ohshitv(const char *fmt, va_list al) NONRETURNING;
 void ohshite(const char *fmt, ...) NONRETURNING PRINTFFORMAT(1, 2);
 void ohshitvb(struct varbuf*) NONRETURNING;
-void badusage(const char *fmt, ...) NONRETURNING PRINTFFORMAT(1, 2);
 void werr(const char *what) NONRETURNING;
 void warning(const char *fmt, ...) PRINTFFORMAT(1, 2);
 

+ 0 - 10
lib/ehandle.c

@@ -302,16 +302,6 @@ warning(const char *fmt, ...)
   fprintf(stderr, _("%s: warning: %s\n"), thisname, buf);
 }
 
-void badusage(const char *fmt, ...) {
-  char buf[1024];
-  va_list al;
-  va_start(al,fmt);
-  vsnprintf(buf,sizeof(buf), fmt,al);
-  va_end(al);
-
-  ohshit("%s\n\n%s", buf, gettext(printforhelp));
-}
-
 void werr(const char *fn) {
   ohshite(_("error writing `%s'"),fn);
 }

+ 14 - 0
lib/myopt.c

@@ -27,11 +27,25 @@
 #include <string.h>
 #include <errno.h>
 #include <ctype.h>
+#include <stdarg.h>
 #include <stdlib.h>
 
 #include <myopt.h>
 #include <dpkg.h>
 
+void
+badusage(const char *fmt, ...)
+{
+  char buf[1024];
+  va_list al;
+
+  va_start(al, fmt);
+  vsnprintf(buf, sizeof(buf), fmt, al);
+  va_end(al);
+
+  ohshit("%s\n\n%s", buf, gettext(printforhelp));
+}
+
 void myfileopt(const char* fn, const struct cmdinfo* cmdinfos) {
   FILE* file;
   char linebuf[MAXDIVERTFILENAME];

+ 2 - 0
lib/myopt.h

@@ -40,6 +40,8 @@ struct cmdinfo {
   voidfnp farg;
 };
 
+void badusage(const char *fmt, ...) NONRETURNING PRINTFFORMAT(1, 2);
+
 void myfileopt(const char* fn, const struct cmdinfo* cmdinfos);
 void myopt(const char *const **argvp, const struct cmdinfo *cmdinfos);
 void loadcfgfile(const char *prog, const struct cmdinfo *cmdinfos);