display_string() that have been used in the search prompt
since 1.3.0. (David Benbennick)
- utils.c:
+ is_blank_char()
+ - Add new function is_blank_char() as an isblank() equivalent,
+ since isblank() is a GNU extension. (DLR)
nstricmp(), nstrnicmp()
- Add extra blank lines for greater readability, and remove
unneeded test for n's being less than zero (since it's already
- Rename to nstristr() to avoid a potential conflict with an
existing stristr() function, and move up to just after
nstrnicmp(). (DLR) David Benbennick: Tweak for efficiency.
+ - Include and use only when strcasestr() is unavailable, since
+ strcasestr() is a GNU extension. (DLR)
- winio.c:
get_verbatim_kbinput()
- Refactor the output in the DEBUG #ifdef. It didn't work
- Use napms() instead of nanosleep(), as it does the same thing
(aside from taking an argument in milliseconds instead of
microseconds) and curses includes it. (DLR)
+- configure.ac:
+ - Add tests for isblank() and strcasestr(), and define
+ _GNU_SOURCE so that the tests work properly. Increase the
+ minimum required autoconf version to 2.54. (DLR)
- faq.html:
- Removed question about the NumLock glitch, as it's no longer
needed. (DLR)
- nanorc.sample:
- Add missing mouse entry, and update the nanorc sample regexes
to account for the backupdir and mouse options. (DLR)
+- README.CVS:
+ - Increase the minimum required autoconf version to 2.54, and
+ change the recommended automake version 1.7 to the minimum
+ required automake version. Note that autoconf 2.54 will
+ technically also work with automake 1.6c, but that is a CVS
+ version as opposed to a stable release version, and automake
+ 1.7 requires at least autoconf 2.54 in any case. (DLR)
GNU nano 1.3.2 - 2004.03.31
- General:
To successfully compile GNU nano from CVS, you'll need the
following packages:
-- autoconf (version >= 2.52)
-- automake (version >= 1.6, 1.7.x recommended)
+- autoconf (version >= 2.54)
+- automake (version >= 1.7)
- gettext (version >= 0.11.5)
- texinfo
- cvs
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER([config.h:config.h.in])
-AC_PREREQ(2.52)
+AC_PREREQ(2.54)
dnl Checks for programs.
+AC_GNU_SOURCE
AC_PROG_CC
AC_ISC_POSIX
AC_SYS_LARGEFILE
esac], [AC_MSG_RESULT(no)])
dnl Checks for functions
-AC_CHECK_FUNCS(snprintf vsnprintf strcasecmp strncasecmp)
+AC_CHECK_FUNCS(snprintf vsnprintf isblank strcasecmp strncasecmp strcasestr)
if test "x$ac_cv_func_snprintf" = "xno" -o "xac_cv_func_vsnprintf" = "xno"
then
AM_PATH_GLIB_2_0(2.0.0,,
assume it's a DOS or Mac formatted file if it hasn't been
detected as one already! */
if (fileformat == 0 && !ISSET(NO_CONVERT)
- && is_cntrl_char((int)input) != 0 && input != '\t'
+ && is_cntrl_char(input) && input != '\t'
&& input != '\r' && input != '\n')
SET(NO_CONVERT);
#endif
tmp = matchbuf;
/* skip any leading white space */
- while (*tmp && isspace((int)*tmp))
+ while (*tmp && isblank(*tmp))
++tmp;
/* Free up any memory already allocated */
int extra = 0;
const char *spc = current->data;
- while (*spc == ' ' || *spc == '\t') {
+ while (isblank(*spc)) {
extra++;
spc++;
}
wrap_line = inptr->data + i;
for (; i < len; i++, wrap_line++) {
/* record where the last word ended */
- if (*wrap_line != ' ' && *wrap_line != '\t')
+ if (!isblank(*wrap_line))
word_back = i;
/* if we have found a "legal wrap point" and the current word
* extends too far, then we stop */
if (wrap_loc != -1 && strnlenpt(inptr->data, word_back + 1) > fill)
break;
/* we record the latest "legal wrap point" */
- if (word_back != i && wrap_line[1] != ' ' && wrap_line[1] != '\t')
+ if (word_back != i && !isblank(wrap_line[1]))
wrap_loc = i;
}
if (wrap_loc < 0 || i == len)
* between after_break and wrap_line. If the line already ends
* in a tab or a space, we don't add a space and decrement
* totsize to account for that. */
- if (!isspace((int) newline[strlen(newline) - 1]))
+ if (!isblank(newline[strlen(newline) - 1]))
strcat(newline, " ");
else
totsize--;
size_t len = 0;
assert(line != NULL);
- while (*line == ' ' || *line == '\t') {
+ while (isblank(*line)) {
line++;
len++;
}
assert(line != NULL);
assert(line->data != NULL);
assert(skip < strlen(line->data));
- assert(line->data[skip] != ' ' && line->data[skip] != '\t');
+ assert(!isblank(line->data[skip]));
back = line->data + skip;
front = back;
int breakable(const char *line, int goal)
{
for (; *line != '\0' && goal >= 0; line++) {
- if (*line == ' ' || *line == '\t')
+ if (isblank(*line))
return TRUE;
if (is_cntrl_char(*line) != 0)
* characters, as searching for the end of the paragraph
* does. */
for (i = 0; current->data[i] != '\0'; i++) {
- if (isspace(current->data[i]))
+ if (isblank(current->data[i]))
j++;
else {
i = 0;
# endif
#endif
-/* If no strcasecmp() or strncasecmp(), use the versions we have. */
+/* If no isblank(), strcasecmp(), strncasecmp(), or strcasestr(), use
+ * the versions we have. */
+#ifndef HAVE_ISBLANK
+#define isblank is_blank_char
+#endif
+
#ifndef HAVE_STRCASECMP
#define strcasecmp nstricmp
#endif
#define strncasecmp nstrnicmp
#endif
+#ifndef HAVE_STRCASESTR
+#define strcasestr nstristr
+#endif
+
/* Assume ERR is defined as -1. To avoid duplicate case values when
* some key definitions are missing, we have to set all of these, and
* all of the special sentinel values below, to different negative
#endif
int regexp_bol_or_eol(const regex_t *preg, const char *string);
#endif
+#ifndef HAVE_ISBLANK
+int is_blank_char(int c);
+#endif
int is_cntrl_char(int c);
int num_of_digits(int n);
void align(char **strp);
#include <sys/stat.h>
#include <fcntl.h>
#include <pwd.h>
+#include <ctype.h>
#include <assert.h>
#include "proto.h"
#include "nano.h"
/* Parse the next word from the string. Returns NULL if we hit EOL. */
char *parse_next_word(char *ptr)
{
- while (*ptr != ' ' && *ptr != '\t' && *ptr != '\n' && *ptr != '\0')
+ while (!isblank(*ptr) && *ptr != '\n' && *ptr != '\0')
ptr++;
if (*ptr == '\0')
/* Null terminate and advance ptr */
*ptr++ = 0;
- while (*ptr == ' ' || *ptr == '\t')
+ while (isblank(*ptr))
ptr++;
return ptr;
ptr = last_quote + 1;
}
if (ptr != NULL)
- while (*ptr == ' ' || *ptr == '\t')
+ while (isblank(*ptr))
ptr++;
return ptr;
}
/* Null terminate and advance ptr. */
*ptr++ = '\0';
- while (*ptr == ' ' || *ptr == '\t')
+ while (isblank(*ptr))
ptr++;
return ptr;
while (fgets(buf, 1023, rcstream) != 0) {
lineno++;
ptr = buf;
- while (*ptr == ' ' || *ptr == '\t')
+ while (isblank(*ptr))
ptr++;
if (*ptr == '\n' || *ptr == '\0')
}
#endif /* HAVE_REGEX_H */
+#ifndef HAVE_ISBLANK
+/* This function is equivalent to isblank(). */
+int is_blank_char(int c)
+{
+ return (c == '\t' || c == ' ');
+}
+#endif
+
+/* This function is equivalent to iscntrl(), except in that it also
+ * handles control characters with their high bits set. */
int is_cntrl_char(int c)
{
return (-128 <= c && c < -96) || (0 <= c && c < 32) ||
- (127 <= c && c < 160);
+ (127 <= c && c < 160);
}
int num_of_digits(int n)
}
#endif
+#ifndef HAVE_STRCASESTR
/* This function is equivalent to strcasestr(). It was adapted from
* mutt's mutt_stristr() function. */
const char *nstristr(const char *haystack, const char *needle)
return NULL;
}
+#endif
/* None of this is needed if we're using NANO_SMALL! */
#ifndef NANO_SMALL
else if (ISSET(REVERSE_SEARCH))
return revstristr(haystack, needle, start);
#endif
- return nstristr(start, needle);
+ return strcasestr(start, needle);
}
/* This is a wrapper for the perror() function. The wrapper takes care