From 0a518ff5d357a1283f4186e355f21c113bcc0058 Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Mon, 1 Mar 1999 19:24:27 +0000 Subject: [PATCH] some hacks (and ifdefs) for macOS until NSPR gets fixed. This at least allows us to test out libReg and find bugs. git-svn-id: svn://10.0.0.236/trunk@22461 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libreg/src/reg.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/mozilla/modules/libreg/src/reg.c b/mozilla/modules/libreg/src/reg.c index 371bd379b9a..d7cf8bfb78f 100644 --- a/mozilla/modules/libreg/src/reg.c +++ b/mozilla/modules/libreg/src/reg.c @@ -249,6 +249,7 @@ fail: static void nr_AddNode(REGFILE* pReg); static void nr_DeleteNode(REGFILE *pReg); static REGFILE* vr_findRegFile(char *filename); + /* -------------------------------------------------------------------- */ static void nr_AddNode(REGFILE* pReg) @@ -712,8 +713,22 @@ static REGERR nr_ReadHdr(REGFILE *reg) static REGERR nr_WriteHdr(REGFILE *reg) { +#ifdef XP_MAC + #define HACK_WRITE_ENTIRE_RESERVE 1 +#endif + REGERR err; +#if HACK_WRITE_ENTIRE_RESERVE + /* + * pinkerton + * Until NSPR can be fixed to seek out past the EOF on MacOS, we need to make + * sure that we write all 128 bytes to push out the EOF to the right location + */ + char hdrBuf[HDRRESERVE]; + memset(hdrBuf, NULL, HDRRESERVE); +#else char hdrBuf[sizeof(REGHDR)]; +#endif XP_ASSERT(reg); @@ -728,7 +743,7 @@ static REGERR nr_WriteHdr(REGFILE *reg) nr_WriteLong ( reg->hdr.root, hdrBuf + HDR_ROOT ); /* err = nr_WriteFile(reg->fh, 0, sizeof(REGHDR), ®->hdr); */ - err = nr_WriteFile(reg->fh, 0, sizeof(REGHDR), &hdrBuf); + err = nr_WriteFile(reg->fh, 0, sizeof(hdrBuf), &hdrBuf); if (err == REGERR_OK) reg->hdrDirty = 0; @@ -764,6 +779,21 @@ static REGERR nr_CreateRoot(REGFILE *reg) root.valuebuf = 0; root.parent = 0; +#ifdef XP_MAC + #define HACK_UNTIL_NSPR_DOES_SEEK_CORRECTLY 1 +#endif +#if HACK_UNTIL_NSPR_DOES_SEEK_CORRECTLY + /* + * pinkerton + * The AppendName() and AppendDesc() code that follows assumes that it can just + * seek out past the end of the file and write a name and descriptor. However, + * mac doesn't allow that. NSPR needs to be "fixed" somehow, but in the meantime, + * we can just write out the header first, extending the EOF to 128 bytes where + * the name and desc can follow w/out silently failing. + */ + nr_WriteHdr(reg); +#endif + err = nr_AppendName(reg, ROOTKEY_STR, &root); if (err != REGERR_OK) return err;