~ubuntu-branches/ubuntu/trusty/libxslt/trusty

« back to all changes in this revision

Viewing changes to debian/patches/0003-code-fix-and-docs-modification.patch

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2012-10-03 00:22:53 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20121003002253-e6cjjwgepg5emub1
Tags: 1.1.27-1
* New upstream release (Closes: #448205, #683353)
* debian/rules:
  + Add hardening flags for dbg package in LDFLAGS (Closes: #681163)
* debian/control:
  - std-ver: 3.9.3 -> 3.9.4, no change required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From: YunQiang Su <wzssyqa@gmail.com>
2
 
Date: Mon, 28 May 2012 18:36:18 +0800
3
 
Subject: code fix and docs modification
4
 
 
5
 
---
6
 
 doc/xsltproc.1      |    8 ++++++++
7
 
 doc/xsltproc.xml    |    5 +++++
8
 
 libxslt/functions.c |   26 +++++++++++++++++++++-----
9
 
 python/generator.py |   18 +++++++++++++-----
10
 
 4 files changed, 47 insertions(+), 10 deletions(-)
11
 
 
12
 
diff --git a/doc/xsltproc.1 b/doc/xsltproc.1
13
 
index d94e7a2..328ef7b 100644
14
 
--- a/doc/xsltproc.1
15
 
+++ b/doc/xsltproc.1
16
 
@@ -161,6 +161,14 @@ as described in RFC 2396 and laters\. This means, that e\.g\.
17
 
 will maybe not work, but
18
 
 \fB\-o directory/\fR
19
 
 will\.
20
 
+.sp
21
 
+Also note that if there is no output to xsltproc,
22
 
+\fIFILE\fR
23
 
+will not be created at all\&. An empty file will
24
 
+\fBnot\fR
25
 
+be created\.
26
 
+.sp .5v
27
 
+.RE
28
 
 .RE
29
 
 .PP
30
 
 \fB\-\-encoding \fR\fB\fIENCODING\fR\fR
31
 
diff --git a/doc/xsltproc.xml b/doc/xsltproc.xml
32
 
index d3849e2..a0cd77f 100644
33
 
--- a/doc/xsltproc.xml
34
 
+++ b/doc/xsltproc.xml
35
 
@@ -282,6 +282,11 @@
36
 
                                e.g. <option>-o directory</option> will maybe not work,
37
 
                                but <option>-o directory/</option> will.
38
 
                        </para>
39
 
+                       <para>
40
 
+                               Also note that if there is no output to xsltproc,
41
 
+                               <replaceable>FILE</replaceable> will not be created at all.
42
 
+                               An empty file will <emphasis role="bold">not</emphasis> be created.
43
 
+                       </para>
44
 
                </note>
45
 
        </listitem>
46
 
                </varlistentry>
47
 
diff --git a/libxslt/functions.c b/libxslt/functions.c
48
 
index 4720c7a..de962f4 100644
49
 
--- a/libxslt/functions.c
50
 
+++ b/libxslt/functions.c
51
 
@@ -654,8 +654,9 @@ xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs)
52
 
 void
53
 
 xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
54
 
     xmlNodePtr cur = NULL;
55
 
-    unsigned long val;
56
 
-    xmlChar str[20];
57
 
+    long val;
58
 
+    xmlChar str[30];
59
 
+    xmlDocPtr doc;
60
 
 
61
 
     if (nargs == 0) {
62
 
        cur = ctxt->context->node;
63
 
@@ -694,9 +695,24 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
64
 
      * Okay this is ugly but should work, use the NodePtr address
65
 
      * to forge the ID
66
 
      */
67
 
-    val = (unsigned long)((char *)cur - (char *)0);
68
 
-    val /= sizeof(xmlNode);
69
 
-    sprintf((char *)str, "id%ld", val);
70
 
+    if (cur->type != XML_NAMESPACE_DECL)
71
 
+        doc = cur->doc;
72
 
+    else {
73
 
+        xmlNsPtr ns = (xmlNsPtr) cur;
74
 
+
75
 
+        if (ns->context != NULL)
76
 
+            doc = ns->context;
77
 
+        else
78
 
+            doc = ctxt->context->doc;
79
 
+
80
 
+    }
81
 
+
82
 
+    val = (long)((char *)cur - (char *)doc);
83
 
+    if (val >= 0) {
84
 
+      sprintf((char *)str, "idp%ld", val);
85
 
+    } else {
86
 
+      sprintf((char *)str, "idm%ld", -val);
87
 
+    }
88
 
     valuePush(ctxt, xmlXPathNewString(str));
89
 
 }
90
 
 
91
 
diff --git a/python/generator.py b/python/generator.py
92
 
index 2269106..63657f1 100755
93
 
--- a/python/generator.py
94
 
+++ b/python/generator.py
95
 
@@ -6,15 +6,23 @@
96
 
 functions = {}
97
 
 enums = {} # { enumType: { enumConstant: enumValue } }
98
 
 
99
 
+import os
100
 
+import sys
101
 
 import string
102
 
 
103
 
+if __name__ == "__main__":
104
 
+    # launched as a script
105
 
+    srcPref = os.path.dirname(sys.argv[0])
106
 
+else:
107
 
+    # imported
108
 
+    srcPref = os.path.dirname(__file__)
109
 
+
110
 
 #######################################################################
111
 
 #
112
 
 #  That part if purely the API acquisition phase from the
113
 
 #  XML API description
114
 
 #
115
 
 #######################################################################
116
 
-import os
117
 
 import xmllib
118
 
 try:
119
 
     import sgmlop
120
 
@@ -442,20 +450,20 @@ def buildStubs():
121
 
     global unknown_types
122
 
 
123
 
     try:
124
 
-        f = open("libxslt-api.xml")
125
 
+        f = open(os.path.join(srcPref,"libxslt-api.xml"))
126
 
         data = f.read()
127
 
         (parser, target)  = getparser()
128
 
         parser.feed(data)
129
 
         parser.close()
130
 
     except IOError, msg:
131
 
         try:
132
 
-            f = open("../doc/libxslt-api.xml")
133
 
+            f = open(os.path.join(srcPref,"..","doc","libxslt-api.xml"))
134
 
             data = f.read()
135
 
             (parser, target)  = getparser()
136
 
             parser.feed(data)
137
 
             parser.close()
138
 
         except IOError, msg:
139
 
-            print "../doc/libxslt-api.xml", ":", msg
140
 
+            print os.path.join(srcPref,"..","doc","libxslt-api.xml"), ":", msg
141
 
 
142
 
     n = len(functions.keys())
143
 
     print "Found %d functions in libxslt-api.xml" % (n)
144
 
@@ -463,7 +471,7 @@ def buildStubs():
145
 
     py_types['pythonObject'] = ('O', "pythonObject", "pythonObject",
146
 
                                 "pythonObject", "libxml_")
147
 
     try:
148
 
-        f = open("libxslt-python-api.xml")
149
 
+        f = open(os.path.join(srcPref,"libxslt-python-api.xml"))
150
 
         data = f.read()
151
 
         (parser, target)  = getparser()
152
 
         parser.feed(data)