1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/enc/trans/escape.trans
yugui 3fa3f9abb9 Supports static linking of extensions and encodings again.
Fixes --with-static-linked-ext.

Patch by Google Inc. [ruby-core:45073].

* Makefile.in (ENCOBJS, EXTOBJS): New variables to specify static
  linked libraries. Also reintroduces extinit.o, introduces encinit.o
  introduces encinit.o

* common.mk: Builds static libraries rather than shared objects if
  specified.

* configure.in (LD): new substitution. 
  Avoids PIE if s

* enc/depend: Supports static linked libraries
  (libencs, libenc, libtrans): New target.

* enc/encinit.c.erb: new template to generate the initialization of
  statically linked encodings.

* enc/make_encmake.rb (--module): new flag to specify whether static
  or dynamic.

* transcode_data.h (TRANS_INIT): New macro to get rid of the name
  collision of encoding initializers and transcoder initializers.

* ext/extmk.rb: Fixes the behavior on $extstatic is true.

* lib/mkmf.rb (clean-static): new target to clean up static linked
  libraries.

* ruby.c (process_options): New initializes statically linked
  encodings here.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-16 05:39:06 +00:00

93 lines
1.9 KiB
Text

#include "transcode_data.h"
<%
def hexstr(str)
str.unpack("H*")[0]
end
transcode_tblgen("", "amp_escape", [
["{00-25,27-FF}", :nomap],
["26", hexstr("&amp;")]
], nil)
transcode_tblgen("", "xml_text_escape", [
["{00-25,27-3B,3D,3F-FF}", :nomap],
["26", hexstr("&amp;")],
["3C", hexstr("&lt;")],
["3E", hexstr("&gt;")]
], nil)
transcode_tblgen("", "xml_attr_content_escape", [
["{00-21,23-25,27-3B,3D,3F-FF}", :nomap],
["22", hexstr("&quot;")],
["26", hexstr("&amp;")],
["3C", hexstr("&lt;")],
["3E", hexstr("&gt;")]
], nil)
map_xml_attr_quote = {}
map_xml_attr_quote["{00-FF}"] = :func_so
transcode_generate_node(ActionMap.parse(map_xml_attr_quote), "escape_xml_attr_quote")
%>
<%= transcode_generated_code %>
#define END 0
#define NORMAL 1
static int
escape_xml_attr_quote_init(void *statep)
{
unsigned char *sp = statep;
*sp = END;
return 0;
}
static ssize_t
fun_so_escape_xml_attr_quote(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
{
unsigned char *sp = statep;
int n = 0;
if (*sp == END) {
*sp = NORMAL;
o[n++] = '"';
}
o[n++] = s[0];
return n;
}
static ssize_t
escape_xml_attr_quote_finish(void *statep, unsigned char *o, size_t osize)
{
unsigned char *sp = statep;
int n = 0;
if (*sp == END) {
o[n++] = '"';
}
o[n++] = '"';
*sp = END;
return n;
}
static const rb_transcoder
rb_escape_xml_attr_quote = {
"", "xml_attr_quote", escape_xml_attr_quote,
TRANSCODE_TABLE_INFO,
1, /* input_unit_length */
1, /* max_input */
7, /* max_output */
asciicompat_encoder, /* asciicompat_type */
1, escape_xml_attr_quote_init, escape_xml_attr_quote_init,
NULL, NULL, NULL, fun_so_escape_xml_attr_quote,
escape_xml_attr_quote_finish
};
TRANS_INIT(escape)
{
<%= transcode_register_code %>
rb_register_transcoder(&rb_escape_xml_attr_quote);
}