diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-27 13:52:51 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-27 14:08:07 +0300 |
commit | abc9addde25c64679ac22bbe29d770791e2be49c (patch) | |
tree | afc7aa27ba17ad3c5f06bcb90328091a3777288a /src | |
parent | 04fe7a244ed60968542bcd79ecff222d37768def (diff) | |
download | wydawca-abc9addde25c64679ac22bbe29d770791e2be49c.tar.gz wydawca-abc9addde25c64679ac22bbe29d770791e2be49c.tar.bz2 |
Update grecs.
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 76 | ||||
-rw-r--r-- | src/wydawca.c | 38 |
2 files changed, 78 insertions, 36 deletions
diff --git a/src/config.c b/src/config.c index 43be903..11a448e 100644 --- a/src/config.c +++ b/src/config.c @@ -246,3 +246,3 @@ assert_string_arg (grecs_locus_t *locus, { - grecs_error (locus, 0, _("expected scalar value as a tag")); + grecs_error (&value->locus, 0, _("expected scalar value as a tag")); return 1; @@ -263,3 +263,3 @@ get_arg (grecs_locus_t *locus, grecs_value_t *value, unsigned n, int type) { - grecs_error (locus, 0, _("argument %d has wrong type"), n); + grecs_error (&value->locus, 0, _("argument %d has wrong type"), n); return NULL; @@ -283,3 +283,3 @@ cb_mailer (enum grecs_callback_command cmd, if (rc) - grecs_error (locus, 0, _("cannot create mailer `%s': %s"), + grecs_error (&value->locus, 0, _("cannot create mailer `%s': %s"), value->v.string, mu_strerror (rc)); @@ -304,3 +304,3 @@ cb_email_address (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("%s: invalid email address: %s"), + grecs_error (&value->locus, 0, _("%s: invalid email address: %s"), value->v.string, mu_strerror (rc)); @@ -326,3 +326,4 @@ cb_email_address (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("%s: invalid email address: %s"), + grecs_error (&value->locus, 0, + _("%s: invalid email address: %s"), vp->v.string, mu_strerror (rc)); @@ -363,3 +364,4 @@ cb_interval (enum grecs_callback_command cmd, if (rc) - grecs_error (locus, 0, _("unrecognized interval format (near `%s')"), + grecs_error (&value->locus, 0, + _("unrecognized interval format (near `%s')"), endp); @@ -385,3 +387,3 @@ cb_absolute_name (enum grecs_callback_command cmd, if (!word || word[0] != '/') - grecs_error (locus, 0, _("must be an absolute file name")); + grecs_error (&value->locus, 0, _("must be an absolute file name")); else @@ -405,3 +407,3 @@ cb_set_umask (enum grecs_callback_command cmd, if (*p) - grecs_error (locus, 0, _("invalid umask (near %s)"), p); + grecs_error (&value->locus, 0, _("invalid umask (near %s)"), p); else @@ -438,3 +440,3 @@ parse_single_statmask (grecs_locus_t *locus, const grecs_value_t *val, { - grecs_error (locus, 0, _("expected scalar value but found list")); + grecs_error (&val->locus, 0, _("expected scalar value but found list")); return 1; @@ -459,3 +461,3 @@ parse_single_statmask (grecs_locus_t *locus, const grecs_value_t *val, { - grecs_error (locus, 0, _("unknown statistics type: %s"), arg); + grecs_error (&val->locus, 0, _("unknown statistics type: %s"), arg); return 1; @@ -560,3 +562,4 @@ cb_sql_host (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("invalid port number (near %s)"), end); + grecs_error (&value->locus, 0, + _("invalid port number (near %s)"), end); return 0; @@ -565,3 +568,4 @@ cb_sql_host (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("port number out of range 1..%d"), + grecs_error (&value->locus, 0, + _("port number out of range 1..%d"), USHRT_MAX); @@ -593,3 +597,4 @@ cb_sql (enum grecs_callback_command cmd, { - grecs_error(locus, 0, _("tag must be a string")); + grecs_error(value ? &value->locus : locus, 0, + _("tag must be a string")); return 0; @@ -645,3 +650,3 @@ cb_syslog_facility (enum grecs_callback_command cmd, if (mu_string_to_syslog_facility (value->v.string, varptr)) - grecs_error (locus, 0, _("Unknown syslog facility `%s'"), + grecs_error (&value->locus, 0, _("Unknown syslog facility `%s'"), value->v.string); @@ -673,3 +678,4 @@ cb_define_message (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("first argument not a string")); + grecs_error (&value->v.arg.v[0]->locus, 0, + _("first argument not a string")); return 1; @@ -680,3 +686,4 @@ cb_define_message (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("second argument not a string")); + grecs_error (&value->v.arg.v[1]->locus, 0, + _("second argument not a string")); return 1; @@ -748,3 +755,3 @@ cb_backup (enum grecs_callback_command cmd, return 1; - *ptype = get_backup_version (locus, NULL, value->v.string); + *ptype = get_backup_version (&value->locus, NULL, value->v.string); return 0; @@ -785,3 +792,4 @@ cb_archive (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("expected scalar value but found list")); + grecs_error (&value->locus, 0, + _("expected scalar value but found list")); return 1; @@ -797,3 +805,3 @@ cb_archive (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("unknown archive type")); + grecs_error (&value->locus, 0, _("unknown archive type")); return 1; @@ -852,3 +860,3 @@ cb_event (enum grecs_callback_command cmd, return 1; - string_to_notification_event (locus, value->v.string, pev); + string_to_notification_event (&value->locus, value->v.string, pev); return 0; @@ -867,3 +875,3 @@ cb_recipient (enum grecs_callback_command cmd, return 1; - string_to_notification_target (locus, value->v.string, tgt); + string_to_notification_target (&value->locus, value->v.string, tgt); return 0; @@ -949,3 +957,4 @@ cb_dictionary_type (enum grecs_callback_command cmd, if (*ptype == dictionary_none) - grecs_error (locus, 0, _("unknown dictionary type: %s"), value->v.string); + grecs_error (&value->locus, 0, + _("unknown dictionary type: %s"), value->v.string); return 0; @@ -970,3 +979,3 @@ cb_dictionary_params (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("expected list value")); + grecs_error (value ? &value->locus : locus, 0, _("expected list value")); return 1; @@ -1049,6 +1058,7 @@ cb_dictionary (enum grecs_callback_command cmd, { - grecs_error(locus, 0, _("tag must be a string")); + grecs_error(value ? &value->locus : locus, 0, + _("tag must be a string")); return 0; } - if (string_to_dictionary_id (locus, value->v.string, &id)) + if (string_to_dictionary_id (&value->locus, value->v.string, &id)) return 1; @@ -1105,3 +1115,3 @@ cb_url (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("cannot create URL `%s': %s"), + grecs_error (&value->locus, 0, _("cannot create URL `%s': %s"), value->v.string, mu_strerror (rc)); @@ -1158,3 +1168,4 @@ cb_spool (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("tag must be a string")); + grecs_error (value ? &value->locus : locus, 0, + _("tag must be a string")); return 1; @@ -1244,3 +1255,4 @@ cb_user (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("no such user: %s"), value->v.string); + grecs_error (&value->locus, 0, + _("no such user: %s"), value->v.string); return 1; @@ -1267,3 +1279,3 @@ cb_supp_groups (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("expected list value")); + grecs_error (value ? &value->locus : locus, 0, _("expected list value")); return 1; @@ -1292,3 +1304,4 @@ cb_supp_groups (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("no such group: %s"), value->v.string); + grecs_error (&value->locus, 0, + _("no such group: %s"), value->v.string); break; @@ -1325,3 +1338,4 @@ cb_locking (enum grecs_callback_command cmd, { - grecs_error (locus, 0, _("expected scalar value as a tag")); + grecs_error (value ? &value->locus : locus, 0, + _("expected scalar value as a tag")); return 1; diff --git a/src/wydawca.c b/src/wydawca.c index c8362f0..6937218 100644 --- a/src/wydawca.c +++ b/src/wydawca.c @@ -224,11 +224,39 @@ grecs_print_diag (grecs_locus_t *locus, int err, int errcode, const char *msg) { + char *locstr = NULL; + if (locus) { + size_t size = 0; + + if (locus->beg.col == 0) + grecs_asprintf (&locstr, &size, "%s:%u", + locus->beg.file, + locus->beg.line); + else if (strcmp (locus->beg.file, locus->end.file)) + grecs_asprintf (&locstr, &size, "%s:%u.%u-%s:%u.%u", + locus->beg.file, + locus->beg.line, locus->beg.col, + locus->end.file, + locus->end.line, locus->end.col); + else if (locus->beg.line != locus->end.line) + grecs_asprintf (&locstr, &size, "%s:%u.%u-%u.%u", + locus->beg.file, + locus->beg.line, locus->beg.col, + locus->end.line, locus->end.col); + else + grecs_asprintf (&locstr, &size, "%s:%u.%u-%u", + locus->beg.file, + locus->beg.line, locus->beg.col, + locus->end.col); + } + + if (locstr) + { if (errcode) - logmsg (err ? LOG_ERR : LOG_WARNING, "%s:%lu: %s: %s", - locus->file, (unsigned long)locus->line, msg, - strerror (errcode)); + logmsg (err ? LOG_ERR : LOG_WARNING, "%s: %s: %s", + locstr, msg, strerror (errcode)); else - logmsg (err ? LOG_ERR : LOG_WARNING, "%s:%lu: %s", - locus->file, (unsigned long)locus->line, msg); + logmsg (err ? LOG_ERR : LOG_WARNING, "%s: %s", + locstr, msg); + free (locstr); } |