gd-libgd / src / entities.tcl


# get names for html-4.0 characters from:
set f [open entities.html r]
set entity_name_length_max 0
set nr_of_entities 0
while {! [eof $f]} {
        set rec [gets $f]
        if {[scan $rec {<!ENTITY %s CDATA "&#%d;"; --} name val] == 2} {
                set entity($name) $val
		set entity_name_length [string length $name]
		if {$entity_name_length > $entity_name_length_max} {
			set entity_name_length_max $entity_name_length
		incr nr_of_entities
close $f

set f [open entities.h w]
puts $f "/*"
puts $f " * Generated file - do not edit directly."
puts $f " *"
puts $f " * This file was generated from:"
puts $f " *"
puts $f " * by means of the script:"
puts $f " *       entities.tcl"
puts $f " */"
puts $f ""
puts $f "struct entities_s {"
puts $f "	char	*name;"
puts $f "	int	value;"
puts $f "} entities\[\] = {"
foreach name [lsort [array names entity]] {
        puts $f "	{\"$name\", $entity($name)},"
puts $f "};"
puts $f ""
puts $f "#define ENTITY_NAME_LENGTH_MAX $entity_name_length_max"
puts $f "#define NR_OF_ENTITIES $nr_of_entities"
close $f
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.