diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2000-03-27 03:37:59 -0500 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2000-03-27 03:37:59 -0500 |
commit | c68ecb8b21bef3908cb17f8d1d4af694bf7e7137 (patch) | |
tree | b433eeff77822973f7bdb7de3642e7a21ccbe5a8 /WWW/Library/Implementation/HTRules.c | |
parent | d70fdcf7f031566fd582362899099f9fba23a7ac (diff) | |
download | lynx-snapshots-c68ecb8b21bef3908cb17f8d1d4af694bf7e7137.tar.gz |
snapshot of project "lynx", label v2-8-3dev_23
Diffstat (limited to 'WWW/Library/Implementation/HTRules.c')
-rw-r--r-- | WWW/Library/Implementation/HTRules.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c index cc36e8d7..e8177af1 100644 --- a/WWW/Library/Implementation/HTRules.c +++ b/WWW/Library/Implementation/HTRules.c @@ -84,20 +84,15 @@ PUBLIC int HTAddRule ARGS5( CONST char *, cond) { /* BYTE_ADDRESSING removed and memory check - AS - 1 Sep 93 */ rule * temp; - char * pPattern; + char * pPattern = NULL; temp = (rule *)calloc(1, sizeof(*temp)); if (temp==NULL) outofmem(__FILE__, "HTAddRule"); - pPattern = (char *)malloc(strlen(pattern)+1); - if (pPattern==NULL) - outofmem(__FILE__, "HTAddRule"); if (equiv) { /* Two operands */ - char * pEquiv = (char *)malloc(strlen(equiv)+1); - if (pEquiv==NULL) - outofmem(__FILE__, "HTAddRule"); + char * pEquiv = NULL; + StrAllocCopy(pEquiv, equiv); temp->equiv = pEquiv; - strcpy(pEquiv, equiv); } else { temp->equiv = 0; } @@ -105,10 +100,10 @@ PUBLIC int HTAddRule ARGS5( StrAllocCopy(temp->condition_op, cond_op); StrAllocCopy(temp->condition, cond); } + StrAllocCopy(pPattern, pattern); temp->pattern = pPattern; temp->op = op; - strcpy(pPattern, pattern); if (equiv) { CTRACE((tfp, "Rule: For `%s' op %d `%s'", pattern, op, equiv)); } else { @@ -330,24 +325,23 @@ char * HTTranslate ARGS1( } else { char * ins = strchr(r->equiv, '*'); /* Insertion point */ if (ins) { /* Consistent rule!!! */ - char * temp = (char *)malloc( - strlen(r->equiv)-1 + m + 1); - if (temp==NULL) - outofmem(__FILE__, "HTTranslate"); /* NT & AS */ - strncpy(temp, r->equiv, ins-r->equiv); - /* Note: temp may be unterminated now! */ - strncpy(temp+(ins-r->equiv), q, m); /* Matched bit */ - strcpy (temp+(ins-r->equiv)+m, ins+1); /* Last bit */ + char * temp = NULL; + + HTSprintf0(&temp, "%.*s%.*s%s", + ins - r->equiv, + r->equiv, + m, + q, + ins + 1); CTRACE((tfp, "For `%s' using `%s'\n", current, temp)); FREE(current); current = temp; /* Use this */ } else { /* No insertion point */ - char * temp = (char *)malloc(strlen(r->equiv)+1); - if (temp==NULL) - outofmem(__FILE__, "HTTranslate"); /* NT & AS */ - strcpy(temp, r->equiv); + char * temp = NULL; + + StrAllocCopy(temp, r->equiv); CTRACE((tfp, "For `%s' using `%s'\n", current, temp)); FREE(current); |