summaryrefslogtreecommitdiff
path: root/libs/files/domc-library.patch
blob: bed3fc88005685e4d1258aa9f6bde70e81f7f589 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
diff -r -U3 domc-0.7.1/Makefile domc/Makefile
--- domc-0.7.1/Makefile	2004-08-05 22:32:24.000000000 -0600
+++ domc/Makefile	2004-08-31 19:19:15.992009233 -0600
@@ -1,7 +1,8 @@
-prefix     = /usr/local
-includedir = $(prefix)/include
-libdir     = $(prefix)/lib
-mandir     = $(prefix)/man
+_EXTRA     = -I../libmba/src/ -L../libmba/
+prefix     = ./
+includedir = $(prefix)
+libdir     = $(prefix)
+mandir     = $(prefix)
 CC         = gcc
 LIBNAME    = domc
 MAJVERSION = 0.7
@@ -11,7 +12,7 @@
 SOVERSION  = lib$(LIBNAME).so.$(MAJVERSION)
 DISTRO     = $(LIBNAME)-$(MINVERSION)
 RPM_OPT_FLAGS = -O2
-CFLAGS     = -Wall -W -DMSGNO $(RPM_OPT_FLAGS) -I$(includedir) -L$(libdir)
+CFLAGS     = -Wall -W -DMSGNO $(RPM_OPT_FLAGS) $(_EXTRA) -I$(includedir) -L$(libdir) 
 #CFLAGS     = -Wall -W -DMSGNO -I$(includedir) -L$(libdir) $(RPM_OPT_FLAGS) -ansi -pedantic -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings -Wtraditional -Wconversion -Waggregate-return -Wno-parentheses
 OBJS       = src/expatls.o src/events.o src/node.o src/nodelist.o src/namednodemap.o src/dom.o src/timestamp.o src/wcwidth.o src/mbs.o
 MAN        = DOM_CharacterData.3m.gz DOM_Document.3m.gz DOM_Element.3m.gz DOM_Implementation.3m.gz DOM_NamedNodeMap.3m.gz DOM_Node.3m.gz DOM_NodeList.3m.gz DOM_Text.3m.gz
@@ -19,7 +20,7 @@
 all: $(ARNAME)($(OBJS)) $(SONAME) src/defines.h
 
 $(SONAME): $(OBJS)
-	$(CC) -shared $(OBJS) -L$(libdir) -lmba -lexpat -Wl,-h,$(SOVERSION) -o $(SONAME)
+	$(CC) -shared $(OBJS) $(_EXTRA) -L$(libdir) -lmba -Wl,-h,$(SOVERSION) -o $(SONAME)
 
 .c.a:
 	$(CC) $(CFLAGS) -c -o $*.o $<
@@ -47,5 +48,5 @@
 
 clean:
 	rm -f $(OBJS) $(ARNAME) $(SONAME) $(includedir)/domc.h $(libdir)/$(ARNAME) $(libdir)/$(SONAME) $(libdir)/$(SOVERSION) $(libdir)/lib$(LIBNAME).so $(DISTRO).zip
-	cd $(mandir)/man3 && rm -f $(MAN)
+	# cd $(mandir)/man3 && rm -f $(MAN)
 
diff -r -U3 domc-0.7.1/Makefile.msvc domc/Makefile.msvc
--- domc-0.7.1/Makefile.msvc	2004-08-04 17:20:02.000000000 -0600
+++ domc/Makefile.msvc	2004-08-31 19:27:30.565550149 -0600
@@ -1,22 +1,29 @@
 !include <win32.mak>
-LIBMBA=..\libmba-0.8.9
-EXPAT=..\Expat-1.95.5
+LIBMBA=..\libmba
+# EXPAT=..\Expat-1.95.5
 # For i18n support in domc the encdec library is required.
 # Specify were the encdec library is below, change HAVE_ENCDEC to 1
 # in src\defines.h and add /LIBPATH:$(ENCDEC) encdec.lib to the
 # .dll link command.
-ENCDEC=..\encdec-0.3.7
+# ENCDEC=..\encdec-0.3.7
 OBJS=src\expatls.obj src\events.obj src\timestamp.obj src\dom.obj src\node.obj src\namednodemap.obj src\nodelist.obj src\wcwidth.obj
 
+# Debug flags
+# CFLAGS=$(cflags) /MLd /GZ /Gm /ZI /Od /D_DEBUG 
 
