2009-06-10 18:29:44 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
* March 31, 1998.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef jsstr_h___
|
|
|
|
#define jsstr_h___
|
2011-03-14 13:59:53 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include <ctype.h>
|
2010-07-14 23:19:36 -07:00
|
|
|
#include "jsapi.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "jsprvtd.h"
|
2010-03-16 11:28:33 -07:00
|
|
|
#include "jshashtable.h"
|
2009-06-10 18:29:44 -07:00
|
|
|
#include "jslock.h"
|
2010-04-14 18:57:30 -07:00
|
|
|
#include "jsobj.h"
|
2010-07-14 23:19:36 -07:00
|
|
|
#include "jsvalue.h"
|
2010-09-24 10:54:39 -07:00
|
|
|
#include "jscell.h"
|
2010-03-22 22:39:29 -07:00
|
|
|
|
2011-07-26 14:10:33 -07:00
|
|
|
#include "vm/Unicode.h"
|
|
|
|
|
2010-11-30 18:41:32 -08:00
|
|
|
namespace js {
|
2010-07-24 20:26:34 -07:00
|
|
|
|
2011-03-14 13:59:53 -07:00
|
|
|
/* Implemented in jsstrinlines.h */
|
2011-01-12 15:28:58 -08:00
|
|
|
class StringBuffer;
|
|
|
|
|
2010-07-16 17:41:22 -07:00
|
|
|
/*
|
2010-11-30 18:41:32 -08:00
|
|
|
* When an algorithm does not need a string represented as a single linear
|
|
|
|
* array of characters, this range utility may be used to traverse the string a
|
|
|
|
* sequence of linear arrays of characters. This avoids flattening ropes.
|
2010-07-16 17:41:22 -07:00
|
|
|
*
|
2010-11-30 18:41:32 -08:00
|
|
|
* Implemented in jsstrinlines.h.
|
2010-07-16 17:41:22 -07:00
|
|
|
*/
|
2010-11-30 18:41:32 -08:00
|
|
|
class StringSegmentRange;
|
2010-12-06 10:26:58 -08:00
|
|
|
class MutatingRopeSegmentRange;
|
2010-07-16 17:41:22 -07:00
|
|
|
|
2010-07-22 17:54:39 -07:00
|
|
|
/*
|
2010-11-30 18:41:32 -08:00
|
|
|
* Utility for building a rope (lazy concatenation) of strings.
|
2010-07-22 17:54:39 -07:00
|
|
|
*/
|
2010-11-30 18:41:32 -08:00
|
|
|
class RopeBuilder;
|
2010-07-16 17:41:22 -07:00
|
|
|
|
2010-11-30 18:41:32 -08:00
|
|
|
} /* namespace js */
|
2010-07-16 17:41:22 -07:00
|
|
|
|
2011-03-14 13:59:53 -07:00
|
|
|
extern JSString * JS_FASTCALL
|
|
|
|
js_ConcatStrings(JSContext *cx, JSString *s1, JSString *s2);
|
2007-08-15 23:23:06 -07:00
|
|
|
|
2009-06-10 18:29:44 -07:00
|
|
|
extern JSString * JS_FASTCALL
|
2008-08-29 17:35:00 -07:00
|
|
|
js_toLowerCase(JSContext *cx, JSString *str);
|
|
|
|
|
2009-06-10 18:29:44 -07:00
|
|
|
extern JSString * JS_FASTCALL
|
2008-08-29 17:35:00 -07:00
|
|
|
js_toUpperCase(JSContext *cx, JSString *str);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
struct JSSubString {
|
|
|
|
size_t length;
|
|
|
|
const jschar *chars;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern jschar js_empty_ucstr[];
|
|
|
|
extern JSSubString js_EmptySubString;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Shorthands for ASCII (7-bit) decimal and hex conversion.
|
|
|
|
* Manually inline isdigit for performance; MSVC doesn't do this for us.
|
|
|
|
*/
|
|
|
|
#define JS7_ISDEC(c) ((((unsigned)(c)) - '0') <= 9)
|
|
|
|
#define JS7_UNDEC(c) ((c) - '0')
|
|
|
|
#define JS7_ISHEX(c) ((c) < 128 && isxdigit(c))
|
|
|
|
#define JS7_UNHEX(c) (uintN)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a')
|
|
|
|
#define JS7_ISLET(c) ((c) < 128 && isalpha(c))
|
|
|
|
|
|
|
|
/* Initialize the String class, returning its prototype object. */
|
|
|
|
extern JSObject *
|
|
|
|
js_InitStringClass(JSContext *cx, JSObject *obj);
|
|
|
|
|
|
|
|
extern const char js_escape_str[];
|
|
|
|
extern const char js_unescape_str[];
|
|
|
|
extern const char js_uneval_str[];
|
|
|
|
extern const char js_decodeURI_str[];
|
|
|
|
extern const char js_encodeURI_str[];
|
|
|
|
extern const char js_decodeURIComponent_str[];
|
|
|
|
extern const char js_encodeURIComponent_str[];
|
|
|
|
|
|
|
|
/* GC-allocate a string descriptor for the given malloc-allocated chars. */
|
2011-03-14 13:59:53 -07:00
|
|
|
extern JSFixedString *
|
2008-08-11 11:03:54 -07:00
|
|
|
js_NewString(JSContext *cx, jschar *chars, size_t length);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-12-06 10:26:58 -08:00
|
|
|
extern JSLinearString *
|
2011-03-14 13:59:53 -07:00
|
|
|
js_NewDependentString(JSContext *cx, JSString *base, size_t start, size_t length);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* Copy a counted string and GC-allocate a descriptor for it. */
|
2011-03-14 13:59:53 -07:00
|
|
|
extern JSFixedString *
|
2007-07-28 09:57:30 -07:00
|
|
|
js_NewStringCopyN(JSContext *cx, const jschar *s, size_t n);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-14 13:59:53 -07:00
|
|
|
extern JSFixedString *
|
2010-07-24 20:26:34 -07:00
|
|
|
js_NewStringCopyN(JSContext *cx, const char *s, size_t n);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* Copy a C string and GC-allocate a descriptor for it. */
|
2011-03-14 13:59:53 -07:00
|
|
|
extern JSFixedString *
|
2007-07-28 09:57:30 -07:00
|
|
|
js_NewStringCopyZ(JSContext *cx, const jschar *s);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-14 13:59:53 -07:00
|
|
|
extern JSFixedString *
|
2010-07-24 20:26:34 -07:00
|
|
|
js_NewStringCopyZ(JSContext *cx, const char *s);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Convert a value to a printable C string.
|
|
|
|
*/
|
2010-11-11 12:40:29 -08:00
|
|
|
extern const char *
|
|
|
|
js_ValueToPrintable(JSContext *cx, const js::Value &,
|
|
|
|
JSAutoByteString *bytes, bool asSource = false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert a value to a string, returning null after reporting an error,
|
|
|
|
* otherwise returning a new string reference.
|
|
|
|
*/
|
2010-07-14 23:19:36 -07:00
|
|
|
extern JSString *
|
|
|
|
js_ValueToString(JSContext *cx, const js::Value &v);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-10-04 11:45:34 -07:00
|
|
|
namespace js {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Most code that calls js_ValueToString knows the value is (probably) not a
|
|
|
|
* string, so it does not make sense to put this inline fast path into
|
|
|
|
* js_ValueToString.
|
|
|
|
*/
|
|
|
|
static JS_ALWAYS_INLINE JSString *
|
|
|
|
ValueToString_TestForStringInline(JSContext *cx, const Value &v)
|
|
|
|
{
|
|
|
|
if (v.isString())
|
|
|
|
return v.toString();
|
|
|
|
return js_ValueToString(cx, v);
|
|
|
|
}
|
|
|
|
|
2009-06-30 17:19:42 -07:00
|
|
|
/*
|
2009-08-07 20:09:11 -07:00
|
|
|
* This function implements E-262-3 section 9.8, toString. Convert the given
|
|
|
|
* value to a string of jschars appended to the given buffer. On error, the
|
2009-06-30 17:19:42 -07:00
|
|
|
* passed buffer may have partial results appended.
|
|
|
|
*/
|
2011-03-29 15:46:51 -07:00
|
|
|
inline bool
|
2011-01-12 15:28:58 -08:00
|
|
|
ValueToStringBuffer(JSContext *cx, const Value &v, StringBuffer &sb);
|
|
|
|
|
|
|
|
} /* namespace js */
|
2009-06-30 17:19:42 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Convert a value to its source expression, returning null after reporting
|
|
|
|
* an error, otherwise returning a new string reference.
|
|
|
|
*/
|
|
|
|
extern JS_FRIEND_API(JSString *)
|
2010-07-14 23:19:36 -07:00
|
|
|
js_ValueToSource(JSContext *cx, const js::Value &v);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-14 13:59:53 -07:00
|
|
|
namespace js {
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
2007-08-11 13:25:16 -07:00
|
|
|
* Compute a hash function from str. The caller can call this function even if
|
|
|
|
* str is not a GC-allocated thing.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2010-12-06 10:26:58 -08:00
|
|
|
inline uint32
|
2011-03-14 13:59:53 -07:00
|
|
|
HashChars(const jschar *chars, size_t length)
|
2010-12-06 10:26:58 -08:00
|
|
|
{
|
2011-03-14 13:59:53 -07:00
|
|
|
uint32 h = 0;
|
|
|
|
for (; length; chars++, length--)
|
|
|
|
h = JS_ROTATE_LEFT32(h, 4) ^ *chars;
|
2010-12-06 10:26:58 -08:00
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
2007-08-11 13:25:16 -07:00
|
|
|
/*
|
|
|
|
* Test if strings are equal. The caller can call the function even if str1
|
|
|
|
* or str2 are not GC-allocated things.
|
|
|
|
*/
|
2010-12-06 10:26:58 -08:00
|
|
|
extern bool
|
|
|
|
EqualStrings(JSContext *cx, JSString *str1, JSString *str2, JSBool *result);
|
|
|
|
|
|
|
|
/* EqualStrings is infallible on linear strings. */
|
|
|
|
extern bool
|
|
|
|
EqualStrings(JSLinearString *str1, JSLinearString *str2);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return less than, equal to, or greater than zero depending on whether
|
|
|
|
* str1 is less than, equal to, or greater than str2.
|
|
|
|
*/
|
2010-12-06 10:26:58 -08:00
|
|
|
extern bool
|
|
|
|
CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32 *result);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-10-28 08:15:53 -07:00
|
|
|
/*
|
|
|
|
* Return true if the string matches the given sequence of ASCII bytes.
|
|
|
|
*/
|
2010-12-06 10:26:58 -08:00
|
|
|
extern bool
|
|
|
|
StringEqualsAscii(JSLinearString *str, const char *asciiBytes);
|
2010-10-28 08:15:53 -07:00
|
|
|
|
|
|
|
} /* namespacejs */
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
extern size_t
|
|
|
|
js_strlen(const jschar *s);
|
|
|
|
|
|
|
|
extern jschar *
|
|
|
|
js_strchr(const jschar *s, jschar c);
|
|
|
|
|
|
|
|
extern jschar *
|
|
|
|
js_strchr_limit(const jschar *s, jschar c, const jschar *limit);
|
|
|
|
|
|
|
|
#define js_strncpy(t, s, n) memcpy((t), (s), (n) * sizeof(jschar))
|
|
|
|
|
2011-05-26 15:50:05 -07:00
|
|
|
namespace js {
|
|
|
|
|
2011-03-21 11:06:34 -07:00
|
|
|
/*
|
2011-05-26 15:50:05 -07:00
|
|
|
* On encodings:
|
|
|
|
*
|
|
|
|
* - Some string functions have an optional FlationCoding argument that allow
|
|
|
|
* the caller to force CESU-8 encoding handling.
|
|
|
|
* - Functions that don't take a FlationCoding base their NormalEncoding
|
|
|
|
* behavior on the js_CStringsAreUTF8 value. NormalEncoding is either raw
|
|
|
|
* (simple zero-extension) or UTF-8 depending on js_CStringsAreUTF8.
|
|
|
|
* - Functions that explicitly state their encoding do not use the
|
|
|
|
* js_CStringsAreUTF8 value.
|
|
|
|
*
|
|
|
|
* CESU-8 (Compatibility Encoding Scheme for UTF-16: 8-bit) is a variant of
|
|
|
|
* UTF-8 that allows us to store any wide character string as a narrow
|
|
|
|
* character string. For strings containing mostly ascii, it saves space.
|
2011-03-21 11:06:34 -07:00
|
|
|
* http://www.unicode.org/reports/tr26/
|
|
|
|
*/
|
|
|
|
|
2011-05-26 15:50:05 -07:00
|
|
|
enum FlationCoding
|
|
|
|
{
|
|
|
|
NormalEncoding,
|
|
|
|
CESU8Encoding
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
2011-05-26 15:50:05 -07:00
|
|
|
* Inflate bytes to jschars. Return null on error, otherwise return the jschar
|
|
|
|
* or byte vector that was malloc'ed. length is updated to the length of the
|
|
|
|
* new string (in jschars).
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
extern jschar *
|
2011-05-26 15:50:05 -07:00
|
|
|
InflateString(JSContext *cx, const char *bytes, size_t *length,
|
|
|
|
FlationCoding fc = NormalEncoding);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
extern char *
|
2011-05-26 15:50:05 -07:00
|
|
|
DeflateString(JSContext *cx, const jschar *chars, size_t length);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
2011-05-26 15:50:05 -07:00
|
|
|
* Inflate bytes to JS chars in an existing buffer. 'chars' must be large
|
|
|
|
* enough for 'length' jschars. The buffer is NOT null-terminated.
|
|
|
|
*
|
|
|
|
* charsLength must be be initialized with the destination buffer size and, on
|
|
|
|
* return, will contain on return the number of copied chars.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-05-26 15:50:05 -07:00
|
|
|
extern bool
|
|
|
|
InflateStringToBuffer(JSContext *cx, const char *bytes, size_t length,
|
|
|
|
jschar *chars, size_t *charsLength);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-05-26 15:50:05 -07:00
|
|
|
extern bool
|
|
|
|
InflateUTF8StringToBuffer(JSContext *cx, const char *bytes, size_t length,
|
|
|
|
jschar *chars, size_t *charsLength,
|
|
|
|
FlationCoding fc = NormalEncoding);
|
2010-04-02 13:05:30 -07:00
|
|
|
|
2011-05-26 15:50:05 -07:00
|
|
|
/* Get number of bytes in the deflated sequence of characters. */
|
2007-03-22 10:30:00 -07:00
|
|
|
extern size_t
|
2011-05-26 15:50:05 -07:00
|
|
|
GetDeflatedStringLength(JSContext *cx, const jschar *chars, size_t charsLength);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-05-26 15:50:05 -07:00
|
|
|
/* This function will never fail (return -1) in CESU-8 mode. */
|
2010-04-02 13:05:30 -07:00
|
|
|
extern size_t
|
2011-05-26 15:50:05 -07:00
|
|
|
GetDeflatedUTF8StringLength(JSContext *cx, const jschar *chars,
|
|
|
|
size_t charsLength,
|
|
|
|
FlationCoding fc = NormalEncoding);
|
2010-04-02 13:05:30 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Deflate JS chars to bytes into a buffer. 'bytes' must be large enough for
|
|
|
|
* 'length chars. The buffer is NOT null-terminated. The destination length
|
|
|
|
* must to be initialized with the buffer size and will contain on return the
|
2010-04-02 13:05:30 -07:00
|
|
|
* number of copied bytes. Conversion behavior depends on js_CStringsAreUTF8.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-05-26 15:50:05 -07:00
|
|
|
extern bool
|
|
|
|
DeflateStringToBuffer(JSContext *cx, const jschar *chars,
|
|
|
|
size_t charsLength, char *bytes, size_t *length);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-02 13:05:30 -07:00
|
|
|
/*
|
2011-05-26 15:50:05 -07:00
|
|
|
* Same as DeflateStringToBuffer, but treats 'bytes' as UTF-8 or CESU-8.
|
2010-04-02 13:05:30 -07:00
|
|
|
*/
|
2011-05-26 15:50:05 -07:00
|
|
|
extern bool
|
|
|
|
DeflateStringToUTF8Buffer(JSContext *cx, const jschar *chars,
|
|
|
|
size_t charsLength, char *bytes, size_t *length,
|
|
|
|
FlationCoding fc = NormalEncoding);
|
|
|
|
|
|
|
|
} /* namespace js */
|
2010-04-02 13:05:30 -07:00
|
|
|
|
2010-08-01 09:58:03 -07:00
|
|
|
/*
|
|
|
|
* The String.prototype.replace fast-native entry point is exported for joined
|
|
|
|
* function optimization in js{interp,tracer}.cpp.
|
|
|
|
*/
|
|
|
|
namespace js {
|
|
|
|
extern JSBool
|
|
|
|
str_replace(JSContext *cx, uintN argc, js::Value *vp);
|
|
|
|
}
|
|
|
|
|
2009-07-15 17:36:24 -07:00
|
|
|
extern JSBool
|
2010-07-14 23:19:36 -07:00
|
|
|
js_str_toString(JSContext *cx, uintN argc, js::Value *vp);
|
2009-07-15 17:36:24 -07:00
|
|
|
|
2010-08-05 22:54:34 -07:00
|
|
|
extern JSBool
|
|
|
|
js_str_charAt(JSContext *cx, uintN argc, js::Value *vp);
|
|
|
|
|
|
|
|
extern JSBool
|
|
|
|
js_str_charCodeAt(JSContext *cx, uintN argc, js::Value *vp);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Convert one UCS-4 char and write it into a UTF-8 buffer, which must be at
|
|
|
|
* least 6 bytes long. Return the number of UTF-8 bytes of data written.
|
|
|
|
*/
|
|
|
|
extern int
|
|
|
|
js_OneUcs4ToUtf8Char(uint8 *utf8Buffer, uint32 ucs4Char);
|
|
|
|
|
2010-10-28 08:15:53 -07:00
|
|
|
namespace js {
|
|
|
|
|
|
|
|
extern size_t
|
2010-12-06 10:26:58 -08:00
|
|
|
PutEscapedStringImpl(char *buffer, size_t size, FILE *fp, JSLinearString *str, uint32 quote);
|
2010-10-28 08:15:53 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
2010-10-28 08:15:53 -07:00
|
|
|
* Write str into buffer escaping any non-printable or non-ASCII character
|
|
|
|
* using \escapes for JS string literals.
|
|
|
|
* Guarantees that a NUL is at the end of the buffer unless size is 0. Returns
|
|
|
|
* the length of the written output, NOT including the NUL. Thus, a return
|
|
|
|
* value of size or more means that the output was truncated. If buffer
|
|
|
|
* is null, just returns the length of the output. If quote is not 0, it must
|
|
|
|
* be a single or double quote character that will quote the output.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2010-10-28 08:15:53 -07:00
|
|
|
inline size_t
|
2010-12-06 10:26:58 -08:00
|
|
|
PutEscapedString(char *buffer, size_t size, JSLinearString *str, uint32 quote)
|
2010-10-28 08:15:53 -07:00
|
|
|
{
|
|
|
|
size_t n = PutEscapedStringImpl(buffer, size, NULL, str, quote);
|
|
|
|
|
|
|
|
/* PutEscapedStringImpl can only fail with a file. */
|
|
|
|
JS_ASSERT(n != size_t(-1));
|
|
|
|
return n;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Write str into file escaping any non-printable or non-ASCII character.
|
2010-10-28 08:15:53 -07:00
|
|
|
* If quote is not 0, it must be a single or double quote character that
|
|
|
|
* will quote the output.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2010-10-28 08:15:53 -07:00
|
|
|
inline bool
|
2010-12-06 10:26:58 -08:00
|
|
|
FileEscapedString(FILE *fp, JSLinearString *str, uint32 quote)
|
2010-10-28 08:15:53 -07:00
|
|
|
{
|
|
|
|
return PutEscapedStringImpl(NULL, 0, fp, str, quote) != size_t(-1);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-10-28 08:15:53 -07:00
|
|
|
} /* namespace js */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-03-09 17:29:42 -07:00
|
|
|
extern JSBool
|
2010-08-10 16:38:08 -07:00
|
|
|
js_String(JSContext *cx, uintN argc, js::Value *vp);
|
2010-03-22 22:39:29 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* jsstr_h___ */
|