along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+#define _POSIX_
+#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#define _POSIX_
-#include <limits.h>
#if !defined(__BORLANDC__) && !defined(_MSC_VER)
#include <unistd.h>
#endif
long newlibpos, indexsize;
char symname[MAXLINE+1];
char c;
+ int IsDOSStyle=0;
strcpy(LibNameTmp, LibName);
ChangeExtension(LibNameTmp, "__L");
lib=fopen(LibName, "w");
libindex=fopen(IndexName, "r");
- fprintf(lib, "<SDCCLIB>\n\n");
- fprintf(lib, "<INDEX>\n");
+ fprintf(lib, "<SDCCLIB>\n\n<INDEX>\n");
+
+ /*Find out if the \n is expanded to \r\n or not*/
+ if(ftell(lib)!=(long)strlen("<SDCCLIB>\n\n<INDEX>\n"))
+ {
+ IsDOSStyle=1;
+ }
+
+ indexsize+=ftell(lib)+strlen("0123456789\n\n</INDEX>\n\n");
+ if(IsDOSStyle) indexsize+=4;
- indexsize+=ftell(lib)+12+14;
fprintf(lib, "%10ld\n", indexsize);
while(!feof(libindex))
fclose(lib);
fclose(libindex);
- unlink(LibNameTmp);
- unlink(IndexName);
+ remove(LibNameTmp);
+ remove(IndexName);
}
void ExtractRel(void)