beta-0.89.2
[luatex.git] / source / texk / web2c / lib / setupvar.c
blobb44ddc7e71c21bcee6dcc44a4baa83f6d5a3686d
1 /* setupvar.c: Look up a value in texmf.cnf or use default.
3 Adapted in 2010 by Peter Breitenlohner. Public domain.
4 Written in 1995 by Karl Berry. Public domain. */
6 #include <w2c/config.h>
7 #include "lib.h"
8 #include <kpathsea/variable.h>
10 /* Look up VAR_NAME in texmf.cnf; assign either the value found there or
11 DFLT to *VAR. */
13 void
14 setupboundvariable (integer *var, const_string var_name, integer dflt)
16 string expansion = kpse_var_value (var_name);
17 *var = dflt;
19 if (expansion) {
20 integer conf_val = atoi (expansion);
21 /* It's ok if the cnf file specifies 0 for extra_mem_{top,bot}, etc.
22 But negative numbers are always wrong. */
23 if (conf_val < 0 || (conf_val == 0 && dflt > 0)) {
24 fprintf (stderr,
25 "%s: Bad value (%ld) in environment or texmf.cnf for %s, keeping %ld.\n",
26 kpse_invocation_name,
27 (long) conf_val, var_name, (long) dflt);
28 } else {
29 *var = conf_val; /* We'll make further checks later. */
31 free (expansion);