Only export symbols starting with razor_ in dynamic library.
Apart from being good practice to avoid clashes with higher-level
libraries and the application, this also fixes an obscure bug: The
gnulib library is used both by librazor (the dynamic library) and
by razor (the executable). In doing so, we want to have two separate
copies of the library despite the code duplication this involves.
Without the explicit limit to export only razor_ symbols, the razor
executable under mingw64 was picking up the getopt_long function
from librazor and the optind variable from libgnu which meant that
it did not see optind changing. Hiding librazor's copy of getopt
causes the linker to find libgnu's copy and everything works.
Note that under mingw librazor-#.dll still contains undocumented
(private) razor_ symbols but these will do no harm as long as nobody
tries to use them.
2 * Copyright (C) 2009 J. Ali Harlow <ali@juiblex.co.uk>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <sys/types.h>
30 #include "razor-internal.h"
33 * This kludge is to work around an apparent bug in Fedora 10's lua package
34 * (it appears to require libm but not to include a DT_NEEDED).
37 void (*kludge)() = (void (*)())sin;
39 static void recursive_remove(const char *directory)
45 dp = opendir(directory);
46 while((dirp = readdir(dp))) {
47 if (strcmp(dirp->d_name, ".") && strcmp(dirp->d_name, "..")) {
48 buf = malloc(strlen(directory) + strlen(dirp->d_name)
50 sprintf(buf, "%s/%s", directory, dirp->d_name);
52 recursive_remove(buf);
60 int main(int argc, char *argv[])
62 char root[] = "/tmp/razor.XXXXXX";
66 char *s, *test_file, *srcdir;
68 struct razor_error *error = NULL;
71 fprintf(stderr, "usage: %s [TESTS-FILE]\n", argv[0]);
77 test_file = "test.lua";
84 s = malloc(strlen(root) + strlen("/testfile") + 1);
86 strcat(s, "/testfile");
92 fprintf(fp, "#!" LUA_BINARY "\n"
93 "print('Abracadabra!')\n");
94 fchmod(fileno(fp), S_IRUSR | S_IWUSR | S_IXUSR);
98 script = razor_file_get_contents(test_file, &len, 0, &error);
100 srcdir = getenv("srcdir");
101 if (srcdir && errno == ENOENT && *test_file != '/') {
102 razor_error_free(error);
103 s = malloc(strlen(srcdir) + strlen(test_file) + 2);
106 strcat(s, test_file);
107 script = razor_file_get_contents(s, &len, 0, &error);
109 fprintf(stderr, "%s\n",
110 razor_error_get_msg(error));
111 razor_error_free(error);
116 fprintf(stderr, "%s\n", razor_error_get_msg(error));
117 razor_error_free(error);
121 r = run_lua_script(root, test_file, script, len, -1);
122 razor_file_free_contents(script, len);
124 recursive_remove(root);