]> git.tuebingen.mpg.de Git - adu.git/blobdiff - interactive.c
Assorted typo fixes in comments.
[adu.git] / interactive.c
index 8f94076c4a8bb08829b482fd830e1820251f8243..61b4f293562bfe8077f9bcc25f528887605bb7ce 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2008 Andre Noll <maan@tuebingen.mpg.de>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -129,6 +129,21 @@ static int icom_set(char *line)
        return parse_select_options(line, &params, &admissible_uids, &fi);
 }
 
+/**
+ * Wrapper for isspace.
+ * NetBSD needs this.
+ */
+/*
+ * The values should be cast to an unsigned char first, then to int.
+ * Why? Because the isdigit (as do all other is/to functions/macros)
+ * expect a number from 0 upto and including 255 as their (int) argument.
+ * Because char is signed on most systems, casting it to int immediately
+ * gives the functions an argument between -128 and 127 (inclusive),
+ * which they will use as an array index, and which will thus fail
+ * horribly for characters which have their most significant bit set.
+ */
+#define adu_isspace(c) isspace((int)(unsigned char)(c))
+
 static int exec_interactive_command(char *line)
 {
        const char const *delim = "\t\n\f\r\v ";
@@ -204,7 +219,7 @@ out:
 int com_interactive(void)
 {
        char line[255];
-       int ret = 1;
+       int ret;
 
        select_cmdline_parser_init(&select_conf);
        ret = parse_select_options(NULL, NULL, &admissible_uids, &fi);