void draw_with_tab_on_img(char ***coord, int i, int maxline, t_struct *param) { int index; int futurindex; futurindex = 0; index = 0; while(index + 1 < i) { if(index + 1 < i) { if(coord[index + 1][2][0] != '\n') first_part(coord, index, param); else futurindex++; } if(index + maxline + 1 < i) { if(coord[index + maxline + 1][2][0] != '\n') second_part(coord, index, maxline, param); else futurindex++; } index = new_index(index, futurindex); futurindex = new_futurindex(index, futurindex); } }
int findfile_recursive(jfs_t *jfs, char *pathname, int inodenum, int file_type) { char firstpart[MAX_FILENAME_LEN]; struct inode i_node; struct dirent *dir_entry; int dir_size, bytes_done=0; char block[BLOCKSIZE]; first_part(pathname, firstpart); get_inode(jfs, inodenum, &i_node); dir_size = i_node.size; /* read in the first block */ jfs_read_block(jfs, block, i_node.blockptrs[0]); /* walk the directory */ dir_entry = (struct dirent*)block; while (1) { char filename[MAX_FILENAME_LEN + 1]; memcpy(filename, dir_entry->name, dir_entry->namelen); filename[dir_entry->namelen] = '\0'; if (strcmp(firstpart, filename)==0) { /* we've found the right one */ char newpathname[strlen(pathname)]; char *p; p = strchr(pathname, '/'); if (p == NULL) { /* we've found the entry with the right name. */ /* Check it actually is a file */ if (dir_entry->file_type != file_type) { return -1; } return dir_entry->inode; } /* More path to go - check this is a directory */ if (dir_entry->file_type != DT_DIRECTORY) { return -1; } /* remove the first part of the path before recursing */ p++; strcpy(newpathname, p); return findfile_recursive(jfs, newpathname, dir_entry->inode, file_type); } bytes_done += dir_entry->entry_len; dir_entry = (struct dirent*)(block + bytes_done); if (bytes_done >= dir_size) { break; } } /* we didn't find the file */ /* the user mistyped the path */ return -1; }
explicit separate_dim_splitter(Matrix const& matrix) : my_row_split(matrix.begin_row() + first_part(matrix.num_rows())), my_col_split(matrix.begin_col() + first_part(matrix.num_cols())) {}
explicit max_dim_splitter(Matrix const& matrix) : // matrix(matrix), my_split(std::max(first_part(matrix.num_rows()), first_part(matrix.num_cols()))), my_row_split(std::min(matrix.begin_row() + my_split, matrix.end_row())), my_col_split(std::min(matrix.begin_col() + my_split, matrix.end_col())) {}
bool PWSRun::runcmd(const StringX &run_command, const bool &bAutotype) const { // Get first parameter either enclosed by quotes or delimited by a space StringX full_string(run_command), first_part(_T("")), the_rest(_T("")); StringX env_var, sx_temp(_T("")); StringX::size_type end_delim; bool bfound(true); TrimLeft(full_string, _T(" ")); if (full_string.c_str()[0] == _T('"')) { end_delim = full_string.find(_T('"'), 1); first_part = full_string.substr(1, end_delim - 1); the_rest = full_string.substr(end_delim + 1); } else { end_delim = full_string.find(_T(' ')); if (end_delim != StringX::npos) { first_part = full_string.substr(0, end_delim); the_rest = full_string.substr(end_delim + 1); } else first_part = full_string; } // tokenize into separate elements using % as the field separator. // If this corresponds to a set envrionmental variable - replace it // and rebuild the command for (StringX::size_type st_startpos = 0; st_startpos < first_part.size(); /* st_startpos advanced in body */) { StringX::size_type st_next = first_part.find(_T('%'), st_startpos); if (st_next == StringX::npos) { sx_temp += first_part.substr(st_startpos); break; } if (st_next > 0) { env_var = first_part.substr(st_startpos, st_next - st_startpos); size_t mblen = pws_os::wcstombs(NULL, 0, env_var.c_str(), size_t(-1), false); unsigned char * mbtemp = new unsigned char[mblen + 1]; // Finally get result size_t tmplen = pws_os::wcstombs((char *)mbtemp, mblen, env_var.c_str(), size_t(-1), false); if (tmplen != mblen) { return false; } mbtemp[mblen - 1] = '\0'; StringX envar = (pws_os::getenv((char *)mbtemp, false)).c_str(); if (!envar.empty()) { sx_temp += envar; } else { sx_temp += StringX(_T("%")) + env_var + StringX(_T("%")); } } st_startpos = st_next + 1; // too complex for for statement } // tokenization for loop // Replace string by rebuilt string first_part = sx_temp; first_part = getruncmd(first_part, bfound); bool rc; if (bfound) rc = issuecmd(first_part, the_rest, bAutotype); else rc = issuecmd(full_string, _T(""), bAutotype); return rc; }