Codebase list libmawk / 30b66529-447f-407d-a34b-b48ac0e29c37/upstream
Import upstream version 1.0.3 Debian Janitor 1 year, 2 months ago
32 changed file(s) with 499 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
00 Changelog for libmawk
11 ~~~~~~~~~~~~~~~~~~~~~
2
3 libmawk 1.0.3 (released: 2021-07-21, r1328)
4 [build] -Fix: move fstool detection from target to host - needed only for installation
5 [build] -Fix: suppress warning on non-existing optional /local/nofork
6 [build] -Fix: make install over a new version over an old version shouldn't fail on lib symlink creation
7 [build] -Add: no-fork configure-time option
8 [vio] -Fix: missing extern caused multiple definitions of the same variable for vio_fifo
29
310 libmawk 1.0.2 (released: 2019-06-22, r1318)
411 [core] -Fix: C function calls with uninitialized variables: not sure if array or not, delay resolving it until all the script is parsed so we see if the symbol is an array
0 Release notes for libmawk 1.0.2
0 Release notes for libmawk 1.0.3
11
2 Minor bugfix release; fixes C function call with uninitialized
3 variables and make uninstall.
2 Minor bugfix release (missing extern and build system fixes). Adds
3 compile time option for no-fork.
44
55
0 0000. packaging and fawk
1 - packaging:
2 - rename example manpage to have libmawk prefix
3 - make sure example manpage .TH has no space and matches the name
4 - fawk
5 - implement the . array syntax
6 - array in array (for orig implementation only?)
7 - isarray()
8 - textblock
9 - vararg?
10
11
012 packging:
113 - manual page headers use the wrong section
214
4557
4658 3.0 extend arrays
4759 - array copy
48 - array in array (for orig implementation only?)
60
4961 - length(array) as in gawk? POSIX: length() works on strings only
5062 update test_3rd funlen accordingly!
5163
100100 /* Runs when things should be detected for the host system */
101101 int hook_detect_host()
102102 {
103 require("fstools/chmodx", 0, 1);
104 require("fstools/cp", 0, 1);
105 require("fstools/rm", 0, 1);
106 require("fstools/ln", 0, 1);
107 require("fstools/mkdir", 0, 1);
108
103109 return 0;
104110 }
105111
144150 require("cc/soname", 0, 0);
145151 require("cc/rdynamic", 0, 0);
146152 require("cc/pragma_message", 0, 0);
147 require("fstools/chmodx", 0, 1);
148 require("fstools/cp", 0, 1);
149 require("fstools/rm", 0, 1);
150 require("fstools/ln", 0, 1);
151 require("fstools/mkdir", 0, 1);
152153 require("sys/types/size_t/includes", 0, 0);
153154 require("libs/fs/realpath/presents", 0, 0);
154155 require("libs/env/putenv", 0, 1);
7474 value++;
7575
7676 if (strcmp(key, "without") == 0) {
77 char *tmp, *end;
77 char *tmp;
7878 if (*value != '/') {
7979 const char **r, *roots[] = {"target", "host", "runtime", NULL};
8080 for(r = roots; *r != NULL; r++) {
8282 break;
8383 if (istrue(d)) {
8484 free(tmp);
85 return USER_WITHOUT;
85 return (fn_wrap_t *)USER_WITHOUT;
8686 }
8787 while(*sep != '/')
8888 sep--;
135135
136136 if (get(name) == NULL) {
137137 w = get_wrap(name, &wild, &missing);
138 if (w == USER_WITHOUT) {
138 if (w == (fn_wrap_t *)USER_WITHOUT) {
139139 if (fatal) {
140140 error("Node %s is required by the software but disabled by the user using --without\n", name);
141141 abort();
3535 dep_add("cc/destructor", find_destructor);
3636 dep_add("cc/rdynamic", find_rdynamic);
3737 dep_add("cc/soname", find_soname);
38 dep_add("cc/so_undefined", find_so_undefined);
3839 dep_add("cc/wlrpath", find_wlrpath);
3940 dep_add("cc/wloutimplib", find_cc_wloutimplib);
4041 dep_add("cc/wloutputdef", find_cc_wloutputdef);
9495 dep_add("libs/fs/getwd/*", find_fs_getwd);
9596 dep_add("libs/fs/mkdir/*", find_fs_mkdir);
9697 dep_add("libs/fs/_mkdir/*", find_fs__mkdir);
98 dep_add("libs/fs/utime/*", find_fs_utime);
99 dep_add("libs/fs/_utime/*", find_fs__utime);
100 dep_add("libs/fs/_utime64/*", find_fs__utime64);
97101 dep_add("libs/fs/mkdtemp/*", find_fs_mkdtemp);
98102 dep_add("libs/fs/mmap/*", find_fs_mmap);
99103 dep_add("libs/fsmount/next_dev/*", find_fsmount_next_dev);
104108 dep_add("libs/fs/statfs/*", find_fs_statfs);
105109 dep_add("libs/fs/statvfs/*", find_fs_statvfs);
106110 dep_add("libs/fs/flock/*", find_fs_flock);
111 dep_add("libs/fs/makedev/*", find_fs_makedev);
107112
108113 dep_add("libs/io/pipe/*", find_io_pipe);
114 dep_add("libs/io/pipe2/*", find_io_pipe2);
115 dep_add("libs/io/_pipe/*", find_io__pipe);
109116 dep_add("libs/io/dup2/*", find_io_dup2);
110117 dep_add("libs/io/fileno/*", find_io_fileno);
111118 dep_add("libs/io/lseek/*", find_io_lseek);
1414 int find_declspec_dllexport(const char *name, int logdepth, int fatal);
1515 int find_rdynamic(const char *name, int logdepth, int fatal);
1616 int find_soname(const char *name, int logdepth, int fatal);
17 int find_so_undefined(const char *name, int logdepth, int fatal);
1718 int find_wlrpath(const char *name, int logdepth, int fatal);
1819 int find_cc_wloutimplib(const char *name, int logdepth, int fatal);
1920 int find_cc_wloutputdef(const char *name, int logdepth, int fatal);
5455 int find_fs_getwd(const char *name, int logdepth, int fatal);
5556 int find_fs_mkdir(const char *name, int logdepth, int fatal);
5657 int find_fs__mkdir(const char *name, int logdepth, int fatal);
58 int find_fs_utime(const char *name, int logdepth, int fatal);
59 int find_fs__utime(const char *name, int logdepth, int fatal);
60 int find_fs__utime64(const char *name, int logdepth, int fatal);
5761 int find_fs_mkdtemp(const char *name, int logdepth, int fatal);
5862 int find_fs_mmap(const char *name, int logdepth, int fatal);
5963 int find_fsmount_next_dev(const char *name, int logdepth, int fatal);
6468 int find_fs_statfs(const char *name, int logdepth, int fatal);
6569 int find_fs_statvfs(const char *name, int logdepth, int fatal);
6670 int find_fs_flock(const char *name, int logdepth, int fatal);
71 int find_fs_makedev(const char *name, int logdepth, int fatal);
6772
6873 /* printf */
6974 int find_printf_x(const char *name, int logdepth, int fatal);
124129
125130 /* find_io.c */
126131 int find_io_pipe(const char *name, int logdepth, int fatal);
132 int find_io_pipe2(const char *name, int logdepth, int fatal);
133 int find_io__pipe(const char *name, int logdepth, int fatal);
127134 int find_io_dup2(const char *name, int logdepth, int fatal);
128135 int find_io_fileno(const char *name, int logdepth, int fatal);
129136 int find_io_lseek(const char *name, int logdepth, int fatal);
644644 return 1;
645645 }
646646
647 int find_so_undefined(const char *name, int logdepth, int fatal)
648 {
649 static const char *test_c =
650 NL "#include <stdio.h>"
651 NL "void intentionally_undefined_symbol(void);"
652 NL "int main() {"
653 NL " intentionally_undefined_symbol();"
654 NL " puts(\"OK\");"
655 NL " return 0;"
656 NL "}"
657 NL ;
658 const char **t, *try_ldflags[] = {
659 "",
660 "-undefined dynamic_lookup", /* OSX + clang */
661 NULL
662 };
663
664 require("cc/cc", logdepth, fatal);
665 require("cc/ldflags_dynlib", logdepth, fatal);
666
667 report("Checking for so_undefined... ");
668 logprintf(logdepth, "find_so_undefined: trying to find so_undefined...\n");
669 logdepth++;
670
671 for(t = try_ldflags; *t != NULL; t++) {
672 const char *fpic;
673 char *ldf, *oname = ".o", *libname_dyn, *cflags_c;
674 int res1, res2;
675
676 fpic = get("cc/fpic");
677 if (fpic == NULL) fpic = "";
678
679 cflags_c = str_concat(" ", "-c", fpic, NULL);
680
681 libname_dyn = (char *)get("sys/ext_dynlib");
682 ldf = str_concat(" ", get("cc/ldflags_dynlib"), *t, NULL);
683 res1 = compile_code(logdepth, test_c, &oname, NULL, cflags_c, NULL);
684 res2 = compile_file(logdepth, oname, &libname_dyn, NULL, NULL, ldf);
685 unlink(libname_dyn);
686 unlink(oname);
687 free(libname_dyn);
688 free(oname);
689 free(cflags_c);
690
691 if ((res1 == 0) && (res2 == 0)) {
692 put(name, *t);
693 report("OK (%s)\n", *t);
694 return 0;
695 }
696 }
697
698 report("Not found.\n");
699 return 1;
700 }
701
647702
648703 int find_wlrpath(const char *name, int logdepth, int fatal)
649704 {
691746 NL "#include <stdlib.h>"
692747 NL "#include <stdio.h>"
693748 NL "#include %s"
749 NL "#ifndef RTLD_NOW"
750 NL "#define RTLD_NOW RTLD_LAZY" /* on old BSD and probably on SunOS */
751 NL "#endif"
694752 NL "int main() {"
695753 NL " void *handle = NULL;"
696754 NL " void (*func)() = NULL;"
698756 NL
699757 NL " handle = dlopen(\"%s\", RTLD_NOW);"
700758 NL " if (handle == NULL) {"
701 NL " printf(\"dlopen fails: \", dlerror());"
759 NL " printf(\"dlopen fails: %%s\", dlerror());"
702760 NL " return 1;"
703761 NL " }"
704762 NL " func = dlsym(handle, \"hello\");"
705763 NL " if (func == NULL) {"
706 NL " printf(\"dlsym fails: \", dlerror());"
764 NL " printf(\"dlsym fails: %%s\", dlerror());"
707765 NL " return 1;"
708766 NL " }"
709767 NL " func();"
742800 libname_dyn = libname = (char *)get("sys/ext_dynlib");
743801 if ((compile_code(logdepth, test_lib, &oname, NULL, cflags_c, NULL) != 0) ||
744802 (compile_file(logdepth, oname, &libname_dyn, NULL, NULL, concated_ldflags) != 0)) {
745 report("FAILED (compiling dynlib)\n");
803 report("('%s': nope) ", concated_ldflags);
746804 }
747805 else {
748806 sprintf(test_host_app, test_host, ld_include, libname_dyn);
777835
778836 if (try_dynlib(logdepth, NULL, concat_nodes("-dynamic -shared", "cc/rdynamic", "libs/ldl", NULL), "cc/ldflags_dynlib", "-dynamic -shared", NULL, get("libs/ldl"))) return 0;
779837 if (try_dynlib(logdepth, NULL, concat_nodes("-shared", "cc/rdynamic", "libs/ldl", NULL), "cc/ldflags_dynlib", "-shared", NULL, get("libs/ldl"))) return 0;
838 if (try_dynlib(logdepth, NULL, concat_nodes("-G", "libs/ldl", NULL), "cc/ldflags_dynlib", "-G", NULL, get("libs/ldl"))) return 0; /* xlc (on AIX) */
780839 report("Not found.\n");
781840 return 1;
782841 }
9191 char *test_c =
9292 NL "#include <stdlib.h>"
9393 NL "#include <stdio.h>"
94 NL "#include <string.h>"
9495 NL "int main() {"
9596 NL " DIR *dirp;"
9697 NL " struct dirent *dp;"
396397 {
397398 char *test_c =
398399 NL "#include <unistd.h>"
400 NL "#include <stdio.h>"
399401 NL "int main() {"
400402 NL " char b[1024];"
401403 NL " if (getcwd(b, sizeof(b)) != NULL)"
418420 {
419421 char *test_c =
420422 NL "#include <stdlib.h>"
423 NL "#include <stdio.h>"
421424 NL "int main() {"
422425 NL " char b[1024];"
423426 NL " if (_getcwd(b, sizeof(b)) != NULL)"
441444 {
442445 char *test_c =
443446 NL "#include <unistd.h>"
447 NL "#include <stdio.h>"
444448 NL "int main() {"
445449 NL " char b[8192];"
446450 NL " if (getwd(b) != NULL)"
573577
574578 rmdir(dir);
575579 return try_fail(logdepth, "libs/fs/_mkdir");
580 }
581
582 static int find_utime_impl(const char *name, int logdepth, int fatal,
583 const char* key, const char* funcname, const char* typename)
584 {
585 char test_c[1024+4096];
586 const char *test_c_templ =
587 NL "void puts_OK();"
588 NL "int main(int argc, char* argv[])"
589 NL "{"
590 NL " struct %s buf;"
591 NL " buf.actime = buf.modtime = 1610958044;"
592 NL " if (%s(\"%s\", &buf) == 0)"
593 NL " puts_OK();"
594 NL " return 0;"
595 NL "}"
596 NL "#include <stdio.h>"
597 NL "void puts_OK()"
598 NL "{"
599 NL " puts(\"OK\");"
600 NL "}"
601 NL;
602
603 const char* includes[] =
604 {
605 /* *NIX */
606 "#include <sys/types.h>\n#include <utime.h>",
607
608 /* windoz */
609 "#include <sys/utime.h>",
610
611 NULL
612 };
613 const char** inc;
614 char* tmpf;
615
616 tmpf = tempfile_new(".txt");
617 sprintf(test_c, test_c_templ, typename, funcname, tmpf);
618
619 require("cc/cc", logdepth, fatal);
620
621 report("Checking for %s... ", funcname);
622 logprintf(logdepth, "find_fs_%s: trying to find %s()...\n", funcname, funcname);
623 logdepth++;
624
625 for (inc=includes; *inc; ++inc)
626 {
627 if (try_icl(logdepth, key, test_c, *inc, NULL, NULL))
628 {
629 unlink(tmpf);
630 free(tmpf);
631 return 0;
632 }
633 }
634
635 unlink(tmpf);
636 free(tmpf);
637
638 return try_fail(logdepth, key);
639 }
640
641 int find_fs_utime(const char *name, int logdepth, int fatal)
642 {
643 return find_utime_impl(name, logdepth, fatal,
644 "libs/fs/utime", "utime", "utimbuf");
645 }
646
647 int find_fs__utime(const char *name, int logdepth, int fatal)
648 {
649 return find_utime_impl(name, logdepth, fatal,
650 "libs/fs/_utime", "_utime", "_utimbuf");
651 }
652
653 int find_fs__utime64(const char *name, int logdepth, int fatal)
654 {
655 return find_utime_impl(name, logdepth, fatal,
656 "libs/fs/_utime64", "_utime64", "__utimbuf64");
576657 }
577658
578659 int find_fs_mkdtemp(const char *name, int logdepth, int fatal)
805886 if (try_icl(logdepth, key, test_c, "#include <sys/file.h>", NULL, NULL)) return 0;
806887 return try_fail(logdepth, key);
807888 }
889
890 int find_fs_makedev(const char *name, int logdepth, int fatal)
891 {
892 const char *key = "libs/fs/makedev";
893 const char *test_c =
894 NL "#include <stdio.h>"
895 NL "int main() {"
896 NL " if (1 == major(makedev(1, 2)) && 2 == minor(makedev(1, 2)))"
897 NL " puts(\"OK\");"
898 NL " return 0;"
899 NL "}"
900 NL;
901 const char *includes[] = {
902 "#include <sys/sysmacros.h>",
903 NULL
904 };
905 const char **i;
906
907 require("cc/cc", logdepth, fatal);
908
909 report("Checking for makedev()... ");
910 logprintf(logdepth, "find_fs_makedev: trying to find makedev...\n");
911 logdepth++;
912
913 for (i = includes; *i != NULL; i++)
914 if (try_icl(logdepth, key, test_c, *i, NULL, NULL))
915 return 0;
916 return try_fail(logdepth, key);
917 }
261261 expected = src;
262262 else
263263 expected++;
264
265 logprintf(logdepth, "test_ar path_sep='%s' expected='%s' result='%s'\n", path_sep, expected, result);
264266
265267 ret = strncmp(expected, result, strlen(expected)) == 0;
266268 if (ret) {
2323 #include <stdio.h>
2424 #include <string.h>
2525 #include <ctype.h>
26 #include <unistd.h>
2627 #include "libs.h"
2728 #include "log.h"
2829 #include "db.h"
3233 {
3334 char *test_c =
3435 NL "#include <unistd.h>"
36 NL "#include <stdio.h>"
3537 NL "int main() {"
3638 NL " int fd[2];"
3739 NL " if (pipe(fd) == 0)"
4648 logprintf(logdepth, "find_io_pipe: trying to find pipe(2)...\n");
4749 logdepth++;
4850
49
50 if (try_icl(logdepth, "libs/io/pipe", test_c, NULL, NULL, NULL)) return 0;
51 if (try_icl(logdepth, "libs/io/pipe", test_c, "#include <unistd.h>\n", NULL, NULL)) return 0;
5152 return try_fail(logdepth, "libs/io/pipe");
53 }
54
55 int find_io_pipe2(const char *name, int logdepth, int fatal)
56 {
57 const char *test_c =
58 NL "#include <unistd.h>"
59 NL "#include <stdio.h>"
60 NL "int main() {"
61 NL " int fd[2];"
62 NL " if (pipe2(fd, 0) == 0)"
63 NL " puts(\"OK\");"
64 NL " return 0;"
65 NL "}"
66 NL;
67
68 require("cc/cc", logdepth, fatal);
69
70 report("Checking for pipe2(2)... ");
71 logprintf(logdepth, "find_io_pipe2: trying to find pipe2(2)...\n");
72 logdepth++;
73
74 if (try_icl(logdepth, "libs/io/pipe2", test_c, "#include <unistd.h>\n", NULL, NULL)) return 0;
75 return try_fail(logdepth, "libs/io/pipe2");
76 }
77
78 int find_io__pipe(const char *name, int logdepth, int fatal)
79 {
80 const char *test_c =
81 NL "#include <stdio.h>"
82 NL "int main() {"
83 NL " int fd[2];"
84 NL " if (_pipe(fd, 1024, _O_BINARY) == 0)"
85 NL " puts(\"OK\");"
86 NL " return 0;"
87 NL "}"
88 NL;
89
90 require("cc/cc", logdepth, fatal);
91
92 report("Checking for _pipe()... ");
93 logprintf(logdepth, "find_io__pipe: trying to find _pipe()...\n");
94 logdepth++;
95
96 if (try_icl(logdepth, "libs/io/_pipe", test_c, "#include <io.h>\n#include <fcntl.h>\n", NULL, NULL)) return 0;
97 return try_fail(logdepth, "libs/io/_pipe");
5298 }
5399
54100 int find_io_dup2(const char *name, int logdepth, int fatal)
80126 char *test_c_ =
81127 NL "#include <stdio.h>"
82128 NL "int main() {"
83 NL no_implicit(int, "%s", "%s")
129 /* NOTE: can not check for implicit declaration as fileno() may be a macro (e.g. on MINIX3) */
84130 NL " if (%s(stdout) >= 0)"
85131 NL " puts(\"OK\"); "
86132 NL " return 0;"
94140 logdepth++;
95141
96142 /* UNIX */
97 sprintf(test_c, test_c_, "fileno", "fileno", "fileno");
143 sprintf(test_c, test_c_, "fileno");
144 if (try_icl(logdepth, "libs/io/fileno", test_c, NULL, NULL, NULL)) {
145 put("libs/io/fileno/call", "fileno");
146 return 0;
147 }
148
149 sprintf(test_c, test_c_, "fileno");
98150 if (try_icl(logdepth, "libs/io/fileno", test_c, "#include <unistd.h>\n", NULL, NULL)) {
99151 put("libs/io/fileno/call", "fileno");
100152 return 0;
101153 }
102154
103 sprintf(test_c, test_c_, "fileno", "fileno", "fileno");
155 sprintf(test_c, test_c_, "fileno");
104156 if (try_icl(logdepth, "libs/io/fileno", test_c, "#define _XOPEN_SOURCE\n#include <unistd.h>\n", NULL, NULL)) {
105157 put("libs/io/fileno/call", "fileno");
106158 return 0;
107159 }
108160
109161 /* windows */
110 sprintf(test_c, test_c_, "_fileno", "_fileno", "_fileno");
162 sprintf(test_c, test_c_, "_fileno");
111163 if (try_icl(logdepth, "libs/io/fileno", test_c, "#include <stdio.h>\n", NULL, NULL)) {
112164 put("libs/io/fileno/call", "_fileno");
113165 return 0;
150202 for (inc = incs, fn = fns; *fn; ++inc, ++fn) {
151203 sprintf(test_c, test_c_template, tmpf, *fn, *fn, *fn);
152204 if (try_icl(logdepth, NODE, test_c, *inc, NULL, NULL)) {
205 unlink(tmpf);
206 free(tmpf);
153207 put(NODE "/call", *fn);
154208 return 0;
155209 }
156210 }
157211
212 unlink(tmpf);
213 free(tmpf);
158214 return try_fail(logdepth, NODE);
159215 #undef NODE
160216 }
5858 char *test_c =
5959 NL "#include <stdio.h>"
6060 NL "#include <dlfcn.h>"
61 NL "#ifndef RTLD_NOW"
62 NL "#define RTLD_NOW RTLD_LAZY" /* on old BSD and probably on SunOS */
63 NL "#endif"
6164 NL "int main() {"
6265 NL " void *handle;"
6366 NL " handle = dlopen(\"/this file does not exist.\", RTLD_NOW);"
7679 NL " return 0;"
7780 NL "}"
7881 NL;
82
83 s = (char *)get("libs/ldl/presents");
84 if (s != NULL)
85 return !istrue(s);
7986
8087 require("cc/cc", logdepth, fatal);
8188
93100 if (try_icl(logdepth, NULL, test_c, NULL, NULL, NULL)) {
94101 put("libs/ldl", "");
95102 put("libs/ldl/includes", "#include <dlfcn.h>\\n");
103 put("libs/ldl/presents", strue);
96104 report("OK ()\n");
97105 return 0;
98106 }
99107 if (try_icl(logdepth, NULL, test_c, NULL, NULL, "-ldl")) {
100108 put("libs/ldl", "-ldl");
101109 put("libs/ldl/includes", "#include <dlfcn.h>\\n");
110 put("libs/ldl/presents", strue);
102111 report("OK (-ldl)\n");
103112 return 0;
104113 }
126135 /* check at normal system installation */
127136 put("libs/ldl", "-ldl-compat");
128137 put("libs/ldl/includes", "#include <dl-compat.h>\\n");
138 put("libs/ldl/presents", strue);
129139 report("OK (-ldl-compat)\n");
130140 return 0;
131141 }
136146 if (try_icl(logdepth, NULL, test_c, NULL, NULL, s)) {
137147 put("libs/ldl", ldl);
138148 put("libs/ldl/includes", "#include <dlfcn.h>\\n");
149 put("libs/ldl/presents", strue);
139150 report("OK (%s)\n", ldl);
140151 free(s);
141152 return 0;
142153 }
143154 free(s);
144155 }
156 put("libs/ldl/presents", sfalse);
145157 report("Not found\n");
146158 return 1;
147159 }
175187 {
176188 char *test_c =
177189 NL "#include <errno.h>"
190 NL "#include <stdio.h>"
178191 NL "int main() {"
179192 NL " errno = 0;"
180193 NL " puts(\"OK\");"
273273 put("sys/path_sep", "\\\\\\\\");
274274 else
275275 put("sys/path_sep", "\\");
276 put("sys/path_sep_escaped", "\\\\");
276277 return 1;
277278 }
278279 tmp = get("sys/tmp");
306307 require("sys/shell", logdepth, fatal);
307308
308309 put("sys/path_sep", "/");
310 put("sys/path_sep_escaped", "/");
309311
310312 report("Detecting temp dir...");
311313 logprintf(logdepth, "Finding temp dir (current working directory)...\n");
337339 put("sys/tmp", usertmp);
338340 report("using user supplied temp dir '%s' for cross-compilation\n", usertmp);
339341 logprintf(logdepth, "using user supplied temp dir '%s' for cross-compilation\n", usertmp);
342 logprintf(logdepth, "Path sep: '%s'\n", get("sys/path_sep"));
340343 }
341344 return 0;
342345 }
351354
352355 report(" validated %s\n", get("sys/tmp"));
353356 logprintf(logdepth, "Detected temp dir '%s'\n", get("sys/tmp"));
357 logprintf(logdepth, "Path sep: '%s'\n", get("sys/path_sep"));
354358 return 0;
355359 }
356360
357361 put("sys/tmp", "");
358362 report("using temp dir fallback .\n");
359363 logprintf(logdepth, "all temp directories failed, using . as tmp\n");
364 logprintf(logdepth, "Path sep: '%s'\n", get("sys/path_sep"));
360365 return 0;
361366 }
362367
3636 char *test_c_recursive =
3737 NL "#define _GNU_SOURCE 1 /* Needed for recursive thread-locking */"
3838 NL "#include <pthread.h>"
39 NL "#include <stdio.h>"
3940 NL "pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;"
4041 NL "int main() {"
4142 NL " pthread_attr_t a;"
4748
4849 char *test_c_simple =
4950 NL "#include <pthread.h>"
51 NL "#include <stdio.h>"
5052 NL "int main() {"
5153 NL " pthread_attr_t a;"
5254 NL " if (pthread_attr_init(&a) == 0)"
3131 {
3232 char *test_c =
3333 NL "#include <unistd.h>"
34 NL "#include <stdio.h>"
3435 NL "int main() {"
3536 NL " if (usleep(1) == 0)"
3637 NL " puts(\"OK\");"
5253 int find_time_Sleep(const char *name, int logdepth, int fatal)
5354 {
5455 char *test_c =
56 NL "#include <stdio.h>"
5557 NL "int main() {"
5658 NL " Sleep(1);"
5759 NL " puts(\"OK\");"
7476 {
7577 char *test_c =
7678 NL "#include <stdlib.h>"
79 NL "#include <stdio.h>"
7780 NL "int main() {"
7881 NL " struct timeval tv;"
7982 NL " if (gettimeofday(&tv, NULL) == 0)"
97100 int find_time_ftime(const char *name, int logdepth, int fatal)
98101 {
99102 char *test_c =
103 NL "#include <stdio.h>"
100104 NL "int main() {"
101105 NL " struct timeb tb;"
102106 NL " if (ftime(&tb) == 0)"
9292 {
9393 char *test_c =
9494 NL "#include <stdint.h>"
95 NL "#include <stdio.h>"
9596 NL "int main() {"
9697 NL " if (sizeof(uint8_t) == 1)"
9798 NL " puts(\"OK\");"
276277
277278 for(include = first_include; *include != NULL; include++) {
278279 sprintf(test_c, test_c_include, define, *include, typ);
279 if ((compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) && (strncmp(out, "OK", 2) == 0)) {
280 if ((compile_run(logdepth, test_c, NULL, NULL, NULL, &out) == 0) && out != NULL && (strncmp(out, "OK", 2) == 0)) {
280281 report("Found; ");
281282 logprintf(logdepth+1, "include %s works\n", *include);
282283 sprintf(nodeend, "includes");
7777 {"[Bb][Ss][Dd]", "BSD", "UNIX", sys_unix},
7878 {"SunOS", "SunOS", "UNIX", sys_unix},
7979 {"OSF1", "OSF", "UNIX", sys_unix}, /* TODO: note the difference in cflags for debugging ("-ms -g") */
80 {"AIX", "AIX", "UNIX", sys_unix},
8081 {"IRIX", "IRIX", "UNIX", sys_unix},
8182 {"SunOS", "SunOS", "UNIX", sys_unix},
8283 {"[Mm]inix", "Minix", "UNIX", sys_unix},
286287 uname_guess("sys/system_name", uname, system_names);
287288
288289 /* on windows, overwrite the path sep with the right amount of \ (the tmp finder may have left / in it) */
289 if (strcmp(class, "WIN32") == 0) {
290 if ((strcmp(class, "WIN32") == 0) || (strcmp(class, "win32") == 0)) {
290291 int eats = istrue(get("sys/shell_eats_backslash"));
291292
292293 if (eats)
293294 put("sys/path_sep", "\\\\\\\\");
294295 else
295296 put("sys/path_sep", "\\");
297
298 put("sys/path_sep_escaped", "\\\\");
296299 }
297300
298301 return 0;
7171
7272 int compile_file_raw(int logdepth, const char *fn_input, char **fn_output, const char *cc, const char *cflags, const char *ldflags)
7373 {
74 char cmd[2048];
74 char *cmdline;
7575 char *cc_esc, *fn_input_esc, *fn_output_esc, *temp_out_esc, *temp_out;
7676 int ret;
7777
8888 fn_output_esc = shell_escape_dup(*fn_output);
8989 temp_out_esc = shell_escape_dup(temp_out);
9090
91 sprintf(cmd, "%s \"%s %s %s %s -o %s 2>&1\" >%s", get("/host/sys/shell"), cc_esc, cflags, fn_input_esc, ldflags, fn_output_esc, temp_out_esc);
91 cmdline = str_concat("",
92 get("/host/sys/shell"), " \"", cc_esc, " ", cflags, " ", fn_input_esc, " ", \
93 ldflags, " -o ", fn_output_esc, " 2>&1\" >", temp_out_esc, NULL);
9294
9395 free(cc_esc);
9496 free(fn_input_esc);
9597 free(fn_output_esc);
9698 free(temp_out_esc);
9799
98 logprintf(logdepth, "compile: '%s'\n", cmd);
99 ret = system(cmd);
100 logprintf(logdepth, "compile: '%s'\n", cmdline);
101 ret = system(cmdline);
102 free(cmdline);
100103 log_merge(logdepth + 1, temp_out);
101104 #ifndef KEEP_TEST_SRCS
102105 unlink(temp_out);
2929 {
3030 char cmd[256];
3131
32 assert(strlen(pkgname) < sizeof(cmd) - 64);
32 if (strlen(confname) + strlen(pkgname) > sizeof(cmd) - 16) {
33 logprintf(logdepth, "run_gen_config(): confname and/or pkgname too long\n");
34 return -1;
35 }
3336
3437 if (cflags != NULL) {
3538 sprintf(cmd, "%s --cflags %s", confname, pkgname);
8184 char cmd[256];
8285 const char *confname = pkg_config_name();
8386
84 assert(strlen(pkgname) < sizeof(cmd) - 64);
87 if (strlen(confname) + strlen(pkgname) > sizeof(cmd) - 16) {
88 logprintf(logdepth, "run_pkg_config_modversion(): confname and/or pkgname too long\n");
89 return -1;
90 }
8591
8692 if (modversion != NULL) {
8793 sprintf(cmd, "%s --modversion %s", confname, pkgname);
139139 char *rincludes, *rcflags, *rldflags; /* real */
140140 char *dbincludes = NULL, *dbcflags = NULL, *dbldflags = NULL; /* what to add in the db at the end */
141141
142 if ((prefix == NULL) ? 0 : strlen(prefix) + strlen(db_cwd) > sizeof(apath)-32) {
143 report("ERROR: no room for try_icl_() - prefix is probably too long.\n");
144 return -1;
145 }
146
142147 /* load uincludes, uclfags, uldflags and uprefix - LOAD() inserts the u */
143 l = sprintf(apath, "/arg/icl/%s/", prefix); apath_end = apath+l;
144 LOAD(includes);
145 LOAD(cflags);
146 LOAD(ldflags);
147 LOAD(prefix);
148 l = sprintf(apath, "/arg/icl/%s/%s/", db_cwd, prefix); apath_end = apath+l;
149 LOAD(includes);
150 LOAD(cflags);
151 LOAD(ldflags);
152 LOAD(prefix);
148 if (prefix != NULL) { /* prefix == NULL means non-standard icl; caller sets non-standard nodes, the user can't affect that */
149 l = sprintf(apath, "/arg/icl/%s/", prefix); apath_end = apath+l;
150 LOAD(includes);
151 LOAD(cflags);
152 LOAD(ldflags);
153 LOAD(prefix);
154 l = sprintf(apath, "/arg/icl/%s/%s/", db_cwd, prefix); apath_end = apath+l;
155 LOAD(includes);
156 LOAD(cflags);
157 LOAD(ldflags);
158 LOAD(prefix);
159 }
153160
154161 /* special case: all three specified by the user - ignore what the detector wanted, but run only once per node prefix */
155162 if ((uincludes != NULL) && (ucflags != NULL) && (uldflags != NULL)) {
200207 rcflags = str_concat("", prfx, "-I", uprefix, "/include ", rcflags, NULL);
201208 if (old != cflags) free(old);
202209
210 /* add -I to the db too */
211 old = dbcflags;
212 dbcflags = str_concat("", "-I", uprefix, "/include ", dbcflags, NULL);
213 free(old);
214
215
203216 old = rldflags;
204217 if ((rldflags != NULL) && (*rldflags == '^')) {
205218 rldflags++;
209222 prfx = "";
210223 rldflags = str_concat("", prfx, "-L", uprefix, "/lib ", rldflags, NULL);
211224 if (old != ldflags) free(old);
225
226 /* add -L to the db too */
227 old = dbldflags;
228 dbldflags = str_concat("", "-L", uprefix, "/lib ", dbldflags, NULL);
229 free(old);
212230 }
213231
214232 res = try_icl__(logdepth, prefix, test_c_in, rincludes, rcflags, rldflags, dbincludes, dbcflags, dbldflags, run, accept_res);
333351 {
334352 char path[1024];
335353
354 if (strlen(key) > sizeof(path)-32) {
355 report("ERROR: no room for import_icl() - key is probably too long.\n");
356 return -1;
357 }
358
336359 switch(*key) {
337360 case 'l': sprintf(path, "/arg/icl/%s/ldflags", key+8); break;
338361 case 'c': sprintf(path, "/arg/icl/%s/cflags", key+7); break;
341364 default:
342365 return 1;
343366 }
344 printf("path='%s' fn='%s'\n", path, fn);
345367 return put(path, fn) == NULL;
346368 }
347369
370392 NL "}"
371393 NL;
372394
395 if (strlen(fieldn) + strlen(structn) + strlen(test_c_in) + 32 >= sizeof(test_c)) {
396 report("ERROR: no room for try_icl_sfield() - struct or field name is probably too long.\n");
397 return -1;
398 }
399
373400 sprintf(test_c, test_c_in, structn, fieldn);
374401
375402 res = try_icl_(logdepth, prefix, test_c, includes, cflags, ldflags, 1, field_accept_res);
3333 int find_math_isnan(const char *name, int logdepth, int fatal)
3434 {
3535 char *test_c =
36 NL "#include <stdio.h>"
3637 NL "int main() {"
3738 NL " if (!isnan(1.0))"
3839 NL " puts(\"OK\");"
5960 int find_math_isinf(const char *name, int logdepth, int fatal)
6061 {
6162 char *test_c =
63 NL "#include <stdio.h>"
6264 NL "int main() {"
6365 NL " if (!isinf(1.0))"
6466 NL " puts(\"OK\");"
8688 int find_math_isfinite(const char *name, int logdepth, int fatal)
8789 {
8890 char *test_c =
91 NL "#include <stdio.h>"
8992 NL "int main() {"
9093 NL " if (isfinite(1.0))"
9194 NL " puts(\"OK\");"
113116 int find_math_isnormal(const char *name, int logdepth, int fatal)
114117 {
115118 char *test_c =
119 NL "#include <stdio.h>"
116120 NL "int main() {"
117121 NL " if (isnormal(1.0))"
118122 NL " puts(\"OK\");"
144148 int find_math_nan(const char *name, int logdepth, int fatal)
145149 {
146150 char *test_c =
151 NL "#include <stdio.h>"
147152 NL "int main() {"
148153 NL " if (nan(\"foo\") != 0.0)"
149154 NL " puts(\"OK\");"
173178 char *test_c_temp =
174179 NL "#include <stdlib.h>"
175180 NL "#include <stdio.h>"
181 NL "#include <string.h>"
176182 NL "%s"
177183 NL
178184 NL "double s2d(const char *s)"
3232 static int test_mathf(const char *name, int logdepth, int fatal, const char *fname, const char *cond)
3333 {
3434 char *test_c_template =
35 NL "#include <stdio.h>"
3536 NL "float one=1.0, zero=0.0;"
3637 NL "int main() {"
3738 NL " if (%s)"
3333 int find_math_minpack(const char *name, int logdepth, int fatal)
3434 {
3535 char *test_c =
36 NL "#include <stdio.h>"
3637 NL "int main() {"
3738 NL " int one=1;"
3839 NL " if (dpmpar_(&one) != 0.0)"
00 /*
11 scconfig - parser generator detection
2 Copyright (C) 2009 Tibor Palinkas
2 Copyright (C) 2009,2020 Tibor Palinkas
33
44 This library is free software; you can redistribute it and/or
55 modify it under the terms of the GNU Lesser General Public
7474 return 1;
7575 }
7676
77 int find_parsgen_bison(const char *name, int logdepth, int fatal)
78 {
79 const char *test_bison =
77 static const char *test_yacc =
8078 NL "%union { char *str; double num;}"
81 NL "%%"
8279 NL "%token <str> TOK1;"
8380 NL "%token <num> TOK2;"
81 NL "%%"
8482 NL "root: one | two;"
8583 NL "one: TOK1;"
8684 NL "two: TOK2;"
8785 NL ;
86
87 int find_parsgen_bison(const char *name, int logdepth, int fatal)
88 {
8889 char *out, *temp_in, *temp_in_esc, *cmd;
8990 int ret;
9091 char *bisfile, *s;
9495 logprintf(logdepth, "find_bison: trying to find bison...\n");
9596 logdepth++;
9697
97 temp_in = tempfile_dump(test_bison, ".y");
98 temp_in = tempfile_dump(test_yacc, ".y");
9899 bisfile = malloc(strlen(temp_in) + 32);
99100 strcpy(bisfile, temp_in);
100101 s = strrchr(bisfile+1, '.');
131132 return 1;
132133 }
133134
135 int find_parsgen_byaccic(const char *name, int logdepth, int fatal)
136 {
137 char *out, *temp_in, *temp_in_esc, *cmd;
138 int ret;
139 char *bisfile, *s;
140 (void) fatal; /* not used */
141
142 report("Checking for byaccic... ");
143 logprintf(logdepth, "find_byaccic: trying to find byaccic...\n");
144 logdepth++;
145
146 temp_in = tempfile_dump(test_yacc, ".y");
147 bisfile = malloc(strlen(temp_in) + 32);
148 strcpy(bisfile, temp_in);
149 s = strrchr(bisfile+1, '.');
150 strcpy(s, ".tab.c");
151 if (is_file(bisfile)) {
152 report("ERROR: %s exists, and I don't dare to delete it. Can't test byaccic, please remove the file by hand.\n", bisfile);
153 logprintf(logdepth, "ERROR: %s exists, and I don't dare to delete it. Can't test byaccic, please remove the file by hand.\n", bisfile);
154 exit(1);
155 }
156 temp_in_esc = shell_escape_dup(temp_in);
157 cmd = malloc(strlen(temp_in_esc)*2 + 32);
158 sprintf(cmd, "byaccic -o %s %s", bisfile, temp_in_esc);
159 free(temp_in_esc);
160
161 ret = run(logdepth, cmd, &out);
162 remove(temp_in);
163 free(temp_in);
164 if (out != NULL)
165 free(out);
166
167 if (is_file(bisfile)) {
168 remove(bisfile);
169 if (ret == 0) {
170 put("parsgen/byaccic", "byaccic");
171 put("parsgen/byaccic/presents", strue);
172 report("Found.\n");
173 return 0;
174 }
175 }
176
177 put("parsgen/byaccic/presents", sfalse);
178 report("Not found.\n");
179 return 1;
180 }
181
182 int find_parsgen_ureglex(const char *name, int logdepth, int fatal)
183 {
184 const char *test_ureglex =
185 NL "rule blank"
186 NL "regex [ \t\r]+"
187 NL "code"
188 NL " ULX_IGNORE;"
189 NL "rulestring 3D_DXF return 0;"
190 NL ;
191 char *out, *temp_in, *temp_in_esc, *cmd;
192 int ret;
193 char *lexfile = "lex.yy.c";
194 (void) fatal; /* not used */
195
196 report("Checking for ureglex... ");
197 logprintf(logdepth, "find_ureglex: trying to find ureglex...\n");
198 logdepth++;
199
200 if (is_file(lexfile)) {
201 report("ERROR: %s exists, and I don't dare to delete it. Can't test ureglex, please remove the file by hand.\n", lexfile);
202 logprintf(logdepth, "ERROR: %s exists, and I don't dare to delete it. Can't test ureglex, please remove the file by hand.\n", lexfile);
203 exit(1);
204 }
205 temp_in = tempfile_dump(test_ureglex, ".lex");
206 temp_in_esc = shell_escape_dup(temp_in);
207 cmd = malloc(strlen(temp_in_esc) + 32);
208 sprintf(cmd, "ureglex -l %s -c %s", temp_in_esc, lexfile);
209 free(temp_in_esc);
210 ret = run(logdepth, cmd, &out);
211 remove(temp_in);
212 free(temp_in);
213 if (out != NULL)
214 free(out);
215
216 if (is_file(lexfile)) {
217 remove(lexfile);
218 if (ret == 0) {
219 put("parsgen/ureglex", "ureglex");
220 put("parsgen/ureglex/presents", strue);
221 report("Found.\n");
222 return 0;
223 }
224 }
225
226 put("parsgen/ureglex/presents", sfalse);
227 report("Not found.\n");
228 return 1;
229 }
230
134231 void deps_parsgen_init()
135232 {
136233 dep_add("parsgen/flex/*", find_parsgen_flex);
137234 dep_add("parsgen/bison/*", find_parsgen_bison);
138 }
235 dep_add("parsgen/byaccic/*", find_parsgen_byaccic);
236 dep_add("parsgen/ureglex/*", find_parsgen_ureglex);
237 }
473473 tmpasm_t *child;
474474
475475 fn = tmpasm_arg2str(ctx, argv[n], 0);
476 path = scc_path(ud, fn);
476 if (*fn != '/')
477 path = scc_path(ud, fn);
478 else
479 path = strclone(fn);
477480 fin = fopen(path, "r");
478481 if (fin == NULL) {
479482 tmpasm_runtime_error(ctx, -8, path);
88 all:
99
1010 install:
11 @fstools/mkdir@ $(LIBPATH)
11 @/host/fstools/mkdir@ $(LIBPATH)
1212 @]
1313 foreach /local/n in /local/libs
14 print [@ @fstools/cp@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk
14 print [@ @/host/fstools/cp@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk
1515 @]
1616 end
1717
1818 print [@
1919 linstall:
20 @fstools/mkdir@ $(LIBPATH)
20 @/host/fstools/mkdir@ $(LIBPATH)
2121 @]
2222 foreach /local/n in /local/libs
23 print [@ @fstools/ln@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk
23 print [@ @/host/fstools/ln@ @/local/n@.awk $(LIBPATH)/@/local/n@.awk
2424 @]
2525 end
2626
2828 uninstall:
2929 @]
3030 foreach /local/n in /local/libs
31 print [@ @fstools/rm@ $(LIBPATH)/@/local/n@.awk
31 print [@ @/host/fstools/rm@ $(LIBPATH)/@/local/n@.awk
3232 @]
3333 end
3434
141141 $(CP) $(PWD)/man/example.7libmawk $(MAN7DIR)/example.7libmawk
142142 $(CHMOD) 0644 $(MAWKMAN)
143143 $(CP) $(PWD)/libmawk.so $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2).$(SOVER3)
144 rm $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2) $(LIBARCHDIR)/libmawk.so.$(SOVER1) 2>/dev/null ; true
144 rm $(LIBARCHDIR)/libmawk.so $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2) $(LIBARCHDIR)/libmawk.so.$(SOVER1) 2>/dev/null ; true
145145 ln -s libmawk.so.$(SOVER1).$(SOVER2).$(SOVER3) $(LIBARCHDIR)/libmawk.so.$(SOVER1).$(SOVER2)
146146 ln -s libmawk.so.$(SOVER1).$(SOVER2).$(SOVER3) $(LIBARCHDIR)/libmawk.so.$(SOVER1)
147147 ln -s libmawk.so.$(SOVER1) $(LIBARCHDIR)/libmawk.so
3636
3737 #----------------- scconfig detected ----------------------------------
3838 CC = @cc/cc@
39 CFLAGS = @cc/cflags@ @cc/fpic@ -I.. -I. $(CFLAGS_APP)
39 CFLAGS = @cc/cflags@ @cc/fpic@ @?/local/nofork@ -I.. -I. $(CFLAGS_APP)
4040 LDFLAGS = @cc/ldflags@
4141 LDFLAGS_SO = @/local/soname@
4242 LDFLAGS_RDYNAMIC = @cc/rdynamic@
4343
44 CHMODX = @fstools/chmodx@
44 CHMODX = @/host/fstools/chmodx@
4545 CHMOD = chmod
46 MKDIR = @fstools/mkdir@
47 CP=@fstools/cp@
48 SYMLINK=@fstools/ln@
46 MKDIR = @/host/fstools/mkdir@
47 CP=@/host/fstools/cp@
48 SYMLINK=@/host/fstools/ln@
4949 @]
5050
5151 switch /local/numeric
1616 #include <string.h>
1717 #include <unistd.h>
1818 #include <sys/types.h>
19 #ifndef MAWK_NO_FORK
1920 #include <sys/wait.h>
21 #endif
2022 #include "mawk.h"
2123 #include "files.h"
2224 #include "memory.h"
88 ********************************************/
99 #include "vio_fifo.h"
1010 #include "memory.h"
11
12 const mawk_vio_imp_t mawk_vio_fifo_imp;
1113
1214 mawk_vio_t *mawk_vio_fifo_open(mawk_state_t *MAWK, const char *name, mawk_vio_open_mode_t mode)
1315 {
1313 int eof_from_app; /* 1 if there won't be more from the app or the app won't accept more data */
1414 } mawk_vio_fifo_t;
1515
16 const mawk_vio_imp_t mawk_vio_fifo_imp;
16 extern const mawk_vio_imp_t mawk_vio_fifo_imp;
1717
1818 mawk_vio_t *mawk_vio_fifo_open(mawk_state_t *MAWK, const char *name, mawk_vio_open_mode_t mode);
1919