[liblouis-liblouisxml] Re: Crash in Python hyphenation

  • From: Milan Zamazal <pdm@xxxxxxxxxxxx>
  • To: Michael Whapples <mwhapples@xxxxxxx>
  • Date: Tue, 05 Jun 2012 09:00:17 +0200

>>>>> "MW" == Michael Whapples <mwhapples@xxxxxxx> writes:

    MW> Does lou_checkhyphens add a new line to the end of input?

Here is a test C program.  You can see that liblouis attaches a 0
terminating character to the end of the output.  Maybe this is the
problem?

#include <stdio.h>
#include <string.h>
#include <liblouis/liblouis.h>

int main (void)
{
  const char *word = "straightforward";
  const int inlen = strlen (word);
  const char *tableList = "en-us-g1.utb,hyph_en_US.dic";
  widechar inbuf[inlen];
  char hyphens[inlen+1];
  int result;
  int i;

  for (i = 0; i < inlen; i++)
    inbuf[i] = word[i];
  hyphens[inlen] = 'X';
  result = lou_hyphenate (tableList, inbuf, inlen, hyphens, 0);

  printf ("%d:%d:", result, inlen);
  for (i = 0; i < inlen + 1; i++)
    printf ("%c", hyphens[i]);
  printf (":\n");

  return ! result;
}

Other related posts: