Apparently trying to diff non-UTF8 documents caused a stack overflow.
The culprit was correctly identified by Yonetani as the redefinition
of wcwidth in the wcwidth.c file. Within that function, it calls itself
recursively forever. I'm not sure how this would work differently
(macro or not) on another system.
My solution was to stop redefining wcwidth and just create a separate
function, one that will call the system wcwidth function as needed.
reported by: Peter Avalos
http://bugs.dragonflybsd.org/issue2134
A list of files and directories removed is in README.DELETED
Local modifications applied to following files:
- diff.c
- diff3.c
- sdiff.c
-
+ src/diff.c
+ src/diff3.c
+ src/sdiff.c
+ src/side.c
+ lib/wcwidth.c
/* Specification. */
#include <wchar.h>
+#include <gnuwidechar.h>
/* Get iswprint. */
#include <wctype.h>
#include "uniwidth.h"
int
-wcwidth (wchar_t wc)
-#undef wcwidth
+special_wcwidth (wchar_t wc)
{
/* In UTF-8 locales, use a Unicode aware width function. */
const char *encoding = locale_charset ();
#include "diff.h"
#include <wchar.h>
+#include <gnuwidechar.h>
static void print_sdiff_common_lines (lin, lin);
static void print_sdiff_hunk (struct change *);
if (0 < bytes && bytes < (size_t) -2)
{
- int width = wcwidth (wc);
+ int width = special_wcwidth (wc);
if (0 < width)
in_position += width;
if (in_position <= out_bound)
--- /dev/null
+/*
+ * Works around wcwidth recursive problem while maintaining UTF-8
+ * handling functionality.
+ */
+
+#ifndef _GNUWIDECHAR_H_
+#define _GNUWIDECHAR_H_
+
+int special_wcwidth(wchar_t);
+
+#endif /* !_GNUWIDECHAR_H_ */