Skip to content

Commit

Permalink
xmlcatalog: restore ability to query system catalog easily
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jnpkrn authored and nwellnhof committed Oct 21, 2017
1 parent 5e986e3 commit 6b780f6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions xmlcatalog.c
Expand Up @@ -312,7 +312,8 @@ static void usage(const char *name) {
/* split into 2 printf's to avoid overly long string (gcc warning) */
printf("\
Usage : %s [options] catalogfile entities...\n\
\tParse the catalog file and query it for the entities\n\
\tParse the catalog file (void specification possibly expressed as \"\"\n\
\tappoints the default system one) and query it for the entities\n\
\t--sgml : handle SGML Super catalogs for --add and --del\n\
\t--shell : run a shell allowing interactive queries\n\
\t--create : create a new catalog\n\
Expand Down Expand Up @@ -408,11 +409,18 @@ int main(int argc, char **argv) {
continue;
} else if (argv[i][0] == '-')
continue;
filename = argv[i];

if (filename == NULL && argv[i][0] == '\0') {
/* Interpret empty-string catalog specification as
a shortcut for a default system catalog. */
xmlInitializeCatalog();
} else {
filename = argv[i];
ret = xmlLoadCatalog(argv[i]);
if ((ret < 0) && (create)) {
xmlCatalogAdd(BAD_CAST "catalog", BAD_CAST argv[i], NULL);
}
}
break;
}

Expand Down

0 comments on commit 6b780f6

Please sign in to comment.