-domc.dll: $(OBJS)
-	$(link) /INCREMENTAL:NO /NOLOGO /LIBPATH:$(EXPAT)\Libs /LIBPATH:$(LIBMBA) /LIBPATH:$(ENCDEC) libexpat.lib libmba.lib encdec.lib /DEF:domc.def /OUT:domc.dll -entry:_DllMainCRTStartup@12 -dll $(OBJS)
+# Normal Flags
+CFLAGS=$(cflags) /ML
+
+all: domc.lib
+  
+# domc.dll: $(OBJS)
+# 	$(link) /INCREMENTAL:NO /NOLOGO /LIBPATH:$(EXPAT)\Libs /LIBPATH:$(LIBMBA) /LIBPATH:$(ENCDEC) libexpat.lib libmba.lib encdec.lib /DEF:domc.def /OUT:domc.dll -entry:_DllMainCRTStartup@12 -dll $(OBJS)
 
 domc.lib: $(OBJS)
 	$(implib) -machine:$(CPU) -out:domc.lib $(OBJS)
 
 .c.obj:
-	$(cc) $(cflags) /I$(EXPAT)\Source\lib /I$(ENCDEC)\src /I$(LIBMBA)\src /Fo$@ $*.c
+	$(cc) $(CFLAGS) /I$(LIBMBA)\src /Fo$@ $*.c
 
 clean:
 	del domc.dll domc.lib domc.exp $(OBJS)
diff -r -U3 domc-0.7.1/src/defines.h domc/src/defines.h
--- domc-0.7.1/src/defines.h	2003-03-22 16:35:36.000000000 -0700
+++ domc/src/defines.h	2004-08-31 18:30:01.078131014 -0600
@@ -7,7 +7,7 @@
 #define HAVE_ENCDEC 0
 #define HAVE_STRDUP 1
 #define HAVE_STRNLEN 0
-#define HAVE_EXPAT 195
+#define HAVE_EXPAT 0
 #define HAVE_MBSTATE 0
 #define HAVE_WCWIDTH 1
 #define HAVE_SNPRINTF 1
@@ -21,7 +21,7 @@
 #define HAVE_ENCDEC 0
 #define HAVE_STRDUP 1
 #define HAVE_STRNLEN 0
-#define HAVE_EXPAT 195
+#define HAVE_EXPAT 0
 #define HAVE_MBSTATE 0
 #define HAVE_WCWIDTH 0
 #define HAVE_SNPRINTF 0
@@ -35,7 +35,7 @@
 #define HAVE_ENCDEC 0
 #define HAVE_STRDUP 1
 #define HAVE_STRNLEN 1
-#define HAVE_EXPAT 195
+#define HAVE_EXPAT 0
 #define HAVE_MBSTATE 1
 #define HAVE_WCWIDTH 1
 #define HAVE_SNPRINTF 1
diff -r -U3 domc-0.7.1/src/domc.h domc/src/domc.h
--- domc-0.7.1/src/domc.h	2004-08-04 17:32:30.000000000 -0600
+++ domc/src/domc.h	2004-08-31 18:30:01.079130884 -0600
@@ -41,6 +41,13 @@
   #include <stdint.h>
 #endif
 
+/* Enable this for hashing and fast access to child node lists */
+#define FAST_NODELIST 1
+
+#if FAST_NODELIST
+#include <mba/hashmap.h>
+#endif
+
 /* DOM_String
  */
 
@@ -185,6 +192,8 @@
             DOM_String *data;
         } ProcessingInstruction;
     } u;
+    unsigned int rtfxRefCount;          /* Reference counting added for RTFX */
+    void* userData;                     /* User data added for RTFX */
 };
 
 DOM_Node *DOM_Node_insertBefore(DOM_Node *node, DOM_Node *newChild, DOM_Node *refChild);
@@ -212,6 +221,10 @@
 	NodeEntry *last;
 	unsigned short filter;
 	struct DOM_NodeList *list; /* Used for entities and notations */
+#if FAST_NODELIST
+	struct hashmap _map;
+#endif
+    unsigned int rtfxRefCount; /* Reference counting added for RTFX */
 };
 
 DOM_Node *DOM_NodeList_item(const DOM_NodeList *nl, int index);
@@ -286,8 +299,10 @@
  * described in the latest W3C drafts at all.
  */
 
+#if HAVE_EXPAT > 0
 int DOM_DocumentLS_load(DOM_DocumentLS *this, const char *uri);
 int DOM_DocumentLS_fread(DOM_DocumentLS *this, FILE *stream);
