Codebase list texinfo / f4a5a15
Fix missing output when doing info --output - (Closes: #814743) Norbert Preining 8 years ago
3 changed file(s) with 321 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 texinfo (6.1.0.dfsg.1-3) UNRELEASED; urgency=medium
1
2 * cherrypick upstream svn 7022: fix missing output when doing
3 info --output - (Closes: #814743)
4
5 -- Norbert Preining <preining@debian.org> Sun, 21 Feb 2016 10:29:13 +0900
6
07 texinfo (6.1.0.dfsg.1-2) unstable; urgency=medium
18
29 * cherrypick upstream svn 7021 for arg parsing (Closes: #814830)
33 info-manpage-mentiones-nonfree
44 #do-not-require-automake-1.15
55 upstream-svn7021-fix-parsing
6 upstream-svn7022-fix-ouput
0 Fix missing output when doing info --output - (Closes: #814743)
1 upstream svn 7022
2
3 2016-02-20 Gavin Smith <gavinsmith0123@gmail.com>
4
5 * info/info.c (get_initial_file): Handle --file option here
6 instead of in 'main', as well as handling invocation as "info
7 '(FILE)NODE'", and the full path to FILE as the "initial file". Use
8 "dir" as the last resort of the initial file. Don't add a node to the
9 list of nodes to load.
10 (add_initial_nodes): Add "Top" node to list of nodes to load if no
11 others are given. Remove error message for initial_file undefined.
12 (main): Handle --where option separately for --all given and not given.
13 * info/session.c (info_follow_menus): Free initial node if following
14 menus strictly and a menu entry is dangling.
15 * info/t/node-no-file.sh: Change expected error message.
16
17 This is so that "info --output -" outputs the dir node, as used to
18 happen. Vincent Lefevre reported that it doesn't happen for
19 Texinfo 6.1.
20
21 2016-02-15 Gavin Smith <gavinsmith0123@gmail.com>
22
23 * doc/texinfo.tex (\setchapterstyle, \headings, \setchapternewpage)
24 ---
25 info/dir.c | 1
26 info/info.c | 165 +++++++++++++++++++++++++++----------------------
27 info/session.c | 8 ++
28 info/t/node-no-file.sh | 4 -
29 4 files changed, 102 insertions(+), 76 deletions(-)
30
31 --- texinfo.orig/info/dir.c
32 +++ texinfo/info/dir.c
33 @@ -52,6 +52,7 @@
34
35 node = xmalloc (sizeof (NODE));
36 *node = *dir_node;
37 + fprintf(stderr, "%p\n", node);
38
39 return node;
40 }
41 --- texinfo.orig/info/info.c
42 +++ texinfo/info/info.c
43 @@ -165,7 +165,9 @@
44 static void init_messages (void);
45
46
47 -/* Interpret the first non-option argument, either by looking it up as a dir
48 +/* Find the first file to load (and possibly the first node as well).
49 + If the --file option is given, use that as the file, otherwise try to
50 + interpret the first non-option argument, either by looking it up as a dir
51 entry, looking for a file by that name, or finding a man page by that name.
52 Set INITIAL_FILE to the name of the initial Info file. */
53 static void
54 @@ -173,14 +175,69 @@
55 {
56 REFERENCE *entry;
57
58 + /* User used "--file". */
59 + if (user_filename)
60 + {
61 + if (!IS_ABSOLUTE(user_filename) && HAS_SLASH(user_filename)
62 + && !(user_filename[0] == '.' && IS_SLASH(user_filename[1])))
63 + {
64 + /* Prefix "./" to the filename to prevent a lookup
65 + in INFOPATH. */
66 + char *s;
67 + asprintf (&s, "%s%s", "./", user_filename);
68 + free (user_filename);
69 + user_filename = s;
70 + }
71 + if (IS_ABSOLUTE(user_filename) || HAS_SLASH(user_filename))
72 + initial_file = info_add_extension (0, user_filename, 0);
73 + else
74 + initial_file = info_find_fullpath (user_filename, 0);
75 +
76 + if (!initial_file)
77 + {
78 + if (!filesys_error_number)
79 + filesys_error_number = ENOENT;
80 + *error = filesys_error_string (user_filename, filesys_error_number);
81 + }
82 +
83 + return;
84 + }
85 +
86 if (!(*argv)[0])
87 - return;
88 + {
89 + /* No more non-option arguments. */
90 + initial_file = xstrdup("dir");
91 + return;
92 + }
93 +
94 + /* If first argument begins with '(', add it as if it were given with
95 + '--node'. This is to support invoking like
96 + "info '(emacs)Buffers'". If it is a well-formed node spec then
97 + the rest of the arguments are menu entries to follow, or an
98 + index entry. */
99 + if ((*argv)[0][0] == '(')
100 + {
101 + info_parse_node ((*argv)[0]);
102 + if (info_parsed_filename)
103 + {
104 + initial_file = info_find_fullpath (info_parsed_filename, 0);
105 + if (initial_file)
106 + {
107 + add_pointer_to_array (info_new_reference (initial_file,
108 + info_parsed_nodename),
109 + ref_index, ref_list, ref_slots, 2);
110 + /* Remove this argument from the argument list. */
111 + memmove (*argv, *argv + 1, *argc-- * sizeof (char *));
112 + return;
113 + }
114 + }
115 + }
116
117 /* If there are any more arguments, the initial file is the
118 dir entry given by the first one. */
119 {
120 - /* If they say info info, show them info-stnd.texi. (Get
121 - info.texi with info -f info.) */
122 + /* If they say info info (or info -O info, etc.), show them
123 + info-stnd.texi. (Get info.texi with info -f info.) */
124 if ((*argv)[0] && mbscasecmp ((*argv)[0], "info") == 0)
125 (*argv)[0] = "info-stnd";
126
127 @@ -267,8 +324,8 @@
128 }
129 }
130
131 - /* Otherwise, we want the dir node. The only node to be displayed
132 - or output will be "Top". */
133 + /* Otherwise, use the dir node. */
134 + initial_file = xstrdup("dir");
135 return;
136 }
137
138 @@ -310,12 +367,7 @@
139 int j;
140
141 if (!initial_file)
142 - {
143 - free (*error);
144 - asprintf (error, _("No file given for node '%s'."),
145 - user_nodenames[i]);
146 - continue;
147 - }
148 + continue; /* Shouldn't happen. */
149
150 /* Check for a node by this name, and if there isn't one
151 look for an inexact match. */
152 @@ -413,9 +465,16 @@
153 free (program);
154 }
155
156 + /* Default is the "Top" node if there were no other nodes. */
157 + if (ref_index == 0 && initial_file)
158 + {
159 + add_pointer_to_array (info_new_reference (initial_file, "Top"),
160 + ref_index, ref_list, ref_slots, 2);
161 + }
162 +
163 /* If there are arguments remaining, they are the names of menu items
164 in sequential info files starting from the first one loaded. */
165 - else if (*argv && ref_index > 0)
166 + if (*argv && ref_index > 0)
167 {
168 NODE *initial_node; /* Node to start following menus from. */
169 NODE *node_via_menus;
170 @@ -459,6 +518,7 @@
171 }
172 }
173
174 + fprintf(stderr, "B %p\n", initial_node);
175 /* If there are arguments remaining, follow menus inexactly. */
176 if (argc != 0)
177 {
178 @@ -883,6 +943,18 @@
179 /* If only one match, don't start in a menu of matches. */
180 if (ref_index == 1)
181 all_matches_p = 0;
182 +
183 + /* --where */
184 + if (print_where_p)
185 + {
186 + int i;
187 + if (!ref_list)
188 + exit (1);
189 +
190 + for (i = 0; ref_list[i]; i++)
191 + printf ("%s\n", ref_list[i]->filename);
192 + exit (0);
193 + }
194 }
195 else
196 {
197 @@ -900,57 +972,7 @@
198 }
199 }
200
201 - /* User used "--file". */
202 - if (user_filename)
203 - {
204 - if (!IS_ABSOLUTE(user_filename) && HAS_SLASH(user_filename)
205 - && !(user_filename[0] == '.' && IS_SLASH(user_filename[1])))
206 - {
207 - /* Prefix "./" to the filename to prevent a lookup
208 - in INFOPATH. */
209 - char *s;
210 - asprintf (&s, "%s%s", "./", user_filename);
211 - free (user_filename);
212 - user_filename = s;
213 - }
214 - if (IS_ABSOLUTE(user_filename) || HAS_SLASH(user_filename))
215 - initial_file = info_add_extension (0, user_filename, 0);
216 - else
217 - initial_file = info_find_fullpath (user_filename, 0);
218 -
219 - if (!initial_file)
220 - {
221 - if (!filesys_error_number)
222 - filesys_error_number = ENOENT;
223 - error = filesys_error_string (user_filename,
224 - filesys_error_number);
225 - }
226 - else
227 - add_pointer_to_array (info_new_reference (initial_file, "Top"),
228 - ref_index, ref_list, ref_slots, 2);
229 - goto skip_get_initial_file;
230 - }
231 -
232 - /* If first argument begins with '(', add it as if it were given with
233 - '--node'. This is to support invoking like
234 - "info '(emacs)Buffers'". If it is a well-formed node spec then
235 - the rest of the arguments are menu entries to follow, or an
236 - index entry. */
237 - if (argv[0] && argv[0][0] == '(')
238 - {
239 - info_parse_node (argv[0]);
240 - if (info_parsed_filename)
241 - {
242 - add_pointer_to_array (info_new_reference (info_parsed_filename,
243 - info_parsed_nodename),
244 - ref_index, ref_list, ref_slots, 2);
245 - memmove (argv, argv + 1, argc-- * sizeof (char *));
246 - goto skip_get_initial_file;
247 - }
248 - }
249 -
250 get_initial_file (&argc, &argv, &error);
251 -skip_get_initial_file:
252
253 /* If the user specified `--index-search=STRING',
254 start the info session in the node corresponding
255 @@ -990,18 +1012,15 @@
256 {
257 add_initial_nodes (argc, argv, &error);
258 }
259 - }
260
261 - /* --where */
262 - if (print_where_p)
263 - {
264 - int i;
265 - if (!ref_list)
266 - exit (1);
267 + /* --where */
268 + if (print_where_p)
269 + {
270 + if (initial_file)
271 + printf ("%s\n", initial_file);
272 + exit (0);
273 + }
274
275 - for (i = 0; ref_list[i]; i++)
276 - printf ("%s\n", ref_list[i]->filename);
277 - exit (0);
278 }
279
280 /* --output */
281 --- texinfo.orig/info/session.c
282 +++ texinfo/info/session.c
283 @@ -2815,7 +2815,13 @@
284 entry->label,
285 node_printed_rep (initial_node));
286 }
287 - return strict ? 0 : initial_node;
288 + if (strict)
289 + {
290 + free_history_node (initial_node);
291 + return 0;
292 + }
293 + else
294 + return initial_node;
295 }
296
297 debug (3, ("node: %s, %s", node->fullpath, node->nodename));
298 --- texinfo.orig/info/t/node-no-file.sh
299 +++ texinfo/info/t/node-no-file.sh
300 @@ -1,5 +1,5 @@
301 #!/bin/sh
302 -# Copyright (C) 2014 Free Software Foundation, Inc.
303 +# Copyright (C) 2014, 2016 Free Software Foundation, Inc.
304 #
305 # This program is free software; you can redistribute it and/or modify
306 # it under the terms of the GNU General Public License as published by
307 @@ -19,4 +19,4 @@
308
309 # Ask for a node without saying which file it's in
310 $GINFO --output - --node nodename \
311 - 2>&1 | grep 'No file given'
312 + 2>&1 | grep 'Cannot find node'