"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/mx/accmacvar.c" between
s-nail-14.9.18.tar.xz and s-nail-14.9.19.tar.xz

About: S-nail is a mail processing system intended to provide the functionality of the POSIX mailx command and offers extensions for line editing, IDNA, MIME, S/MIME, SMTP and POP3 (and IMAP). It is usable as a mail batch language.

accmacvar.c  (s-nail-14.9.18.tar.xz):accmacvar.c  (s-nail-14.9.19.tar.xz)
skipping to change at line 399 skipping to change at line 399
/* Check for special housekeeping. _VIP_SET_POST and _VIP_CLEAR do not fail /* Check for special housekeeping. _VIP_SET_POST and _VIP_CLEAR do not fail
* (or propagate errors), _VIP_SET_PRE may and should case abortion */ * (or propagate errors), _VIP_SET_PRE may and should case abortion */
static boole a_amv_var_check_vips(enum a_amv_var_vip_mode avvm, static boole a_amv_var_check_vips(enum a_amv_var_vip_mode avvm,
enum okeys okey, char const **val); enum okeys okey, char const **val);
/* _VF_NUM / _VF_POSNUM */ /* _VF_NUM / _VF_POSNUM */
static boole a_amv_var_check_num(char const *val, boole posnum); static boole a_amv_var_check_num(char const *val, boole posnum);
/* Verify that the given name is an acceptable variable name */ /* Verify that the given name is an acceptable variable name */
static boole a_amv_var_check_name(char const *name); static boole a_amv_var_check_name(char const *name, boole forenviron);
/* Try to reverse lookup a name to an enum okeys mapping, zeroing avcp. /* Try to reverse lookup a name to an enum okeys mapping, zeroing avcp.
* Updates .avc_name and .avc_hash; .avc_map is NULL if none found. * Updates .avc_name and .avc_hash; .avc_map is NULL if none found.
* We may try_harder to identify name: it may be an extended chain. * We may try_harder to identify name: it may be an extended chain.
* That test only is actually performed by the latter(, then) */ * That test only is actually performed by the latter(, then) */
static boole a_amv_var_revlookup(struct a_amv_var_carrier *avcp, static boole a_amv_var_revlookup(struct a_amv_var_carrier *avcp,
char const *name, boole try_harder); char const *name, boole try_harder);
static boole a_amv_var_revlookup_chain(struct a_amv_var_carrier *avcp, static boole a_amv_var_revlookup_chain(struct a_amv_var_carrier *avcp,
char const *name); char const *name);
skipping to change at line 1321 skipping to change at line 1321
/* TODO Unless we store integers we need to look and forbid, because /* TODO Unless we store integers we need to look and forbid, because
* TODO callee may not be able to swallow, e.g., "-1" */ * TODO callee may not be able to swallow, e.g., "-1" */
if(posnum && (ids & su_IDEC_STATE_SEEN_MINUS)) if(posnum && (ids & su_IDEC_STATE_SEEN_MINUS))
rv = FAL0; rv = FAL0;
} }
NYD2_OU; NYD2_OU;
return rv; return rv;
} }
static boole static boole
a_amv_var_check_name(char const *name){ a_amv_var_check_name(char const *name, boole forenviron){
char c; char c;
boole rv;
char const *cp; char const *cp;
boole rv;
NYD2_IN; NYD2_IN;
rv = TRU1;
/* Empty name not tested, as documented */ /* Empty name not tested, as documented */
for(rv = TRU1, cp = name; (c = *cp) != '\0'; ++cp) for(cp = name; (c = *cp) != '\0'; ++cp)
if(c == '=' || su_cs_is_space(c) || su_cs_is_cntrl(c)){ if(c == '=' || su_cs_is_space(c) || su_cs_is_cntrl(c)){
n_err(_("Variable names may not contain =, space or control " n_err(_("Variable names may not contain =, space or control "
"characters: %s\n"), n_shexp_quote_cp(name, TRU1)); "characters: %s\n"), n_shexp_quote_cp(name, TRU1));
rv = FAL0; rv = FAL0;
break; goto jleave;
} }
if(rv && forenviron && !(rv = n_shexp_is_valid_varname(name, TRU1)))
n_err(_("Invalid environment variable: %s\n"),
n_shexp_quote_cp(name, TRU1));
jleave:
NYD2_OU; NYD2_OU;
return rv; return rv;
} }
static boole static boole
a_amv_var_revlookup(struct a_amv_var_carrier *avcp, char const *name, a_amv_var_revlookup(struct a_amv_var_carrier *avcp, char const *name,
boole try_harder){ boole try_harder){
u32 hash, i, j; u32 hash, i, j;
struct a_amv_var_map const *avmp; struct a_amv_var_map const *avmp;
char c; char c;
skipping to change at line 2576 skipping to change at line 2584
*cp2++ = c; *cp2++ = c;
*cp2 = '\0'; *cp2 = '\0';
if(c == '\0') if(c == '\0')
cp = n_UNCONST(n_empty); cp = n_UNCONST(n_empty);
else else
++cp; ++cp;
if(varbuf == cp2){ if(varbuf == cp2){
n_err(_("Empty variable name ignored\n")); n_err(_("Empty variable name ignored\n"));
++errs; ++errs;
}else if(!a_amv_var_check_name(varbuf)){ }else if(!a_amv_var_check_name(varbuf,
((avscf & a_AMV_VSETCLR_ENV) != 0))){
/* Log done */ /* Log done */
++errs; ++errs;
}else{ }else{
struct a_amv_var_carrier avc; struct a_amv_var_carrier avc;
boole isunset; boole isunset;
if((isunset = (varbuf[0] == 'n' && varbuf[1] == 'o'))){ if((isunset = (varbuf[0] == 'n' && varbuf[1] == 'o'))){
if(c != '\0') if(c != '\0')
n_err(_("Un`set'ting via \"no\" takes no value: %s=%s\n"), n_err(_("Un`set'ting via \"no\" takes no value: %s=%s\n"),
varbuf, n_shexp_quote_cp(cp, FAL0)); varbuf, n_shexp_quote_cp(cp, FAL0));
skipping to change at line 3509 skipping to change at line 3518
else{ else{
if(a_amv_lopts == NULL){ if(a_amv_lopts == NULL){
n_err(_("unset: cannot use `local' in this context\n")); n_err(_("unset: cannot use `local' in this context\n"));
err = 1; err = 1;
goto jleave; goto jleave;
} }
avscf = a_AMV_VSETCLR_LOCAL; avscf = a_AMV_VSETCLR_LOCAL;
} }
for(err = 0, ap = vp; *ap != NULL; ++ap){ for(err = 0, ap = vp; *ap != NULL; ++ap){
if(!a_amv_var_check_name(*ap)){ if(!a_amv_var_check_name(*ap, FAL0)){
err |= 1; err |= 1;
continue; continue;
} }
a_amv_var_revlookup(&avc, *ap, FAL0); a_amv_var_revlookup(&avc, *ap, FAL0);
err |= !a_amv_var_clear(&avc, avscf); err |= !a_amv_var_clear(&avc, avscf);
} }
jleave: jleave:
NYD_OU; NYD_OU;
skipping to change at line 3535 skipping to change at line 3544
char **ap; char **ap;
NYD_IN; NYD_IN;
if(*(ap = v) == NULL) if(*(ap = v) == NULL)
v = NULL; v = NULL;
else{ else{
struct n_string msg, *msgp = &msg; struct n_string msg, *msgp = &msg;
msgp = n_string_creat(msgp); msgp = n_string_creat(msgp);
for(; *ap != NULL; ++ap) for(; *ap != NULL; ++ap)
if(a_amv_var_check_name(*ap)) if(a_amv_var_check_name(*ap, FAL0))
a_amv_var_show(*ap, n_stdout, msgp); a_amv_var_show(*ap, n_stdout, msgp);
n_string_gut(msgp); n_string_gut(msgp);
} }
NYD_OU; NYD_OU;
return (v == NULL ? !STOP : !OKAY); /* xxx 1:bad 0:good -- do some */ return (v == NULL ? !STOP : !OKAY); /* xxx 1:bad 0:good -- do some */
} }
FL int FL int
c_environ(void *v){ c_environ(void *v){
struct a_amv_var_carrier avc; struct a_amv_var_carrier avc;
int err; int err;
char **ap; char **ap;
boole islnk; boole islnk;
NYD_IN; NYD_IN;
if((islnk = su_cs_starts_with_case("link", *(ap = v))) || if((islnk = su_cs_starts_with_case("link", *(ap = v))) ||
su_cs_starts_with_case("unlink", *ap)){ su_cs_starts_with_case("unlink", *ap)){
for(err = 0; *++ap != NIL;){ for(err = 0; *++ap != NIL;){
if(!a_amv_var_check_name(*ap)){ if(!a_amv_var_check_name(*ap, TRU1)){
err = 1; err = 1;
continue; continue;
} }
a_amv_var_revlookup(&avc, *ap, TRU1); a_amv_var_revlookup(&avc, *ap, TRU1);
if(a_amv_var_lookup(&avc, (a_AMV_VLOOK_NONE | if(a_amv_var_lookup(&avc, (a_AMV_VLOOK_NONE |
a_AMV_VLOOK_LOG_OBSOLETE)) && (islnk || a_AMV_VLOOK_LOG_OBSOLETE)) && (islnk ||
(avc.avc_var->av_flags & a_AMV_VF_EXT_LINKED))){ (avc.avc_var->av_flags & a_AMV_VF_EXT_LINKED))){
if(!islnk){ if(!islnk){
skipping to change at line 3595 skipping to change at line 3604
n_err(_("environ: link: cannot link to non-existent: %s\n"), n_err(_("environ: link: cannot link to non-existent: %s\n"),
*ap); *ap);
err = 1; err = 1;
} }
} }
} }
}else if(su_cs_starts_with_case("set", *ap)) }else if(su_cs_starts_with_case("set", *ap))
err = !a_amv_var_c_set(++ap, a_AMV_VSETCLR_ENV); err = !a_amv_var_c_set(++ap, a_AMV_VSETCLR_ENV);
else if(su_cs_starts_with_case("unset", *ap)){ else if(su_cs_starts_with_case("unset", *ap)){
for(err = 0; *++ap != NIL;){ for(err = 0; *++ap != NIL;){
if(!a_amv_var_check_name(*ap)){ if(!a_amv_var_check_name(*ap, TRU1)){
err = 1; err = 1;
continue; continue;
} }
a_amv_var_revlookup(&avc, *ap, FAL0); a_amv_var_revlookup(&avc, *ap, FAL0);
if(!a_amv_var_clear(&avc, a_AMV_VSETCLR_ENV)) if(!a_amv_var_clear(&avc, a_AMV_VSETCLR_ENV))
err = 1; err = 1;
} }
}else{ }else{
 End of changes. 13 change blocks. 
10 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)