Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11855
Modified Files: Tag: desiredata s_loader.c Log Message: removed some MAXPDSTRING
Index: s_loader.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_loader.c,v retrieving revision 1.4.4.5.2.10.2.5 retrieving revision 1.4.4.5.2.10.2.6 diff -C2 -d -r1.4.4.5.2.10.2.5 -r1.4.4.5.2.10.2.6 *** s_loader.c 18 Jul 2007 20:19:40 -0000 1.4.4.5.2.10.2.5 --- s_loader.c 18 Jul 2007 20:52:38 -0000 1.4.4.5.2.10.2.6 *************** *** 18,24 **** --- 18,27 ---- #endif #include <string.h> + #define PD_PLUSPLUS_FACE #include "desire.h" #include "s_stuff.h" #include <stdio.h> + #include <sstream> + using namespace std;
typedef void (*t_xxx)(); *************** *** 79,87 **** }
static int sys_do_load_lib(t_canvas *canvas, char *objectname) { ! char symname[MAXPDSTRING], filename[MAXPDSTRING], dirbuf[MAXPDSTRING], *classname, *nameptr; void *dlobj; t_xxx makeout = NULL; ! int i, hexmunge = 0, fd; #ifdef MSW HINSTANCE ntdll; --- 82,111 ---- }
+ static char *make_setup_name(const char *s) { + bool hexmunge=0; + ostringstream buf; + for (; *s; s++) { + char c = *s; + if ((c>='0' && c<='9') || (c>='A' && c<='Z') || (c>='a' && c<='z' )|| c == '_') { + buf << c; + } else if (c=='~' && s[1]==0) { /* trailing tilde becomes "_tilde" */ + buf << "_tilde"; + } else { /* anything you can't put in a C symbol is sprintf'ed in hex */ + // load_object: symbol "setup_0xbf861ee4" not found + oprintf(buf,"0x%02x",c); + hexmunge = 1; + } + } + char *r; + if (hexmunge) asprintf(&r,"setup_%s",buf.str().data()); + else asprintf(&r,"%s_setup",buf.str().data()); + return r; + } + static int sys_do_load_lib(t_canvas *canvas, char *objectname) { ! char filename[MAXPDSTRING], dirbuf[MAXPDSTRING], *classname, *nameptr; void *dlobj; t_xxx makeout = NULL; ! int fd; #ifdef MSW HINSTANCE ntdll; *************** *** 93,119 **** return 1; } ! for (i = 0, nameptr = classname; i < MAXPDSTRING-7 && *nameptr; nameptr++) { ! char c = *nameptr; ! if ((c>='0' && c<='9') || (c>='A' && c<='Z') || (c>='a' && c<='z' )|| c == '_') { ! symname[i++] = c; ! } else if (c == '~' && nameptr[1] == 0) { /* trailing tilde becomes "_tilde" */ ! strcpy(symname+i, "_tilde"); ! i += strlen(symname+i); ! } else { /* anything you can't put in a C symbol is sprintf'ed in hex */ ! sprintf(symname+i, "0x%02x", c); ! i+=4; ! hexmunge = 1; ! } ! } ! symname[i] = 0; ! post("symname=%s",symname); ! if (hexmunge) { ! memmove(symname+6, symname, strlen(symname)+1); ! strncpy(symname, "setup_", 6); ! } else strcat(symname, "_setup"); ! post("symname=%s",symname); ! #if 0 ! fprintf(stderr, "lib: %s\n", classname); ! #endif /* try looking in the path for (objectname).(sys_dllextent) ... */ if ((fd = canvas_open(canvas, objectname, sys_dllextent , dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) goto gotone; --- 117,121 ---- return 1; } ! char *symname = make_setup_name(classname); /* try looking in the path for (objectname).(sys_dllextent) ... */ if ((fd = canvas_open(canvas, objectname, sys_dllextent , dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) goto gotone; *************** *** 132,136 **** close(fd); class_set_extern_dir(gensym(dirbuf)); - /* rebuild the absolute pathname */ strncpy(filename, dirbuf, MAXPDSTRING); --- 134,137 ---- *************** *** 139,143 **** strncat(filename, nameptr, MAXPDSTRING-strlen(filename)); filename[MAXPDSTRING-1] = 0; - #ifdef DL_OPEN dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); --- 140,143 ---- *************** *** 145,151 **** post("%s: %s", filename, dlerror()); class_set_extern_dir(&s_); return 0; } ! makeout = (t_xxx)dlsym(dlobj, symname); #endif #ifdef MSW --- 145,152 ---- post("%s: %s", filename, dlerror()); class_set_extern_dir(&s_); + free(symname); return 0; } ! makeout = (t_xxx)dlsym(dlobj, symname); #endif #ifdef MSW *************** *** 155,165 **** post("%s: couldn't load", filename); class_set_extern_dir(&s_); return 0; } ! makeout = (t_xxx)GetProcAddress(ntdll, symname); #endif if (!makeout) { ! post("load_object: Symbol "%s" not found", symname); class_set_extern_dir(&s_); return 0; } --- 156,168 ---- post("%s: couldn't load", filename); class_set_extern_dir(&s_); + free(symname); return 0; } ! makeout = (t_xxx)GetProcAddress(ntdll); #endif if (!makeout) { ! post("%s: can't find symbol '%s' in library", filename, symname); class_set_extern_dir(&s_); + free(symname); return 0; } *************** *** 167,170 **** --- 170,174 ---- class_set_extern_dir(&s_); sys_putonloadlist(objectname); + free(symname); return 1; }