NODE *memberp_help(NODE *args, BOOLEAN notp, BOOLEAN substr) { NODE *obj1, *obj2, *val; int leng; int caseig = varTrue(Caseignoredp); val = FalseName(); obj1 = car(args); obj2 = cadr(args); if (is_list(obj2)) { if (substr) return FalseName(); while (obj2 != NIL && NOT_THROWING) { if (equalp_help(obj1, car(obj2), caseig)) return (notp ? obj2 : TrueName()); obj2 = cdr(obj2); if (check_throwing) break; } return (notp ? NIL : FalseName()); } else if (nodetype(obj2) == ARRAY) { int len = getarrdim(obj2); NODE **data = getarrptr(obj2); if (notp) err_logo(BAD_DATA_UNREC,obj2); if (substr) return FalseName(); while (--len >= 0 && NOT_THROWING) { if (equalp_help(obj1, *data++, caseig)) return TrueName(); } return FalseName(); } else { NODE *tmp; int i; if (aggregate(obj1)) return (notp ? Null_Word : FalseName()); setcar (cdr(args), cnv_node_to_strnode(obj2)); obj2 = cadr(args); setcar (args, cnv_node_to_strnode(obj1)); obj1 = car(args); tmp = NIL; if (obj1 != UNBOUND && obj2 != UNBOUND && getstrlen(obj1) <= getstrlen(obj2) && (substr || (getstrlen(obj1) == 1))) { leng = getstrlen(obj2) - getstrlen(obj1); setcar(cdr(args),make_strnode(getstrptr(obj2), getstrhead(obj2), getstrlen(obj1), nodetype(obj2), strnzcpy)); tmp = cadr(args); for (i = 0; i <= leng; i++) { if (equalp_help(obj1, tmp, caseig)) { if (notp) { setstrlen(tmp,leng+getstrlen(obj1)-i); return tmp; } else return TrueName(); } setstrptr(tmp, getstrptr(tmp) + 1); } } return (notp ? Null_Word : FalseName()); } }
NODE *make_strnode(char *strptr, char *strhead, int len, NODETYPES typ, char * (*copy_routine) (char *, char *, int)) { NODE *strnode; unsigned short *temp; if (len == 0 && Null_Word != NIL) return (Null_Word); strnode = newnode(typ); if (strhead == NULL) { strhead = (char *) malloc((size_t) len + sizeof(short) + 1); if (strhead == NULL) { err_logo(OUT_OF_MEM, NIL); return UNBOUND; } (*copy_routine) (strhead + sizeof(short), strptr, len); strptr = strhead + sizeof(short); temp = (unsigned short *) strhead; setstrrefcnt(temp, 0); } setstrlen(strnode, len); setstrptr(strnode, strptr); setstrhead(strnode, strhead); temp = (unsigned short *) strhead; incstrrefcnt(temp); return (strnode); }
NODE *make_static_strnode(char *strptr) { NODE *strnode = newnode(STRING); setstrptr(strnode, strptr); setstrhead(strnode, NULL); setstrlen(strnode, (int) strlen(strptr)); return (strnode); }
void MCExecPoint::setstringf(const char *p_spec, ...) { va_list t_args; int t_count; #if defined(_HAS_VSCPRINTF) va_start(t_args, p_spec); t_count = _vscprintf(p_spec, t_args); va_end(t_args); #elif defined(_HAS_VSNPRINTF) va_start(t_args, p_spec); t_count = vsnprintf(nil, 0, p_spec, t_args); va_end(t_args); #else #error MCExecPoint::setstringf not implemented #endif va_start(t_args, p_spec); vsprintf(getbuffer(t_count + 1), p_spec, t_args); va_end(t_args); setstrlen(); }
void MCExecPoint::setrectangle(int32_t p_left, int32_t p_top, int32_t p_right, int32_t p_bottom) { sprintf(getbuffer(I4L * 4 + 4), "%d,%d,%d,%d", p_left, p_top, p_right, p_bottom); setstrlen(); }
void MCExecPoint::setrectangle(const MCRectangle32& p_rect) { sprintf(getbuffer(I4L * 4 + 4), "%d,%d,%d,%d", p_rect . x, p_rect . y, p_rect . x + p_rect . width, p_rect . y + p_rect . height); setstrlen(); }
void MCExecPoint::setpoint(int16_t x, int16_t y) { sprintf(getbuffer(I2L * 2 + 2), "%d,%d", x, y); setstrlen(); }