+#endif
 int DOM_DocumentLS_save(DOM_DocumentLS *this, const char *uri, const DOM_Node *node);
 int DOM_DocumentLS_fwrite(const DOM_DocumentLS *this, FILE *stream);
 
diff -r -U3 domc-0.7.1/src/expatls.c domc/src/expatls.c
--- domc-0.7.1/src/expatls.c	2004-08-04 17:28:49.000000000 -0600
+++ domc/src/expatls.c	2004-08-31 19:17:46.448679654 -0600
@@ -70,6 +70,14 @@
 
 DOM_Node *Document_createNode(DOM_Document *doc, unsigned short nodeType);
 
+static int
+fputds(const DOM_String *s, FILE *stream)
+{
+	return fputs(s, stream);
+}
+
+#if HAVE_EXPAT > 0
+
 struct user_data {
 	DOM_String *buf;
 	size_t siz;
@@ -115,14 +123,6 @@
 	return n;
 }
 
-static int
-fputds(const DOM_String *s, FILE *stream)
-{
-	return fputs(s, stream);
-}
-
-#if HAVE_EXPAT > 0
-
 static void
 xmldecl_fn(void *userData, const XML_Char *version, const XML_Char *encoding, int standalone)
 {
@@ -711,7 +711,7 @@
     size_t l;
     
     while (*s) {
-        l = strcspn(s, "<>&\"'");
+        l = strcspn(s, "<>&\"");
         if (l > 0) {
             fwrite((void*)s, 1, sizeof(DOM_String) * l, stream);
             s += l;
@@ -731,9 +731,6 @@
         case '"':
             fputs("&quot;", stream);
             break;
-        case '\'':
-            fputs("&squot;", stream);
-            break;
         default:
             AMSG("");
             break;
diff -r -U3 domc-0.7.1/src/node.c domc/src/node.c
--- domc-0.7.1/src/node.c	2004-08-04 17:29:12.000000000 -0600
+++ domc/src/node.c	2004-08-31 18:30:01.097128538 -0600
@@ -337,7 +337,6 @@
 DOM_Node *
 DOM_Node_replaceChild(DOM_Node *node, DOM_Node *newChild, DOM_Node *oldChild)
 {
-	DOM_Node *tmp;
 	DOM_MutationEvent evt;
 
     if (node == NULL || newChild == NULL || oldChild == NULL) {
@@ -352,12 +351,7 @@
 		return NULL;
 	}
 
-	for (tmp = node->firstChild;
-					tmp != NULL && tmp != oldChild;
-					tmp = tmp->nextSibling) {
-		;
-	}
-	if (tmp != oldChild) {
+	if (!NodeList_exists(node->childNodes, oldChild)) {
 		DOM_Exception = DOM_NOT_FOUND_ERR;
 		PMNO(DOM_Exception);
 		return NULL;
diff -r -U3 domc-0.7.1/src/nodelist.c domc/src/nodelist.c
--- domc-0.7.1/src/nodelist.c	2004-08-04 17:19:25.000000000 -0600
+++ domc/src/nodelist.c	2004-08-31 18:30:01.117125932 -0600
@@ -30,6 +30,14 @@
 #include "domc.h"
 #include "dom.h"
 
+#if FAST_NODELIST
+static void _removeFromMap(struct hashmap* hm, void* key)
+{
+	void* d = NULL;
+	hashmap_remove(hm, &key, &d);
+}
+#endif
+
 /* NodeList
  */
 
@@ -42,8 +50,16 @@
 		DOM_Exception = errno;
 		PMNO(DOM_Exception);
 	}
+
 	r->_ownerDocument = doc;
 
+	if(hashmap_init(&(r->_map), 0, NULL, NULL, NULL, NULL) == -1) {
+		DOM_Exception = errno;
+		PMNO(DOM_Exception);
+		free(r);
+		r = NULL;
+	}
+
 	return r;
 }
 void
@@ -63,6 +79,7 @@
 				free(tmp); 
 			}
 		}
+		hashmap_deinit(&(nl->_map), NULL, NULL, NULL);
 		free(nl);
 	}
 }
