aboutsummaryrefslogtreecommitdiff
path: root/src/diag.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/diag.c')
-rw-r--r--src/diag.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/diag.c b/src/diag.c
index 53bc044..fe057d0 100644
--- a/src/diag.c
+++ b/src/diag.c
@@ -1,3 +1,3 @@
1/* This file is part of GNU Pies. 1/* This file is part of GNU Pies.
2 Copyright (C) 2009, 2010 Sergey Poznyakoff 2 Copyright (C) 2009, 2010, 2011 Sergey Poznyakoff
3 3
@@ -127,11 +127,39 @@ grecs_print_diag (grecs_locus_t *locus, int err, int errcode, const char *msg)
127{ 127{
128 char *locstr = NULL;
129
128 if (locus) 130 if (locus)
129 { 131 {
132 size_t size = 0;
133
134 if (locus->beg.col == 0)
135 grecs_asprintf (&locstr, &size, "%s:%u",
136 locus->beg.file,
137 locus->beg.line);
138 else if (strcmp (locus->beg.file, locus->end.file))
139 grecs_asprintf (&locstr, &size, "%s:%u.%u-%s:%u.%u",
140 locus->beg.file,
141 locus->beg.line, locus->beg.col,
142 locus->end.file,
143 locus->end.line, locus->end.col);
144 else if (locus->beg.line != locus->end.line)
145 grecs_asprintf (&locstr, &size, "%s:%u.%u-%u.%u",
146 locus->beg.file,
147 locus->beg.line, locus->beg.col,
148 locus->end.line, locus->end.col);
149 else
150 grecs_asprintf (&locstr, &size, "%s:%u.%u-%u",
151 locus->beg.file,
152 locus->beg.line, locus->beg.col,
153 locus->end.col);
154 }
155
156 if (locstr)
157 {
130 if (errcode) 158 if (errcode)
131 logmsg (err ? LOG_ERR : LOG_WARNING, "%s:%lu: %s: %s", 159 logmsg (err ? LOG_ERR : LOG_WARNING, "%s: %s: %s",
132 locus->file, (unsigned long)locus->line, msg, 160 locstr, msg, strerror (errcode));
133 strerror (errcode));
134 else 161 else
135 logmsg (err ? LOG_ERR : LOG_WARNING, "%s:%lu: %s", 162 logmsg (err ? LOG_ERR : LOG_WARNING, "%s: %s",
136 locus->file, (unsigned long)locus->line, msg); 163 locstr, msg);
164 free (locstr);
137 } 165 }

Return to:

Send suggestions and report system problems to the System administrator.