--- configure +++ configure @@ -3283,7 +3283,7 @@ # Check whether --enable-hebrew was given. if test "${enable_hebrew+set}" = set; then : - enableval=$enable_hebrew; USE_HEBREW=yes + enableval=$enable_hebrew; USE_HEBREW=$enableval else USE_HEBREW=no fi --- src/hebrev.c +++ src/hebrev.c @@ -48,6 +48,7 @@ short int mode = 0, imode; const char *hmark = NULL, *lmark, *nmark, *nlmark; char ch; + const char* srcstart = src; if (src == NULL) return NULL; @@ -69,7 +70,7 @@ if (*src == 0 || iseng(*src)) { lmark = src-1; - while ((!isheb(*lmark)) && (!ispunct(*lmark))) lmark--; + while (lmark > srcstart && !isheb(*lmark) && !ispunct(*lmark)) lmark--; src = lmark; imode = 0; nmark = NULL; @@ -114,6 +115,7 @@ hmark = NULL; mode = 0; } + if (*src == '\0') *dest = '\0'; } if (!*src++) break; @@ -141,15 +143,16 @@ char *temp=NULL, *tmp=NULL; char *arg=NULL, *arg2=NULL; int i=0; + char* saveptr = NULL; temp = (char*) malloc(strlen(input)+1); tmp = temp; strcpy(temp, input); - arg = strtok(temp, "\n"); + arg = strtok_r(temp, "\n", &saveptr); for(i = 0; (i < index) && (arg!=NULL); i++) - arg = strtok(NULL, "\n"); + arg = strtok_r(NULL, "\n", &saveptr); if(arg != NULL) { @@ -164,6 +167,7 @@ { char* temp_str = NULL; char* temp = NULL; + char* arg = NULL; int i=0; int size = 0; if(src == NULL) @@ -172,21 +176,23 @@ if((temp_str = (char*)malloc(strlen(src)+1))== NULL) return NULL; - temp = GetArg(src, i); - while(temp != NULL) + arg = GetArg(src, i); + while(arg != NULL) { i++; - temp = hebrew(temp); + temp = hebrew(arg); + free(arg); memcpy(temp_str + size , temp, strlen(temp)); size += strlen(temp) ; temp_str[size++] = '\n'; free(temp); temp = NULL; - temp = GetArg(src, i); + arg = GetArg(src, i); } - free(temp); - temp_str[size]= '\0'; + // Above loop adds a line break after last line that wasn't there in src + // replace it with the null terminator + temp_str[--size]= '\0'; return temp_str; }