[BACK]Return to mansearch.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/mansearch.c between version 1.38 and 1.39

version 1.38, 2014/07/12 14:00:25 version 1.39, 2014/07/24 20:30:45
Line 94  static void   exprfree(struct expr *);
Line 94  static void   exprfree(struct expr *);
 static  struct expr     *exprspec(struct expr *, uint64_t,  static  struct expr     *exprspec(struct expr *, uint64_t,
                                  const char *, const char *);                                   const char *, const char *);
 static  struct expr     *exprterm(const struct mansearch *, char *, int);  static  struct expr     *exprterm(const struct mansearch *, char *, int);
   static  int              manpage_compare(const void *, const void *);
 static  void             sql_append(char **sql, size_t *sz,  static  void             sql_append(char **sql, size_t *sz,
                                 const char *newstr, int count);                                  const char *newstr, int count);
 static  void             sql_match(sqlite3_context *context,  static  void             sql_match(sqlite3_context *context,
Line 331  mansearch(const struct mansearch *search,
Line 332  mansearch(const struct mansearch *search,
                                     maxres, sizeof(struct manpage));                                      maxres, sizeof(struct manpage));
                         }                          }
                         mpage = *res + cur;                          mpage = *res + cur;
                           mpage->sec = 10;
                         mpage->form = mp->form;                          mpage->form = mp->form;
                         buildnames(mpage, db, s, mp->pageid,                          buildnames(mpage, db, s, mp->pageid,
                             paths->paths[i], mp->form);                              paths->paths[i], mp->form);
Line 347  mansearch(const struct mansearch *search,
Line 349  mansearch(const struct mansearch *search,
                 sqlite3_close(db);                  sqlite3_close(db);
                 ohash_delete(&htab);                  ohash_delete(&htab);
         }          }
           qsort(*res, cur, sizeof(struct manpage), manpage_compare);
         rc = 1;          rc = 1;
 out:  out:
         if (-1 != fd) {          if (-1 != fd) {
Line 360  out:
Line 363  out:
         return(rc);          return(rc);
 }  }
   
   static int
   manpage_compare(const void *vp1, const void *vp2)
   {
           const struct manpage    *mp1, *mp2;
           int                      diff;
   
           mp1 = vp1;
           mp2 = vp2;
           diff = mp1->sec - mp2->sec;
           return(diff ? diff : strcasecmp(mp1->names, mp2->names));
   }
   
 static void  static void
 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,  buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
                 uint64_t pageid, const char *path, int form)                  uint64_t pageid, const char *path, int form)
Line 391  buildnames(struct manpage *mpage, sqlite3 *db, sqlite3
Line 406  buildnames(struct manpage *mpage, sqlite3 *db, sqlite3
                 sec = sqlite3_column_text(s, 0);                  sec = sqlite3_column_text(s, 0);
                 arch = sqlite3_column_text(s, 1);                  arch = sqlite3_column_text(s, 1);
                 name = sqlite3_column_text(s, 2);                  name = sqlite3_column_text(s, 2);
   
                   /* Remember the first section found. */
   
                   if (9 < mpage->sec && '1' <= *sec && '9' >= *sec)
                           mpage->sec = (*sec - '1') + 1;
   
                 /* If the section changed, append the old one. */                  /* If the section changed, append the old one. */
   

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.39

CVSweb