Skip to content

Commit 6b780f6

Browse files
jnpkrnnwellnhof
authored andcommitted
xmlcatalog: restore ability to query system catalog easily
I've noticed that easy way of locating a DocBook XSLT in a configure script of another project doesn't work anymore. It is using something like: xmlcatalog "" ${DOCBOOK_XSL_URI}/${DOCBOOK_XSL_PATH}. The script is then forced to a plain, suboptimal search using find utility. Indeed, I retrospectively realize that the check was working just by mere accident given that the window this presumably side-effect was applicable had not lasted long, some 8 months between 054c716 introducing xmlInitializeCatalog in the LIBXML_TEST_VERSION-rooted call chain, and f65128f reverting that again. So while one can state /etc/xml/catalog constant explicitly, in some use cases (such as the mentioned one -- that's why I wanted to omit stating the full path in the first place), this is rather an implementation detail, perhaps subject to change from that POV. Therefore I propose to restore that behaviour in the targeted manner without global disruptions this time around. As a side-effect, this fixes indenting of the affected part.
1 parent 5e986e3 commit 6b780f6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

xmlcatalog.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ static void usage(const char *name) {
312312
/* split into 2 printf's to avoid overly long string (gcc warning) */
313313
printf("\
314314
Usage : %s [options] catalogfile entities...\n\
315-
\tParse the catalog file and query it for the entities\n\
315+
\tParse the catalog file (void specification possibly expressed as \"\"\n\
316+
\tappoints the default system one) and query it for the entities\n\
316317
\t--sgml : handle SGML Super catalogs for --add and --del\n\
317318
\t--shell : run a shell allowing interactive queries\n\
318319
\t--create : create a new catalog\n\
@@ -408,11 +409,18 @@ int main(int argc, char **argv) {
408409
continue;
409410
} else if (argv[i][0] == '-')
410411
continue;
411-
filename = argv[i];
412+
413+
if (filename == NULL && argv[i][0] == '\0') {
414+
/* Interpret empty-string catalog specification as
415+
a shortcut for a default system catalog. */
416+
xmlInitializeCatalog();
417+
} else {
418+
filename = argv[i];
412419
ret = xmlLoadCatalog(argv[i]);
413420
if ((ret < 0) && (create)) {
414421
xmlCatalogAdd(BAD_CAST "catalog", BAD_CAST argv[i], NULL);
415422
}
423+
}
416424
break;
417425
}
418426

0 commit comments

Comments
 (0)