nokogumbo 0.5 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/work/Makefile +213 -0
- data/work/attribute.c +44 -0
- data/work/attribute.h +37 -0
- data/work/attribute.o +0 -0
- data/work/char_ref.c +2561 -0
- data/work/char_ref.h +61 -0
- data/work/char_ref.o +0 -0
- data/work/error.c +258 -0
- data/work/error.h +225 -0
- data/work/error.o +0 -0
- data/work/gumbo.h +800 -0
- data/work/insertion_mode.h +54 -0
- data/work/mkmf.log +41 -0
- data/work/nokogumbo.c +97 -0
- data/work/nokogumbo.o +0 -0
- data/work/nokogumboc.so +0 -0
- data/work/parser.c +3893 -0
- data/work/parser.h +57 -0
- data/work/parser.o +0 -0
- data/work/string_buffer.c +106 -0
- data/work/string_buffer.h +82 -0
- data/work/string_buffer.o +0 -0
- data/work/string_piece.c +49 -0
- data/work/string_piece.h +39 -0
- data/work/string_piece.o +0 -0
- data/work/tag.c +222 -0
- data/work/tag.o +0 -0
- data/work/token_type.h +40 -0
- data/work/tokenizer.c +2978 -0
- data/work/tokenizer.h +123 -0
- data/work/tokenizer.o +0 -0
- data/work/tokenizer_states.h +103 -0
- data/work/utf8.c +268 -0
- data/work/utf8.h +127 -0
- data/work/utf8.o +0 -0
- data/work/util.c +58 -0
- data/work/util.h +57 -0
- data/work/util.o +0 -0
- data/work/vector.c +121 -0
- data/work/vector.h +66 -0
- data/work/vector.o +0 -0
- metadata +42 -2
- data/Rakefile +0 -68
data/work/Makefile
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
# V=0 quiet, V=1 verbose. other values don't work.
|
5
|
+
V = 0
|
6
|
+
Q1 = $(V:1=)
|
7
|
+
Q = $(Q1:0=@)
|
8
|
+
n=$(NULLCMD)
|
9
|
+
ECHO1 = $(V:1=@$n)
|
10
|
+
ECHO = $(ECHO1:0=@echo)
|
11
|
+
|
12
|
+
#### Start of system configuration section. ####
|
13
|
+
|
14
|
+
srcdir = .
|
15
|
+
topdir = /usr/include/ruby-1.9.1
|
16
|
+
hdrdir = /usr/include/ruby-1.9.1
|
17
|
+
arch_hdrdir = /usr/include/ruby-1.9.1/$(arch)
|
18
|
+
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
19
|
+
prefix = $(DESTDIR)/usr
|
20
|
+
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
21
|
+
exec_prefix = $(prefix)
|
22
|
+
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
23
|
+
sitehdrdir = $(rubyhdrdir)/site_ruby
|
24
|
+
rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
|
25
|
+
vendordir = $(DESTDIR)/usr/lib/ruby/vendor_ruby
|
26
|
+
sitedir = $(DESTDIR)/usr/local/lib/site_ruby
|
27
|
+
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
28
|
+
mandir = $(prefix)/share/man
|
29
|
+
localedir = $(datarootdir)/locale
|
30
|
+
libdir = $(exec_prefix)/lib
|
31
|
+
psdir = $(docdir)
|
32
|
+
pdfdir = $(docdir)
|
33
|
+
dvidir = $(docdir)
|
34
|
+
htmldir = $(docdir)
|
35
|
+
infodir = $(prefix)/share/info
|
36
|
+
docdir = $(datarootdir)/doc/$(PACKAGE)
|
37
|
+
oldincludedir = $(DESTDIR)/usr/include
|
38
|
+
includedir = $(prefix)/include
|
39
|
+
localstatedir = $(DESTDIR)/var
|
40
|
+
sharedstatedir = $(prefix)/com
|
41
|
+
sysconfdir = $(DESTDIR)/etc
|
42
|
+
datadir = $(datarootdir)
|
43
|
+
datarootdir = $(prefix)/share
|
44
|
+
libexecdir = $(prefix)/lib/ruby1.9.1
|
45
|
+
sbindir = $(exec_prefix)/sbin
|
46
|
+
bindir = $(exec_prefix)/bin
|
47
|
+
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
48
|
+
archdir = $(rubylibdir)/$(arch)
|
49
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
50
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
51
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
52
|
+
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
53
|
+
|
54
|
+
NULLCMD = :
|
55
|
+
|
56
|
+
CC = gcc
|
57
|
+
CXX = g++
|
58
|
+
LIBRUBY = $(LIBRUBY_SO)
|
59
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
60
|
+
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
61
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
62
|
+
OUTFLAG = -o
|
63
|
+
COUTFLAG = -o
|
64
|
+
|
65
|
+
RUBY_EXTCONF_H =
|
66
|
+
cflags = $(optflags) $(debugflags) $(warnflags)
|
67
|
+
optflags = -O3
|
68
|
+
debugflags = -ggdb
|
69
|
+
warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
|
70
|
+
CFLAGS = -fPIC -std=c99 -I/usr/include/libxml2 $(ARCH_FLAG)
|
71
|
+
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) -I/var/lib/gems/1.9.1/gems/nokogiri-1.5.5/ext/nokogiri
|
72
|
+
DEFS =
|
73
|
+
CPPFLAGS = -D_FORTIFY_SOURCE=2 $(DEFS) $(cppflags)
|
74
|
+
CXXFLAGS = $(CFLAGS) -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing
|
75
|
+
ldflags = -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic
|
76
|
+
dldflags =
|
77
|
+
ARCH_FLAG =
|
78
|
+
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
|
79
|
+
LDSHARED = $(CC) -shared
|
80
|
+
LDSHAREDXX = $(CXX) -shared
|
81
|
+
AR = ar
|
82
|
+
EXEEXT =
|
83
|
+
|
84
|
+
RUBY_BASE_NAME = ruby
|
85
|
+
RUBY_INSTALL_NAME = ruby1.9.1
|
86
|
+
RUBY_SO_NAME = ruby-1.9.1
|
87
|
+
arch = x86_64-linux
|
88
|
+
sitearch = $(arch)
|
89
|
+
ruby_version = 1.9.1
|
90
|
+
ruby = /usr/bin/ruby1.9.1
|
91
|
+
RUBY = $(ruby)
|
92
|
+
RM = rm -f
|
93
|
+
RM_RF = $(RUBY) -run -e rm -- -rf
|
94
|
+
RMDIRS = rmdir --ignore-fail-on-non-empty -p
|
95
|
+
MAKEDIRS = /bin/mkdir -p
|
96
|
+
INSTALL = /usr/bin/install -c
|
97
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
98
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
99
|
+
COPY = cp
|
100
|
+
|
101
|
+
#### End of system configuration section. ####
|
102
|
+
|
103
|
+
preload =
|
104
|
+
|
105
|
+
libpath = . $(libdir)
|
106
|
+
LIBPATH = -L. -L$(libdir)
|
107
|
+
DEFFILE =
|
108
|
+
|
109
|
+
CLEANFILES = mkmf.log
|
110
|
+
DISTCLEANFILES =
|
111
|
+
DISTCLEANDIRS =
|
112
|
+
|
113
|
+
extout =
|
114
|
+
extout_prefix =
|
115
|
+
target_prefix =
|
116
|
+
LOCAL_LIBS =
|
117
|
+
LIBS = $(LIBRUBYARG_SHARED) -lxml2 -lpthread -lrt -ldl -lcrypt -lm -lc
|
118
|
+
SRCS = nokogumbo.c vector.c string_buffer.c error.c attribute.c char_ref.c string_piece.c tag.c util.c parser.c utf8.c tokenizer.c
|
119
|
+
OBJS = nokogumbo.o vector.o string_buffer.o error.o attribute.o char_ref.o string_piece.o tag.o util.o parser.o utf8.o tokenizer.o
|
120
|
+
TARGET = nokogumboc
|
121
|
+
DLLIB = $(TARGET).so
|
122
|
+
EXTSTATIC =
|
123
|
+
STATIC_LIB =
|
124
|
+
|
125
|
+
BINDIR = $(bindir)
|
126
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
127
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
128
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
129
|
+
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
|
130
|
+
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
|
131
|
+
|
132
|
+
TARGET_SO = $(DLLIB)
|
133
|
+
CLEANLIBS = $(TARGET).so
|
134
|
+
CLEANOBJS = *.o *.bak
|
135
|
+
|
136
|
+
all: $(DLLIB)
|
137
|
+
static: $(STATIC_LIB)
|
138
|
+
.PHONY: all install static install-so install-rb
|
139
|
+
.PHONY: clean clean-so clean-rb
|
140
|
+
|
141
|
+
clean-rb-default::
|
142
|
+
clean-rb::
|
143
|
+
clean-so::
|
144
|
+
clean: clean-so clean-rb-default clean-rb
|
145
|
+
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
146
|
+
|
147
|
+
distclean-rb-default::
|
148
|
+
distclean-rb::
|
149
|
+
distclean-so::
|
150
|
+
distclean: clean distclean-so distclean-rb-default distclean-rb
|
151
|
+
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
152
|
+
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
153
|
+
@-$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
|
154
|
+
|
155
|
+
realclean: distclean
|
156
|
+
install: install-so install-rb
|
157
|
+
|
158
|
+
install-so: $(RUBYARCHDIR)
|
159
|
+
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
160
|
+
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
161
|
+
@-$(MAKEDIRS) $(@D)
|
162
|
+
$(INSTALL_PROG) $(DLLIB) $(@D)
|
163
|
+
install-rb: pre-install-rb install-rb-default
|
164
|
+
install-rb-default: pre-install-rb-default
|
165
|
+
pre-install-rb: Makefile
|
166
|
+
pre-install-rb-default: Makefile
|
167
|
+
pre-install-rb-default:
|
168
|
+
$(ECHO) installing default nokogumboc libraries
|
169
|
+
$(RUBYARCHDIR):
|
170
|
+
$(Q) $(MAKEDIRS) $@
|
171
|
+
|
172
|
+
site-install: site-install-so site-install-rb
|
173
|
+
site-install-so: install-so
|
174
|
+
site-install-rb: install-rb
|
175
|
+
|
176
|
+
.SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
|
177
|
+
|
178
|
+
.cc.o:
|
179
|
+
$(ECHO) compiling $(<)
|
180
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
181
|
+
|
182
|
+
.mm.o:
|
183
|
+
$(ECHO) compiling $(<)
|
184
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
185
|
+
|
186
|
+
.cxx.o:
|
187
|
+
$(ECHO) compiling $(<)
|
188
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
189
|
+
|
190
|
+
.cpp.o:
|
191
|
+
$(ECHO) compiling $(<)
|
192
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
193
|
+
|
194
|
+
.C.o:
|
195
|
+
$(ECHO) compiling $(<)
|
196
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
197
|
+
|
198
|
+
.c.o:
|
199
|
+
$(ECHO) compiling $(<)
|
200
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
201
|
+
|
202
|
+
.m.o:
|
203
|
+
$(ECHO) compiling $(<)
|
204
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
205
|
+
|
206
|
+
$(DLLIB): $(OBJS) Makefile
|
207
|
+
$(ECHO) linking shared-object $(DLLIB)
|
208
|
+
@-$(RM) $(@)
|
209
|
+
$(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
|
data/work/attribute.c
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
// Copyright 2010 Google Inc. All Rights Reserved.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
//
|
15
|
+
// Author: jdtang@google.com (Jonathan Tang)
|
16
|
+
|
17
|
+
#include "attribute.h"
|
18
|
+
|
19
|
+
#include <assert.h>
|
20
|
+
#include <stdlib.h>
|
21
|
+
#include <string.h>
|
22
|
+
#include <strings.h>
|
23
|
+
|
24
|
+
#include "util.h"
|
25
|
+
|
26
|
+
struct _GumboParser;
|
27
|
+
|
28
|
+
GumboAttribute* gumbo_get_attribute(
|
29
|
+
const struct _GumboVector* attributes, const char* name) {
|
30
|
+
for (int i = 0; i < attributes->length; ++i) {
|
31
|
+
GumboAttribute* attr = attributes->data[i];
|
32
|
+
if (!strcasecmp(attr->name, name)) {
|
33
|
+
return attr;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return NULL;
|
37
|
+
}
|
38
|
+
|
39
|
+
void gumbo_destroy_attribute(
|
40
|
+
struct _GumboParser* parser, GumboAttribute* attribute) {
|
41
|
+
gumbo_parser_deallocate(parser, (void*) attribute->name);
|
42
|
+
gumbo_parser_deallocate(parser, (void*) attribute->value);
|
43
|
+
gumbo_parser_deallocate(parser, (void*) attribute);
|
44
|
+
}
|
data/work/attribute.h
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
// Copyright 2010 Google Inc. All Rights Reserved.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
//
|
15
|
+
// Author: jdtang@google.com (Jonathan Tang)
|
16
|
+
|
17
|
+
#ifndef GUMBO_ATTRIBUTE_H_
|
18
|
+
#define GUMBO_ATTRIBUTE_H_
|
19
|
+
|
20
|
+
#include "gumbo.h"
|
21
|
+
|
22
|
+
#ifdef __cplusplus
|
23
|
+
extern "C" {
|
24
|
+
#endif
|
25
|
+
|
26
|
+
struct _GumboParser;
|
27
|
+
|
28
|
+
// Release the memory used for an GumboAttribute, including the attribute
|
29
|
+
// itself.
|
30
|
+
void gumbo_destroy_attribute(
|
31
|
+
struct _GumboParser* parser, GumboAttribute* attribute);
|
32
|
+
|
33
|
+
#ifdef __cplusplus
|
34
|
+
}
|
35
|
+
#endif
|
36
|
+
|
37
|
+
#endif // GUMBO_ATTRIBUTE_H_
|
data/work/attribute.o
ADDED
Binary file
|