2 ===================================================================
3 --- m_pd.h (revision 9725)
4 +++ m_pd.h (working copy)
6 #include <stddef.h> /* just for size_t -- how lame! */
9 -#define MAXPDSTRING 1000 /* use this for anything you want */
10 +#define MAXPDSTRING 1000 /* must be >= FILENAME_MAX */
11 #define MAXPDARG 5 /* max number of args we can typecheck today */
13 /* signed and unsigned integer types the size of a pointer: */
15 ===================================================================
16 --- g_editor.c (revision 9725)
17 +++ g_editor.c (working copy)
20 static void canvas_done_popup(t_canvas *x, t_float which, t_float xpos, t_float ypos)
22 - char pathbuf[MAXPDSTRING], namebuf[MAXPDSTRING];
23 + char pathbuf[FILENAME_MAX], namebuf[FILENAME_MAX];
25 for (y = x->gl_list; y; y = y->g_next)
28 t_atom *av = binbuf_getvec(ob->te_binbuf);
31 - atom_string(av, namebuf, MAXPDSTRING);
32 + atom_string(av, namebuf, FILENAME_MAX);
33 dir = canvas_getdir((t_canvas *)y)->s_name;
37 ===================================================================
38 --- s_file.c (revision 9725)
39 +++ s_file.c (working copy)
42 static void sys_initloadpreferences( void)
44 - char filenamebuf[MAXPDSTRING], *homedir = getenv("HOME");
45 + char filenamebuf[FILENAME_MAX], *homedir = getenv("HOME");
47 - char user_prefs_file[MAXPDSTRING]; /* user prefs file */
48 + char user_prefs_file[FILENAME_MAX]; /* user prefs file */
49 /* default prefs embedded in the package */
50 - char default_prefs_file[MAXPDSTRING];
51 + char default_prefs_file[FILENAME_MAX];
54 - snprintf(default_prefs_file, MAXPDSTRING, "%s/default.pdsettings",
55 + snprintf(default_prefs_file, FILENAME_MAX, "%s/default.pdsettings",
58 - snprintf(user_prefs_file, MAXPDSTRING, "%s/.pdsettings", homedir);
59 + snprintf(user_prefs_file, FILENAME_MAX, "%s/.pdsettings", homedir);
60 if (stat(user_prefs_file, &statbuf) == 0)
61 - strncpy(filenamebuf, user_prefs_file, MAXPDSTRING);
62 + strncpy(filenamebuf, user_prefs_file, FILENAME_MAX);
63 else if (stat(default_prefs_file, &statbuf) == 0)
64 - strncpy(filenamebuf, default_prefs_file, MAXPDSTRING);
65 + strncpy(filenamebuf, default_prefs_file, FILENAME_MAX);
67 - filenamebuf[MAXPDSTRING-1] = 0;
68 + filenamebuf[FILENAME_MAX-1] = 0;
69 if ((fd = open(filenamebuf, 0)) < 0)
74 static void sys_initsavepreferences( void)
76 - char filenamebuf[MAXPDSTRING], errbuf[MAXPDSTRING],
77 + char filenamebuf[FILENAME_MAX], errbuf[FILENAME_MAX],
78 *homedir = getenv("HOME");
83 - snprintf(filenamebuf, MAXPDSTRING, "%s/.pdsettings", homedir);
84 - filenamebuf[MAXPDSTRING-1] = 0;
85 + snprintf(filenamebuf, FILENAME_MAX, "%s/.pdsettings", homedir);
86 + filenamebuf[FILENAME_MAX-1] = 0;
87 if ((sys_prefsavefp = fopen(filenamebuf, "w")) == NULL)
89 - snprintf(errbuf, MAXPDSTRING, "%s: %s",filenamebuf, strerror(errno));
90 + snprintf(errbuf, FILENAME_MAX, "%s: %s",filenamebuf, strerror(errno));
97 int nread = 0, nleft = size;
98 - char embedded_prefs[MAXPDSTRING];
99 - char user_prefs[MAXPDSTRING];
100 + char embedded_prefs[FILENAME_MAX];
101 + char user_prefs[FILENAME_MAX];
102 char *homedir = getenv("HOME");
104 /* the 'defaults' command expects the filename without .plist at the
106 - snprintf(embedded_prefs, MAXPDSTRING, "%s/../org.puredata.pd",
107 + snprintf(embedded_prefs, FILENAME_MAX, "%s/../org.puredata.pd",
109 - snprintf(user_prefs, MAXPDSTRING,
110 + snprintf(user_prefs, FILENAME_MAX,
111 "%s/Library/Preferences/org.puredata.pd.plist", homedir);
112 if (stat(user_prefs, &statbuf) == 0)
113 snprintf(cmdbuf, 256, "defaults read org.puredata.pd %s 2> /dev/null\n",
115 ===================================================================
116 --- configure.in (revision 9725)
117 +++ configure.in (working copy)
118 @@ -347,11 +347,11 @@
120 if test x$jack = "xyes";
122 - LDFLAGS=$LDFLAGS" -weak_framework Jack"
123 + LDFLAGS=$LDFLAGS" -weak_framework Jackmp"
125 if test x$jack = "xrun";
127 - LDFLAGS=$LDFLAGS" -weak_framework Jack"
128 + LDFLAGS=$LDFLAGS" -weak_framework Jackmp"
133 ===================================================================
134 --- s_main.c (revision 9725)
135 +++ s_main.c (working copy)
138 static void openit(const char *dirname, const char *filename)
140 - char dirbuf[MAXPDSTRING], *nameptr;
141 + char dirbuf[FILENAME_MAX], *nameptr;
142 int fd = open_via_path(dirname, filename, "", dirbuf, &nameptr,
149 INSTALL_PREFIX. In MSW, we don't try to use INSTALL_PREFIX. */
150 void sys_findprogdir(char *progname)
152 - char sbuf[MAXPDSTRING], sbuf2[MAXPDSTRING], *sp;
153 + char sbuf[FILENAME_MAX], sbuf2[FILENAME_MAX], *sp;
157 @@ -439,12 +439,12 @@
158 /* find out by what string Pd was invoked; put answer in "sbuf". */
160 GetModuleFileName(NULL, sbuf2, sizeof(sbuf2));
161 - sbuf2[MAXPDSTRING-1] = 0;
162 + sbuf2[FILENAME_MAX-1] = 0;
163 sys_unbashfilename(sbuf2, sbuf);
166 - strncpy(sbuf, progname, MAXPDSTRING);
167 - sbuf[MAXPDSTRING-1] = 0;
168 + strncpy(sbuf, progname, FILENAME_MAX);
169 + sbuf[FILENAME_MAX-1] = 0;
171 lastslash = strrchr(sbuf, '/');
173 @@ -491,16 +491,16 @@
174 sys_libdir = gensym(sbuf2);
175 sys_guidir = &s_; /* in MSW the guipath just depends on the libdir */
177 - strncpy(sbuf, sbuf2, MAXPDSTRING-30);
178 - sbuf[MAXPDSTRING-30] = 0;
179 + strncpy(sbuf, sbuf2, FILENAME_MAX-30);
180 + sbuf[FILENAME_MAX-30] = 0;
181 strcat(sbuf, "/lib/pd");
182 if (stat(sbuf, &statbuf) >= 0)
184 /* complicated layout: lib dir is the one we just stat-ed above */
185 sys_libdir = gensym(sbuf);
186 /* gui lives in .../lib/pd/bin */
187 - strncpy(sbuf, sbuf2, MAXPDSTRING-30);
188 - sbuf[MAXPDSTRING-30] = 0;
189 + strncpy(sbuf, sbuf2, FILENAME_MAX-30);
190 + sbuf[FILENAME_MAX-30] = 0;
191 strcat(sbuf, "/lib/pd/bin");
192 sys_guidir = gensym(sbuf);
195 /* simple layout: lib dir is the parent */
196 sys_libdir = gensym(sbuf2);
197 /* gui lives in .../bin */
198 - strncpy(sbuf, sbuf2, MAXPDSTRING-30);
199 - sbuf[MAXPDSTRING-30] = 0;
200 + strncpy(sbuf, sbuf2, FILENAME_MAX-30);
201 + sbuf[FILENAME_MAX-30] = 0;
202 strcat(sbuf, "/bin");
203 sys_guidir = gensym(sbuf);
207 int sys_argparse(int argc, char **argv)
209 - char sbuf[MAXPDSTRING];
211 while ((argc > 0) && **argv == '-')
214 from command-line arguments */
215 static void sys_afterargparse(void)
217 - char sbuf[MAXPDSTRING];
218 + char sbuf[FILENAME_MAX];
220 int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV];
221 int naudiooutdev, audiooutdev[MAXAUDIOOUTDEV], choutdev[MAXAUDIOOUTDEV];
222 @@ -909,13 +908,13 @@
223 int nmidiindev = 0, midiindev[MAXMIDIINDEV];
224 int nmidioutdev = 0, midioutdev[MAXMIDIOUTDEV];
225 /* add "extra" library to path */
226 - strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30);
227 - sbuf[MAXPDSTRING-30] = 0;
228 + strncpy(sbuf, sys_libdir->s_name, FILENAME_MAX-30);
229 + sbuf[FILENAME_MAX-30] = 0;
230 strcat(sbuf, "/extra");
231 sys_setextrapath(sbuf);
232 /* add "doc/5.reference" library to helppath */
233 - strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30);
234 - sbuf[MAXPDSTRING-30] = 0;
235 + strncpy(sbuf, sys_libdir->s_name, FILENAME_MAX-30);
236 + sbuf[FILENAME_MAX-30] = 0;
237 strcat(sbuf, "/doc/5.reference");
238 sys_helppath = namelist_append_files(sys_helppath, sbuf);
239 /* correct to make audio and MIDI device lists zero based. On
241 ===================================================================
242 --- s_path.c (revision 9725)
243 +++ s_path.c (working copy)
244 @@ -256,10 +256,10 @@
248 - char dirbuf[MAXPDSTRING];
249 + char dirbuf[FILENAME_MAX];
250 int dirlen = (strrchr(name, '/') - name);
251 - if (dirlen > MAXPDSTRING-1)
252 - dirlen = MAXPDSTRING-1;
253 + if (dirlen > FILENAME_MAX-1)
254 + dirlen = FILENAME_MAX-1;
255 strncpy(dirbuf, name, dirlen);
257 *fdp = sys_trytoopenone(dirbuf, name+(dirlen+1), ext,
258 @@ -326,32 +326,32 @@
260 void open_via_helppath(const char *name, const char *dir)
262 - char realname[MAXPDSTRING], dirbuf[MAXPDSTRING], *basename;
263 + char realname[FILENAME_MAX], dirbuf[FILENAME_MAX], *basename;
264 /* make up a silly "dir" if none is supplied */
265 const char *usedir = (*dir ? dir : "./");
268 /* 1. "objectname-help.pd" */
269 - strncpy(realname, name, MAXPDSTRING-10);
270 - realname[MAXPDSTRING-10] = 0;
271 + strncpy(realname, name, FILENAME_MAX-10);
272 + realname[FILENAME_MAX-10] = 0;
273 if (strlen(realname) > 3 && !strcmp(realname+strlen(realname)-3, ".pd"))
274 realname[strlen(realname)-3] = 0;
275 strcat(realname, "-help.pd");
276 if ((fd = do_open_via_path(dir, realname, "", dirbuf, &basename,
277 - MAXPDSTRING, 0, sys_helppath)) >= 0)
278 + FILENAME_MAX, 0, sys_helppath)) >= 0)
281 /* 2. "help-objectname.pd" */
282 strcpy(realname, "help-");
283 - strncat(realname, name, MAXPDSTRING-10);
284 - realname[MAXPDSTRING-1] = 0;
285 + strncat(realname, name, FILENAME_MAX-10);
286 + realname[FILENAME_MAX-1] = 0;
287 if ((fd = do_open_via_path(dir, realname, "", dirbuf, &basename,
288 - MAXPDSTRING, 0, sys_helppath)) >= 0)
289 + FILENAME_MAX, 0, sys_helppath)) >= 0)
292 /* 3. "objectname.pd" */
293 if ((fd = do_open_via_path(dir, name, "", dirbuf, &basename,
294 - MAXPDSTRING, 0, sys_helppath)) >= 0)
295 + FILENAME_MAX, 0, sys_helppath)) >= 0)
297 post("sorry, couldn't find help patch for \"%s\"", name);
301 char* rcargv[NUMARGS];
303 - char fname[MAXPDSTRING], buf[1000], *home = getenv("HOME");
304 + char fname[FILENAME_MAX], buf[1000], *home = getenv("HOME");
305 int retval = 1; /* that's what we will return at the end; for now, let's think it'll be an error */
307 /* initialize rc-arg-array so we can safely clean up at the end */
312 - strncat(fname, home? home : ".", MAXPDSTRING-10);
313 + strncat(fname, home? home : ".", FILENAME_MAX-10);
316 strcat(fname, STARTUPNAME);
318 ===================================================================
319 --- g_canvas.c (revision 9725)
320 +++ g_canvas.c (working copy)
321 @@ -1543,7 +1543,6 @@
323 t_namelist *nl, thislist;
325 - char listbuf[MAXPDSTRING];
328 /* first check if "name" is absolute (and if so, try to open) */
329 @@ -1563,12 +1562,12 @@
330 dir = (x2 ? canvas_getdir(x2)->s_name : ".");
331 for (nl = y->gl_env->ce_path; nl; nl = nl->nl_next)
333 - char realname[MAXPDSTRING];
334 - strncpy(realname, dir, MAXPDSTRING);
335 - realname[MAXPDSTRING-3] = 0;
336 + char realname[FILENAME_MAX];
337 + strncpy(realname, dir, FILENAME_MAX);
338 + realname[FILENAME_MAX-3] = 0;
339 strcat(realname, "/");
340 - strncat(realname, nl->nl_string, MAXPDSTRING-strlen(realname));
341 - realname[MAXPDSTRING-1] = 0;
342 + strncat(realname, nl->nl_string, FILENAME_MAX-strlen(realname));
343 + realname[FILENAME_MAX-1] = 0;
344 if ((fd = sys_trytoopenone(realname, name, ext,
345 dirresult, nameresult, size, bin)) >= 0)
348 ===================================================================
349 --- s_loader.c (revision 9725)
350 +++ s_loader.c (working copy)
353 static int sys_do_load_lib(t_canvas *canvas, char *objectname)
355 - char symname[MAXPDSTRING], filename[MAXPDSTRING], dirbuf[MAXPDSTRING],
356 + char symname[MAXPDSTRING], filename[FILENAME_MAX], dirbuf[FILENAME_MAX],
357 *classname, *nameptr, altsymname[MAXPDSTRING];
359 t_xxx makeout = NULL;
360 @@ -137,23 +137,23 @@
362 /* try looking in the path for (objectname).(sys_dllextent) ... */
363 if ((fd = canvas_open(canvas, objectname, sys_dllextent,
364 - dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0)
365 + dirbuf, &nameptr, FILENAME_MAX, 1)) >= 0)
367 /* same, with the more generic sys_dllextent2 */
368 if ((fd = canvas_open(canvas, objectname, sys_dllextent2,
369 - dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0)
370 + dirbuf, &nameptr, FILENAME_MAX, 1)) >= 0)
372 /* next try (objectname)/(classname).(sys_dllextent) ... */
373 - strncpy(filename, objectname, MAXPDSTRING);
374 + strncpy(filename, objectname, FILENAME_MAX);
375 filename[MAXPDSTRING-2] = 0;
376 strcat(filename, "/");
377 - strncat(filename, classname, MAXPDSTRING-strlen(filename));
378 - filename[MAXPDSTRING-1] = 0;
379 + strncat(filename, classname, FILENAME_MAX-strlen(filename));
380 + filename[FILENAME_MAX-1] = 0;
381 if ((fd = canvas_open(canvas, filename, sys_dllextent,
382 - dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0)
383 + dirbuf, &nameptr, FILENAME_MAX, 1)) >= 0)
385 if ((fd = canvas_open(canvas, filename, sys_dllextent2,
386 - dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0)
387 + dirbuf, &nameptr, FILENAME_MAX, 1)) >= 0)
391 @@ -161,11 +161,11 @@
392 class_set_extern_dir(gensym(dirbuf));
394 /* rebuild the absolute pathname */
395 - strncpy(filename, dirbuf, MAXPDSTRING);
396 - filename[MAXPDSTRING-2] = 0;
397 + strncpy(filename, dirbuf, FILENAME_MAX);
398 + filename[FILENAME_MAX-2] = 0;
399 strcat(filename, "/");
400 - strncat(filename, nameptr, MAXPDSTRING-strlen(filename));
401 - filename[MAXPDSTRING-1] = 0;
402 + strncat(filename, nameptr, FILENAME_MAX-strlen(filename));
403 + filename[FILENAME_MAX-1] = 0;
406 dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
408 ===================================================================
409 --- m_binbuf.c (revision 9725)
410 +++ m_binbuf.c (working copy)
413 static int binbuf_doopen(char *s, int mode)
415 - char namebuf[MAXPDSTRING];
416 + char namebuf[FILENAME_MAX];
422 static FILE *binbuf_dofopen(char *s, char *mode)
424 - char namebuf[MAXPDSTRING];
425 + char namebuf[FILENAME_MAX];
426 sys_bashfilename(s, namebuf);
427 return (fopen(namebuf, mode));
433 - char namebuf[MAXPDSTRING];
434 + char namebuf[FILENAME_MAX];
442 - char buf[MAXPDSTRING], *bufptr;
443 + char buf[FILENAME_MAX], *bufptr;
444 if ((filedesc = canvas_open(canvas, filename, "",
445 - buf, &bufptr, MAXPDSTRING, 0)) < 0)
446 + buf, &bufptr, FILENAME_MAX, 0)) < 0)
448 error("%s: can't open", filename);
454 - char buf[MAXPDSTRING], *bufptr;
455 + char buf[FILENAME_MAX], *bufptr;
456 if ((filedesc = open_via_path(
457 - dirname, filename, "", buf, &bufptr, MAXPDSTRING, 0)) < 0)
458 + dirname, filename, "", buf, &bufptr, FILENAME_MAX, 0)) < 0)
460 error("%s: can't open", filename);
463 int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag)
466 - char sbuf[WBUFSIZE], fbuf[MAXPDSTRING], *bp = sbuf, *ep = sbuf + WBUFSIZE;
467 + char sbuf[WBUFSIZE], fbuf[FILENAME_MAX], *bp = sbuf, *ep = sbuf + WBUFSIZE;
469 int indx, deleteit = 0;
472 ===================================================================
473 --- d_soundfile.c (revision 9725)
474 +++ d_soundfile.c (working copy)
476 int *p_bytespersamp, int *p_bigendian, int *p_nchannels, long *p_bytelimit,
479 - char buf[OBUFSIZE], *bufptr;
480 + char buf[FILENAME_MAX], *bufptr;
482 - fd = open_via_path(dirname, filename, "", buf, &bufptr, MAXPDSTRING, 1);
483 + fd = open_via_path(dirname, filename, "", buf, &bufptr, FILENAME_MAX, 1);
486 else return (open_soundfile_via_fd(fd, headersize, p_bytespersamp,
488 int *p_bytespersamp, int *p_bigendian, int *p_nchannels, long *p_bytelimit,
491 - char buf[OBUFSIZE], *bufptr;
492 + char buf[FILENAME_MAX], *bufptr;
494 - fd = canvas_open(canvas, filename, "", buf, &bufptr, MAXPDSTRING, 1);
495 + fd = canvas_open(canvas, filename, "", buf, &bufptr, FILENAME_MAX, 1);
498 else return (open_soundfile_via_fd(fd, headersize, p_bytespersamp,
499 @@ -738,15 +738,15 @@
500 int filetype, int nframes, int bytespersamp,
501 int bigendian, int nchannels, int swap, t_float samplerate)
503 - char filenamebuf[MAXPDSTRING], buf2[MAXPDSTRING];
504 + char filenamebuf[FILENAME_MAX], buf2[FILENAME_MAX];
505 char headerbuf[WRITEHDRSIZE];
506 t_wave *wavehdr = (t_wave *)headerbuf;
507 t_nextstep *nexthdr = (t_nextstep *)headerbuf;
508 t_aiff *aiffhdr = (t_aiff *)headerbuf;
509 int fd, headersize = 0;
511 - strncpy(filenamebuf, filename, MAXPDSTRING-10);
512 - filenamebuf[MAXPDSTRING-10] = 0;
513 + strncpy(filenamebuf, filename, FILENAME_MAX-10);
514 + filenamebuf[FILENAME_MAX-10] = 0;
516 if (filetype == FORMAT_NEXT)
519 headersize = sizeof(t_wave);
522 - canvas_makefilename(canvas, filenamebuf, buf2, MAXPDSTRING);
523 + canvas_makefilename(canvas, filenamebuf, buf2, FILENAME_MAX);
524 sys_bashfilename(buf2, buf2);
525 if ((fd = open(buf2, BINCREATE, 0666)) < 0)
528 ===================================================================
529 --- m_class.c (revision 9725)
530 +++ m_class.c (working copy)
533 static t_symbol *addfileextent(t_symbol *s)
535 - char namebuf[MAXPDSTRING], *str = s->s_name;
536 + char namebuf[FILENAME_MAX], *str = s->s_name;
537 int ln = strlen(str);
538 if (!strcmp(str + ln - 3, ".pd")) return (s);
539 strcpy(namebuf, str);
544 - char dirbuf[MAXPDSTRING], *nameptr;
545 + char dirbuf[FILENAME_MAX], *nameptr;
546 if (tryingalready) return;
551 current = s__X.s_thing;
552 if ((fd = canvas_open(canvas_getcurrent(), s->s_name, ".pd",
553 - dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0 ||
554 + dirbuf, &nameptr, FILENAME_MAX, 0)) >= 0 ||
555 (fd = canvas_open(canvas_getcurrent(), s->s_name, ".pat",
556 - dirbuf, &nameptr, MAXPDSTRING, 0)) >= 0)
557 + dirbuf, &nameptr, FILENAME_MAX, 0)) >= 0)
560 if (!pd_setloadingabstraction(s))
562 ===================================================================
563 --- g_array.c (revision 9725)
564 +++ g_array.c (working copy)
565 @@ -1384,7 +1384,7 @@
567 int nelem, filedesc, i;
569 - char buf[MAXPDSTRING], *bufptr;
570 + char buf[FILENAME_MAX], *bufptr;
571 int yonset, elemsize;
572 t_array *array = garray_getarray_floatonly(x, &yonset, &elemsize);
574 @@ -1394,7 +1394,7 @@
577 if ((filedesc = canvas_open(glist_getcanvas(x->x_glist),
578 - filename->s_name, "", buf, &bufptr, MAXPDSTRING, 0)) < 0
579 + filename->s_name, "", buf, &bufptr, FILENAME_MAX, 0)) < 0
580 || !(fd = fdopen(filedesc, "r")))
582 error("%s: can't open", filename->s_name);