[liblouis-liblouisxml] Help! C programmers

  • From: Paul wood <paulw.torchtrust@xxxxxxxxx>
  • To: "liblouis-liblouisxml@xxxxxxxxxxxxx" <liblouis-liblouisxml@xxxxxxxxxxxxx>
  • Date: Tue, 06 Aug 2013 11:39:22 +0100

Hi guys,
I'm trying to truncate the running header at a space so we don't get half a word or in a test case we just got a capitol sign! Anyway I've written a routine to truncate at the last space before the truncate length but then I look at the code and the 'string' definition refers to widechar, but when I find the definition of widechar at line 33 of liblouis.h it says:
#define widechar unsigned short int

How can a string be an int!

Here is my test routine in case it helps.
Thanks
Paul

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

int main ()
{
  char str[] = "This is t h ";
  char * pch;
  char str1[40];
  int lenstr1;
  int length=10;
  printf ("Looking for the 'space' character in \"%s\"...\n",str);
  pch=str;
  lenstr1=strlen(str);
  while (pch!=NULL && (pch-str)<=length)
  {
   strncpy ( str1, str, pch-str ); /* Save previous string */
   lenstr1=(pch-str); /* Save previous length of string */
   pch=strchr(pch+1,' '); /* Find next space */
    printf ("found at %d\n pch is %s\n",pch-str+1,pch);

  }
  if (lenstr1==0) { /* i.e. Not found any spaces */
      strncpy ( str1, str, strlen(str) );
      lenstr1=strlen(str);
  }
  str1[lenstr1] = '\0'; /* add Null as required */
  printf("string is:\"%s\"\n",str1);
  return 0;
}
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts: