Enlightenment CVS committal
Author : tsauerbeck
Project : e17
Module : libs/embryo
Dir : e17/libs/embryo/src/bin
Modified Files:
embryo_cc_sc.h embryo_cc_sc1.c embryo_cc_sc5.c
embryo_cc_scvars.c
Log Message:
command line arguments are now handled in a sane way: '-i blah' instead of '-iblah'
etc. removed error filename crap, we prefer to redirect stderr.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/embryo/src/bin/embryo_cc_sc.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- embryo_cc_sc.h 9 Sep 2004 00:48:12 -0000 1.5
+++ embryo_cc_sc.h 12 Oct 2004 16:57:37 -0000 1.6
@@ -9,7 +9,7 @@
* Copyright J.E. Hendrix, 1982, 1983
* Copyright T. Riemersma, 1997-2003
*
- * Version: $Id: embryo_cc_sc.h,v 1.5 2004/09/09 00:48:12 raster Exp $
+ * Version: $Id: embryo_cc_sc.h,v 1.6 2004/10/12 16:57:37 tsauerbeck Exp $
*
* This software is provided "as-is", without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
@@ -630,7 +630,6 @@
extern symbol *curfunc; /* pointer to current function */
extern char *inpfname; /* name of the file currently read from */
extern char outfname[]; /* output file name */
-extern char errfname[]; /* error file name */
extern char sc_ctrlchar; /* the control character (or escape character) */
extern int litidx; /* index to literal table */
extern int litmax; /* current size of the literal table */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/embryo/src/bin/embryo_cc_sc1.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- embryo_cc_sc1.c 28 Sep 2004 03:06:21 -0000 1.16
+++ embryo_cc_sc1.c 12 Oct 2004 16:57:37 -0000 1.17
@@ -1,5 +1,7 @@
-/* Small compiler
+/*
+ * vim:ts=8:sw=3:sts=3:noexpandtab
*
+ * Small compiler
* Function and variable definition and declaration, statement parser.
*
* Copyright (c) ITB CompuPhase, 1997-2003
@@ -19,7 +21,7 @@
* must not be misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source
* distribution.
- * Version: $Id: embryo_cc_sc1.c,v 1.16 2004/09/28 03:06:21 raster Exp $
+ * Version: $Id: embryo_cc_sc1.c,v 1.17 2004/10/12 16:57:37 tsauerbeck Exp $
*/
#include <assert.h>
#include <ctype.h>
@@ -38,8 +40,8 @@
static void resetglobals(void);
static void initglobals(void);
static void setopt(int argc, char **argv,
- char *iname, char *oname,
- char *ename, char *pname, char *rname);
+ char *iname, char *oname,
+ char *pname, char *rname);
static void setconfig(char *root);
static void setcaption(void);
static void about(void);
@@ -312,7 +314,7 @@
if (!phopt_init())
error(103); /* insufficient memory */
- setopt(argc, argv, inpfname, outfname, errfname, incfname, reportname);
+ setopt(argc, argv, inpfname, outfname, incfname, reportname);
/* set output names that depend on the input name */
if (sc_listing)
set_extension(outfname, ".lst", TRUE);
@@ -320,10 +322,6 @@
set_extension(outfname, ".asm", TRUE);
strcpy(binfname, outfname);
set_extension(binfname, ".amx", TRUE);
- if (strlen(errfname) != 0)
- unlink(errfname); /* delete file on startup */
- else
- setcaption();
setconfig(argv[0]); /* the path to the include files */
lcl_ctrlchar = sc_ctrlchar;
lcl_packstr = sc_packstr;
@@ -473,14 +471,12 @@
#endif
if (errnum != 0)
{
- if (strlen(errfname) == 0)
- sc_printf("\n%d Error%s.\n", errnum, (errnum > 1) ? "s" : "");
+ sc_printf("\n%d Error%s.\n", errnum, (errnum > 1) ? "s" : "");
retcode = 2;
}
else if (warnnum != 0)
{
- if (strlen(errfname) == 0)
- sc_printf("\n%d Warning%s.\n", warnnum, (warnnum > 1) ? "s" : "");
+ sc_printf("\n%d Warning%s.\n", warnnum, (warnnum > 1) ? "s" : "");
retcode = 1;
}
else
@@ -595,7 +591,6 @@
rational_digits = 0; /* number of fractional digits */
outfname[0] = '\0'; /* output file name */
- errfname[0] = '\0'; /* error file name */
inpf = NULL; /* file read from */
inpfname = NULL; /* pointer to name of the file currently
* read from */
@@ -652,193 +647,78 @@
static void
parseoptions(int argc, char **argv, char *iname, char *oname,
- char *ename, char *pname, char *rname)
+ char *pname, char *rname)
{
- char str[_MAX_PATH], *ptr;
- int arg, i, isoption;
+ char str[PATH_MAX];
+ int i, stack_size;
+ size_t len;
- /**/
- /* use embryo include dir always */
- insert_path(PACKAGE_DATA_DIR "/include/");
+ /* use embryo include dir always */
+ insert_path(PACKAGE_DATA_DIR "/include/");
insert_path(PACKAGE_DATA_DIR "./");
- /**/ for (arg = 1; arg < argc; arg++)
- {
- isoption = argv[arg][0] == '-';
- if (isoption)
- {
- ptr = &argv[arg][1];
- switch (*ptr)
- {
-#if 0
- case 'A':
- i = atoi(ptr + 1);
- if ((i % sizeof(cell)) == 0)
- sc_dataalign = i;
- else
- about();
- break;
- case 'a':
- if (*(ptr + 1) != '\0')
- about();
- sc_asmfile = TRUE; /* skip last pass of making binary file */
- break;
- case 'C':
- sc_compress = toggle_option(ptr, sc_compress);
- break;
- case 'c':
- i = atoi(ptr + 1);
- if (i == 8 || i == 16)
- charbits = i; /* character size is 8 or 16 bits */
- else
- about();
- break;
-#if defined dos_setdrive
- case 'D': /* set active directory */
- ptr++;
- if (ptr[1] == ':')
- dos_setdrive(toupper(*ptr) - 'A' + 1); /* set active drive */
- chdir(ptr);
- break;
-#endif
- case 'd':
- switch (ptr[1])
- {
- case '0':
- sc_debug = 0;
- break;
- case '1':
- sc_debug = sCHKBOUNDS; /* assertions and bounds checking */
- break;
- case '2':
- sc_debug = sCHKBOUNDS | sSYMBOLIC; /* also symbolic info
*/
- break;
- case '3':
- sc_debug = sCHKBOUNDS | sSYMBOLIC | sNOOPTIMIZE;
- /* also avoid peephole optimization */
- break;
- default:
- about();
- } /* switch */
- break;
-#endif
- case 'e':
- strcpy(ename, ptr + 1); /* set name of error file */
- break;
- case 'i':
- strcpy(str, ptr + 1); /*set name of include directory */
- i = strlen(str);
- if (i > 0)
- {
- if (str[i - 1] != DIRSEP_CHAR)
- {
- str[i] = DIRSEP_CHAR;
- str[i + 1] = '\0';
- } /* if */
- insert_path(str);
- } /* if */
- break;
-#if 0
- case 'l':
- if (*(ptr + 1) != '\0')
- about();
- sc_listing = TRUE; /* skip second pass & code generation */
- break;
-#endif
- case 'o':
- strcpy(oname, ptr + 1); /* set name of (binary) output file */
- break;
-#if 0
- case 'P':
- sc_packstr = toggle_option(ptr, sc_packstr);
- break;
- case 'p':
- strcpy(pname, ptr + 1); /* set name of implicit include file */
- break;
-#endif
- case 'S':
- i = atoi(ptr + 1);
- if (i > 64)
- sc_stksize = (cell) i; /* stack size has minimum size */
- else
- about();
- break;
-#if 0
- case 's':
- skipinput = atoi(ptr + 1);
- break;
- case 't':
- sc_tabsize = atoi(ptr + 1);
- break;
- case '\\': /* use \ instead for escape characters */
- sc_ctrlchar = '\\';
- break;
- case '^': /* use ^ instead for escape characters */
- sc_ctrlchar = '^';
- break;
- case ';':
- sc_needsemicolon = toggle_option(ptr, sc_needsemicolon);
- break;
-#endif
- default: /* wrong option */
- about();
- } /* switch */
- }
- else if (argv[arg][0] == '@')
- {
- }
- else if ((ptr = strchr(argv[arg], '=')) != NULL)
- {
- i = (int)(ptr - argv[arg]);
- if (i > sNAMEMAX)
- {
- i = sNAMEMAX;
- error(200, argv[arg], sNAMEMAX); /* symbol too long,
- *truncated to sNAMEMAX chars*/
- } /* if */
- strncpy(str, argv[arg], i);
- str[i] = '\0'; /* str holds symbol name */
- i = atoi(ptr + 1);
- add_constant(str, i, sGLOBAL, 0);
- }
- else if (strlen(iname) > 0)
- {
- about();
- }
- else
- {
- strcpy(iname, argv[arg]);
- set_extension(iname, ".sma", FALSE);
- /* The output name is the input name with a different extension,
- * but it is stored in a different directory
- */
-#if 0
- if (strlen(oname) == 0)
- {
- if ((ptr = strrchr(iname, DIRSEP_CHAR)) != NULL)
- ptr++; /* strip path */
- else
- ptr = iname;
- strcpy(oname, ptr);
- } /* if */
- set_extension(oname, ".asm", TRUE);
-#endif
- } /* if */
- } /* for */
+ for (i = 1; i < argc; i++)
+ {
+ if (!strcmp (argv[i], "-i") && *argv[i + 1])
+ {
+ /* include directory */
+ i++;
+ snprintf(str, sizeof(str), "%s", argv[i]);
+
+ len = strlen(str);
+ if (len > 0)
+ {
+ if (str[len - 1] != DIRSEP_CHAR)
+ {
+ str[len] = DIRSEP_CHAR;
+ str[len + 1] = '\0';
+ }
+
+ insert_path(str);
+ }
+ }
+ else if (!strcmp (argv[i], "-o") && *argv[i + 1])
+ {
+ /* output file */
+ i++;
+ strcpy(oname, argv[i]); /* FIXME */
+ }
+ else if (!strcmp (argv[i], "-S") && *argv[i + 1])
+ {
+ /* stack size */
+ i++;
+ stack_size = atoi(argv[i]);
+
+ if (stack_size > 64)
+ sc_stksize = (cell) stack_size;
+ else
+ about();
+ }
+ else if (!*iname)
+ {
+ /* input file */
+ strcpy(iname, argv[i]); /* FIXME */
+ set_extension(iname, ".sma", FALSE);
+ }
+ else
+ {
+ /* only allow one input filename */
+ about ();
+ }
+ }
}
static void
setopt(int argc, char **argv, char *iname, char *oname,
- char *ename, char *pname, char *rname)
+ char *pname, char *rname)
{
*iname = '\0';
*oname = '\0';
- *ename = '\0';
*pname = '\0';
*rname = '\0';
strcpy(pname, sDEF_PREFIX);
- parseoptions(argc, argv, iname, oname, ename, pname, rname);
+ parseoptions(argc, argv, iname, oname, pname, rname);
if (strlen(iname) == 0)
about();
}
@@ -884,11 +764,9 @@
static void
about(void)
{
- if (strlen(errfname) == 0)
- {
- setcaption();
- sc_printf("Usage: embryo_cc <filename> [options]\n\n");
- sc_printf("Options:\n");
+ setcaption();
+ sc_printf("Usage: embryo_cc <filename> [options]\n\n");
+ sc_printf("Options:\n");
#if 0
sc_printf
(" -A<num> alignment in bytes of the data segment and the\
@@ -916,13 +794,12 @@
(" -d2 full debug information and dynamic checking\n");
sc_printf(" -d3 full debug information, dynamic checking,\
no optimization\n");
- sc_printf(" -e<name> set name of error file (quiet compile)\n");
#endif
- sc_printf(" -i<name> path for include files\n");
+ sc_printf(" -i <name> path for include files\n");
#if 0
sc_printf(" -l create list file (preprocess only)\n");
#endif
- sc_printf(" -o<name> set base name of output file\n");
+ sc_printf(" -o <name> set base name of output file\n");
#if 0
sc_printf
(" -P[+/-] strings are \"packed\" by default (default=%c)\n",
@@ -932,7 +809,7 @@
longjmp(errbuf, 3);
#endif
sc_printf
- (" -S<num> stack/heap size in cells (default=%d)\n",
+ (" -S <num> stack/heap size in cells (default=%d, min=65)\n",
(int)sc_stksize);
#if 0
sc_printf(" -s<num> skip lines from the input file\n");
@@ -947,8 +824,7 @@
(" sym=val define constant \"sym\" with value \"val\"\n");
sc_printf(" sym= define constant \"sym\" with value 0\n");
#endif
- } /* if */
- longjmp(errbuf, 3); /* user abort */
+ longjmp(errbuf, 3); /* user abort */
}
static void
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/embryo/src/bin/embryo_cc_sc5.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- embryo_cc_sc5.c 27 Apr 2004 08:05:12 -0000 1.3
+++ embryo_cc_sc5.c 12 Oct 2004 16:57:38 -0000 1.4
@@ -1,4 +1,7 @@
-/* Small compiler - Error message system
+/*
+ * vim:ts=8:sw=3:sts=3:noexpandtab
+ *
+ * Small compiler - Error message system
* In fact a very simple system, using only 'panic mode'.
*
* Copyright (c) ITB CompuPhase, 1997-2003
@@ -19,7 +22,7 @@
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
- * Version: $Id: embryo_cc_sc5.c,v 1.3 2004/04/27 08:05:12 raster Exp $
+ * Version: $Id: embryo_cc_sc5.c,v 1.4 2004/10/12 16:57:38 tsauerbeck Exp $
*/
#include <unistd.h>
#include <stdio.h>
@@ -52,6 +55,7 @@
char *msg, *pre;
va_list argptr;
char string[1024];
+ int start;
/* errflag is reset on each semicolon.
* In a two-pass compiler, an error should not be reported twice. Therefore
@@ -85,42 +89,24 @@
strexpand(string, (unsigned char *)msg, sizeof string, SCPACK_TABLE);
va_start(argptr, number);
- if (strlen(errfname) == 0)
- {
- int start = (errstart == fline) ? -1 : errstart;
- if (sc_error(number, string, inpfname, start, fline, argptr))
- {
- sc_closeasm(outf, TRUE);
- outf = NULL;
- longjmp(errbuf, 3);
- }
- }
- else
- {
- FILE *fp;
-
- fp = fopen(errfname, "a+");
- if (fp != NULL)
- {
- if (errstart >= 0 && errstart != fline)
- fprintf(fp, "%s(%d -- %d) : %s %03d: ", inpfname, errstart, fline,
pre, number);
- else
- fprintf(fp, "%s(%d) : %s %03d: ", inpfname, fline, pre, number);
- vfprintf(fp, string, argptr);
- fclose(fp);
- }
- }
+ start = (errstart == fline) ? -1 : errstart;
+
+ if (sc_error(number, string, inpfname, start, fline, argptr))
+ {
+ sc_closeasm(outf, TRUE);
+ outf = NULL;
+ longjmp(errbuf, 3);
+ }
+
va_end(argptr);
if (((number >= 100) && (number < 200)) || (errnum > 250))
{
- if (strlen(errfname) == 0)
- {
- va_start(argptr, number);
- sc_error(0, "\nCompilation aborted.", NULL, 0, 0, argptr);
- va_end(argptr);
- } /* if */
+ va_start(argptr, number);
+ sc_error(0, "\nCompilation aborted.", NULL, 0, 0, argptr);
+ va_end(argptr);
+
if (outf != NULL)
{
sc_closeasm(outf, TRUE);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/embryo/src/bin/embryo_cc_scvars.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- embryo_cc_scvars.c 28 Sep 2004 03:06:21 -0000 1.3
+++ embryo_cc_scvars.c 12 Oct 2004 16:57:38 -0000 1.4
@@ -20,7 +20,7 @@
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
- * Version: $Id: embryo_cc_scvars.c,v 1.3 2004/09/28 03:06:21 raster Exp $
+ * Version: $Id: embryo_cc_scvars.c,v 1.4 2004/10/12 16:57:38 tsauerbeck Exp $
*/
#include <stdio.h>
#include <stdlib.h> /* for _MAX_PATH */
@@ -42,7 +42,6 @@
symbol *curfunc; /* pointer to current function */
char *inpfname; /* pointer to name of the file currently read from */
char outfname[_MAX_PATH]; /* output file name */
-char errfname[_MAX_PATH]; /* error file name */
char sc_ctrlchar = CTRL_CHAR; /* the control character (or escape character)
*/
int litidx = 0; /* index to literal table */
int litmax = sDEF_LITMAX; /* current size of the literal table */
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs