/*
- * Command line utility for making sense of C declarations.
- * Copyright © 2011 Nick Bowler
+ * Command line utility for making sense of C declarations.
+ * Copyright © 2011-2012 Nick Bowler
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * This program 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.
+ * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
+#include <ctype.h>
#include <errno.h>
#include <locale.h>
#include <getopt.h>
#include <gettext.h>
#include <assert.h>
#include "readline.h"
+#include "history.h"
#include "cdecl.h"
#define _(x) gettext(x)
return -1;
}
+static bool is_blank_line(const char *line)
+{
+ for (size_t i = 0; line[i]; i++) {
+ if (!isblank((unsigned char)line[i]))
+ return false;
+ }
+
+ return true;
+}
+
static int repl(void)
{
char *line;
for (; (line = readline("> ")); free(line)) {
+ if (!is_blank_line(line))
+ cdecl_add_history(line);
+
if (!run_command(line))
break;
}