@@ -110,7 +127,8 @@
 NodeList_insert(DOM_NodeList *nl, DOM_Node *newChild, DOM_Node *refChild)
 {
 	NodeEntry *e;
-
+	NodeEntry *s = NULL;
+	
 	if (nl == NULL) {
 		DOM_Exception = NULL_POINTER_ERR;
 		PMNO(DOM_Exception);
@@ -122,12 +140,40 @@
 		return NULL;
 	}
 
+	if(refChild != NULL)
+	{
+#if FAST_NODELIST
+		s = (NodeEntry*)hashmap_get(&(nl->_map), refChild);
+#else
+		for (s = nl->first; s != NULL && s->node != refChild; s = s->next) {
+			;
+		}
+#endif		
+		if(s == NULL || s->node != refChild) {
+			DOM_Exception = DOM_NOT_FOUND_ERR;
+			PMNO(DOM_Exception);
+			return NULL;
+		}		
+	}
+	
 	if ((e = calloc(sizeof *e, 1)) == NULL) {
 		DOM_Exception = errno;
 		PMNO(DOM_Exception);
 		return NULL;
 	}
 
+#if FAST_NODELIST
+	if(hashmap_get(&(nl->_map), newChild) != NULL)
+		_removeFromMap(&(nl->_map), newChild);
+		
+	if(hashmap_put(&(nl->_map), newChild, e) == -1) {
+		DOM_Exception = errno;
+		PMNO(DOM_Exception);
+		free(e);
+		return NULL;
+	}
+#endif
+	
 	e->node = newChild;
 	if (nl->length == 0) {
 		nl->first = nl->last = e;
@@ -136,18 +182,6 @@
 		nl->last->next = e;
 		nl->last = e;
 	} else {
-		NodeEntry *s;
-
-		for (s = nl->first; s != NULL && s->node != refChild; s = s->next) {
-			;
-		}
-		if (s == NULL || s->node != refChild) {
-			DOM_Exception = DOM_NOT_FOUND_ERR;
-			PMNO(DOM_Exception);
-			free(e);
-			return NULL;
-		}
-
 		e->prev = s->prev;
 		e->next = s;
 		if (s == nl->first) {
@@ -184,14 +218,32 @@
 		return NULL;
 	}
 
+#if FAST_NODELIST
+	e = (NodeEntry*)hashmap_get(&(nl->_map), oldChild);
+#else
 	for (e = nl->first; e != NULL && e->node != oldChild; e = e->next) {
 		;
 	}
+#endif
 	if (e == NULL) {
 		DOM_Exception = DOM_NOT_FOUND_ERR;
 		PMNO(DOM_Exception);
 		return NULL;
 	}
+
+#if FAST_NODELIST
+	_removeFromMap(&(nl->_map), oldChild);
+		
+	if(hashmap_get(&(nl->_map), newChild) != NULL)
+		_removeFromMap(&(nl->_map), newChild);
+				
+	if(hashmap_put(&(nl->_map), newChild, e) == -1) {
+		DOM_Exception = errno;
+		PMNO(DOM_Exception);
+		return NULL;
+	}
+#endif
+
 	e->node = newChild;
 
 	if (oldChild->nodeType == DOM_ATTRIBUTE_NODE) {
@@ -216,12 +268,20 @@
 		return NULL;
 	}
 
+#if FAST_NODELIST
+	e = (NodeEntry*)hashmap_get(&(nl->_map), oldChild);
+#else
 	for (e = nl->first; e != NULL && e->node != oldChild; e = e->next) {
 		;
 	}
+#endif
 	if (e == NULL) {
 		return NULL;
 	}
+	
+#if FAST_NODELIST
+	_removeFromMap(&(nl->_map), oldChild);	
+#endif
 
 	if (nl->first == nl->last) {
 		nl->first = nl->last = NULL;
@@ -269,6 +329,18 @@
 		return NULL;
 	}
 
+#if FAST_NODELIST
+	if(hashmap_get(&(nl->_map), newChild) != NULL)
+		_removeFromMap(&(nl->_map), newChild);
+		
+	if(hashmap_put(&(nl->_map), newChild, e) == -1) {
+		DOM_Exception = errno;
+		PMNO(DOM_Exception);
+		free(e);
+		return NULL;
+	}
+#endif
+
 	e->node = newChild;
 	if (nl->first == NULL) {
 		nl->first = nl->last = e;
@@ -311,9 +383,14 @@
 		return 0;
 	}
 
+#if FAST_NODELIST
+	e = (NodeEntry*)hashmap_get(&(nl->_map), child);
+#else	
 	for (e = nl->first; e != NULL && e->node != child; e = e->next) {
 		;
 	}
+#endif
+
 	return e != NULL;
 }