[PD-cvs] pd/src s_path.c,1.1.1.2.2.2.2.2,1.1.1.2.2.2.2.3 s_main.c,1.1.1.4.2.8.4.6,1.1.1.4.2.8.4.7

Mathieu Bouchard matju at users.sourceforge.net
Tue Mar 30 02:23:46 CEST 2004


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27699

Modified Files:
      Tag: impd_0_37
	s_path.c s_main.c 
Log Message:
now looks for lib/pd/.impdrc, lib/pd/.pdrc, wherever pd is installed


Index: s_main.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_main.c,v
retrieving revision 1.1.1.4.2.8.4.6
retrieving revision 1.1.1.4.2.8.4.7
diff -C2 -d -r1.1.1.4.2.8.4.6 -r1.1.1.4.2.8.4.7
*** s_main.c	27 Mar 2004 23:41:10 -0000	1.1.1.4.2.8.4.6
--- s_main.c	30 Mar 2004 00:23:43 -0000	1.1.1.4.2.8.4.7
***************
*** 233,239 ****
      pd_init();    	    	    	    	/* start the message system */
      sys_findprogdir(argv[0]);	    	    	/* set sys_progname, guipath */
- #ifdef UNIX
      sys_rcfile();                               /* parse the startup file */
- #endif
      if (sys_argparse(argc, argv)) return (1);	/* parse cmd line */
      sys_addextrapath();
--- 233,237 ----

Index: s_path.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_path.c,v
retrieving revision 1.1.1.2.2.2.2.2
retrieving revision 1.1.1.2.2.2.2.3
diff -C2 -d -r1.1.1.2.2.2.2.2 -r1.1.1.2.2.2.2.3
*** s_path.c	28 Mar 2004 00:02:30 -0000	1.1.1.2.2.2.2.2
--- s_path.c	30 Mar 2004 00:23:43 -0000	1.1.1.2.2.2.2.3
***************
*** 308,361 ****
  }
  
! /* Startup file reading for linux and MACOSX.  This should be replaced by
  a better mechanism.  This should be integrated with the audio, MIDI, and
  path dialog system. */
  
- #ifdef UNIX
- 
  #define NUMARGS 1000
- 
  int sys_argparse(int argc, char **argv);
! 
! int sys_rcfile(void)
! {
!     FILE* file;
!     int i,j,k,rcargc;
!     char *rcargv[NUMARGS], *buffer;
!     char  fname[MAXPDSTRING], buf[1000], *home = getenv("HOME");
!     static char *names[] = {".impdrc",".pdrc"};
! 
!     /* parse a startup file */
!     for (j=0; j<2; j++) {
! 	*fname = '\0'; 
! 	snprintf(fname,MAXPDSTRING,"%s/%s",
! 		home? home : ".", names[j]);
! 	file = fopen(fname, "r");
! 	if (file) {
! 		post("reading startup file: %s", fname);
! 		goto got_one;
! 	}
!     }
!     
!     got_one:
      rcargv[0] = ".";	/* this no longer matters to sys_argparse() */
  
!     for (i = 1; i < NUMARGS-1; i++)
      {
!     	if (fscanf(file, "%999s", buf) < 0)
! 	    break;
! 	buf[1000] = 0;
! 	if (!(rcargv[i] = malloc(strlen(buf) + 1)))
! 	    return (1);
! 	strcpy(rcargv[i], buf);
      }
!     if (i >= NUMARGS-1)
!     	fprintf(stderr, "startup file too long; extra args dropped\n");
      rcargv[i] = 0;
- 
      rcargc = i;
- 
      /* parse the options */
- 
      fclose(file);
      if (sys_verbose)
--- 308,333 ----
  }
  
! /* Startup file reading.  This should be replaced by
  a better mechanism.  This should be integrated with the audio, MIDI, and
  path dialog system. */
  
  #define NUMARGS 1000
  int sys_argparse(int argc, char **argv);
! static int sys_this_rcfile(FILE *file) {
!     int i,rcargc;
!     char *rcargv[NUMARGS];
!     char buf[1000];
      rcargv[0] = ".";	/* this no longer matters to sys_argparse() */
  
!     for (i=1; i<NUMARGS-1; i++)
      {
!     	if (fscanf(file,"%999s",buf)<0) break;
! 	buf[999] = 0;
! 	rcargv[i] = strdup(buf);
      }
!     if (i>=NUMARGS-1) post("startup file too long; extra args dropped\n");
      rcargv[i] = 0;
      rcargc = i;
      /* parse the options */
      fclose(file);
      if (sys_verbose)
***************
*** 372,379 ****
      {
      	post("error parsing RC arguments");
! 	return (1);
      }
!     return (0);
  }
  #endif /* UNIX */
  
--- 344,380 ----
      {
      	post("error parsing RC arguments");
! 	return 1;
      }
!     return 0;
  }
+ 
+ #ifdef UNIX
+ int sys_rcfile(void)
+ {
+     FILE* file;
+     int i,j,ndirs=0;
+     char  fname[MAXPDSTRING];
+     static char *fnames[] = {".impdrc",".pdrc",0};
+     static char *dnames[] = {0,0,0};
+ #ifdef UNIX
+     char *home = getenv("HOME");
+     dnames[ndirs++] = home ? home : ".";
+ #endif
+     dnames[ndirs++] = sys_libdir->s_name;
+     /* find a startup file */
+     for (i=0; dnames[i]; i++) {
+         for (j=0; fnames[j]; j++) {
+ 	    int n = snprintf(fname,MAXPDSTRING,"%s/%s", dnames[i], fnames[j]);
+ 	    if (n>=MAXPDSTRING) {post("sys_rcfile: buffer overflow"); return 1;}
+ 	    post("trying startup file: %s",fname);
+ 	    file = fopen(fname, "r");
+ 	    if (file) {
+ 		post("reading startup file: %s", fname);
+ 		return sys_this_rcfile(file);
+ 	    }
+ 	}
+     }
+     return 0;
+ }    
  #endif /* UNIX */
  





More information about the Pd-cvs mailing list