* - Added conditional stuff (#define and #include) for IBM's compiler.
*/
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <fcntl.h>
# include "splintMacros.nf"
# include "llbasic.h"
# include "osd.h"
# include "llmain.h"
# include "portab.h"
+
# if defined(__IBMC__) && defined(OS2)
# include <process.h>
+# include <io.h>
# define getpid _getpid
+# define S_IRUSR S_IREAD
+# define S_IWUSR S_IWRITE
+# define S_IXUSR S_IEXEC
# endif
/*@access fileId*/
cstring abspath;
if (ft == NULL) return NOT_FOUND;
abspath = osd_absolutePath (cstring_undefined, s);
+
+ if (context_getFlag (FLG_CASEINSENSITIVEFILENAMES))
+ {
+ abspath = cstring_downcase (abspath);
+ }
+
DPRINTF (("Absolute path: %s: %s", s, abspath));
res = cstringTable_lookup (ft->htable, abspath);
cstring_free (abspath);
ft->nspace--;
DPRINTF (("Adding: %s", e->fname));
- cstringTable_insert (ft->htable, e->fname, ft->nentries);
+
+ if (context_getFlag (FLG_CASEINSENSITIVEFILENAMES))
+ {
+ cstring sd = cstring_downcase (e->fname);
+ cstringTable_insert (ft->htable, sd, ft->nentries);
+ cstring_free (e->fname);
+ }
+ else
+ {
+ cstringTable_insert (ft->htable, e->fname, ft->nentries);
+ }
+
ft->elements[ft->nentries] = e;
ft->nentries++;
cstring absname = osd_absolutePath (NULL, name);
int tindex = fileTable_getIndex (ft, absname);
- DPRINTF (("Got abs path: %s", absname));
+ /*@i534 fprintf (stderr, "Got abs path: %s", absname); */
llassert (ft != fileTable_undefined);
if (tindex != NOT_FOUND)
fileId
fileTable_lookupBase (fileTable ft, cstring base)
{
- int tindex = fileTable_getIndex (ft, base);
+ int tindex;
+
+ if (context_getFlag (FLG_CASEINSENSITIVEFILENAMES))
+ {
+ cstring dbase = cstring_downcase (base);
+ tindex = fileTable_getIndex (ft, dbase);
+ cstring_free (dbase);
+ }
+ else
+ {
+ tindex = fileTable_getIndex (ft, base);
+ }
if (tindex == NOT_FOUND)
{
if (msg)
{
(void) fflush (g_warningstream);
- fprintf (stderr, "< cleaning");
+ displayScanOpen (cstring_makeLiteral ("cleaning"));
}
for (i = 0; i < ft->nentries; i++)
if (msg && ((i % skip) == 0))
{
- (void) fflush (g_warningstream);
-
- if (i == 0) {
- fprintf (stderr, " ");
- } else {
- fprintf (stderr, ".");
- }
-
- (void) fflush (stderr);
+ displayScanContinue (cstring_makeLiteral (i == 0 ? " " : "."));
}
}
-
+
if (msg)
{
- fprintf (stderr, " >\n");
+ displayScanClose ();
}
}
smsg = message ("%s%s%s%s%s", dir, pre, pidname, cstring_fromChars (msg), suf);
nextMsg (msg);
}
-
return smsg;
}
ft->nopen++;
}
-FILE *fileTable_openFile (fileTable ft, cstring fname, char *mode)
+FILE *fileTable_createFile (fileTable ft, cstring fname)
{
- FILE *res = fopen (cstring_toCharsSafe (fname), mode);
+ int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR);
+
+ if (fdesc == -1)
+ {
+ osd_setTempError ();
+ llfatalerror (message ("Temporary file for "
+ "pre-processor output already exists. Trying to "
+ "open: %s.",
+ fname));
+
+ /*@notreached@*/ return NULL;
+ }
+ else
+ {
+ FILE *res = fdopen (fdesc, "w");
+
+ if (res != NULL)
+ {
+ fileTable_addOpen (ft, res, cstring_copy (fname));
+ DPRINTF (("Opening file: %s / %p", fname, res));
+ }
+ else
+ {
+ DPRINTF (("Error opening: %s", fname));
+ }
+
+ return res;
+ }
+}
+
+FILE *fileTable_createMacrosFile (fileTable ft, cstring fname)
+{
+ int fdesc = open (cstring_toCharsSafe (fname), O_RDWR | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR);
+
+ if (fdesc == -1)
+ {
+ osd_setTempError ();
+ llfatalerror (message ("Temporary file for "
+ "pre-processor output already exists. Trying to "
+ "open: %s.",
+ fname));
+
+ /*@notreached@*/ return NULL;
+ }
+ else
+ {
+ FILE *res = fdopen (fdesc, "w+");
+
+ if (res != NULL)
+ {
+ fileTable_addOpen (ft, res, cstring_copy (fname));
+ DPRINTF (("Opening file: %s / %p", fname, res));
+ }
+ else
+ {
+ DPRINTF (("Error opening: %s", fname));
+ }
+
+ return res;
+ }
+}
+
+FILE *fileTable_openReadFile (fileTable ft, cstring fname)
+{
+ FILE *res = fopen (cstring_toCharsSafe (fname), "r");
+
+ if (res != NULL)
+ {
+ fileTable_addOpen (ft, res, cstring_copy (fname));
+ DPRINTF (("Opening read file: %s / %p", fname, res));
+ }
+ else
+ {
+ DPRINTF (("Cannot open read file: %s", fname));
+ }
+
+ return res;
+}
+
+/*
+** Allows overwriting
+*/
+
+FILE *fileTable_openWriteFile (fileTable ft, cstring fname)
+{
+ FILE *res = fopen (cstring_toCharsSafe (fname), "w");
+
+ if (res != NULL) {
+ fileTable_addOpen (ft, res, cstring_copy (fname));
+ DPRINTF (("Opening file: %s / %p", fname, res));
+ }
+
+ return res;
+}
+
+FILE *fileTable_openWriteUpdateFile (fileTable ft, cstring fname)
+{
+ FILE *res = fopen (cstring_toCharsSafe (fname), "w+");
if (res != NULL) {
fileTable_addOpen (ft, res, cstring_copy (fname));
if (ft->openelements[i]->f == f)
{
DPRINTF (("Closing file: %p = %s", f, ft->openelements[i]->fname));
-
+
if (i == ft->nopen - 1)
{
foentry_free (ft->openelements[i]);