/*-----------------------------------------------------------------------*/ adjoin_synonym_lists() /* the parser along with begin_synonym_proc and assert_synonym_proc builds a linked list of synonym list headers which point to lists of synonyms as they occur in the CSL source. global ptr synonyms is the header of this data structure. This func applies the transitivity property of synonyms to group together all lists that have common synonym names. Thus if A B C and B E F are two separate syn decl, then this func groups these (in the same data struc) as A B C D E F for every element in the 1st list (the 1st element) every other element of all other lists (the 2nd elements) succeeding it are checked for duplicates. In case of dupl, the second list is immediately appended to the first one and the node containing it's header is removed from the list headed by global ptr synonyms. checking is then continued. checking ends when less than 2 lists are available */ { int found; struct list_of_syn_lists *lslp1, /* 1st list header node */ *lslp2, /* 2nd list header node */ *lslp_tmp; struct syn_node *snp1, /* 1st element in 1st list */ *snp2; /* 2nd element in 2nd list */ lslp1 = synonyms; while (lslp1 != NULL && lslp1->next != NULL) /* while 2 lists at least */ { find_end(lslp1); /* find end of 1st in global curr_syn_node */ snp1 = lslp1->curr_list; while (snp1 != NULL) /* for each 1st element */ { lslp2 = lslp1; while (lslp2->next != NULL) /* for each 2nd list */ { snp2 = lslp2->next->curr_list; found = FALSE; while (snp2 != NULL)/* for each 2nd element */ { if (strcmp(snp1->name, snp2->name) == 0) /* duplicate? */ { curr_syn_node->next = lslp2->next->curr_list; /* adjoin */ /* delete 2nd list from list of syn lists */ lslp_tmp = lslp2->next; lslp2->next = lslp2->next->next; free(lslp_tmp); find_end(lslp1); /* find new end */ found = TRUE; break; } snp2 = snp2->next; } if (!found) /* 2nd list not deleted? */ lslp2 = lslp2->next; /* advance ptr */ } snp1 = snp1->next; } lslp1 = lslp1->next; } }
/* * Name: combine_wrap_spill * Purpose: combine word wrap lines so we don't push each word onto a * separate line. * Date: November 27, 1991 * Passed: window: pointer to current window * wrap_col: col to combine next line * lm: left margin * rm: right margin * side: left or right margin to insert spaces * new_line: boolean, should we insert a new line? */ void combine_wrap_spill( WINDOW *window, int wrap_col, int lm, int rm, int side, int new_line ) { line_list_ptr p; /* line we wrapped */ line_list_ptr pp; /* pointer to next line after wrapped line */ int p_len; /* length of line we just word wrapped */ int non_blank; /* first non-blank column on next line */ int control_t; /* number of times to call word_delete */ int next_line_len; /* length of next line counting from 1st word */ WINDOW w; /* scratch window */ dup_window_info( &w, window ); g_status.command = WordWrap; w.rcol = wrap_col; if (new_line) { insert_newline( &w ); if (mode.right_justify == TRUE) justify_right_margin( &w, w.ll->prev, mode.word_wrap == FIXED_WRAP ? find_left_margin( w.ll->prev, mode.word_wrap ) : lm, rm, side ); p = window->ll->next; } else p = window->ll; if (p != NULL) { p_len = find_end( p->line, p->len ); pp = p->next; if (pp != NULL) { non_blank = first_non_blank( pp->line, pp->len ); next_line_len = find_end( pp->line, pp->len ) - non_blank; if (!is_line_blank( pp->line, pp->len ) && p_len + next_line_len <= rm) { control_t = 1; if (mode.inflate_tabs) { if (*pp->line == ' ' || *pp->line == '\t') ++control_t; } else if (*pp->line == ' ') ++control_t; w.ll = p; w.rcol = p_len + 1; if (*(p->line+p_len-1) == '.') ++w.rcol; while (control_t--) word_delete( &w ); remove_spaces( lm ); un_copy_line( w.ll, &w, TRUE ); } window->file_info->dirty = GLOBAL; } } }
int cmp_l(char *com) { int c; int b; int start; int end; b = 0; c = 0; start = find_start(com); end = find_end(com); while (start < end) { if (com[start] == ' ') { b++; while (com[start] == ' ') start++; } else { start++; c++; } } //my_printf("Nombre de mot : %d\nNombre d'espace : %d\nNombre a malloc : %d\n", c, b, (c + b)); return (c + b); }
char *epure_str(char *com) { char *to_return; int start; int end; int i; start = find_start(com); end = find_end(com); i = 0; if ((to_return = malloc(sizeof(char) * cmp_l(com))) == NULL) return ("Error malloc"); while (start < end) { if (com[start] == ' ' && i != end) { to_return[i] = com[start]; while (com[start] == ' ') start++; i++; } else { to_return[i] = com[start]; start++; i++; } } to_return[cmp_l(com) + 1] == '\0'; return (to_return); }
// ------------------------------------------------------ // load // ------------------------------------------------------ bool RegistryReader::load(const char* fileName,const char* directory) { char buffer[256]; sprintf(buffer,"%s\\%s",directory,fileName); std::string line; std::ifstream myfile(buffer); int cnt = 0; if (myfile.is_open()) { while (std::getline(myfile, line)) { ++cnt; if (line.find("#") == std::string::npos && line.find(",") != std::string::npos) { Entry e; e.line = line; e.count = _num_fields; e.line_nr = cnt; for ( int i = 0; i < _num_fields; ++i ) { if ( line.find(_field_names[i]) != std::string::npos) { size_t idx = line.find(_field_names[i]); int nidx = line.find(":",idx); if ( nidx != std::string::npos) { nidx = find_end(line,nidx); } e.set(i,nidx); } } _lines.push_back(e); } } myfile.close(); return true; } return false; }
static int launch_cmd(char *line, t_client *client, t_kernel *kernel) { char **av; int i; int ret; while (line && *line) { if (!(av = my_str_to_wordtab(line))) return (-1); i = 0; ret = -1; while (ret == -1 && av[0] && g_functions[i].name) { if (!strcmp(av[0], g_functions[i].name)) { if ((ret = call_cmd(i, client, av, kernel))) return (ret); } ++i; } if (!g_functions[i].name) if ((ret = game_auth(av, client, kernel))) return (ret); line = find_end(line); } return (0); }
int linear_searcher::search(const char *buffer, const char *bufend, const char **startp, int *lengthp) const { assert(bufend - buffer > 0); assert(buffer[-1] == '\n'); assert(bufend[-1] == '\n'); if (nkeys == 0) return 0; for (;;) { const char *refstart; const char *found = search_and_check(keys[0], buffer, bufend, &refstart); if (!found) break; const char *refend = find_end(bufend, found + keys[0]->length()); int i; for (i = 1; i < nkeys; i++) if (!search_and_check(keys[i], refstart, refend)) break; if (i >= nkeys) { *startp = refstart; *lengthp = refend - refstart; return 1; } buffer = refend; } return 0; }
int parse_first_line (char **buf, const char *end, int *type) { int offset; char *fline; offset = find_end (*buf, end); if (offset < 4) /* first line to short, just go out */ return 1; fline = (char *) strndup (*buf, offset); if (LOG_PARSER) log_info ("First line is : %s\n", fline); if (check ("REGISTER", 8, fline, NULL)) { //log_info ("REGISTER\n"); *type = MSG_REG; } else if (check ("SIP/2.0", 7, fline, NULL)) { //log_info ("SIP/2.0\n"); *type = MSG_REP; } else if (check ("CERT", 4, fline, NULL)) { //log_info ("CERT\n"); *type = MSG_CERT; } else *type = MSG_OTH; *buf += offset; m_free (fline); return 0; }
int parse_via_header (struct sip_msg *msg, char ip[]) { size_t len; char *via = NULL; char *addr = NULL; char *tmp = NULL; char *tmp1 = NULL; int i; if (!msg->via1) return 1; /* locate via and its length first */ via = msg->orig + (msg->via1 - msg->buf); len = find_end (via, msg->orig + msg->len); addr = m_alloc (len + 1); memcpy (addr, via, len); addr[len] = '\0'; tmp = strstr (addr, "SIP/2.0"); if (tmp) { len -= (tmp - addr); if ((tmp1 = strstr (tmp, "UDP")) || (tmp1 = strstr (tmp, "TCP"))) { tmp1 += 3; len -= 3; } else { m_free (addr); return 1; // No UDP or TCP } while ((*tmp1 == ' ') && (len > 0)) { tmp1++; // remove space len--; } tmp = tmp1; while ((isdigit (*tmp1) || (*tmp1 == '.')) && (len > 0) && (tmp1 - tmp < 15)) { /* Just copy the bytes now, * we will check if it is right or not with inet_aton later on */ ip[tmp1 - tmp] = *tmp1; tmp1++; len--; } ip[tmp1 - tmp + 1] = '\0'; m_free (addr); return 0; } else return 1; // no SIP/2.0 }
void pure_numeric_algo(){ cout<<endl<<"pure_numeric_algo :"<<endl; int ia[11] = {0, 1, 2, 3, 4, 5, 6,6,6, 7, 8 }; vector<int> iv(ia,ia+11); vector<int> iv2(ia+6,ia+8); vector<int>::iterator itr; itr = adjacent_find(iv.begin(),iv.end(), equal_to<int>()); //找到相邻元素相等的第一个元素 cout<<"adjacent_find: "<<*itr<<endl; cout<<"count: "<<count(iv.begin(),iv.end(), 6)<<endl; //找到元素值等于6的个数 cout<<"count_if: "<<count_if(iv.begin(),iv.end(), bind2nd(less<int>() , 7))<<endl; //找到小于7的元素个数 itr = find(iv.begin(),iv.end(), 4); //找到元素等于4的第一个元素位置 cout<<"find: "<<*itr<<endl; itr = find_if(iv.begin(),iv.end(), bind2nd(greater<int>() , 2)); //找到元素大于2的第一个元素位置 cout<<"find_if: "<<*itr<<endl; itr = find_end(iv.begin(),iv.end(), iv2.begin(),iv2.end()); //找到iv序列中最后子序列匹配出现的位置 cout<<"find_end: "<<*(itr+3)<<endl; itr = find_first_of(iv.begin(),iv.end(), iv2.begin(),iv2.end()); //找到iv序列中最先子序列匹配出现的位置 cout<<"find_end: "<<*(itr+3)<<endl; remove(iv.begin(),iv.end(), 6); //删除元素,向前移,但是容器size不变,后面会剩余数据 cout<<"remove: "<<iv<<endl; vector<int> iv3(12,-1); remove_copy(iv.begin(),iv.end(), iv3.begin(), 6); //删除元素,将数据拷贝到新容器,后面会剩余数据 cout<<"remove_copy: "<<iv3<<endl; remove_if(iv.begin(),iv.end(), bind2nd(less<int>(), 6)); //删除小于6的元素,后面会剩余数据 cout<<"remove_if: "<<iv<<endl; remove_copy_if(iv.begin(),iv.end(), iv3.begin(), bind2nd(less<int>(), 7)); //删除小于7的元素,并拷贝到新容器 cout<<"remove_copy_if: "<<iv3<<endl; replace(iv.begin(),iv.end(), 6, 3); //将所有元素值为6的改为3 cout<<"replace: "<<iv<<endl; replace_copy(iv.begin(),iv.end(),iv3.begin(), 3, 5); //将所有元素值为3的改为5,结果保存在新容器中 cout<<"replace_copy: "<<iv3<<endl; replace_if(iv.begin(),iv.end(), bind2nd(less<int>(),5), 2); //将所有元素值小于5的改为2 cout<<"replace_if: "<<iv<<endl; replace_copy_if(iv.begin(),iv.end(),iv3.begin(), bind2nd(equal_to<int>(),8), 9); //将所有元素值为8的改为9,结果保存在新容器中 cout<<"replace_copy_if: "<<iv3<<endl; reverse(iv.begin(),iv.end()); cout<<"reverse: "<<iv<<endl; //反转 reverse_copy(iv.begin(),iv.end(),iv3.begin()); cout<<"reverse_copy: "<<iv3<<endl; //反转,结果保存在新容器 rotate(iv.begin(),iv.begin() + 4, iv.end()); cout<<"rotate: "<<iv<<endl; //互换元素 rotate_copy(iv.begin(),iv.begin() + 5,iv.end(),iv3.begin()); cout<<"rotate_copy: "<<iv3<<endl; //互换元素,结果保存在新容器 int ia2[] = {2, 8}; vector<int> iv4(ia2,ia2+2); cout<<"search: "<<*search(iv.begin(),iv.end(),iv4.begin(),iv4.end())<<endl; //查找子序列出现的第一次出现地点 swap_ranges(iv4.begin(),iv4.end(),iv.begin()); //按区域交换 cout<<"swap_ranges: "<<iv<<endl<<iv4<<endl; transform(iv.begin(),iv.end(),iv.begin(),bind2nd(minus<int>(), 2)); //所有元素减2 cout<<"transform: "<<iv<<endl; transform(iv4.begin(),iv4.end(),iv.begin(),iv4.begin(),plus<int>()); //区间对应元素相加 cout<<"transform: "<<iv4<<endl; /************************************************************************/ vector<int> iv5(ia,ia+11); vector<int> iv6(ia+4,ia+8); vector<int> iv7(15); cout<<"max_element: "<<*max_element(iv5.begin(), iv5.end())<<endl; //最大元素游标 cout<<"min_element: "<<*min_element(iv5.begin(), iv5.end())<<endl; cout<<"includes: "<<includes(iv5.begin(),iv5.end(),iv6.begin(),iv6.end())<<endl; //iv6中元素是不是都在iv5中,这两个必须排过序 merge(iv5.begin(),iv5.end(),iv6.begin(),iv6.end(),iv7.begin()); //两个排序号的容器合并 cout<<"merge: "<<iv7<<endl; partition(iv7.begin(),iv7.end(),bind2nd(equal_to<int>(), 5)); //满足条件的放在左边,不满足条件的放在右边 cout<<"partition: "<<iv7<<endl; unique(iv5.begin(),iv5.end()); //去重,重复的元素放在后面 cout<<"unique: "<<iv5<<endl; unique_copy(iv5.begin(),iv5.end(),iv7.begin()); //去重,结果保存在新容器 cout<<"unique_copy: "<<iv7<<endl; }
void machine_t::save_image(FILE* f) const { int32_t *start = memory; int32_t *end = find_end() + sizeof(int32_t); while ( start != end ) { fwrite(start, sizeof(Op), 1, f); start += sizeof(int32_t); } }
/* just returns if line is not completed yet */ int write_boundary(struct COOR *seed) { struct COOR *point, *line_begin, *line_end; int dir, line_type, n, n1; point = seed; if ((dir = at_end(point))) { /* already have one end of line */ line_begin = point; line_end = find_end(point, dir, &line_type, &n); if (line_type == OPEN) return (-1); /* unfinished line */ direction = dir; } else { /* in middle of a line */ line_end = find_end(point, FORWARD, &line_type, &n); if (line_type == OPEN) /* line not finished */ return (-1); if (line_type == END) { /* found one end at least *//* look for other one */ line_begin = find_end(point, BACKWARD, &line_type, &n1); if (line_type == OPEN) /* line not finished */ return (-1); if (line_type == LOOP) { /* this should NEVER be the case */ return (-1); } direction = at_end(line_begin); /* found both ends now; total length */ n += n1; /* is sum of distances to each end */ } else { /* line_type = LOOP by default */ /* already have correct length */ line_begin = line_end; /* end and beginning are the same */ direction = FORWARD; /* direction is arbitrary */ } } if (smooth_flag == SMOOTH) write_smooth_bnd(line_begin, line_end, n); else write_bnd(line_begin, line_end, n); return (0); }
/* * Name: find_left_margin * Purpose: find left margin depending on word wrap mode * Date: June 5, 1992 * Passed: ll: node pointer to current line * wrap_mode: current word wrap mode * Notes: the algorithm used to figure the indent column was yanked out * of the insert_newline( ) function and was made into a more * general algorithm for figuring the left margin irregardless * of word wrap or indent mode. when in the DYNAMIC_WRAP mode, * the user don't have to keep changing the left margin when * special indentation is needed. */ int find_left_margin( line_list_ptr ll, int wrap_mode ) { register int lm; int len; text_ptr source; if (wrap_mode == FIXED_WRAP) { /* * for FIXED_WRAP mode, the left and paragraph margins are determined * from the master mode structure. */ if (g_status.copied) { source = (text_ptr)g_status.line_buff; len = g_status.line_buff_len; } else { if (ll->prev != NULL) { source = ll->prev->line; len = ll->prev->len; } else { source = NULL; len = 0; } } if (source == NULL) lm = mode.parg_margin; else if (find_end( source, len ) == 0) lm = mode.parg_margin; else lm = mode.left_margin; } else { /* * for Indent and DYNAMIC_WRAP modes, the left margin is determined * from the first non blank line above the cursor. */ if (g_status.copied == TRUE) { source = (text_ptr)g_status.line_buff; len = g_status.line_buff_len; } else { source = ll->line; len = ll->len; } lm = first_non_blank( source, len ); if (is_line_blank( source, len ) && ll->prev != NULL) { for (ll=ll->prev; ll != NULL; ll=ll->prev) { lm = first_non_blank( ll->line, ll->len ); if (!is_line_blank( ll->line, ll->len )) break; } } } return( lm ); }
vector<string> fullJustify(vector<string> &words, int L) { // Start typing your C/C++ solution below // DO NOT write int main() function vector<string> ret; int start = 0; while (start<words.size()) { int end = find_end(words, start, L); string s = justify(words, start, end, L); ret.push_back(s); start = end; } return ret; }
// ------------------------------------------------------ // get int // ------------------------------------------------------ int RegistryReader::get_int(int index,const char* name) const { assert ( index >= 0 && index < _lines.size()); int idx = find_index(name); if ( idx != -1 ) { const Entry& e = _lines[index]; int p = e.positions[idx]; int end = find_end(e.line,p); std::string str = e.line.substr(p,end); int v; sscanf(str.c_str(),"%d",&v); return v; } return -1; }
/* For Next function */ int opcode_for(int program_counter, char *buf) { int pcounter = 0; int res = 0; /* Check if the loop already exists */ if(find_end(program_counter) == INVALID_LOOP) { add_entry(program_counter); } /* Evaluate For Condition */ str_addnewline(buf); res = eval_exp(buf); if(res) { /* Condition Valid = Execute loop */ pcounter = program_counter; } else { /* Condition Invalid = Exit loop */ pcounter = find_end(program_counter); } return pcounter; }
bool IsSubDomain(const CString& subdomain, const CString& domain) { if (subdomain == domain) return true; // sub domain test by prepending dot('.') to domain const TCHAR* iter1 = subdomain.GetString(); const TCHAR* iter1end = iter1 + subdomain.GetLength(); CString dotDomain = _T(".") + domain; const TCHAR* iter2 = dotDomain.GetString(); const TCHAR* iter2end = iter2 + dotDomain.GetLength(); const TCHAR* pos = find_end(iter1, iter1end, iter2, iter2end); if (pos == iter1end) return false; return pos + dotDomain.GetLength() == iter1end; }
static t_node *find_end(t_node *start, const t_node *end) { t_node *p; for (p = start + 1; p < end; ++p) { if (p->action == INS_WEND) { start->attr.bro = p; p->attr.bro = start; return p; } if (p->action == INS_WHILE) { t_node *const tmp = find_end(p, end); if (!tmp) { return NULL; } p = tmp; } } return NULL; }
/* * Parses the bitstream and returns the preformated datastring. */ char *parse_data(const char *buffer) { int i, j=0, start, end; static char data[50]; char tmp; start = find_start(buffer); end = find_end(buffer, start); for(i=start;i<end;i+=5) { tmp = 1 * buffer[i]; tmp += 2 * buffer[i+1]; tmp += 4 * buffer[i+2]; tmp += 8 * buffer[i+3]; tmp += 0x30; data[j] = tmp; lcd_data(tmp); j++; } return data; }
int main(void) { t_env *env; env = init_env(); parse(env) ? tt_pl("") : error(); if (env->nodes) { set_weight_end(env, find_end(env), 0) ? 0 : error(); sort_nodes(env->nodes, env->nb_nodes); print_result(env, 0, 0); env->path_found ? solve(env) : error(); print_result(env, 0, 1); } else error(); free_env(env); return (0); }
static int connect(t_node *p, size_t len) { const t_node *const end = p + len; for (; p < end; ++p) { if (p->action == INS_WEND) { fprintf(stderr, "%s: unmatched ']'\n", prog); return -1; } if (p->action == INS_WHILE) { t_node *const tmp = find_end(p, end); if (!tmp) { fprintf(stderr, "%s: unmatched '['\n", prog); return -1; } p = tmp; } } return 0; }
void go_down_level(void) { ccell * end; lexical_stack_height--; end = find_end(((cd *)lexical_stack[lexical_stack_height-1])->content); if(current_col_size == 0) end->car=NULL; else { fix_quote(lexical_stack[lexical_stack_height]->content); /* fixing occurs */ end->car=lexical_stack[lexical_stack_height];/* linking occurs */ if(lexical_stack[lexical_stack_height]->col_tag == QUOTE) pop(scope_stack); } current_col_size = 1; end->cdr=cons(NULL,NULL); current_node = end->cdr; lexical_stack =realloc(lexical_stack,sizeof(void*)*lexical_stack_height); }
int strutil_parse_csv(STRUTIL_PARSE_CSV_TOKEN cbToken, void *pCbTokenArg, const char *line) { const char *p, *p2; unsigned int sz; int rc = 0; char buf[1024]; if(!cbToken || !line) { return -1; } p = (char *) line; while(*p != '\n' && *p != '\0') { p2 = (char *) find_end(p); if(*p2 != '\n' && *p2 != '\0') { sz = MIN(p2 - p, sizeof(buf) - 1); while(sz > 1 && (p[sz - 1] == ' ' || p[sz - 1] == '\t')) { sz--; } memcpy(buf, p, sz); buf[sz] = '\0'; p = buf; p2++; } while(*p == ' ' || *p == '\t') { p++; } //fprintf(stderr, "line: --%s--\n", p); if((rc = cbToken(pCbTokenArg, p)) < 0) { break; } p = p2; } return rc; }
void ft_move_lemmins(t_room **rooms, t_best_route *best, t_lemmin *lemmin) { int tot_lem; t_room *end; t_room *start; t_lemmin *first_lem; t_best_route *best_start; best_start = best; end = find_end(rooms); start = find_start(rooms); first_lem = lemmin; tot_lem = start->num_of_lem; mv_start(first_lem, best, rooms); ft_putstr("\n"); while (end->num_of_lem < tot_lem) { mv_play(first_lem, best, rooms); mv_start(first_lem, best, rooms); ft_putstr("\n"); } }
int parse_body (char *buffer, int length, struct body_msg *body) { char *tmp = buffer; char *end = buffer + length; int offset; int off; char *bodyline; char *address; uint16_t port = 0; size_t keylen; struct reg_body *tmp_body = NULL; struct id_body *tmp_body1 = NULL; struct add_body *tmp_body2 = NULL; struct key_body *tmp_body3 = NULL; /* strip the beginning space */ for (tmp; ((*tmp == '\n') || (*tmp == '\r')) && ((tmp - buffer) < length); tmp++); offset = tmp - buffer; do { switch (*tmp) { case 'U': case 'u': { if (!tmp_body) tmp_body = create_reg_body (); body->type = BODYREG; if (off = check ("USER", 4, tmp, end)) { if (LOG_PARSER) log_info ("Body USER found in %u\n", tmp - buffer); offset += off; /* find the end of this header */ offset += find_end (tmp + off, end); /* find the user address */ tmp = tmp + off; for (tmp; (*tmp == ' ') && ((tmp) < end); tmp++); /* copy it to structure */ tmp_body->user = (char *) strndup (tmp, buffer + offset - tmp - 1); tmp_body->user_len = buffer + offset - tmp - 1; if (LOG_PARSER) log_info ("The user is : %s\n", tmp_body->user); tmp = buffer + offset; break; } } case 'A': case 'a': { if (off = check ("ADDRESS", 7, tmp, end)) { if (!tmp_body) tmp_body = create_reg_body (); body->type = BODYREG; if (LOG_PARSER) log_info ("Body ADDRESS found in %u\n", tmp - buffer); offset += off; /* find the end of this header */ offset += find_end (tmp + off, end); /* find the IP address */ tmp = tmp + off; for (tmp; (*tmp == ' ') && ((tmp) < end); tmp++); /* copy it to structure */ tmp_body->ip = (char *) strndup (tmp, buffer + offset - tmp - 1); tmp_body->ip_len = buffer + offset - tmp - 1; if (LOG_PARSER) log_info ("The IP address is : %s\n", tmp_body->ip); tmp = buffer + offset; break; } else if (off = check ("ADDER", 5, tmp, end)) { char *data; MPI val = mpi_alloc (0); if (!tmp_body2) tmp_body2 = create_add_body (); body->type = BODYADD; if (LOG_PARSER) log_info ("Body Adder found in %u\n", tmp - buffer); offset += off; /* find the end of this line */ offset += find_end (tmp + off, end); /* find the adder */ tmp = tmp + off; for (tmp; (*tmp == ' ') && ((tmp) < end); tmp++); data = m_alloc_clear (buffer + offset - tmp); strncpy (data, tmp, buffer + offset - tmp - 1); if (mpi_fromstr (val, data)) { mpi_free (val); m_free (data); tmp = buffer + offset; break; } tmp_body2->adder[tmp_body2->num] = val; (tmp_body2->num)++; m_free (data); tmp = buffer + offset; break; } } case 'P': case 'p': { if (off = check ("PORT", 4, tmp, end)) { if (!tmp_body) tmp_body = create_reg_body (); body->type = BODYREG; if (LOG_PARSER) log_info ("Body PORT found in %u\n", tmp - buffer); offset += off; /* find the end of this header */ offset += find_end (tmp + off, end); /* find the user address */ tmp = tmp + off; for (tmp; (*tmp == ' ') && ((tmp) < end); tmp++); for (tmp; tmp < (buffer + offset - 1); tmp++) { if ((*tmp - 48) <= 9 && (*tmp - 48) >= 0) port = port * 10 + (*tmp - 48); else { log_error ("Error while changing port to number\n"); return 1; } } /* copy it to structure */ tmp_body->port = port; if (LOG_PARSER) log_info ("The PORT is : %u\n", port); tmp = buffer + offset; break; } } case '-': { if (!tmp_body) tmp_body = create_reg_body (); body->type = BODYREG; if (keylen = check_public_key (tmp, end)) { tmp_body->public_key = (char *) strndup (tmp, keylen); tmp_body->pk_len = keylen; if (LOG_PARSER) log_info ("We found begin pgp length : %u\n" "%s\n", keylen, strndup (tmp, keylen)); tmp += (keylen + 1); } } break; case 'I': case 'i': { uint32_t address; char c; if (!tmp_body1) tmp_body1 = create_id_body (); body->type = BODYID; if (off = check ("ID_LIST", 7, tmp, end)) { if (LOG_PARSER) log_info ("Body id list found in %u\n", tmp - buffer); offset += off; /* find the end of this header */ offset += find_end (tmp + off, end); /* find the id */ tmp = tmp + off; for (tmp; (*tmp == ' ') && ((tmp) < end); tmp++); if (sscanf (tmp, "%x%c", &address, &c) == 2) { tmp_body1->id[tmp_body1->num] = address; (tmp_body1->num)++; } tmp = buffer + offset; break; } } case 'K': case 'k': { int length; if (!tmp_body3) tmp_body3 = create_key_body (); body->type = BODYKEY; if (off = check ("KEY", 3, tmp, end)) { if (LOG_PARSER) log_info ("Body key found in %u\n", tmp - buffer); offset += off; /* find the end of this header */ offset += find_end (tmp + off, end); /* find the key */ tmp = tmp + off; for (tmp; (*tmp == ' ') && ((tmp) < end); tmp++); length = buffer + offset - tmp; tmp_body3->radmsg = m_alloc (length); strncpy (tmp_body3->radmsg, tmp, length - 1); tmp_body3->radmsg[length] = '\0'; tmp_body3->length = length - 1; tmp = buffer + offset; break; } } default: { log_error ("Other body type is found %c. Dont know what to do in %u\n", *tmp, tmp - buffer); return 1; } } } while (*tmp != '\n' && *tmp != '\r' && tmp < end); if (body->type == BODYREG) { /* check if any field is empty, we need a full one */ if (!tmp_body->user || !tmp_body->ip || (tmp_body->port == 0) || !tmp_body->public_key) { if (tmp_body->user) m_free (tmp_body->user); if (tmp_body->ip) m_free (tmp_body->ip); if (tmp_body->public_key) m_free (tmp_body->public_key); m_free (tmp_body); return 1; } else { body->msg.regbody = tmp_body; tmp_body = NULL; return 0; } } else if (body->type == BODYID) { body->msg.idbody = tmp_body1; tmp_body1 = NULL; return 0; } else if (body->type == BODYADD) { body->msg.addbody = tmp_body2; tmp_body2 = NULL; return 0; } else if (body->type == BODYKEY) { body->msg.keybody = tmp_body3; tmp_body2 = NULL; return 0; } return 1; }
int parse_msg (struct sip_msg *msg, STRLIST * sender, STRLIST * recipient) { char *tmp; char *end; int length; int offset; char *header; char address[80] = { 0 }; char *body; int body_length; int off; int type; int evt; /* parse the data */ tmp = msg->buf; end = msg->buf + msg->len; /* strip the beginning space */ for (tmp; ((*tmp == '\n') || (*tmp == '\r')) && ((tmp - msg->buf) < length); tmp++); if (parse_first_line (&tmp, end, &(msg->type))) return 1; offset = tmp - msg->buf; do { switch (*tmp) { case 't': case 'T': { if (off = check ("TO", 2, tmp, end)) { if (LOG_PARSER) log_info ("Header To found in %u\n", tmp - msg->buf); offset += off; offset += find_end (tmp + off, end); /* find the user address */ tmp += off; if (get_address (tmp, address, msg->buf + offset - tmp, &(msg->sips))) { tmp = msg->buf + offset; break; } add_to_strlist2 (recipient, address, 0); if (LOG_PARSER) log_info ("The address is : %s\n", address); /* We only need one to header */ if (!msg->to) msg->to = parser_create_address (address, 0, msg->sips); tmp = msg->buf + offset; break; } } case 'f': case 'F': { if (off = check ("FROM", 4, tmp, end)) { if (LOG_PARSER) log_info ("Header From found in %u\n", tmp - msg->buf); offset += off; /* find the end of this header */ offset += find_end (tmp + off, end); /* find the user address */ tmp += off; if (get_address (tmp, address, msg->buf + offset - tmp, &(msg->sips))) { tmp = msg->buf + offset; break; } add_to_strlist2 (sender, address, 0); if (LOG_PARSER) log_info ("The address is : %s\n", address); /* We only require one from */ if (!msg->from) { /* copy from header to be used later */ msg->from = parser_create_address (address, 1, msg->sips); } tmp = msg->buf + offset; break; } } case 'v': case 'V': { if (off = check ("VIA", 3, tmp, end)) { if (LOG_PARSER) log_info ("Header Via found in %u\n", tmp - msg->buf); offset += off; /* find the end of this header */ offset += find_end (tmp + off, end); if (!msg->via1) msg->via1 = tmp; else if (!msg->via2) msg->via2 = tmp; tmp = msg->buf + offset; break; } } case 'e': case 'E': { if (off = check ("Event", 5, tmp, end)) { if (LOG_PARSER) log_info ("Header Event found in %u\n", tmp - msg->buf); offset += off; /* find the end of this header */ offset += find_end (tmp + off, end); tmp += off; msg->evt = parse_event (tmp, msg->buf + offset); tmp = msg->buf + offset; break; } } case 'r': case 'R': { if (off = check ("REQ", 3, tmp, end)) { if (LOG_PARSER) log_info ("Header Requester found in %u\n", tmp - msg->buf); offset += off; /* find the end of this header */ offset += find_end (tmp + off, end); /* find the user address */ tmp += off; for (tmp; (*tmp == ' ') && ((tmp) < end); tmp++); if (!msg->req) msg->req = parser_create_req (tmp); tmp = msg->buf + offset; break; } } default: { if (LOG_PARSER) log_info ("Other header found in %u\n", tmp - msg->buf); offset += find_end (tmp, end); tmp = msg->buf + offset; } } } while (not_out (&tmp) && tmp < end); msg->hdr_len = msg->hdr_len2 = tmp - msg->buf; /* We still have data left, it means body */ if (tmp < end) { msg->body_len = end - tmp; msg->body = tmp; } return 0; }
int main(int argc, const char *argv[]) { // Item 46. Consider function objects instead of functions as algorithm parameters. [ effective stl ] // because we can define function operator as inline function, and the compiler is not optimize for functions even if you // specify it as inline function int a[] = {1, 2, 3, 4}; std::vector<int> ivec(a, a + sizeof(a)/sizeof(int)); std::for_each(ivec.begin(), ivec.end(), Double<int>()); std::for_each(ivec.begin(), ivec.end(), print<int>); std::cout << std::endl; std::for_each(ivec.begin(), ivec.end(), doubleFun<int>); std::for_each(ivec.begin(), ivec.end(), print<int>); std::cout << std::endl; // liner search function, find and find_if // for random iterator, find algorithm use loop expand to optimize typedef std::vector<int>::iterator IVecInterator; IVecInterator iter = find(ivec.begin(), ivec.end(), 5); if (iter == ivec.end()) { std::cout << "could not find 5 in the vector ivec" << std::endl; } // similar with assocative container, they both have count and find member function. there is also count algorithm // count, count_if std::cout << "there is " << std::count(ivec.begin(), ivec.end(), 5) << " in the vector ivec" << std::endl; // search the first same or last same value in the two ranges int b[] = {4, 3, 3, 5, 4}; std::vector<int> ivec2(b, b + sizeof(b)/sizeof(int)); // return the first element in range 2 which occur in the range 1, // in this example, range1 is "4, 8, 12, 16", range 2 is "4, 3, 3, 5, 4" // so return 4 IVecInterator firstIter = find_first_of(ivec.begin(), ivec.end(), ivec2.begin(), ivec2.end()); if (firstIter != ivec.end()) { std::cout << *firstIter << std::endl; } IVecInterator secondIter = find_end(ivec.begin(), ivec.end(), ivec2.begin(), ivec2.end()); if (secondIter != ivec.end()) { std::cout << *secondIter << std::endl; } // find subsequence algorithm // adjacent_find ,return the first duplicated element which are adjacent,otherwise return end IVecInterator adjacent = adjacent_find(ivec2.begin(), ivec2.end()); if (adjacent != ivec2.end()) { std::cout << *adjacent << std::endl; } // search subsequence int c[] = {3, 5, 4}; std::vector<int> ivec3(c, c + sizeof(c)/sizeof(int)); IVecInterator subsequence = search(ivec2.begin(), ivec2.end(), ivec3.begin(), ivec3.end()); if (subsequence != ivec2.end()) { std::cout << *subsequence << std::endl; } // IVecInterator n = search_n(ivec3.begin(), ivec3.end(), // binary search // write only alogrithm // fill_n(dest, cnt, val) // generate_n(dest, cnt, Gen) // copy(beg, end, dest) // transform(beg, end, dest, unaryOp) // transform(beg, end, beg2, dest, binaryOp) // merge(beg1, end1, beg2, end2, dest) // merge(beg1, end1, beg2, end2, dest, comp) // sort and partition algorithm // partition, stable_partition // stable_partition(beg, end, unaryPred) // partition(beg, end, unaryPred) // sort, stable_sort, partitial_sort // nth_element // general reorder algorithm // unique, reverse, rotate, remove, remove_if // remove_copy, unique_copy, rotate_copy, random_shuffle // permutation alogrithm // prev_permutation(beg, end), next_permutation(beg, end) int a5[] = {1, 2, 3, 4}; std::vector<int> ivec5(a5, a5 + 4); // alogrithm for next_permutation : std::next_permutation(ivec5.begin(), ivec5.end()); std::for_each(ivec5.begin(), ivec5.end(), print<int>); std::cout << std::endl; std::next_permutation(ivec5.begin(), ivec5.end()); std::for_each(ivec5.begin(), ivec5.end(), print<int>); std::cout << std::endl; // ordered set algorithm : set_union, set_intersection, set_difference, set_symmetric_difference // compare algorithm // min(val1, val2), max(val1, val2), min_element, max_element(beg, end) // math algorithm return 0; }
static int find_file(int fd, zentry *entry, const char *file_name) { int bytes; int res; int entry_size; int read_size; int base_offset; Byte *p; Byte *bp; Byte *buffer; Byte locbuf[LOCHDR]; if ((buffer = (Byte*)malloc(BUFSIZE)) == NULL) { return(-1); } p = buffer; bp = buffer; /* * Read the END Header, which is the starting point for ZIP files. * (Clearly designed to make writing a zip file easier than reading * one. Now isn't that precious...) */ if ((base_offset = find_end(fd, bp)) == -1) { free(buffer); return (-1); } /* * There is a historical, but undocumented, ability to allow for * additional "stuff" to be prepended to the zip/jar file. It seems * that this has been used to prepend an actual java launcher * executable to the jar on Windows. Although this is just another * form of statically linking a small piece of the JVM to the * application, we choose to continue to support it. Note that no * guarantees have been made (or should be made) to the customer that * this will continue to work. * * Therefore, calculate the base offset of the zip file (within the * expanded file) by assuming that the central directory is followed * immediately by the end record. */ base_offset = base_offset - ENDSIZ(p) - ENDOFF(p); /* * The END Header indicates the start of the Central Directory * Headers. Remember that the desired Central Directory Header (CEN) * will almost always be the second one and the first one is a small * directory entry ("META-INF/"). Keep the code optimized for * that case. * * Begin by seeking to the beginning of the Central Directory and * reading in the first buffer full of bits. */ if (lseek(fd, base_offset + ENDOFF(p), SEEK_SET) < (off_t)0) { free(buffer); return (-1); } if ((bytes = read(fd, bp, MINREAD)) < 0) { free(buffer); return (-1); } /* * Loop through the Central Directory Headers. Note that a valid zip/jar * must have an ENDHDR (with ENDSIG) after the Central Directory. */ while (GETSIG(p) == CENSIG) { /* * If a complete header isn't in the buffer, shift the contents * of the buffer down and refill the buffer. Note that the check * for "bytes < CENHDR" must be made before the test for the entire * size of the header, because if bytes is less than CENHDR, the * actual size of the header can't be determined. The addition of * SIGSIZ guarantees that the next signature is also in the buffer * for proper loop termination. */ if (bytes < CENHDR) { p = memmove(bp, p, bytes); if ((res = read(fd, bp + bytes, MINREAD)) <= 0) { free(buffer); return (-1); } bytes += res; } entry_size = CENHDR + CENNAM(p) + CENEXT(p) + CENCOM(p); if (bytes < entry_size + SIGSIZ) { if (p != bp) p = memmove(bp, p, bytes); read_size = entry_size - bytes + SIGSIZ; read_size = (read_size < MINREAD) ? MINREAD : read_size; if ((res = read(fd, bp + bytes, read_size)) <= 0) { free(buffer); return (-1); } bytes += res; } /* * Check if the name is the droid we are looking for; the jar file * manifest. If so, build the entry record from the data found in * the header located and return success. */ if (CENNAM(p) == strlen(file_name) && memcmp((p + CENHDR), file_name, strlen(file_name)) == 0) { if (lseek(fd, base_offset + CENOFF(p), SEEK_SET) < (off_t)0) { free(buffer); return (-1); } if (read(fd, locbuf, LOCHDR) < 0) { free(buffer); return (-1); } if (GETSIG(locbuf) != LOCSIG) { free(buffer); return (-1); } entry->isize = CENLEN(p); entry->csize = CENSIZ(p); entry->offset = base_offset + CENOFF(p) + LOCHDR + LOCNAM(locbuf) + LOCEXT(locbuf); entry->how = CENHOW(p); free(buffer); return (0); } /* * Point to the next entry and decrement the count of valid remaining * bytes. */ bytes -= entry_size; p += entry_size; } free(buffer); return (-1); /* Fell off the end the loop without a Manifest */ }
/* * Name: differ * Purpose: diff text pointers * Date: October 31, 1992 * Passed: initial_rcol1: beginning column to begin diff in window1 * initial_rcol2: beginning column to begin diff in window2 * bottom: line to display diagnostics * Notes: a straight diff on text pointers is simple; however, diffing * with leading spaces and tabs is kinda messy. let's do the * messy diff. */ int differ( int initial_rcol1, int initial_rcol2, int bottom ) { int rcol1; /* virtual real column on diff window 1 */ int rcol2; /* virtual real column on diff window 2 */ int r1; /* real real column rcol1 - needed for tabs */ int r2; /* real real column rcol2 - needed for tabs */ char c1; /* character under r1 */ char c2; /* character under r2 */ int leading1; /* adjustment for leading space in window 1 */ int leading2; /* adjustment for leading space in window 2 */ int len1; /* length of diff1 line */ int len2; /* length of diff2 line */ line_list_ptr node1; /* scratch node in window 1 */ line_list_ptr node2; /* scratch node in window 2 */ text_ptr diff1; /* scratch text ptr in window 1 */ text_ptr diff2; /* scratch text ptr in window 2 */ long rline1; /* real line number of diff pointer 1 */ long rline2; /* real line number of diff pointer 2 */ long bin_offset1; /* binary offset of diff pointer 1 */ long bin_offset2; /* binary offset of diff pointer 2 */ int len; /* line length variable */ register int tabs; /* local variable for mode.inflate_tabs, T or F */ char line_buff[(MAX_COLS+1)*2]; /* buffer for char and attribute */ /* * initialize the text pointers and the initial column. skip any * initial blank lines. */ rline1 = diff.rline1; rline2 = diff.rline2; node1 = diff.d1; node2 = diff.d2; bin_offset1 = diff.bin_offset1; bin_offset2 = diff.bin_offset2; tabs = mode.inflate_tabs; if (diff.blank_lines) { while (node1->len != EOF && is_line_blank( node1->line, node1->len )) { bin_offset1 += node1->len; node1 = node1->next; ++rline1; initial_rcol1 = 0; } while (node2->len != EOF && is_line_blank( node2->line , node2->len)) { bin_offset2 += node2->len; node2 = node2->next; ++rline2; initial_rcol2 = 0; } } /* * if everything is everything, initialize the diff variables and diff. */ if (node1->len != EOF && node2->len != EOF) { diff1 = node1->line; diff2 = node2->line; rcol1 = initial_rcol1; rcol2 = initial_rcol2; len1 = node1->len; len2 = node2->len; assert( rcol1 >= 0 ); assert( rcol1 < MAX_LINE_LENGTH ); assert( rcol2 >= 0 ); assert( rcol2 < MAX_LINE_LENGTH ); assert( len1 >= 0 ); assert( len1 < MAX_LINE_LENGTH ); assert( len2 >= 0 ); assert( len2 < MAX_LINE_LENGTH ); /* * if cursors are past EOL, move them back to EOL. */ len = find_end( diff1, len1 ); if (rcol1 > len) rcol1 = len; len = find_end( diff2, len2 ); if (rcol2 > len) rcol2 = len; /* * if skip leading space, make sure our cursors start on first non-space. */ if (diff.leading) { leading1 = skip_leading_space( diff1, len1 ); leading2 = skip_leading_space( diff2, len2 ); if (tabs) { leading1 = detab_adjust_rcol( diff1, leading1 ); leading2 = detab_adjust_rcol( diff2, leading2 ); } if (rcol1 < leading1) rcol1 = leading1; if (rcol2 < leading2) rcol2 = leading2; } /* * we now have a valid rcol for the diff start, we may need to adjust * for tabs, though. */ assert( rcol1 >= 0 ); assert( rcol1 < MAX_LINE_LENGTH ); assert( rcol2 >= 0 ); assert( rcol2 < MAX_LINE_LENGTH ); r1 = tabs ? entab_adjust_rcol( diff1, len1, rcol1 ) : rcol1; r2 = tabs ? entab_adjust_rcol( diff2, len2, rcol2 ) : rcol2; assert( r1 >= 0 ); assert( r1 <= len1 ); assert( r2 >= 0 ); assert( r2 <= len2 ); assert( r1 <= rcol1 ); assert( r2 <= rcol2 ); s_output( diff_message, g_display.mode_line, 67, g_display.diag_color ); while (node1->len != EOF && node2->len != EOF && !g_status.control_break) { /* * look at each character in each diff window */ c1 = (char)(r1 < len1 ? *(diff1 + r1) : 0); c2 = (char)(r2 < len2 ? *(diff2 + r2) : 0); /* * tabs == space */ if (tabs) { if (c1 == '\t') c1 = ' '; if (c2 == '\t') c2 = ' '; } /* * skip spaces, if needed */ if (diff.all_space) { while (c1 == ' ' && r1 < len1) { ++rcol1; r1 = tabs ? entab_adjust_rcol( diff1, len1, rcol1 ) : rcol1; c1 = (char)(r1 < len1 ? *(diff1 + r1) : 0); if (c1 == '\t' && tabs) c1 = ' '; } while (c2 == ' ' && r2 < len2) { ++rcol2; r2 = tabs ? entab_adjust_rcol( diff2, len2, rcol2 ) : rcol2; c2 = (char)(r2 < len2 ? *(diff2 + r2) : 0); if (c2 == '\t' && tabs) c2 = ' '; } } /* * if one of the node pointers has come to EOL, move to next * diff line. */ if (diff.ignore_eol) { if (r1 >= len1) { node1 = skip_eol( node1, &r1, &rcol1, &rline1, &bin_offset1 ); len1 = node1->len; if (len1 != EOF) { diff1 = node1->line; c1 = (char)(r1 < len1 ? *(diff1 + r1) : 0); if (c1 == '\t' && tabs) c1 = ' '; } } if (r2 >= len2) { node2 = skip_eol( node2, &r2, &rcol2, &rline2, &bin_offset2 ); len2 = node2->len; if (len2 != EOF) { diff2 = node2->line; c2 = (char)(r2 < len2 ? *(diff2 + r2) : 0); if (c2 == '\t' && tabs) c2 = ' '; } } } /* * convert the characters to lower case, if needed. */ if (mode.search_case == IGNORE) { c1 = (char)tolower( c1 ); c2 = (char)tolower( c2 ); } /* * diff each character in the diff lines until we reach EOL */ while (r1 < len1 && r2 < len2) { if (c1 == c2) { if (diff.all_space) { do { ++rcol1; r1 = tabs ? entab_adjust_rcol( diff1,len1,rcol1 ) : rcol1; c1 = (char)(r1 < len1 ? *(diff1 + r1) : 0); if (c1 == '\t' && tabs) c1 = ' '; } while (c1 == ' ' && r1 < len1); do { ++rcol2; r2 = tabs ? entab_adjust_rcol( diff2,len2,rcol2 ) : rcol2; c2 = (char)(r2 < len2 ? *(diff2 + r2) : 0); if (c2 == '\t' && tabs) c2 = ' '; } while (c2 == ' ' && r2 < len2); } else { ++rcol1; ++rcol2; r1 = tabs ? entab_adjust_rcol( diff1, len1, rcol1 ) : rcol1; r2 = tabs ? entab_adjust_rcol( diff2, len2, rcol2 ) : rcol2; c1 = (char)(r1 < len1 ? *(diff1 + r1) : 0); c2 = (char)(r2 < len2 ? *(diff2 + r2) : 0); if (tabs) { if (c1 == '\t') c1 = ' '; if (c2 == '\t') c2 = ' '; } } if (diff.ignore_eol) { if (r1 >= len1) { node1 = skip_eol(node1, &r1, &rcol1, &rline1,&bin_offset1); len1 = node1->len; if (len1 != EOF) { diff1 = node1->line; c1 = (char)(r1 < len1 ? *(diff1 + r1) : 0); if (c1 == '\t' && tabs) c1 = ' '; } } if (r2 >= len2) { node2 = skip_eol(node2, &r2, &rcol2, &rline2,&bin_offset2); len2 = node2->len; if (len2 != EOF) { diff2 = node2->line; c2 = (char)(r2 < len2 ? *(diff2 + r2) : 0); if (c2 == '\t' && tabs) c2 = ' '; } } } if (mode.search_case == IGNORE) { c1 = (char)tolower( c1 ); c2 = (char)tolower( c2 ); } } else { /* * when we show the diff, use rcol1 and rcol2, as * find_adjust does not adjust rcol for tabs. */ update_line( diff.w1 ); diff.w1->bin_offset = bin_offset1; find_adjust( diff.w1, node1, rline1, rcol1 ); check_virtual_col( diff.w1, rcol1, rcol1 ); show_diff_window( diff.w1 ); update_line( diff.w2 ); diff.w2->bin_offset = bin_offset2; bin_offset_adjust( diff.w2, rline2 ); find_adjust( diff.w2, node2, rline2, rcol2 ); check_virtual_col( diff.w2, rcol2, rcol2 ); show_diff_window( diff.w2 ); s_output( diff_blank, g_display.mode_line, 67, g_display.mode_color ); return( OK ); } } /* * if we haven't come to the end of a file buffer, check the last * characters. see if pointers are at EOL. */ if (node1->len != EOF && node2->len != EOF) { if (rcol1 != len1 && rcol2 != len2) { update_line( diff.w1 ); diff.w1->bin_offset = bin_offset1; find_adjust( diff.w1, node1, rline1, rcol1 ); show_diff_window( diff.w1 ); update_line( diff.w2 ); diff.w2->bin_offset = bin_offset2; find_adjust( diff.w2, node2, rline2, rcol2 ); show_diff_window( diff.w2 ); s_output( diff_blank, g_display.mode_line, 67, g_display.mode_color ); return( OK ); } else { node1 = skip_eol( node1, &r1, &rcol1, &rline1, &bin_offset1 ); len1 = node1->len; diff1 = node1->line; node2 = skip_eol( node2, &r2, &rcol2, &rline2, &bin_offset2 ); len2 = node2->len; diff2 = node2->line; } } assert( rcol1 >= 0 ); assert( rcol1 < MAX_LINE_LENGTH ); assert( rcol2 >= 0 ); assert( rcol2 < MAX_LINE_LENGTH ); assert( r1 >= 0 ); assert( r1 < MAX_LINE_LENGTH ); assert( r2 >= 0 ); assert( r2 < MAX_LINE_LENGTH ); assert( r1 <= rcol1 ); assert( r2 <= rcol2 ); if (node1->len == EOF) assert( len1 == EOF ); else { assert( len1 >= 0 ); assert( len1 < MAX_LINE_LENGTH ); } if (node2->len == EOF) assert( len2 == EOF ); else { assert( len2 >= 0 ); assert( len2 < MAX_LINE_LENGTH ); } } save_screen_line( 0, bottom, line_buff ); set_prompt( diff_prompt4, bottom ); getkey( ); restore_screen_line( 0, bottom, line_buff ); s_output( diff_blank, g_display.mode_line, 67, g_display.mode_color ); } return( ERROR ); }
size_t machine_t::size() const { return find_end() - &memory[0]; }