X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;ds=inline;f=util%2Fres.c;h=df6d2217a488b14b59b8c55e517620706706a45b;hb=d310ea540d84722bcda486995c29b4dd2b08cb61;hp=90cf2d969d0228cfc98a99e89c3fc0bbc37d113f;hpb=c71dc4cafd880d69e6b14b308630fbc69a7d7b23;p=idzebra-moved-to-github.git diff --git a/util/res.c b/util/res.c index 90cf2d9..df6d221 100644 --- a/util/res.c +++ b/util/res.c @@ -1,4 +1,4 @@ -/* $Id: res.c,v 1.35 2004-06-14 23:42:33 adam Exp $ +/* $Id: res.c,v 1.37.2.2 2006-08-14 10:39:24 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -15,11 +15,10 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. -*/ +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include #include @@ -32,7 +31,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #endif #include -#include struct res_entry { char *name; @@ -80,16 +78,19 @@ static char *xstrdup_env(const char *src) char *env_val; int k = 0; i = i + 2; - while (k < 127 && src[i] && !strchr("}\n\r\f", src[i])) + while (k < 127 && src[i] && !strchr(":}\n\r\f", src[i])) envname[k++] = src[i++]; envname[k] = '\0'; - if (src[i] == '}') - i++; + env_val = getenv(envname); if (env_val) env_strlen += 1 + strlen(env_val); else env_strlen++; + while (src[i] && !strchr("}\n\r\f", src[i])) + i++; + if (src[i] == '}') + i++; } else i++; @@ -104,17 +105,25 @@ static char *xstrdup_env(const char *src) char *env_val; int k = 0; i = i + 2; - while(k < 127 && src[i] && !strchr("}\n\r\f", src[i])) + while(k < 127 && src[i] && !strchr(":}\n\r\f", src[i])) envname[k++] = src[i++]; envname[k] = '\0'; - if (src[i] == '}') - i++; env_val = getenv(envname); if (env_val) { strcpy(dst+j, env_val); j += strlen(env_val); } + else if (src[i] == ':' && src[i+1] == '-') + { + i = i + 2; + while (src[i] && !strchr("}\n\r\f", src[i])) + dst[j++] = src[i++]; + } + while (src[i] && !strchr("}\n\r\f", src[i])) + i++; + if (src[i] == '}') + i++; } else dst[j++] = src[i++]; @@ -135,8 +144,6 @@ static void reread (Res r) assert (r); r->init = 1; - val_buf = (char*) xmalloc (val_max); - if (!r->name) return; @@ -146,6 +153,7 @@ static void reread (Res r) logf (LOG_WARN|LOG_ERRNO, "Cannot open `%s'", r->name); return ; } + val_buf = (char*) xmalloc (val_max); while (1) { line = fgets (fr_buf, sizeof(fr_buf)-1, fr);