/* * Insert a comment into the project database. * See the API documentation for detailed information. */ int sn_insert_comment(char *classname, char *funcname, char *filename, char *comment, int beg_line, int beg_col) { if (sn_getopt(SN_OPT_COMMENTS)) { return put_comment(classname, funcname, filename, comment, beg_line, beg_col); } return(0); }
void insert_new_tag2(GapIO *io, int into, int *cache, int cache_len, int *cache_pos, int pos, int length, char *type, char *comment, int sense) { tag_id prev, next, newt; tagRecord prev_tag, next_tag, new_tag; int i; /* Initialise cache if required */ if (pos >= *cache_pos) { next = cache[*cache_pos]; if (!next) next = first_tag(io, into); while (next) { read_tag(io, next, &next_tag); if (next_tag.position < *cache_pos) { next = next_tag.next; continue; } if (next_tag.position > pos) break; for (i = *cache_pos; i < next_tag.position; i++) cache[i] = cache[*cache_pos]; for (; i <= next_tag.position; i++) { cache[i] = next; } *cache_pos = i-1; next = next_tag.next; } for (i = *cache_pos+1; i <= pos; i++) cache[i] = cache[*cache_pos]; *cache_pos = pos; } /* Find previous and next tags - quick lookup in cache */ prev = cache[pos]; if (!prev) { next = first_tag(io, into); } else { read_tag(io, prev, &prev_tag); next = prev_tag.next; } /* Create and initialise new tag */ newt = get_free_tag(io); new_tag.position = pos; new_tag.length = length; strncpy(new_tag.type.c,type,4); if (comment!=NULL) new_tag.comment = put_comment(io, comment); else new_tag.comment = 0; new_tag.next = next; new_tag.sense = sense; write_tag(io, newt, new_tag); /* Update cache */ i = pos; while (i <= *cache_pos && cache[i] == prev) cache[i++] = newt; if (pos > *cache_pos) { int j, k = cache[*cache_pos]; for (j = *cache_pos; j < pos; j++) cache[j] = k; cache[pos] = newt; *cache_pos = pos; } /* Link previous tag */ if (prev) { prev_tag.next = newt; write_tag(io, prev, prev_tag); } else { update_tag(io, into, newt); } }