/[jscoverage]/trunk/js/jsscan.cpp
ViewVC logotype

Diff of /trunk/js/jsscan.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 398 by siliconforks, Thu Oct 23 19:03:33 2008 UTC revision 399 by siliconforks, Tue Dec 9 03:37:47 2008 UTC
# Line 749  Line 749 
749      sb->ptr = bp;      sb->ptr = bp;
750  }  }
751    
752    void
753    js_AppendUCString(JSStringBuffer *sb, const jschar *buf, uintN len)
754    {
755        jschar *bp;
756    
757        if (!STRING_BUFFER_OK(sb))
758            return;
759        if (len == 0 || !ENSURE_STRING_BUFFER(sb, len))
760            return;
761        bp = sb->ptr;
762        js_strncpy(bp, buf, len);
763        bp += len;
764        *bp = 0;
765        sb->ptr = bp;
766    }
767    
768  #if JS_HAS_XML_SUPPORT  #if JS_HAS_XML_SUPPORT
769    
770  void  void
# Line 786  Line 802 
802  void  void
803  js_AppendJSString(JSStringBuffer *sb, JSString *str)  js_AppendJSString(JSStringBuffer *sb, JSString *str)
804  {  {
805      size_t length;      js_AppendUCString(sb, JSSTRING_CHARS(str), JSSTRING_LENGTH(str));
     jschar *bp;  
   
     if (!STRING_BUFFER_OK(sb))  
         return;  
     length = JSSTRING_LENGTH(str);  
     if (length == 0 || !ENSURE_STRING_BUFFER(sb, length))  
         return;  
     bp = sb->ptr;  
     js_strncpy(bp, JSSTRING_CHARS(str), length);  
     bp += length;  
     *bp = 0;  
     sb->ptr = bp;  
806  }  }
807    
808  static JSBool  static JSBool
# Line 814  Line 818 
818      /* Put the entity, including the '&' already scanned, in ts->tokenbuf. */      /* Put the entity, including the '&' already scanned, in ts->tokenbuf. */
819      offset = PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar);      offset = PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar);
820      FastAppendChar(&ts->tokenbuf, '&');      FastAppendChar(&ts->tokenbuf, '&');
821        if (!STRING_BUFFER_OK(&ts->tokenbuf))
822            return JS_FALSE;
823      while ((c = GetChar(ts)) != ';') {      while ((c = GetChar(ts)) != ';') {
824          if (c == EOF || c == '\n') {          if (c == EOF || c == '\n') {
825              js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,              js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
# Line 821  Line 827 
827              return JS_FALSE;              return JS_FALSE;
828          }          }
829          FastAppendChar(&ts->tokenbuf, (jschar) c);          FastAppendChar(&ts->tokenbuf, (jschar) c);
830            if (!STRING_BUFFER_OK(&ts->tokenbuf))
831                return JS_FALSE;
832      }      }
833    
834      /* Let length be the number of jschars after the '&', including the ';'. */      /* Let length be the number of jschars after the '&', including the ';'. */
# Line 906  Line 914 
914      msg = JSMSG_BAD_XML_NCR;      msg = JSMSG_BAD_XML_NCR;
915  bad:  bad:
916      /* No match: throw a TypeError per ECMA-357 10.3.2.1 step 8(a). */      /* No match: throw a TypeError per ECMA-357 10.3.2.1 step 8(a). */
917        JS_ASSERT(STRING_BUFFER_OK(&ts->tokenbuf));
918        JS_ASSERT(PTRDIFF(ts->tokenbuf.ptr, bp, jschar) >= 1);
919      bytes = js_DeflateString(cx, bp + 1,      bytes = js_DeflateString(cx, bp + 1,
920                               PTRDIFF(ts->tokenbuf.ptr, bp, jschar) - 1);                               PTRDIFF(ts->tokenbuf.ptr, bp, jschar) - 1);
921      if (bytes) {      if (bytes) {

Legend:
Removed from v.398  
changed lines
  Added in v.399

  ViewVC Help
Powered by ViewVC 1.1.24