optimize for C source code
[idzebra-moved-to-github.git] / recctrl / safari.c
index f22ef34..045bf70 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: safari.c,v 1.8 2005-06-23 06:45:47 adam Exp $
+/* $Id: safari.c,v 1.10 2006-03-21 14:36:22 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -86,13 +86,16 @@ static int fi_getchar(struct fi_info *fi, char *dst)
 
 static int fi_gets(struct fi_info *fi, char *dst, int max)
 {
-    int l;
-    for (l = 0; l < max; l++)
+    int l = 0;
+    while(1)
     {
-       if (!fi_getchar(fi, dst+l))
+       char dstbyte;
+       if (!fi_getchar(fi, &dstbyte))
            return 0;
-       if (dst[l] == '\n')
+       if (dstbyte == '\n')
            break;
+       if (l < max)
+           dst[l++] = dstbyte;
     }
     dst[l] = '\0';
     return 1;
@@ -123,7 +126,7 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p)
        return RECCTRL_EXTRACT_ERROR_GENERIC;
     sscanf(line, "%255s", p->match_criteria);
     
-    recWord.index_type = 'w';
+    recWord.index_type = '0';
     while (fi_gets(fi, line, sizeof(line)-1))
     {
        int nor = 0;