From c69ab79e7615743dd1261b0627bcc831ae8ea339 Mon Sep 17 00:00:00 2001 From: cuz Date: Sat, 15 Jul 2000 08:43:55 +0000 Subject: [PATCH] Update from Maciek git-svn-id: svn://svn.cc65.org/cc65/trunk@147 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/grc/grc.c | 31 ++++++++++++++++++++++--------- src/grc/grc.h | 3 +++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/grc/grc.c b/src/grc/grc.c index 9564d93c4..d592c45c9 100644 --- a/src/grc/grc.c +++ b/src/grc/grc.c @@ -15,7 +15,6 @@ - more or less comments? it was hard to code, should be even harder to understand =D - add loadable icons feature (binary - 63 bytes) - - counted menusize is most possibly wrong (const offsets, not sure about text) */ /* - err, maybe free allocated memory, huh? (who cares, it's just a little prog...) @@ -61,21 +60,32 @@ void printSHeader (void) { } void openCFile (void) { - if ((outputCFile = fopen (outputCName,"a"))==0) + if ((CFnum==0) && (forceFlag==0)) { + /* test if file exists already and no forcing*/ + if ((outputCFile = fopen (outputCName,"r"))!=0) + Error("file %s already exists, no forcing, aborting\n", outputCName); + } + if ((outputCFile = fopen (outputCName,outputCMode))==0) Error("can't open file %s for writting: %s\n",outputCName,strerror (errno)); - if (CFnum==0) { printCHeader(); CFnum++; } + if (CFnum==0) { outputCMode[0]='a'; printCHeader(); CFnum++; } } void openSFile (void) { - if ((outputSFile = fopen (outputSName,"a"))==0) + if ((SFnum==0) && (forceFlag==0)) { + /* test if file exists already and no forcing*/ + if ((outputSFile = fopen (outputSName,"r"))!=0) + Error("file %s already exists, no forcing, aborting\n", outputSName); + } + if ((outputSFile = fopen (outputSName,outputSMode))==0) Error("can't open file %s for writting: %s\n",outputSName,strerror (errno)); - if (SFnum==0) { printSHeader(); SFnum++; } + if (SFnum==0) { outputSMode[0]='a'; printSHeader(); SFnum++; } } void printUsage (void) { fprintf(stderr, "Usage: %s [options] file\n" "Options:\n" "\t-h, -?\t\tthis help\n" + "\t-f\t\tforce writting files\n" "\t-o name\t\tname C output file\n" "\t-s name\t\tname asm output file\n", progName); @@ -197,14 +207,14 @@ struct menuitem *curItem, *newItem; }; } else { /* menu is VERTICAL, ysize=item*15, count largest xsize of all items +~8? */ - myMenu.bot=myMenu.top+(15*item); + myMenu.bot=myMenu.top+(14*item)-1; for (a=0;a!=item;a++) { tmpsize=getNameSize(curItem->name); size = (size > tmpsize) ? size : tmpsize; curItem=curItem->next; }; }; - myMenu.right=myMenu.left+size; + myMenu.right=myMenu.left+size-1; curItem=myMenu.item; for (a=0;a!=item;a++) { @@ -449,6 +459,9 @@ char *p, *tmp; const char *arg = argv[i]; if (arg[0] == '-') { switch (arg[1]) { + case 'f': + forceFlag=1; + break; case 'o': outputCName=argv[++i]; break; @@ -474,14 +487,14 @@ char *p, *tmp; if (outputCName==NULL) { outputCName = malloc(strlen(arg)); strcpy (outputCName, tmp); - strcat (outputCName, ".hh"); + strcat (outputCName, ".h"); } if (outputSName==NULL) { outputSName = malloc(strlen(arg)); strcpy (outputSName, tmp); - strcat (outputSName, ".ss"); + strcat (outputSName, ".s"); } diff --git a/src/grc/grc.h b/src/grc/grc.h index 25f2579ed..2ee05a8a1 100644 --- a/src/grc/grc.h +++ b/src/grc/grc.h @@ -65,3 +65,6 @@ char *progName; char *outputCName=NULL, *outputSName=NULL; FILE *outputCFile, *outputSFile; int CFnum=0, SFnum=0; +int forceFlag=0; +char outputCMode[2]="w"; +char outputSMode[2]="w"; -- 2.39.5