1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include <libpspp/alloc.h>
22 #include "msg-locator.h"
23 #include <libpspp/message.h>
24 #include <libpspp/assertion.h>
27 /* File locator stack. */
28 static const struct msg_locator **file_loc;
30 static int nfile_loc, mfile_loc;
33 msg_locator_done (void)
37 nfile_loc = mfile_loc = 0;
41 /* File locator stack functions. */
43 /* Pushes F onto the stack of file locations. */
45 msg_push_msg_locator (const struct msg_locator *loc)
47 if (nfile_loc >= mfile_loc)
54 file_loc = xnrealloc (file_loc, mfile_loc, sizeof *file_loc);
57 file_loc[nfile_loc++] = loc;
60 /* Pops F off the stack of file locations.
61 Argument F is only used for verification that that is actually the
62 item on top of the stack. */
64 msg_pop_msg_locator (const struct msg_locator *loc)
66 assert (nfile_loc >= 0 && file_loc[nfile_loc - 1] == loc);
70 /* Puts the current file and line number into LOC, or NULL and -1 if
73 get_msg_location (const struct source_stream *ss, struct msg_locator *loc)
77 *loc = *file_loc[nfile_loc - 1];
81 loc->file_name = getl_source_name (ss);
82 loc->line_number = getl_source_location (ss);