+ /* some sanity checks in c1 mode */
+ if (options.c1mode)
+ {
+ const char *s;
+
+ if (fullSrcFileName)
+ {
+ fclose (srcFile);
+ werror (W_NO_FILE_ARG_IN_C1, fullSrcFileName);
+ }
+ fullSrcFileName = NULL;
+ for (s = setFirstItem(relFilesSet); s != NULL; s = setNextItem(relFilesSet))
+ {
+ werror (W_NO_FILE_ARG_IN_C1, s);
+ }
+ for (s = setFirstItem(libFilesSet); s != NULL; s = setNextItem(libFilesSet))
+ {
+ werror (W_NO_FILE_ARG_IN_C1, s);
+ }
+ deleteSet(&relFilesSet);
+ deleteSet(&libFilesSet);
+
+ if (options.cc_only || noAssemble || preProcOnly)
+ {
+ werror (W_ILLEGAL_OPT_COMBINATION);
+ }
+ options.cc_only = noAssemble = preProcOnly = 0;
+ if (!dstFileName)
+ {
+ werror (E_NEED_OPT_O_IN_C1);
+ exit (1);
+ }
+ }
+ /* if no dstFileName given with -o, we've to find one: */
+ if (!dstFileName)
+ {
+ const char *s;
+
+ /* use the modulename from the C-source */
+ if (fullSrcFileName)
+ {
+ size_t bufSize = strlen (dstPath) + strlen (moduleName) + 1;
+
+ dstFileName = Safe_alloc (bufSize);
+ strncpyz (dstFileName, dstPath, bufSize);
+ strncatz (dstFileName, moduleName, bufSize);
+ }
+ /* use the modulename from the first object file */
+ else if ((s = peekSet(relFilesSet)) != NULL)
+ {
+ char *objectName;
+ size_t bufSize;
+
+ strncpyz (buffer, s, sizeof(buffer));
+ /* remove extension (it must be .rel) */
+ *strrchr (buffer, '.') = '\0';
+ /* remove path */
+ objectName = strrchr (buffer, DIR_SEPARATOR_CHAR);
+ if (objectName)
+ {
+ ++objectName;
+ }
+ else
+ {
+ objectName = buffer;
+ }
+ bufSize = strlen (dstPath) + strlen (objectName) + 1;
+ dstFileName = Safe_alloc (bufSize);
+ strncpyz (dstFileName, dstPath, bufSize);
+ strncatz (dstFileName, objectName, bufSize);
+ }
+ /* else no module given: help text is displayed */
+ }
+