Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30374
Modified Files: Tag: desiredata m_class.c m_pd.h Log Message: gensym2 (support for NUL in symbols)
Index: m_pd.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_pd.h,v retrieving revision 1.4.4.11.2.33.2.14 retrieving revision 1.4.4.11.2.33.2.15 diff -C2 -d -r1.4.4.11.2.33.2.14 -r1.4.4.11.2.33.2.15 *** m_pd.h 20 Dec 2006 04:01:33 -0000 1.4.4.11.2.33.2.14 --- m_pd.h 20 Dec 2006 06:05:23 -0000 1.4.4.11.2.33.2.15 *************** *** 78,82 **** EXTERN_STRUCT _glist; #define t_glist struct _glist ! #define t_canvas struct _glist /* LATER lose this */
#ifdef PD_PLUSPLUS_FACE --- 78,82 ---- EXTERN_STRUCT _glist; #define t_glist struct _glist ! #define t_canvas struct _glist
#ifdef PD_PLUSPLUS_FACE *************** *** 295,298 **** --- 295,299 ---- EXTERN void pd_forwardmess(t_pd *x, int argc, t_atom *argv); EXTERN t_symbol *gensym(char *s); + EXTERN t_symbol *gensym2(char *s, size_t n); EXTERN t_gotfn getfn(t_pd *x, t_symbol *s); EXTERN t_gotfn zgetfn(t_pd *x, t_symbol *s);
Index: m_class.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_class.c,v retrieving revision 1.3.4.7.2.22.2.12 retrieving revision 1.3.4.7.2.22.2.13 diff -C2 -d -r1.3.4.7.2.22.2.12 -r1.3.4.7.2.22.2.13 *** m_class.c 20 Dec 2006 04:01:33 -0000 1.3.4.7.2.22.2.12 --- m_class.c 20 Dec 2006 06:05:23 -0000 1.3.4.7.2.22.2.13 *************** *** 371,377 **** #endif
/* tb: made dogensym() threadsafe * supported by vibrez.net */ ! t_symbol *dogensym(char *s, t_symbol *oldsym) { static t_symbol *symhash[HASHSIZE]; --- 371,394 ---- #endif
+ #ifdef NEWHASH + static short hash(char *s, size_t n) { + unsigned short hash1 = 0, hash2 = 0; + #else + static int hash(char *s, size_t n) { + unsigned int hash1 = 0, hash2 = 0; + #endif + char *s2 = s; + while (n) { + hash1 += *s2; + hash2 += hash1; + s2++; + n--; + } + return hash2; + } + /* tb: made dogensym() threadsafe * supported by vibrez.net */ ! t_symbol *dogensym(char *s, size_t n, t_symbol *oldsym) { static t_symbol *symhash[HASHSIZE]; *************** *** 382,398 **** t_symbol **sym1, *sym2; #ifdef NEWHASH ! unsigned short hash1 = 0, hash2 = 0; #else ! unsigned int hash1 = 0, hash2 = 0; #endif - int length = 0; - char *s2 = s; - while (*s2) - { - hash1 += *s2; - hash2 += hash1; - length++; - s2++; - } #ifdef NEWHASH hash2 = hash2 * HASHFACTOR; --- 399,406 ---- t_symbol **sym1, *sym2; #ifdef NEWHASH ! unsigned short hash2 = hash(s,n); #else ! unsigned int hash2 = hash(s,n); #endif #ifdef NEWHASH hash2 = hash2 * HASHFACTOR; *************** *** 423,433 ****
if (oldsym) sym2 = oldsym; ! else ! { sym2 = (t_symbol *)t_getbytes(sizeof(*sym2)); ! sym2->s_name = (char *)t_getbytes(length+1); sym2->s_next = 0; sym2->s_thing = 0; ! strcpy(sym2->s_name, s); } *sym1 = sym2; --- 431,441 ----
if (oldsym) sym2 = oldsym; ! else { sym2 = (t_symbol *)t_getbytes(sizeof(*sym2)); ! sym2->s_name = (char *)t_getbytes(n+1); sym2->s_next = 0; sym2->s_thing = 0; ! memcpy(sym2->s_name, s, n); ! sym2->s_name[n]=0; } *sym1 = sym2; *************** *** 438,443 **** }
! ! t_symbol *gensym(char *s) {return dogensym(s, 0);}
static int tryingalready; --- 446,451 ---- }
! t_symbol *gensym(char *s) {return dogensym(s,strlen(s),0);} ! t_symbol *gensym2(char *s, size_t n) {return dogensym(s,n,0);}
static int tryingalready; *************** *** 535,550 **** &s_list, &s_anything, &s_signal, &s__N, &s__X, &s_x, &s_y, &s_};
! void mess_init(void) ! { t_symbol **sp; int i; ! ! if (pd_objectmaker) return; for (i = sizeof(symlist)/sizeof(*symlist), sp = symlist; i--; sp++) ! (void) dogensym((*sp)->s_name, *sp); ! pd_objectmaker = class_new(gensym("objectmaker"), 0, 0, sizeof(t_pd), ! CLASS_DEFAULT, A_NULL); ! pd_canvasmaker = class_new(gensym("canvasmaker"), 0, 0, sizeof(t_pd), ! CLASS_DEFAULT, A_NULL); pd_bind(&pd_canvasmaker, &s__N); class_addanything(pd_objectmaker, (t_method)new_anything); --- 543,554 ---- &s_list, &s_anything, &s_signal, &s__N, &s__X, &s_x, &s_y, &s_};
! void mess_init(void) { t_symbol **sp; int i; ! if (pd_objectmaker) return; for (i = sizeof(symlist)/sizeof(*symlist), sp = symlist; i--; sp++) ! (void) dogensym((*sp)->s_name, strlen((*sp)->s_name), *sp); ! pd_objectmaker = class_new(gensym("objectmaker"), 0, 0, sizeof(t_pd), CLASS_DEFAULT, A_NULL); ! pd_canvasmaker = class_new(gensym("canvasmaker"), 0, 0, sizeof(t_pd), CLASS_DEFAULT, A_NULL); pd_bind(&pd_canvasmaker, &s__N); class_addanything(pd_objectmaker, (t_method)new_anything);