diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-12 19:31:41 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-12 19:31:41 +0000 |
commit | 9603c8e626c6818e92368904b9b5d8d21191d376 (patch) | |
tree | 7cbdb7c9938bd50b14d0a2a807becbcb3dee37be | |
parent | 90c99ae664f06a478d9957cffc116bb816121c19 (diff) | |
download | chromium_src-9603c8e626c6818e92368904b9b5d8d21191d376.zip chromium_src-9603c8e626c6818e92368904b9b5d8d21191d376.tar.gz chromium_src-9603c8e626c6818e92368904b9b5d8d21191d376.tar.bz2 |
Remove the generation of HtmlEntityCodes.c since the same data is in HtmlEntityNames.c.
Review URL: http://codereview.chromium.org/11005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5275 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/build/WebCore/generate_entitycodes.pl | 79 | ||||
-rw-r--r-- | webkit/build/port/SConscript | 5 | ||||
-rw-r--r-- | webkit/glue/entity_map.cc | 36 | ||||
-rw-r--r-- | webkit/port/DerivedSources.make | 5 |
4 files changed, 19 insertions, 106 deletions
diff --git a/webkit/build/WebCore/generate_entitycodes.pl b/webkit/build/WebCore/generate_entitycodes.pl deleted file mode 100644 index 8ee0566..0000000 --- a/webkit/build/WebCore/generate_entitycodes.pl +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/perl -w -# Copyright 2008, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# -# This script is for generating the reverse entity code mapping using -# HTMLEntityNames.gperf as input. - -# Get original file path from agruments. -my $originalFileName = shift; - -# Open file for reading. -open $FILE, "<", $originalFileName or die "Can't open $originalFileName: $!"; - -# status for indicating current parsing status. -# 0 means waiting start, 1 means starting parsing, 2 means stopping parsing. -my $parseStatus = 0; - -# Counter for calculating number of entities. -my $dataCount = 0; - -# print file head comments. -print "// This file is generated from HTMLEntityNames.gperf. DO NOT EDIT IT!\n\n"; - -#print an anonymous namespace to avoid link-time conflicts. -print "namespace {\n\n"; - -# print the strutcure declaration of EntityCode. -print "struct EntityCode {\n wchar_t code;\n const char* name;\n};\n\n"; - -# print the array declaration of entities. -print "static const EntityCode entity_codes[] = {\n"; - -while(<$FILE>) { - chomp; - if (/^\%\%$/i) { - ++$parseStatus; - } elsif (!/^\#/ && $parseStatus == 1) { - my ($name, $code) = split(/,/); - if (defined($name) && defined($code)) { - $name =~ s/\s//g; - $code =~ s/\s//g; - if (length($name) > 0 && length($code) > 0) { - print ",\n" if $dataCount > 0; - print " {$code, \"&$name;\"}"; - ++$dataCount; - } - } - } -} - -# print declaration of entity_codes_length and close anonymous namespace declaration. -print "\n};\n\nstatic int entity_codes_length = sizeof(entity_codes) / sizeof(EntityCode);\n\n}\n"; diff --git a/webkit/build/port/SConscript b/webkit/build/port/SConscript index 9a75cb8..5258f6b 100644 --- a/webkit/build/port/SConscript +++ b/webkit/build/port/SConscript @@ -644,11 +644,6 @@ env.Command('$DERIVED_DIR/HTMLEntityNames.c', 'gperf -a -L ANSI-C -C -G -c -o -t -k "*" -N findEntity ' + \ '-D -s 2 $SOURCE > $TARGET') -env.Command('$DERIVED_DIR/HTMLEntityCodes.c', - '$WEBKIT_PORT_DIR/html/HTMLEntityNames.gperf', - 'perl $WEBKIT_BUILD/WebCore/generate_entitycodes.pl ' + \ - '$SOURCE > $TARGET') - # CSS tokenizer env.Command('$DERIVED_DIR/tokenizer.cpp', ['$WEBKIT_PORT_DIR/css/tokenizer.flex', diff --git a/webkit/glue/entity_map.cc b/webkit/glue/entity_map.cc index da7f200..e854e6c 100644 --- a/webkit/glue/entity_map.cc +++ b/webkit/glue/entity_map.cc @@ -4,17 +4,21 @@ #include "webkit/glue/entity_map.h" -#include "HTMLEntityCodes.c" - #include "base/hash_tables.h" namespace webkit_glue { +// Note that this file is also included by HTMLTokenizer.cpp so we are getting +// two copies of the data in memory. We can fix this by changing the script +// that generated the array to create a static const that is its length, but +// this is low priority since the data is less than 4K. +#include "HTMLEntityNames.c" + typedef base::hash_map<char16, const char*> EntityMapType; class EntityMapData { public: - EntityMapData(const EntityCode* entity_codes, int entity_codes_length, + EntityMapData(const Entity* entity_codes, int entity_codes_length, bool user_number_entity_apos) : entity_codes_(entity_codes), entity_codes_length_(entity_codes_length), @@ -27,7 +31,7 @@ class EntityMapData { private: // Data structure which saves all pairs of Unicode character and its // corresponding entity notation. - const EntityCode* entity_codes_; + const Entity* entity_codes_; const int entity_codes_length_; // IE does not support '''(html entity name for symbol ') as HTML entity // (but it does support ' as xml entity), so if user_number_entity_apos_ @@ -44,7 +48,7 @@ const EntityMapType* EntityMapData::GetEntityMapData() { if (!map_) { // lazily create the entity map. map_ = new EntityMapType; - const EntityCode* entity_code = &entity_codes_[0]; + const Entity* entity_code = &entity_codes_[0]; for (int i = 0; i < entity_codes_length_; ++i, ++entity_code) (*map_)[entity_code->code] = entity_code->name; if (user_number_entity_apos_) @@ -53,23 +57,21 @@ const EntityMapType* EntityMapData::GetEntityMapData() { return map_; } -static const EntityCode xml_built_in_entity_codes[] = { - {0x003c, "<"}, - {0x003e, ">"}, - {0x0026, "&"}, - {0x0027, "'"}, - {0x0022, """} +static const Entity xml_built_in_entity_codes[] = { + {"<", 0x003c}, + {">", 0x003e}, + {"&", 0x0026}, + {"'", 0x0027}, + {""", 0x0022} }; static const int xml_entity_codes_length = arraysize(xml_built_in_entity_codes); -static EntityMapData html_entity_map_singleton(entity_codes, - entity_codes_length, - true); -static EntityMapData xml_entity_map_singleton(xml_built_in_entity_codes, - xml_entity_codes_length, - false); +static EntityMapData html_entity_map_singleton( + wordlist, sizeof(wordlist) / sizeof(Entity), true); +static EntityMapData xml_entity_map_singleton( + xml_built_in_entity_codes, xml_entity_codes_length, false); const char* EntityMap::GetEntityNameByCode(char16 code, bool is_html) { const EntityMapType* entity_map; diff --git a/webkit/port/DerivedSources.make b/webkit/port/DerivedSources.make index 803328d..b7443fc 100644 --- a/webkit/port/DerivedSources.make +++ b/webkit/port/DerivedSources.make @@ -621,7 +621,6 @@ all : \ CSSValueKeywords.h \ ColorData.c \ DocTypeStrings.cpp \ - HTMLEntityCodes.c \ HTMLEntityNames.c \ V8Attr.h \ V8BarInfo.h \ @@ -971,10 +970,6 @@ DocTypeStrings.cpp : html/DocTypeStrings.gperf # HTML entity names -# This Google addition generates a reverse-mapping of entity codes back to entity names, for the DOM serialization code used by the Save page feature. -HTMLEntityCodes.c : html/HTMLEntityNames.gperf - perl $(WebCore)/../../../webkit/build/WebCore/generate_entitycodes.pl $< > $@ - HTMLEntityNames.c : html/HTMLEntityNames.gperf gperf -a -L ANSI-C -C -G -c -o -t -k '*' -N findEntity -D -s 2 $< > $@ |