/[global]/global/libutil/gtagsop.c
ViewVC logotype

Diff of /global/libutil/gtagsop.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.76 by shigio, Tue Oct 4 07:59:04 2005 UTC revision 1.77 by shigio, Sat Oct 8 14:59:00 2005 UTC
# Line 164  makecommand(const char *comline, STRBUF Line 164  makecommand(const char *comline, STRBUF
164   * func              83 ./func.c       func()   * func              83 ./func.c       func()
165   */   */
166  void  void
167  formatcheck(const char *line)           /* virtually const */  formatcheck(const char *ctags_x)                /* virtually const */
168  {  {
169          int n;          int n;
170          const char *p;          const char *p;
# Line 173  formatcheck(const char *line)          /* virtua Line 173  formatcheck(const char *line)          /* virtua
173          /*          /*
174           * Extract parts.           * Extract parts.
175           */           */
176          n = split((char *)line, 4, &ptable);          n = split((char *)ctags_x, 4, &ptable);
177    
178          /*          /*
179           * line number           * line number
180           */           */
181          if (n < 4) {          if (n < 4) {
182                  recover(&ptable);                  recover(&ptable);
183                  die("too small number of parts.\n'%s'", line);                  die("too small number of parts.\n'%s'", ctags_x);
184          }          }
185          for (p = ptable.part[1].start; *p; p++) {          for (p = ptable.part[PART_LNO].start; *p; p++) {
186                  if (!isdigit((unsigned char)*p)) {                  if (!isdigit((unsigned char)*p)) {
187                          recover(&ptable);                          recover(&ptable);
188                          die("line number includes other than digit.\n'%s'", line);                          die("line number includes other than digit.\n'%s'", ctags_x);
189                  }                  }
190          }          }
191          /*          /*
192           * path name           * path name
193           */           */
194          p = ptable.part[2].start;          p = ptable.part[PART_PATH].start;
195          if (!(*p == '.' && *(p + 1) == '/' && *(p + 2))) {          if (!(*p == '.' && *(p + 1) == '/' && *(p + 2))) {
196                  recover(&ptable);                  recover(&ptable);
197                  die("path name must start with './'.\n'%s'", line);                  die("path name must start with './'.\n'%s'", ctags_x);
198          }          }
199    
200          recover(&ptable);          recover(&ptable);
# Line 334  gtags_open(const char *dbpath, const cha Line 334  gtags_open(const char *dbpath, const cha
334   *   *
335   *      i)      gtop    descripter of GTOP   *      i)      gtop    descripter of GTOP
336   *      i)      tag     tag name   *      i)      tag     tag name
337   *      i)      record  ctags -x image   *      i)      ctags_x ctags -x image
338   *   *
339   * NOTE: If format is GTAGS_COMPACT or GTAGS_PATHINDEX   * NOTE: If format is GTAGS_COMPACT or GTAGS_PATHINDEX
340   *       then this function is destructive.   *       then this function is destructive.
341   */   */
342  void  void
343  gtags_put(GTOP *gtop, const char *tag, const char *record)      /* virtually const */  gtags_put(GTOP *gtop, const char *tag, const char *ctags_x)     /* virtually const */
344  {  {
345          const char *line, *path;          const char *tagname;
346          SPLIT ptable;          SPLIT ptable;
347          struct gtop_compact_entry *entry, **prev;          struct gtop_compact_entry *entry, **prev;
348          int *lno;          int *lno;
349    
350          if (gtop->format == GTAGS_STANDARD) {          if (gtop->format == GTAGS_STANDARD) {
351                  /* entab(record); */                  /* entab(ctags_x); */
352                  dbop_put(gtop->dbop, tag, record);                  dbop_put(gtop->dbop, tag, ctags_x);
353                  return;                  return;
354          }          }
355          if (gtop->format == GTAGS_PATHINDEX) {          if (gtop->format == GTAGS_PATHINDEX) {
356                  char *p = locatestring(record, "./", MATCH_FIRST);                  char *p = locatestring(ctags_x, "./", MATCH_FIRST);
357                  const char *fid;                  const char *fid, *path;
358                  int savec;                  int savec;
359    
360                  if (p == NULL)                  if (p == NULL)
# Line 370  gtags_put(GTOP *gtop, const char *tag, c Line 370  gtags_put(GTOP *gtop, const char *tag, c
370                          die("GPATH is corrupted.('%s' not found)", path);                          die("GPATH is corrupted.('%s' not found)", path);
371                  *p = savec;                  *p = savec;
372                  strbuf_reset(gtop->sb);                  strbuf_reset(gtop->sb);
373                  strbuf_nputs(gtop->sb, record, path - record);                  strbuf_nputs(gtop->sb, ctags_x, path - ctags_x);
374                  strbuf_puts(gtop->sb, fid);                  strbuf_puts(gtop->sb, fid);
375                  strbuf_puts(gtop->sb, p);                  strbuf_puts(gtop->sb, p);
376                  dbop_put(gtop->dbop, tag, strbuf_value(gtop->sb));                  dbop_put(gtop->dbop, tag, strbuf_value(gtop->sb));
# Line 379  gtags_put(GTOP *gtop, const char *tag, c Line 379  gtags_put(GTOP *gtop, const char *tag, c
379          /*          /*
380           * gtop->format & GTAGS_COMPACT           * gtop->format & GTAGS_COMPACT
381           */           */
382          if (split((char *)record, 4, &ptable) != 4) {          if (split((char *)ctags_x, 4, &ptable) != 4) {
383                  recover(&ptable);                  recover(&ptable);
384                  die("illegal tag format.\n'%s'", record);                  die("illegal tag format.\n'%s'", ctags_x);
385          }          }
386          line = ptable.part[1].start;          tagname = ptable.part[PART_TAG].start;
         path = ptable.part[2].start;  
387          /*          /*
388           * Register each record into the hash table.           * Register each record into the hash table.
389           * Duplicated records will be combined.           * Duplicated records will be combined.
390           */           */
391          if (gtop->prev_path[0] && strcmp(gtop->prev_path, path))          if (gtop->prev_path[0] && strcmp(gtop->prev_path, ptable.part[PART_PATH].start))
392                  gtop_flush_htab(gtop);                  gtop_flush_htab(gtop);
393          strlimcpy(gtop->prev_path, path, sizeof(gtop->prev_path));          strlimcpy(gtop->prev_path, ptable.part[PART_PATH].start, sizeof(gtop->prev_path));
394          for (prev = gtop->htab + hashpjw(record) % HASHBUCKETS;          for (prev = gtop->htab + hashpjw(tagname) % HASHBUCKETS;
395               (entry = *prev) != NULL;               (entry = *prev) != NULL;
396               prev = &entry->next) {               prev = &entry->next) {
397                  if (strcmp(entry->tag, record) == 0)                  if (strcmp(entry->tag, tagname) == 0)
398                          break;                          break;
399          }          }
400          if (entry == NULL) {          if (entry == NULL) {
401                  entry = malloc(offsetof(struct gtop_compact_entry, tag) + strlen(record) + 1);                  entry = malloc(offsetof(struct gtop_compact_entry, tag) + strlen(tagname) + 1);
402                  if (entry == NULL)                  if (entry == NULL)
403                          die("short of memory.");                          die("short of memory.");
404                  entry->next = NULL;                  entry->next = NULL;
405                  entry->vb = varray_open(sizeof(int), 100);                  entry->vb = varray_open(sizeof(int), 100);
406                  strcpy(entry->tag, record);                  strcpy(entry->tag, tagname);
407                  *prev = entry;                  *prev = entry;
408          }          }
409          lno = varray_append(entry->vb);          lno = varray_append(entry->vb);
410          *lno = atoi(line);          *lno = atoi(ptable.part[PART_LNO].start);
411          recover(&ptable);          recover(&ptable);
412  }  }
413  /*  /*

Legend:
Removed from v.1.76  
changed lines
  Added in v.1.77

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26