From b1450980b54619d6b5a690b1ceb3f4e66f7f133a Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Wed, 10 Jul 1996 14:46:01 +0000 Subject: [PATCH] Changed dbExpandInclude to dbExpand --- src/dbStatic/Makefile.Unix | 6 +-- .../{dbExpandInclude.c => dbExpand.c} | 53 +++++++++++-------- 2 files changed, 34 insertions(+), 25 deletions(-) rename src/dbStatic/{dbExpandInclude.c => dbExpand.c} (66%) diff --git a/src/dbStatic/Makefile.Unix b/src/dbStatic/Makefile.Unix index 90e06ea7f..8e83b5525 100755 --- a/src/dbStatic/Makefile.Unix +++ b/src/dbStatic/Makefile.Unix @@ -24,7 +24,7 @@ INC += guigroup.h SRCS.c = \ dbYacc.c \ ../dbReadTest.c\ - ../dbExpandInclude.c\ + ../dbExpand.c\ ../dbPvdLib.c\ ../dbStaticNoRun.c\ ../dbStaticLib.c\ @@ -33,7 +33,7 @@ SRCS.c = \ OBJS = \ dbReadTest.o\ - dbExpandInclude.o\ + dbExpand.o\ dbToMenuH.o\ dbToRecordtypeH.o @@ -42,7 +42,7 @@ LIBNAME = libDb.a PROD = \ dbReadTest\ - dbExpandInclude\ + dbExpand\ dbToMenuH\ dbToRecordtypeH diff --git a/src/dbStatic/dbExpandInclude.c b/src/dbStatic/dbExpand.c similarity index 66% rename from src/dbStatic/dbExpandInclude.c rename to src/dbStatic/dbExpand.c index 09aa0847a..8117e722a 100644 --- a/src/dbStatic/dbExpandInclude.c +++ b/src/dbStatic/dbExpand.c @@ -1,4 +1,4 @@ -/* dbExpandInclude.c */ +/* dbExpand.c */ /* Author: Marty Kraimer Date: 30NOV95 */ /***************************************************************** COPYRIGHT NOTIFICATION @@ -28,33 +28,38 @@ of this distribution. #include DBBASE *pdbbase = NULL; -#define MAX_PATH_LENGTH 256 -static void addPath(char *path,char *newdir) -{ - if((strlen(path)+strlen(newdir)+2) > (size_t)MAX_PATH_LENGTH) { - fprintf(stderr,"path > 256 characters\n"); - exit(-1); - } - if(strlen(path) > (size_t)0) strcat(path,":"); - strcat(path,newdir); -} - int main(int argc,char **argv) { - int strip; - char path[MAX_PATH_LENGTH]; - long status; int i; + int strip; + char *path = NULL; + char *sub = NULL; + int pathLength = 0; + int subLength = 0; + char **pstr; + char *psep; + int *len; + long status; + static char *pathSep = ":"; + static char *subSep = ","; - /*Look for path, i.e. -I dir or -Idir*/ - path[0] = 0; - while(strncmp(argv[1],"-I",2)==0) { + /*Look for options*/ + while((strncmp(argv[1],"-I",2)==0)||(strncmp(argv[1],"-S",2)==0)) { + if(strncmp(argv[1],"-I",2)==0) { + pstr = &path; + psep = pathSep; + len = &pathLength; + } else { + pstr = ⊂ + psep = subSep; + len = &subLength; + } if(strlen(argv[1])==2) { - addPath(path,argv[2]); + dbCatString(pstr,len,argv[2],psep); strip = 2; } else { - addPath(path,argv[1]+2); + dbCatString(pstr,len,argv[1]+2,psep); strip = 1; } argc -= strip; @@ -62,11 +67,13 @@ int main(int argc,char **argv) } if(argc<2 || (strncmp(argv[1],"-",1)==0)) { fprintf(stderr, - "usage: dbExpandInclude -Idir -Idir file1.dbd file2.dbd ...\n"); + "usage: dbExpand -Idir -Idir " + "-S substitutions -S substitutions" + " file1.dbd file2.dbd ...\n"); exit(0); } for(i=1; i