aboutsummaryrefslogtreecommitdiffstats
path: root/g10/build-packet.c
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2006-03-09 19:43:29 +0000
committerDavid Shaw <[email protected]>2006-03-09 19:43:29 +0000
commite9143116087444483120a163ea7947db40c94965 (patch)
tree7c3f6241e442ef9a74b745375bff4e1143fa56d5 /g10/build-packet.c
parentkeep on walking towards rc3 (diff)
downloadgnupg-e9143116087444483120a163ea7947db40c94965.tar.gz
gnupg-e9143116087444483120a163ea7947db40c94965.zip
* build-packet.c (string_to_notation): Add ability to indicate a notation
to be deleted with a '-' prefix. * keyedit.c (menu_set_notation): Use it here to allow deleting a notation marked with '-'. This works with either "-notation" or "-notation=value".
Diffstat (limited to '')
-rw-r--r--g10/build-packet.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/g10/build-packet.c b/g10/build-packet.c
index 2ffc758e2..5c239b79e 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -891,12 +891,18 @@ build_attribute_subpkt(PKT_user_id *uid,byte type,
struct notation *
string_to_notation(const char *string,int is_utf8)
{
- const char *s,*i;
- int saw_at=0,highbit=0;
+ const char *s;
+ int saw_at=0;
struct notation *notation;
notation=xmalloc_clear(sizeof(*notation));
+ if(*string=='-')
+ {
+ notation->flags.ignore=1;
+ string++;
+ }
+
if(*string=='!')
{
notation->flags.critical=1;
@@ -911,6 +917,10 @@ string_to_notation(const char *string,int is_utf8)
if( *s=='@')
saw_at++;
+ /* -notationname is legal without an = sign */
+ if(!*s && notation->flags.ignore)
+ break;
+
if( !*s || !isascii (*s) || (!isgraph(*s) && !isspace(*s)) )
{
log_error(_("a notation name must have only printable characters"
@@ -936,26 +946,30 @@ string_to_notation(const char *string,int is_utf8)
goto fail;
}
- i=s+1;
-
- /* we only support printable text - therefore we enforce the use of
- only printable characters (an empty value is valid) */
- for(s++; *s ; s++ )
+ if(*s)
{
- if ( !isascii (*s) )
- highbit=1;
- else if (iscntrl(*s))
+ const char *i=s+1;
+ int highbit=0;
+
+ /* we only support printable text - therefore we enforce the use
+ of only printable characters (an empty value is valid) */
+ for(s++; *s ; s++ )
{
- log_error(_("a notation value must not use any"
- " control characters\n"));
- goto fail;
+ if ( !isascii (*s) )
+ highbit=1;
+ else if (iscntrl(*s))
+ {
+ log_error(_("a notation value must not use any"
+ " control characters\n"));
+ goto fail;
+ }
}
- }
- if(!highbit || is_utf8)
- notation->value=xstrdup(i);
- else
- notation->value=native_to_utf8(i);
+ if(!highbit || is_utf8)
+ notation->value=xstrdup(i);
+ else
+ notation->value=native_to_utf8(i);
+ }
return notation;