Quellcode durchsuchen

Add lib/utils.c with general utility functions. Add cisalpha() and cisdigit()
functions, similar to the ctype is* ones but which only accept C locale

Wichert Akkerman vor 24 Jahren
Ursprung
Commit
a4f9322a64
4 geänderte Dateien mit 49 neuen und 2 gelöschten Zeilen
  1. 9 1
      ChangeLog
  2. 5 0
      include/dpkg.h.in
  3. 2 1
      lib/Makefile.in
  4. 33 0
      lib/utils.c

+ 9 - 1
ChangeLog

@@ -1,4 +1,12 @@
-Mon Dec 31 15:25:46 CET 2001  Wichert Akkerman <wakkerma@debian.org>
+Mon Dec 31 17:28:10 CET 2001 Wichert Akkerman <wakkerma@debian.org>
+
+  * lib/utils.c: new file with general utility functions. Add
+    cisalpha() and cisdigit() functions, similar to the ctype is*
+    ones but which only accept C locale
+  * lib/Makefile.in: add utils.c
+  * include/dpkg.h: add utils.c functions
+
+Mon Dec 31 15:25:46 CET 2001 Wichert Akkerman <wakkerma@debian.org>
 
   * scripts/dpkg-architecture.pl: fix syntax error
 

+ 5 - 0
include/dpkg.h.in

@@ -293,4 +293,9 @@ extern volatile int onerr_abort;
 struct cmdinfo;
 void showcopyright(const struct cmdinfo*, const char*);
 
+/*** from utils.c ***/
+
+int cisdigit(int c);
+int cisalpha(int c);
+
 #endif /* DPKG_H */

+ 2 - 1
lib/Makefile.in

@@ -7,7 +7,8 @@ include ../Makefile.conf
 
 SOURCES		= compat.c database.c dbmodify.c dump.c ehandle.c fields.c \
 		    lock.c mlib.c myopt.c nfmalloc.c parse.c parsehelp.c \
-		    showcright.c showpkg.c tarfn.c varbuf.c vercmp.c md5.c
+		    showcright.c showpkg.c tarfn.c varbuf.c vercmp.c md5.c \
+		    utils.c
 
 OBJECTS		= $(patsubst %.c, %.o, $(SOURCES))
 GENFILES	= $(OBJECTS) libdpkg.a

+ 33 - 0
lib/utils.c

@@ -0,0 +1,33 @@
+/*
+ * libdpkg - Debian packaging suite library routines
+ * utils.c - Helper functions for dpkg
+ *
+ * Copyright (C) 2001 Wichert Akkerman <wakkerma@debian.org>
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with dpkg; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <config.h>
+
+/* Reimplementation of the standard ctype.h is* functions. Since gettext
+ * has overloaded the meaning of LC_CTYPE we can't use that to force C
+ * locale, so use these cis* functions instead.
+ */
+int cisdigit(int c) {
+	return (c>='0') && (c<='9');
+}
+
+int cisalpha(int c) {
+	return ((c>='a') && (c<='z')) || ((c>='A') && (c<='Z'));
+}