Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19281
Modified Files: Tag: desiredata s_path.c Log Message: removed some MAXPDSTRING
Index: s_path.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_path.c,v retrieving revision 1.3.4.6.2.8.2.11 retrieving revision 1.3.4.6.2.8.2.12 diff -C2 -d -r1.3.4.6.2.8.2.11 -r1.3.4.6.2.8.2.12 *** s_path.c 19 Jul 2007 23:41:27 -0000 1.3.4.6.2.8.2.11 --- s_path.c 20 Jul 2007 04:23:40 -0000 1.3.4.6.2.8.2.12 *************** *** 228,249 **** even though we have to tear it back off for one of the search attempts. */ extern "C" void open_via_helppath(const char *name, const char *dir) { ! char realname[MAXPDSTRING], *dirbuf, *basename; int fd; ! /* 1. "objectname-help.pd" */ ! strncpy(realname, name, MAXPDSTRING-10); ! realname[MAXPDSTRING-10] = 0; ! if (strlen(realname) > 3 && !strcmp(realname+strlen(realname)-3, ".pd")) realname[strlen(realname)-3] = 0; ! strcat(realname, "-help.pd"); if ((fd = do_open_via_path(dir,realname,"",&dirbuf,&basename,0,sys_helppath))>=0) goto gotone; ! /* 2. "help-objectname.pd" */ ! snprintf(realname,MAXPDSTRING,"help-%s",name); ! realname[MAXPDSTRING-1] = 0; if ((fd = do_open_via_path(dir,realname,"",&dirbuf,&basename,0,sys_helppath))>=0) goto gotone; ! /* 3. "objectname.pd" */ if ((fd = do_open_via_path(dir, name,"",&dirbuf,&basename,0,sys_helppath))>=0) goto gotone; post("sorry, couldn't find help patch for "%s"", name); return; gotone: ! close(fd); glob_evalfile(0, gensym((char*)basename), gensym(dirbuf)); } --- 228,245 ---- even though we have to tear it back off for one of the search attempts. */ extern "C" void open_via_helppath(const char *name, const char *dir) { ! char *realname=0, *dirbuf, *basename; ! int suffixed = strlen(realname) > 3 && !strcmp(realname+strlen(realname)-3, ".pd"); int fd; ! asprintf(&realname,"%.*s-help.pd",strlen(name)-3*suffixed,name); if ((fd = do_open_via_path(dir,realname,"",&dirbuf,&basename,0,sys_helppath))>=0) goto gotone; ! free(realname); ! asprintf(&realname,"help-%s",name); if ((fd = do_open_via_path(dir,realname,"",&dirbuf,&basename,0,sys_helppath))>=0) goto gotone; ! free(realname); if ((fd = do_open_via_path(dir, name,"",&dirbuf,&basename,0,sys_helppath))>=0) goto gotone; post("sorry, couldn't find help patch for "%s"", name); return; gotone: ! close(fd); if (realname) free(realname); glob_evalfile(0, gensym((char*)basename), gensym(dirbuf)); } *************** *** 254,258 ****
extern "C" int sys_parsercfile(char *filename) { - int i; int rcargc; char* rcargv[NUMARGS]; --- 250,253 ---- *************** *** 261,265 **** int retval = 1; /* that's what we will return at the end; for now, let's think it'll be an error */ /* initialize rc-arg-array so we can safely clean up at the end */ ! for (i = 1; i < NUMARGS-1; i++) rcargv[i]=0; /* parse a startup file */ FILE* file = fopen(filename, "r"); --- 256,260 ---- int retval = 1; /* that's what we will return at the end; for now, let's think it'll be an error */ /* initialize rc-arg-array so we can safely clean up at the end */ ! for (int i=1; i<NUMARGS-1; i++) rcargv[i]=0; /* parse a startup file */ FILE* file = fopen(filename, "r"); *************** *** 268,274 **** rcargv[0] = "."; /* this no longer matters to sys_argparse() */ /* tb: comments in pdrc file { */ ! i=1; while ((fgets(c,MAXPDSTRING,file)) != 0) { ! if ( c[strlen(c)-1] !='\n') { //it is unlikely that this is ever the case fprintf(stderr, "startup file contains a line that's too long\n"); --- 263,269 ---- rcargv[0] = "."; /* this no longer matters to sys_argparse() */ /* tb: comments in pdrc file { */ ! int i=1; while ((fgets(c,MAXPDSTRING,file)) != 0) { ! if (c[strlen(c)-1] !='\n') { //it is unlikely that this is ever the case fprintf(stderr, "startup file contains a line that's too long\n"); *************** *** 312,322 **** #define STARTUPNAME ".pdrc" extern "C" int sys_rcfile () { ! char fname[MAXPDSTRING], *home = getenv("HOME"); // parse a startup file */ ! *fname = '\0'; ! strncat(fname, home? home : ".", MAXPDSTRING-10); ! strcat(fname, "/"); ! strcat(fname, STARTUPNAME); ! return sys_parsercfile(fname); } #endif /* MSW */ --- 307,317 ---- #define STARTUPNAME ".pdrc" extern "C" int sys_rcfile () { ! char *fname, *home = getenv("HOME"); // parse a startup file */ ! *fname = 0; ! asprintf(&fname,"%s/%s",home? home : ".",STARTUPNAME); ! int r = sys_parsercfile(fname); ! free(fname); ! return r; } #endif /* MSW */