backout 118c07dc56f9 (bug 742179) for windows build bustage

This commit is contained in:
Daniel Holbert 2012-04-05 10:56:10 -07:00
parent b74a7df1cf
commit b1e2d31e5b
4 changed files with 54 additions and 32 deletions

View File

@ -41,7 +41,33 @@
#include "nsDirectoryServiceUtils.h"
#include "nsDirectoryServiceDefs.h"
#include "nsNetUtil.h"
#include "nsCRT.h"
// XXX this code is ripped from profile/src/nsProfile.cpp and is further
// duplicated in uriloader/exthandler. this should probably be moved
// into xpcom or some other shared library.
#include <stdlib.h>
#define TABLE_SIZE 36
static const char table[] =
{ 'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t',
'u','v','w','x','y','z','0','1','2','3',
'4','5','6','7','8','9' };
static void
MakeRandomString(char *buf, PRInt32 bufLen)
{
// turn PR_Now() into milliseconds since epoch
// and salt rand with that.
double fpTime;
LL_L2D(fpTime, PR_Now());
srand((uint)(fpTime * 1e-6 + 0.5)); // use 1e-6, granularity of PR_Now() on the mac is seconds
PRInt32 i;
for (i=0;i<bufLen;i++) {
*buf++ = table[rand()%TABLE_SIZE];
}
*buf = 0;
}
// XXX
nsDownloader::~nsDownloader()
{
@ -90,7 +116,7 @@ nsDownloader::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
if (NS_FAILED(rv)) return rv;
char buf[13];
NS_MakeRandomString(buf, 8);
MakeRandomString(buf, 8);
memcpy(buf+8, ".tmp", 5);
rv = mLocation->AppendNative(nsDependentCString(buf, 12));
if (NS_FAILED(rv)) return rv;

View File

@ -69,8 +69,33 @@
#include "nsITimer.h"
#include "nsThreadUtils.h"
// XXX Duped from profile/src/nsProfile.cpp.
#include <stdlib.h>
using namespace mozilla;
#define TABLE_SIZE 36
static const char table[] =
{ 'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t',
'u','v','w','x','y','z','0','1','2','3',
'4','5','6','7','8','9' };
static void
MakeRandomString(char *buf, PRInt32 bufLen)
{
// turn PR_Now() into milliseconds since epoch
// and salt rand with that.
double fpTime;
LL_L2D(fpTime, PR_Now());
srand((uint)(fpTime * 1e-6 + 0.5)); // use 1e-6, granularity of PR_Now() on the mac is seconds
PRInt32 i;
for (i=0;i<bufLen;i++) {
*buf++ = table[rand()%TABLE_SIZE];
}
*buf = 0;
}
NS_IMPL_ISUPPORTS1(nsDataObj::CStream, nsIStreamListener)
//-----------------------------------------------------------------------------
@ -1442,7 +1467,7 @@ HRESULT nsDataObj::DropImage(FORMATETC& aFE, STGMEDIUM& aSTG)
// Photoshop which handle multiple drags into a single window.
char buf[13];
nsCString filename;
NS_MakeRandomString(buf, 8);
MakeRandomString(buf, 8);
memcpy(buf+8, ".bmp", 5);
filename.Append(nsDependentCString(buf, 12));
dropFile->AppendNative(filename);

View File

@ -41,9 +41,6 @@
#include "nsCRTGlue.h"
#include "nsXPCOM.h"
#include "nsDebug.h"
#include "prtime.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
@ -273,30 +270,6 @@ bool NS_IsAsciiDigit(PRUnichar aChar)
return aChar >= '0' && aChar <= '9';
}
#define TABLE_SIZE 36
static const char table[] = {
'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t',
'u','v','w','x','y','z','0','1','2','3',
'4','5','6','7','8','9'
};
void NS_MakeRandomString(char *aBuf, PRInt32 aBufLen)
{
// turn PR_Now() into milliseconds since epoch
// and salt rand with that.
double fpTime;
LL_L2D(fpTime, PR_Now());
srand((uint)(fpTime * 1e-6 + 0.5)); // use 1e-6, granularity of PR_Now() on the mac is seconds
PRInt32 i;
for (i=0;i<aBufLen;i++) {
*aBuf++ = table[rand()%TABLE_SIZE];
}
*aBuf = 0;
}
#if defined(XP_WIN)
void
printf_stderr(const char *fmt, ...)

View File

@ -133,8 +133,6 @@ NS_COM_GLUE bool NS_IsAsciiWhitespace(PRUnichar aChar);
NS_COM_GLUE bool NS_IsAscii(const char* aString);
NS_COM_GLUE bool NS_IsAscii(const char* aString, PRUint32 aLength);
NS_COM_GLUE void NS_MakeRandomString(char *buf, PRInt32 bufLen);
#define FF '\f'
#define TAB '\t'