diff options
author | Jim Meyering <meyering@redhat.com> | 2009-09-24 10:59:01 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-09-24 11:00:44 +0200 |
commit | 6a14f1c2502f58ff7bed8cb451f95a83f5ee920a (patch) | |
tree | 975cb6488e6413dab5aece9fcf1aee5a595381ac | |
parent | 0ca36888c6975ffa7e03df11bf8ded42156939c7 (diff) | |
download | libguestfs-6a14f1c2502f58ff7bed8cb451f95a83f5ee920a.tar.gz libguestfs-6a14f1c2502f58ff7bed8cb451f95a83f5ee920a.tar.xz libguestfs-6a14f1c2502f58ff7bed8cb451f95a83f5ee920a.zip |
avoid use of all ctype macros
* cfg.mk (disable_temporarily): Don't disable sc_avoid_ctype_macros.
* fish/tilde.c: Remove unnecessary inclusion of ctype.h.
* bootstrap: Add gnulib's c-ctype module to the list.
* daemon/m4/gnulib-cache.m4: Likewise.
* daemon/ext2.c: Include "c-ctype.h", not <ctype.h>.
Use c_isspace, etc, rather than isspace.
* daemon/guestfsd.c: Likewise.
* daemon/lvm.c: Likewise.
* daemon/proto.c: Likewise.
* fish/fish.c: Likewise.
* fish/tilde.c: Likewise.
* src/generator.ml: Likewise.
* src/guestfs.c: Likewise.
* examples/to-xml.c: Likewise.
* examples/Makefile.am (to_xml_CPPFLAGS): Add -I$(top_srcdir)/gnulib/lib
so inclusion of "c-ctype.h" works.
(to_xml_CPPFLAGS): Rename from to_xml_CFLAGS.
-rwxr-xr-x | bootstrap | 1 | ||||
-rw-r--r-- | cfg.mk | 1 | ||||
-rw-r--r-- | daemon/ext2.c | 8 | ||||
-rw-r--r-- | daemon/guestfsd.c | 4 | ||||
-rw-r--r-- | daemon/lvm.c | 6 | ||||
-rw-r--r-- | daemon/m4/gnulib-cache.m4 | 3 | ||||
-rw-r--r-- | daemon/proto.c | 4 | ||||
-rw-r--r-- | examples/Makefile.am | 4 | ||||
-rw-r--r-- | examples/to-xml.c | 4 | ||||
-rw-r--r-- | fish/fish.c | 6 | ||||
-rw-r--r-- | fish/tilde.c | 1 | ||||
-rwxr-xr-x | src/generator.ml | 10 | ||||
-rw-r--r-- | src/guestfs.c | 4 |
13 files changed, 29 insertions, 27 deletions
@@ -58,6 +58,7 @@ gnulib_tool=$GNULIB_SRCDIR/gnulib-tool modules=' arpa_inet +c-ctype closeout gitlog-to-changelog gnu-make @@ -50,7 +50,6 @@ disable_temporarily = \ sc_unmarked_diagnostics \ sc_prohibit_ctype_h \ sc_prohibit_asprintf \ - sc_avoid_ctype_macros \ sc_avoid_write # Avoid uses of write(2). Either switch to streams (fwrite), or use diff --git a/daemon/ext2.c b/daemon/ext2.c index a26891b0..0021a065 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -21,10 +21,10 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include <ctype.h> #include "../src/guestfs_protocol.h" #include "daemon.h" +#include "c-ctype.h" #include "actions.h" char ** @@ -72,7 +72,7 @@ do_tune2fs_l (const char *device) if (colon) { *colon = '\0'; - do { colon++; } while (*colon && isspace (*colon)); + do { colon++; } while (*colon && c_isspace (*colon)); if (add_string (&ret, &size, &alloc, p) == -1) { free (out); @@ -202,7 +202,7 @@ do_get_e2uuid (const char *device) } p += 17; - while (*p && isspace (*p)) + while (*p && c_isspace (*p)) p++; if (!*p) { reply_with_error ("malformed Filesystem UUID in the output of tune2fs -l"); @@ -212,7 +212,7 @@ do_get_e2uuid (const char *device) /* Now 'p' hopefully points to the start of the UUID. */ q = p; - while (*q && (isxdigit (*q) || *q == '-')) + while (*q && (c_isxdigit (*q) || *q == '-')) q++; if (!*q) { reply_with_error ("malformed Filesystem UUID in the output of tune2fs -l"); diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index e3b8883e..8c39c39c 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -34,10 +34,10 @@ #include <sys/wait.h> #include <sys/stat.h> #include <fcntl.h> -#include <ctype.h> #include <signal.h> #include <printf.h> +#include "c-ctype.h" #include "daemon.h" static char *read_cmdline (void); @@ -835,7 +835,7 @@ print_shell_quote (FILE *stream, const struct printf_info *info ATTRIBUTE_UNUSED, const void *const *args) { -#define SAFE(c) (isalnum((c)) || \ +#define SAFE(c) (c_isalnum((c)) || \ (c) == '/' || (c) == '-' || (c) == '_' || (c) == '.') int i, len; const char *str = *((const char **) (args[0])); diff --git a/daemon/lvm.c b/daemon/lvm.c index 742b40ba..9865bb23 100644 --- a/daemon/lvm.c +++ b/daemon/lvm.c @@ -22,9 +22,9 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <ctype.h> #include "daemon.h" +#include "c-ctype.h" #include "actions.h" /* LVM actions. Keep an eye on liblvm, although at the time @@ -49,12 +49,12 @@ convert_lvm_output (char *out, const char *prefix) pend++; } - while (*p && isspace (*p)) /* Skip any leading whitespace. */ + while (*p && c_isspace (*p)) /* Skip any leading whitespace. */ p++; /* Sigh, skip trailing whitespace too. "pvs", I'm looking at you. */ len = strlen (p)-1; - while (*p && isspace (p[len])) + while (*p && c_isspace (p[len])) p[len--] = '\0'; if (!*p) { /* Empty line? Skip it. */ diff --git a/daemon/m4/gnulib-cache.m4 b/daemon/m4/gnulib-cache.m4 index bd6cf61d..df69113a 100644 --- a/daemon/m4/gnulib-cache.m4 +++ b/daemon/m4/gnulib-cache.m4 @@ -15,11 +15,12 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl hash ignore-value manywarnings warnings +# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl c-ctype hash ignore-value manywarnings warnings # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) gl_MODULES([ + c-ctype hash ignore-value manywarnings diff --git a/daemon/proto.c b/daemon/proto.c index c22bbee4..a0d3736a 100644 --- a/daemon/proto.c +++ b/daemon/proto.c @@ -24,11 +24,11 @@ #include <string.h> #include <unistd.h> #include <errno.h> -#include <ctype.h> #include <sys/param.h> /* defines MIN */ #include <rpc/types.h> #include <rpc/xdr.h> +#include "c-ctype.h" #include "ignore-value.h" #include "daemon.h" @@ -96,7 +96,7 @@ main_loop (int _sock) printf (" "); printf ("|"); for (j = i; j < MIN (i+16, len); ++j) - if (isprint (buf[j])) + if (c_isprint (buf[j])) printf ("%c", buf[j]); else printf ("."); diff --git a/examples/Makefile.am b/examples/Makefile.am index fb3d656c..adbb9343 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -7,7 +7,9 @@ hello_CFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src -Wall hello_LDADD = $(top_builddir)/src/libguestfs.la to_xml_SOURCES = to-xml.c -to_xml_CFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src -Wall +to_xml_CPPFLAGS = \ + -I$(top_srcdir)/gnulib/lib \ + -I$(top_srcdir)/src -I$(top_builddir)/src -Wall to_xml_LDADD = $(top_builddir)/src/libguestfs.la CLEANFILES = $(noinst_PROGRAMS) diff --git a/examples/to-xml.c b/examples/to-xml.c index 6d0a1dfb..e9ea0639 100644 --- a/examples/to-xml.c +++ b/examples/to-xml.c @@ -16,9 +16,9 @@ #include <stdint.h> #include <inttypes.h> #include <unistd.h> -#include <ctype.h> #include <guestfs.h> +#include "c-ctype.h" /* Note that if any API call fails, we can just exit. The * standard error handler will have printed the error message @@ -149,7 +149,7 @@ display_partitions (guestfs_h *g, const char *dev) * That's a limitation of sorts of the Linux kernel. (Actually, * we could do this if we add the kpartx program to libguestfs). */ - if (strncmp (dev, "/dev/sd", 7) != 0 || isdigit (dev[strlen(dev)-1])) { + if (strncmp (dev, "/dev/sd", 7) != 0 || c_isdigit (dev[strlen(dev)-1])) { printf ("<vm-image dev=\"%s\"/>\n", dev); return; } diff --git a/fish/fish.c b/fish/fish.c index f8c04836..3300536d 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -26,7 +26,6 @@ #include <getopt.h> #include <signal.h> #include <assert.h> -#include <ctype.h> #include <sys/types.h> #include <sys/wait.h> @@ -38,6 +37,7 @@ #include <guestfs.h> #include "fish.h" +#include "c-ctype.h" #include "closeout.h" #include "progname.h" @@ -579,7 +579,7 @@ script (int prompt) /* Skip any initial whitespace before the command. */ again: - while (*buf && isspace (*buf)) + while (*buf && c_isspace (*buf)) buf++; if (!*buf) continue; @@ -1127,7 +1127,7 @@ parse_string_list (const char *str) * as separate fragments because we can't just copy it: we have to remove * the \. */ - while (*p && (!isblank (*p) || in_quote)) { + while (*p && (!c_isblank (*p) || in_quote)) { const char *end = p; /* Check if the fragment starts with a quote */ diff --git a/fish/tilde.c b/fish/tilde.c index 40854178..1c52d3ed 100644 --- a/fish/tilde.c +++ b/fish/tilde.c @@ -22,7 +22,6 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <ctype.h> #include <assert.h> #include <pwd.h> #include <sys/types.h> diff --git a/src/generator.ml b/src/generator.ml index 6f77e4ba..4f03c062 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -4956,11 +4956,11 @@ and generate_daemon_actions () = pr "#include <stdlib.h>\n"; pr "#include <string.h>\n"; pr "#include <inttypes.h>\n"; - pr "#include <ctype.h>\n"; pr "#include <rpc/types.h>\n"; pr "#include <rpc/xdr.h>\n"; pr "\n"; pr "#include \"daemon.h\"\n"; + pr "#include \"c-ctype.h\"\n"; pr "#include \"../src/guestfs_protocol.h\"\n"; pr "#include \"actions.h\"\n"; pr "\n"; @@ -5186,7 +5186,7 @@ and generate_daemon_actions () = pr " fprintf (stderr, \"%%s: failed: passed a NULL string\\n\", __func__);\n"; pr " return -1;\n"; pr " }\n"; - pr " if (!*str || isspace (*str)) {\n"; + pr " if (!*str || c_isspace (*str)) {\n"; pr " fprintf (stderr, \"%%s: failed: passed a empty string or one beginning with whitespace\\n\", __func__);\n"; pr " return -1;\n"; pr " }\n"; @@ -5288,7 +5288,7 @@ and generate_daemon_actions () = pr " pend++;\n"; pr " }\n"; pr "\n"; - pr " while (*p && isspace (*p)) /* Skip any leading whitespace. */\n"; + pr " while (*p && c_isspace (*p)) /* Skip any leading whitespace. */\n"; pr " p++;\n"; pr "\n"; pr " if (!*p) { /* Empty line? Skip it. */\n"; @@ -6073,9 +6073,9 @@ and generate_fish_cmds () = pr "#include <stdlib.h>\n"; pr "#include <string.h>\n"; pr "#include <inttypes.h>\n"; - pr "#include <ctype.h>\n"; pr "\n"; pr "#include <guestfs.h>\n"; + pr "#include \"c-ctype.h\"\n"; pr "#include \"fish.h\"\n"; pr "\n"; @@ -6193,7 +6193,7 @@ and generate_fish_cmds () = | name, FBuffer -> pr " printf (\"%%s%s: \", indent);\n" name; pr " for (i = 0; i < %s->%s_len; ++i)\n" typ name; - pr " if (isprint (%s->%s[i]))\n" typ name; + pr " if (c_isprint (%s->%s[i]))\n" typ name; pr " printf (\"%%s%%c\", indent, %s->%s[i]);\n" typ name; pr " else\n"; pr " printf (\"%%s\\\\x%%02x\", indent, %s->%s[i]);\n" typ name; diff --git a/src/guestfs.c b/src/guestfs.c index 03089ea0..e49f57a4 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -25,7 +25,6 @@ #include <stdarg.h> #include <stddef.h> #include <unistd.h> -#include <ctype.h> #include <string.h> #include <fcntl.h> #include <time.h> @@ -62,6 +61,7 @@ #include "guestfs.h" #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" +#include "c-ctype.h" #include "ignore-value.h" #ifdef HAVE_GETTEXT @@ -2136,7 +2136,7 @@ recv_from_daemon (guestfs_h *g, uint32_t *size_rtn, void **buf_rtn) printf (" "); printf ("|"); for (j = i; j < MIN (i+16, nr); ++j) - if (isprint ((*(char **)buf_rtn)[j])) + if (c_isprint ((*(char **)buf_rtn)[j])) printf ("%c", (*(char **)buf_rtn)[j]); else printf ("."); |