void move_history_down(t_prompt *prompt, char **history) { int max_hist; max_hist = dlen(history); clear_line(prompt); ++prompt->curr_history; while (prompt->curr_history < max_hist && prompt->count_char > 0 && !strncmp(prompt->line, history[prompt->curr_history], prompt->count_char)) ++prompt->curr_history; if (prompt->curr_history == dlen(history)) { memcpy(prompt->line, prompt->tmp_history, strlen(prompt->tmp_history)); prompt->count_char = strlen(prompt->tmp_history); } else { memcpy(prompt->line, history[prompt->curr_history], strlen(history[prompt->curr_history])); prompt->count_char = strlen(history[prompt->curr_history]); } prompt->count_pos = prompt->count_char; }
zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) #endif { cred_t *cr = CRED(); struct inode *ip; int error; fstrans_cookie_t cookie; if (dlen(dentry) > ZFS_MAXNAMELEN) return (ERR_PTR(-ENAMETOOLONG)); crhold(cr); cookie = spl_fstrans_mark(); error = -zfs_lookup(dir, dname(dentry), &ip, 0, cr, NULL, NULL); spl_fstrans_unmark(cookie); ASSERT3S(error, <=, 0); crfree(cr); spin_lock(&dentry->d_lock); dentry->d_time = jiffies; #ifndef HAVE_S_D_OP d_set_d_op(dentry, &zpl_dentry_operations); #endif /* HAVE_S_D_OP */ spin_unlock(&dentry->d_lock); if (error) { if (error == -ENOENT) return (d_splice_alias(NULL, dentry)); else return (ERR_PTR(error)); } return (d_splice_alias(ip, dentry)); }
double ddist( LWDVector a, LWDVector b ) { LWDVector c; dsub( a, b, c ); return dlen( c ); }
void move_cursor(t_prompt *prompt, char *buffer, char **history, char flag) { if (!(strcmp(prompt->caps->left, buffer)) && prompt->count_pos > 0) --prompt->count_pos; else if (!(strcmp(prompt->caps->right, buffer)) && prompt->count_pos < prompt->count_char) ++prompt->count_pos; else if (flag && !(strcmp(prompt->caps->up, buffer)) && prompt->curr_history > 0) move_history_up(prompt, history); else if (flag && !(strcmp(prompt->caps->down, buffer)) && prompt->curr_history < dlen(history)) move_history_down(prompt, history); }
void move_history_up(t_prompt *prompt, char **history) { if (prompt->curr_history == dlen(history)) save_current_line(prompt); clear_line(prompt); --prompt->curr_history; while (prompt->count_char > 0 && prompt->curr_history > 0 && !strncmp(prompt->line, history[prompt->curr_history], prompt->count_char)) --prompt->curr_history; memcpy(prompt->line, history[prompt->curr_history], strlen(history[prompt->curr_history])); prompt->count_char = strlen(history[prompt->curr_history]); prompt->count_pos = prompt->count_char; }
// TODO: COMPROMISED? size_t fdlen(double x, int prec, char format) { static const double f[] = {-1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}; const char const *g = (const char const *)f; if(strstr(g, (const char const *)&x) != 0) { // printf(" (hit %lg) ", x); /* disambiguate digits AND make sure, could be cross boundary */ if(x == 0.0 || x == 1.0 || x == 2.0 || x == 3.0 || x == 4.0 || x == 5.0 || x == 6.0 || x == 7.0 || x == 8.0 || x == 9.0) return 3; if(x == -1.0 || 10.0) return 4; } return dlen(x, prec, format); }
zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) #endif { cred_t *cr = CRED(); struct inode *ip; int error; fstrans_cookie_t cookie; pathname_t *ppn = NULL; pathname_t pn; int zfs_flags = 0; zfs_sb_t *zsb = dentry->d_sb->s_fs_info; if (dlen(dentry) > ZFS_MAX_DATASET_NAME_LEN) return (ERR_PTR(-ENAMETOOLONG)); crhold(cr); cookie = spl_fstrans_mark(); /* If we are a case insensitive fs, we need the real name */ if (zsb->z_case == ZFS_CASE_INSENSITIVE) { zfs_flags = FIGNORECASE; pn_alloc(&pn); ppn = &pn; } error = -zfs_lookup(dir, dname(dentry), &ip, zfs_flags, cr, NULL, ppn); spl_fstrans_unmark(cookie); ASSERT3S(error, <=, 0); crfree(cr); spin_lock(&dentry->d_lock); dentry->d_time = jiffies; #ifndef HAVE_S_D_OP d_set_d_op(dentry, &zpl_dentry_operations); #endif /* HAVE_S_D_OP */ spin_unlock(&dentry->d_lock); if (error) { /* * If we have a case sensitive fs, we do not want to * insert negative entries, so return NULL for ENOENT. * Fall through if the error is not ENOENT. Also free memory. */ if (ppn) { pn_free(ppn); if (error == -ENOENT) return (NULL); } if (error == -ENOENT) return (d_splice_alias(NULL, dentry)); else return (ERR_PTR(error)); } /* * If we are case insensitive, call the correct function * to install the name. */ if (ppn) { struct dentry *new_dentry; struct qstr ci_name; ci_name.name = pn.pn_buf; ci_name.len = strlen(pn.pn_buf); new_dentry = d_add_ci(dentry, ip, &ci_name); pn_free(ppn); return (new_dentry); } else { return (d_splice_alias(ip, dentry)); } }
zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) #endif { cred_t *cr = CRED(); struct inode *ip; int error; fstrans_cookie_t cookie; pathname_t *ppn = NULL; pathname_t pn; zfs_sb_t *zsb = dentry->d_sb->s_fs_info; if (dlen(dentry) > ZFS_MAXNAMELEN) return (ERR_PTR(-ENAMETOOLONG)); crhold(cr); cookie = spl_fstrans_mark(); /* If we are a case insensitive fs, we need the real name */ if (zsb->z_case == ZFS_CASE_INSENSITIVE) { pn.pn_bufsize = ZFS_MAXNAMELEN; pn.pn_buf = kmem_zalloc(ZFS_MAXNAMELEN, KM_SLEEP); ppn = &pn; } error = -zfs_lookup(dir, dname(dentry), &ip, 0, cr, NULL, ppn); spl_fstrans_unmark(cookie); ASSERT3S(error, <=, 0); crfree(cr); spin_lock(&dentry->d_lock); dentry->d_time = jiffies; #ifndef HAVE_S_D_OP d_set_d_op(dentry, &zpl_dentry_operations); #endif /* HAVE_S_D_OP */ spin_unlock(&dentry->d_lock); if (error) { if (ppn) kmem_free(pn.pn_buf, ZFS_MAXNAMELEN); if (error == -ENOENT) return (d_splice_alias(NULL, dentry)); else return (ERR_PTR(error)); } /* * If we are case insensitive, call the correct function * to install the name. */ if (ppn) { struct dentry *new_dentry; struct qstr ci_name; ci_name.name = pn.pn_buf; ci_name.len = strlen(pn.pn_buf); new_dentry = d_add_ci(dentry, ip, &ci_name); kmem_free(pn.pn_buf, ZFS_MAXNAMELEN); return (new_dentry); } else { return (d_splice_alias(ip, dentry)); } }
void dsetlen( LWDVector a, double d ) { double d0 = dlen( a ); if ( d0 != 0.0 ) dscalev( a, d / d0 ); }