summaryrefslogtreecommitdiff
blob: a0fdb936bdb229e6eb3abca42daf296e3250ada1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
--- 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;
 }